diff --git a/Content/Common/DefaultHudPrefab.prefab b/Content/Common/DefaultHudPrefab.prefab index 4704d36..6624386 100644 --- a/Content/Common/DefaultHudPrefab.prefab +++ b/Content/Common/DefaultHudPrefab.prefab @@ -1,7 +1,7 @@ { "ID": "cb74184545f392e5c67815808bc63e58", "TypeName": "FlaxEngine.Prefab", - "EngineBuild": 6332, + "EngineBuild": 6606, "Data": [ { "ID": "9e1b61dc44338f962e69f78ecb3d0536", @@ -28,7 +28,9 @@ "B": 0.0, "A": 1.0 }, - "ConsoleFont": "43f32bec443158643f53699f07b2e09c" + "ConsoleFont": "43f32bec443158643f53699f07b2e09c", + "InputSettingsGameplay": "8ec53dba4c238bfbea1d62922e612a4d", + "InputSettingsMenu": "d1c7e5f241c7c7602e84a39a31d6b532" } }, { @@ -46,6 +48,9 @@ "Control": "FlaxEngine.GUI.Label", "Data": { "Text": "120fps", + "CaseOption": 0, + "Bold": false, + "Italic": false, "TextColor": { "R": 1.0, "G": 1.0, @@ -61,9 +66,10 @@ "HorizontalAlignment": 2, "VerticalAlignment": 2, "Wrapping": 0, + "BaseLinesGapScale": 1.0, "Font": { "Font": "43f32bec443158643f53699f07b2e09c", - "Size": 15 + "Size": 15.0 }, "Material": null, "Margin": { @@ -115,6 +121,7 @@ "B": 0.0, "A": 0.0 }, + "BackgroundBrush": null, "Enabled": true, "Visible": true, "AutoFocus": false diff --git a/Content/Settings/EngineSettings/MenuInputSettings.json b/Content/Settings/EngineSettings/MenuInputSettings.json new file mode 100644 index 0000000..ae1dd47 --- /dev/null +++ b/Content/Settings/EngineSettings/MenuInputSettings.json @@ -0,0 +1,74 @@ +{ + "ID": "d1c7e5f241c7c7602e84a39a31d6b532", + "TypeName": "FlaxEditor.Content.Settings.InputSettings", + "EngineBuild": 6606, + "Data": { + "ActionMappings": [ + { + "Name": "Exit", + "Mode": 1, + "Key": 27, + "MouseButton": 0, + "GamepadButton": 0, + "Gamepad": 0 + }, + { + "Name": "DebugTrigger1", + "Mode": 2, + "Key": 112, + "MouseButton": 0, + "GamepadButton": 0, + "Gamepad": 0 + }, + { + "Name": "DebugTrigger2", + "Mode": 2, + "Key": 113, + "MouseButton": 0, + "GamepadButton": 0, + "Gamepad": 0 + }, + { + "Name": "DebugTrigger3", + "Mode": 2, + "Key": 114, + "MouseButton": 0, + "GamepadButton": 0, + "Gamepad": 0 + }, + { + "Name": "Console", + "Mode": 1, + "Key": 220, + "MouseButton": 0, + "GamepadButton": 0, + "Gamepad": 0 + }, + { + "Name": "Console", + "Mode": 1, + "Key": 223, + "MouseButton": 0, + "GamepadButton": 0, + "Gamepad": 0 + }, + { + "Name": "Console", + "Mode": 1, + "Key": 192, + "MouseButton": 0, + "GamepadButton": 0, + "Gamepad": 0 + }, + { + "Name": "ClearConsole", + "Mode": 1, + "Key": 66, + "MouseButton": 0, + "GamepadButton": 0, + "Gamepad": 0 + } + ], + "AxisMappings": [] +} +} \ No newline at end of file diff --git a/Source/Game/Camera/CameraMovement.cs b/Source/Game/Camera/CameraMovement.cs index 16f2fd5..a7a727a 100644 --- a/Source/Game/Camera/CameraMovement.cs +++ b/Source/Game/Camera/CameraMovement.cs @@ -26,8 +26,8 @@ public class CameraMovement : Script Actor rootActor = Actor.GetChild(0); Camera camera = rootActor.GetChild(); - float xAxis = InputManager.GetAxisRaw("Mouse X"); - float yAxis = InputManager.GetAxisRaw("Mouse Y"); + float xAxis = Input.GetAxisRaw("Mouse X"); + float yAxis = Input.GetAxisRaw("Mouse Y"); if (xAxis != 0.0f || yAxis != 0.0f) { viewPitch += yAxis; @@ -40,8 +40,8 @@ public class CameraMovement : Script camera.Orientation = Quaternion.Euler(viewPitch, viewYaw, viewRoll); } - float inputH = InputManager.GetAxis("Horizontal"); - float inputV = InputManager.GetAxis("Vertical"); + float inputH = Input.GetAxis("Horizontal"); + float inputV = Input.GetAxis("Vertical"); Float3 move = new Float3(inputH, 0.0f, inputV); if (!move.IsZero) diff --git a/Source/Game/Console/ConsoleScript.cs b/Source/Game/Console/ConsoleScript.cs index 207dc1d..6de7465 100644 --- a/Source/Game/Console/ConsoleScript.cs +++ b/Source/Game/Console/ConsoleScript.cs @@ -1,6 +1,7 @@ using System; using System.Linq; using FlaxEditor; +using FlaxEditor.Content.Settings; using FlaxEngine; using FlaxEngine.Assertions; using FlaxEngine.GUI; @@ -13,23 +14,27 @@ public class ConsoleScript : Script public Color BackgroundColor; public Texture BackgroundTexture; - private ConsoleContentTextBox consoleBox; - + public FontAsset ConsoleFont; + [Limit(5, 720)] public int ConsoleFontSize = 16; [Limit(0.05f, 1.0f)] public float ConsoleHeight = 0.65f; - private ConsoleInputTextBox consoleInputBox; - - internal InputEvent consoleInputEvent; - private ConsoleContentTextBox consoleNotifyBox; [Limit(0)] public int ConsoleNotifyLines = 15; [Limit(0f)] public float ConsoleSpeed = 3500f; - private UIControl rootControl; + public JsonAssetReference InputSettingsGameplay; + + public JsonAssetReference InputSettingsMenu; + + private ConsoleInputTextBox consoleInputBox; + internal InputEvent consoleInputEvent; + private ConsoleContentTextBox consoleBox; + private ConsoleContentTextBox consoleNotifyBox; + private UIControl rootControl; private int fontHeight; public override void OnStart() @@ -259,6 +264,8 @@ public class ConsoleScript : Script consoleInputBox.Focus(); Parent.As().ReceivesEvents = true; + + Input.SetInputMappingFromSettings(InputSettingsMenu); } public void OnConsoleClose() @@ -271,6 +278,7 @@ public class ConsoleScript : Script Editor.Instance.Windows.GameWin.Focus(); #endif Parent.As().ReceivesEvents = false; + Input.SetInputMappingFromSettings(InputSettingsGameplay); } public override void OnUpdate() diff --git a/Source/Game/Player/InputManager.cs b/Source/Game/Player/InputManager.cs deleted file mode 100644 index ebc33a3..0000000 --- a/Source/Game/Player/InputManager.cs +++ /dev/null @@ -1,27 +0,0 @@ -using FlaxEngine; - -namespace Game; - -public static class InputManager -{ - public static bool GetAction(string name) - { - if (Console.IsOpen) - return false; - return Input.GetAction(name); - } - - public static float GetAxis(string name) - { - if (Console.IsOpen) - return 0.0f; - return Input.GetAxis(name); - } - - public static float GetAxisRaw(string name) - { - if (Console.IsOpen) - return 0.0f; - return Input.GetAxisRaw(name); - } -} \ No newline at end of file diff --git a/Source/Game/Player/PlayerInputLocal.cs b/Source/Game/Player/PlayerInputLocal.cs index bd8c6bf..a1229a0 100644 --- a/Source/Game/Player/PlayerInputLocal.cs +++ b/Source/Game/Player/PlayerInputLocal.cs @@ -51,19 +51,19 @@ public class PlayerInputLocal : PlayerInput float sensitivity = 1.0f / 8.0f; sensitivity = 1.0f; - //var asf = InputManager.GetAxisRaw("Mouse X"); + //var asf = Input.GetAxisRaw("Mouse X"); //if (asf != 0.0f) - // Console.Print(InputManager.GetAxisRaw("Mouse X").ToString("G9", System.Globalization.CultureInfo.InvariantCulture)); + // Console.Print(Input.GetAxisRaw("Mouse X").ToString("G9", System.Globalization.CultureInfo.InvariantCulture)); - currentState.input.viewDeltaX += InputManager.GetAxisRaw("Mouse X") * sensitivity; - currentState.input.viewDeltaY += InputManager.GetAxisRaw("Mouse Y") * sensitivity; - currentState.input.viewDeltaX += InputManager.GetAxisRaw("LookRight") * Time.DeltaTime * 100; - currentState.input.viewDeltaY += -InputManager.GetAxisRaw("LookUp") * Time.DeltaTime * 100; + currentState.input.viewDeltaX += Input.GetAxisRaw("Mouse X") * sensitivity; + currentState.input.viewDeltaY += Input.GetAxisRaw("Mouse Y") * sensitivity; + currentState.input.viewDeltaX += Input.GetAxisRaw("LookRight") * Time.DeltaTime * 100; + currentState.input.viewDeltaY += -Input.GetAxisRaw("LookUp") * Time.DeltaTime * 100; - currentState.input.moveForward = InputManager.GetAxis("Vertical"); - currentState.input.moveRight = InputManager.GetAxis("Horizontal"); - currentState.input.attacking = InputManager.GetAction("Attack"); - currentState.input.jumping = InputManager.GetAction("Jump"); + currentState.input.moveForward = Input.GetAxis("Vertical"); + currentState.input.moveRight = Input.GetAxis("Horizontal"); + currentState.input.attacking = Input.GetAction("Attack"); + currentState.input.jumping = Input.GetAction("Jump"); }