view sens and styles

This commit is contained in:
ntr committed 2023-09-03 22:09:13 +10:00
1 parent 6cba0f1295
commit 847b69c401
8 files changed
+90 -21

No files matched your search

@@ -22034,6 +22034,10 @@ PrefabInstance:
propertyPath: m_Name propertyPath: m_Name
value: Timing value: Timing
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 2603084029878042569, guid: dcb64e3a91f1fec7ab6098f4f407830b, type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4743817676494260426, guid: dcb64e3a91f1fec7ab6098f4f407830b, type: 3} - target: {fileID: 4743817676494260426, guid: dcb64e3a91f1fec7ab6098f4f407830b, type: 3}
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: 3 value: 3
+21 -2
View File
@@ -26,6 +26,23 @@ public class ShipControls : MonoBehaviour {
float camYaw; float camYaw;
float clampAngle = 90.0f; float clampAngle = 90.0f;
float _invertY = 1.0f;
public bool InvertY {
set {
_invertY = value ? -1.0f : 1.0f;
Debug.Log($"Set invert Y {_invertY}");
}
}
float _viewSens = 1.0f;
public float ViewSens {
get => _viewSens;
set {
_viewSens = value;
Debug.Log($"Set view sensitivity {_viewSens}");
}
}
public PowerUnit powerUnit = new(); public PowerUnit powerUnit = new();
public float Speed => rigidBody.velocity.magnitude; public float Speed => rigidBody.velocity.magnitude;
@@ -107,9 +124,11 @@ public class ShipControls : MonoBehaviour {
// delta *= 0.1f; // Account for sensitivity setting on old Mouse X and Y axes. // delta *= 0.1f; // Account for sensitivity setting on old Mouse X and Y axes.
// def needs to be configurable // def needs to be configurable
Vector2 lookDelta = input.ship.look.ReadValue<Vector2>(); Vector2 lookDelta = input.ship.look.ReadValue<Vector2>();
camYaw += lookDelta.x;
camPitch -= lookDelta.y; camYaw += lookDelta.x * _viewSens;
camPitch -= lookDelta.y * _viewSens * _invertY;
camPitch = Mathf.Clamp(camPitch, -clampAngle, clampAngle); camPitch = Mathf.Clamp(camPitch, -clampAngle, clampAngle);
aim.transform.eulerAngles = new Vector3(camPitch, camYaw, 0.0f); aim.transform.eulerAngles = new Vector3(camPitch, camYaw, 0.0f);
} }
+14
View File
@@ -0,0 +1,14 @@
:root {
--green: rgb(31, 240, 31);
--red: rgb(165, 42, 42);
--blue: rgb(48, 80, 248);
--purple: rgb(164, 35, 188);
--yellow: rgb(255, 161, 0);
--white: rgb(245, 245, 245);
color: rgb(245, 245, 245);
border-color: var(--white);
font-size: 24px;
letter-spacing: 24px;
-unity-font: url("/Assets/UI Toolkit/Fonts/Jura-Medium.otf");
-unity-font-definition: initial;
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 000591923dc977463bf0fd9f4e7d463e
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0}
disableValidation: 0
+19 -6
View File
@@ -1,5 +1,5 @@
#Menu #main VisualElement { #Menu #main {
flex-basis: 50%; flex-grow: 1;
} }
#logo { #logo {
@@ -9,12 +9,25 @@
height: 256px; height: 256px;
} }
/*#exit {
width: 256px;
}
*/
Button { Button {
background-color: rgba(0, 0, 0, 0.26); background-color: rgba(0, 0, 0, 0.26);
color: rgb(255, 255, 255); color: rgb(255, 255, 255);
border-radius: 5px; border-radius: 5px;
width: 33%;
}
Button:focus {
border-color: var(--green);
}
Button:hover {
border-color: var(--green);
}
Toggle:focus {
border-color: var(--green);
}
Toggle:hover {
border-color: var(--green);
} }
+7 -11
View File
@@ -1,24 +1,20 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False"> <ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
<Style src="project://database/Assets/Src/UI/TimingUi.uss?fileID=7433441132597879392&amp;guid=cf92f075876ddf7ffb4cd5c59633ad7b&amp;type=3#TimingUi" />
<Style src="project://database/Assets/Src/UI/Menu.uss?fileID=7433441132597879392&amp;guid=144cc2c04c975bad88fb864cea91f099&amp;type=3#Menu" /> <Style src="project://database/Assets/Src/UI/Menu.uss?fileID=7433441132597879392&amp;guid=144cc2c04c975bad88fb864cea91f099&amp;type=3#Menu" />
<ui:VisualElement name="Menu" style="flex-grow: 1; background-color: rgba(0, 0, 0, 0); -unity-font: url(&apos;project://database/Assets/UI%20Toolkit/Fonts/Jura-Medium.otf?fileID=12800000&amp;guid=65648a14640996362a6b0929c723b6e4&amp;type=3#Jura-Medium&apos;); -unity-font-definition: initial; font-size: 38px; letter-spacing: 24px; flex-direction: row;"> <Style src="project://database/Assets/Src/UI/Global.uss?fileID=7433441132597879392&amp;guid=000591923dc977463bf0fd9f4e7d463e&amp;type=3#Global" />
<ui:VisualElement name="nav" style="flex-grow: 1; background-color: rgba(0, 0, 0, 0);"> <ui:VisualElement name="main" class="nav" style="flex-grow: 1;">
<ui:VisualElement name="logo" /> <ui:VisualElement name="logo" />
<ui:VisualElement style="flex-grow: 1; background-color: rgba(0, 0, 0, 0);"> <ui:VisualElement name="tracksCtr" style="flex-grow: 1; background-color: rgba(0, 0, 0, 0);">
<ui:Label tabindex="-1" text="TRACK" display-tooltip-when-elided="true" name="Track" style="-unity-font: url(&apos;project://database/Assets/UI%20Toolkit/Fonts/Jura-DemiBold.otf?fileID=12800000&amp;guid=1d103e83da4f14189b3e8b0b865eca3d&amp;type=3#Jura-DemiBold&apos;); -unity-font-style: bold;" /> <ui:Label tabindex="-1" text="TRACK" display-tooltip-when-elided="true" name="Track" style="-unity-font: url(&apos;project://database/Assets/UI%20Toolkit/Fonts/Jura-DemiBold.otf?fileID=12800000&amp;guid=1d103e83da4f14189b3e8b0b865eca3d&amp;type=3#Jura-DemiBold&apos;); -unity-font-style: bold;" />
<ui:VisualElement name="tracks"> <ui:VisualElement name="tracks">
<ui:Button text="sr_junglism" display-tooltip-when-elided="true" /> <ui:Button text="sr_junglism" display-tooltip-when-elided="true" />
<ui:Button text="sr_silverstorage" display-tooltip-when-elided="true" /> <ui:Button text="sr_silverstorage" display-tooltip-when-elided="true" />
</ui:VisualElement> </ui:VisualElement>
</ui:VisualElement> </ui:VisualElement>
<ui:VisualElement name="settings" style="flex-grow: 1; background-color: rgba(0, 0, 0, 0); flex-direction: column; display: flex; visibility: visible; align-items: flex-start;"> <ui:VisualElement name="settings" style="flex-grow: 1; background-color: rgba(0, 0, 0, 0); flex-direction: column; display: flex; visibility: visible; align-items: flex-start; width: 33%;">
<ui:Label tabindex="-1" text="SETTINGS" display-tooltip-when-elided="true" style="-unity-font-style: bold;" /> <ui:Label tabindex="-1" text="SETTINGS" display-tooltip-when-elided="true" style="-unity-font-style: bold;" />
<ui:VisualElement name="controls" style="flex-grow: 1; background-color: rgba(0, 0, 0, 0); font-size: 24px; align-items: flex-start;"> <ui:Slider picking-mode="Ignore" label="View Sensitivity" value="1" high-value="3" name="mouseSens" low-value="0.1" style="width: 100%;" />
<ui:Toggle label="Invert Y" name="Toggle" tooltip="NYI" /> <ui:Toggle label="Invert Y" name="invertY" tooltip="NYI" />
<ui:FloatField label="View Sensitivity" value="42.2" tooltip="NYI" />
</ui:VisualElement>
</ui:VisualElement>
<ui:Button text="EXIT" display-tooltip-when-elided="true" name="exit" />
</ui:VisualElement> </ui:VisualElement>
<ui:Button text="EXIT" display-tooltip-when-elided="true" name="exit" style="flex-shrink: 1;" />
</ui:VisualElement> </ui:VisualElement>
</ui:UXML> </ui:UXML>
+14 -1
View File
@@ -26,6 +26,10 @@ public class MenuControls : MonoBehaviour, SpaceRaceInput.IMenuActions {
ControlsUI controlsUI; ControlsUI controlsUI;
SpaceRaceInput input; SpaceRaceInput input;
Toggle invertYToggle;
Slider viewSensSlider;
bool visible = false; bool visible = false;
void Awake() { void Awake() {
@@ -43,7 +47,6 @@ public class MenuControls : MonoBehaviour, SpaceRaceInput.IMenuActions {
return; return;
} }
Hide(); Hide();
} }
@@ -58,6 +61,8 @@ public class MenuControls : MonoBehaviour, SpaceRaceInput.IMenuActions {
menuUi.AddTracks(); menuUi.AddTracks();
menuUi.FocusTracks(); menuUi.FocusTracks();
BindSettings();
// TODO abstract all this cause it's shit // TODO abstract all this cause it's shit
// take control off the ship // take control off the ship
timingDoc.enabled = false; timingDoc.enabled = false;
@@ -94,4 +99,12 @@ public class MenuControls : MonoBehaviour, SpaceRaceInput.IMenuActions {
Hide(); Hide();
return; return;
} }
void BindSettings() {
Debug.Log("Setting controls change callbacks");
invertYToggle = menuDoc.rootVisualElement.Q<Toggle>("invertY");
viewSensSlider = menuDoc.rootVisualElement.Q<Slider>("mouseSens");
invertYToggle.RegisterValueChangedCallback(evt => shipControls.InvertY = evt.newValue);
viewSensSlider.RegisterValueChangedCallback(evt => shipControls.ViewSens = evt.newValue);
}
} }
-1
View File
@@ -15,7 +15,6 @@ public class MenuUI : MonoBehaviour {
} }
public void FocusTracks() { public void FocusTracks() {
Debug.Log("focusing");
uiDocument.rootVisualElement.Q<Button>().Focus(); uiDocument.rootVisualElement.Q<Button>().Focus();
} }