From d9bae2644f47f7f22765c6e193be9b2224646395 Mon Sep 17 00:00:00 2001 From: Rmojarro1 <48000819+Rmojarro1@users.noreply.github.com> Date: Thu, 20 Feb 2025 18:20:10 -0800 Subject: [PATCH 1/4] Create Remap.tscn --- scenes/Remapping/Remap.tscn | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 scenes/Remapping/Remap.tscn diff --git a/scenes/Remapping/Remap.tscn b/scenes/Remapping/Remap.tscn new file mode 100644 index 00000000..83f9a979 --- /dev/null +++ b/scenes/Remapping/Remap.tscn @@ -0,0 +1,3 @@ +[gd_scene format=3 uid="uid://bew23sumjs0fg"] + +[node name="Remap" type="Node2D"] From 2b75171c461873a820713f69ea5e34dfaf55c6a1 Mon Sep 17 00:00:00 2001 From: Rmojarro1 <48000819+Rmojarro1@users.noreply.github.com> Date: Mon, 24 Feb 2025 12:00:28 -0800 Subject: [PATCH 2/4] Remapping for arrow, WASD, QWER added a seperate scene were the player can choose from the three schemes, defaults to arrows. slight tweak to inputhandler to refresh the controls. button to control scene was addded. will try to use sprites/icons to show which keys will correspend to each arrow in next push --- Globals/FunkEngineNameSpace.cs | 34 +++++++++++++ Globals/StageProducer.cs | 3 ++ project.godot | 8 +++ scenes/NoteManager/scripts/InputHandler.cs | 27 ++++++++++ scenes/Remapping/ControlSchemes.cs | 42 ++++++++++++++++ scenes/Remapping/ControlSettings.cs | 35 +++++++++++++ scenes/Remapping/Remap.tscn | 55 ++++++++++++++++++++- scenes/SceneTransitions/TitleScreen.tscn | 6 +++ scenes/SceneTransitions/testTransition.tscn | 2 - 9 files changed, 209 insertions(+), 3 deletions(-) create mode 100644 scenes/Remapping/ControlSchemes.cs create mode 100644 scenes/Remapping/ControlSettings.cs diff --git a/Globals/FunkEngineNameSpace.cs b/Globals/FunkEngineNameSpace.cs index b2eb208f..39cf3cbb 100644 --- a/Globals/FunkEngineNameSpace.cs +++ b/Globals/FunkEngineNameSpace.cs @@ -4,6 +4,40 @@ namespace FunkEngine; +public enum ArrowType +{ + Up = 0, + Down = 1, + Left = 2, + Right = 3, +} + +public enum BattleEffectTrigger +{ + NotePlaced, + NoteHit, + SelfNoteHit, + OnPickup, +} + +public enum Timing +{ + Miss = 0, + Bad = 1, + Okay = 2, + Good = 3, + Perfect = 4, +} + +public enum Stages +{ + Title, + Battle, + Quit, + Map, + Controls, +} + public struct SongData { public int Bpm; diff --git a/Globals/StageProducer.cs b/Globals/StageProducer.cs index d0403ae5..21b49376 100644 --- a/Globals/StageProducer.cs +++ b/Globals/StageProducer.cs @@ -59,6 +59,9 @@ public void TransitionStage(Stages nextStage, int nextRoomIdx = -1) Config = MakeConfig(nextStage, nextRoomIdx); GetTree().ChangeSceneToFile("res://scenes/BattleDirector/test_battle_scene.tscn"); break; + case Stages.Controls: + GetTree().ChangeSceneToFile("res://scenes/Remapping/Remap.tscn"); + break; case Stages.Chest: Config = MakeConfig(nextStage, nextRoomIdx); GetTree().ChangeSceneToFile("res://scenes/ChestScene/ChestScene.tscn"); diff --git a/project.godot b/project.godot index a677fd5d..3c45d31e 100644 --- a/project.godot +++ b/project.godot @@ -32,6 +32,10 @@ window/stretch/scale_mode="integer" project/assembly_name="Funk Engine" +[game] + +input_scheme="QWERT" + [input] arrowUp={ @@ -39,6 +43,7 @@ arrowUp={ "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"location":0,"echo":false,"script":null) , Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) , Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":88,"key_label":0,"unicode":120,"location":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":69,"key_label":0,"unicode":101,"location":0,"echo":false,"script":null) ] } arrowDown={ @@ -46,6 +51,7 @@ arrowDown={ "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"location":0,"echo":false,"script":null) , Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) , Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":67,"key_label":0,"unicode":99,"location":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"location":0,"echo":false,"script":null) ] } arrowLeft={ @@ -53,6 +59,7 @@ arrowLeft={ "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"location":0,"echo":false,"script":null) , Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194319,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) , Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":90,"key_label":0,"unicode":122,"location":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":81,"key_label":0,"unicode":113,"location":0,"echo":false,"script":null) ] } arrowRight={ @@ -60,6 +67,7 @@ arrowRight={ "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194321,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) , Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"location":0,"echo":false,"script":null) , Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":86,"key_label":0,"unicode":118,"location":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":82,"key_label":0,"unicode":114,"location":0,"echo":false,"script":null) ] } Pause={ diff --git a/scenes/NoteManager/scripts/InputHandler.cs b/scenes/NoteManager/scripts/InputHandler.cs index b1961d4d..440834d6 100644 --- a/scenes/NoteManager/scripts/InputHandler.cs +++ b/scenes/NoteManager/scripts/InputHandler.cs @@ -56,6 +56,33 @@ private void InitializeArrowCheckers() public override void _Ready() { InitializeArrowCheckers(); + LoadControlScheme(); + } + + private void LoadControlScheme() + { + string scheme = ProjectSettings.HasSetting("game/input_scheme") + ? (string)ProjectSettings.GetSetting("game/input_scheme") + : "ARROW"; + foreach (var arrow in Arrows) + { + var events = InputMap.ActionGetEvents(arrow.Key); + foreach (var inputEvent in events) + { + InputMap.ActionEraseEvent(arrow.Key, inputEvent); + } + } + + var selectedScheme = ControlSchemes.Schemes[scheme]; + foreach (var arrow in Arrows) + { + if (selectedScheme.ContainsKey(arrow.Key)) + { + InputEventKey eventKey = new InputEventKey(); + eventKey.Keycode = (Key)Enum.Parse(typeof(Key), selectedScheme[arrow.Key]); + InputMap.ActionAddEvent(arrow.Key, eventKey); + } + } } public override void _Process(double delta) diff --git a/scenes/Remapping/ControlSchemes.cs b/scenes/Remapping/ControlSchemes.cs new file mode 100644 index 00000000..eb91da62 --- /dev/null +++ b/scenes/Remapping/ControlSchemes.cs @@ -0,0 +1,42 @@ +using System.Collections.Generic; +using Godot; + +public static class ControlSchemes +{ + public static Dictionary> Schemes = new Dictionary< + string, + Dictionary + >() + { + { + "WASD", + new Dictionary() + { + { "arrowUp", "W" }, + { "arrowDown", "S" }, + { "arrowLeft", "A" }, + { "arrowRight", "D" }, + } + }, + { + "ARROWS", + new Dictionary() + { + { "arrowUp", "Up" }, + { "arrowDown", "Down" }, + { "arrowLeft", "Left" }, + { "arrowRight", "Right" }, + } + }, + { + "QWERT", + new Dictionary() + { + { "arrowUp", "E" }, + { "arrowDown", "W" }, + { "arrowLeft", "Q" }, + { "arrowRight", "R" }, + } + }, + }; +} diff --git a/scenes/Remapping/ControlSettings.cs b/scenes/Remapping/ControlSettings.cs new file mode 100644 index 00000000..3fa40c54 --- /dev/null +++ b/scenes/Remapping/ControlSettings.cs @@ -0,0 +1,35 @@ +using System; +using Godot; + +public partial class ControlSettings : Node2D +{ + public override void _Ready() + { + GetNode