From d104a68e4216496fc08ff18dbd511dfa9faf16ff Mon Sep 17 00:00:00 2001 From: cornerloan Date: Mon, 28 Apr 2025 20:21:44 -0700 Subject: [PATCH 1/2] Now only escape and start close the popup (#166) Also added text to inform user of how to close the popup. Possible change: change text to statically say "Press Escape/Start to close" instead of having them be individually tied to keyboard and controller tabs. --- Globals/Translations/Translations.csv | 2 ++ Scenes/UI/Remapping/ControlSettings.cs | 10 +++++++++- Scenes/UI/Remapping/Remap.tscn | 11 ++++++++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Globals/Translations/Translations.csv b/Globals/Translations/Translations.csv index 6f9346d4..00db3b30 100644 --- a/Globals/Translations/Translations.csv +++ b/Globals/Translations/Translations.csv @@ -17,6 +17,8 @@ CONTROLS_ARROW_BUTTON,Arrow Keys,箭头键 CONTROLS_RETURN_BUTTON,Return,返回 CONTROLS_CHOOSE_SCHEME,Choose Control Scheme,选择控制方式 CONTROLS_CHOOSE_BUTTON,Choose new button,选择输入按钮 +CONTROLS_CHOOSE_TEXT_KEYBOARD,"Press Escape to close","按下 Escape 键关闭" +CONTROLS_CHOOSE_TEXT_CONTROLLER,"Press Start to close","按下 Start 键关闭" ESCAPE_MENU_RESUME,Resume,继续 ESCAPE_MENU_QUIT,Quit,退出 ESCAPE_MENU_TITLE,Quit to Title,返回标题 diff --git a/Scenes/UI/Remapping/ControlSettings.cs b/Scenes/UI/Remapping/ControlSettings.cs index 279ebba4..2efbae50 100644 --- a/Scenes/UI/Remapping/ControlSettings.cs +++ b/Scenes/UI/Remapping/ControlSettings.cs @@ -19,6 +19,11 @@ public partial class ControlSettings : Node2D, IFocusableMenu [Export] private Label _remapLabel; + private string _keyboardRemap = "CONTROLS_CHOOSE_TEXT_KEYBOARD"; + private string _controllerRemap = "CONTROLS_CHOOSE_TEXT_CONTROLLER"; + + [Export] + private Label _remapDescription; [Export] private Timer _remapTimer; @@ -122,6 +127,8 @@ public override void _Ready() ? 0 : 1; + _remapDescription.Text = Tr(_remapTabs.CurrentTab == 0 ? _keyboardRemap : _controllerRemap); + _remapTimer.Timeout += OnTimerEnd; _remapTabs.TabChanged += (_) => ChangeInputType(); _closeButton.Pressed += ReturnToPrev; @@ -197,6 +204,7 @@ private void ChangeInputType() SaveSystem.ConfigSettings.InputType, _remapTabs.CurrentTab == 0 ? KeyboardPrefix : JoyPrefix ); + _remapDescription.Text = Tr(_remapTabs.CurrentTab == 0 ? _keyboardRemap : _controllerRemap); } /// @@ -255,7 +263,7 @@ public override void _Input(InputEvent @event) { if (_remapPopup.Visible) { - if (@event.IsActionPressed("ui_cancel")) + if (@event.IsActionPressed("Pause")) { _remapTimer.Stop(); OnTimerEnd(); diff --git a/Scenes/UI/Remapping/Remap.tscn b/Scenes/UI/Remapping/Remap.tscn index 81e3b860..adbf744d 100644 --- a/Scenes/UI/Remapping/Remap.tscn +++ b/Scenes/UI/Remapping/Remap.tscn @@ -19,12 +19,13 @@ [ext_resource type="Texture2D" uid="uid://cpxcg12lovxu5" path="res://Scenes/UI/Remapping/Assets/Joypad Button 4 (Back, Sony Select, Xbox Back, Nintendo -).png" id="16_s0mtp"] [ext_resource type="Texture2D" uid="uid://djd6iw2g84bba" path="res://Scenes/UI/Assets/UI_CenterFrame.png" id="18_8iace"] -[node name="Remap" type="Node2D" node_paths=PackedStringArray("_closeButton", "_remapPopup", "_remapLabel", "_remapTimer", "_remapTabs")] +[node name="Remap" type="Node2D" node_paths=PackedStringArray("_closeButton", "_remapPopup", "_remapLabel", "_remapDescription", "_remapTimer", "_remapTabs")] process_mode = 3 script = ExtResource("1_ir12b") _closeButton = NodePath("Panel/TitleButton") _remapPopup = NodePath("RemapPopup") _remapLabel = NodePath("RemapPopup/Label2") +_remapDescription = NodePath("RemapPopup/Label3") _remapTimer = NodePath("RemapPopup/Timer") _remapTabs = NodePath("Panel/TabContainer") @@ -580,6 +581,14 @@ offset_bottom = 59.0 text = "CONTROLS_CHOOSE_BUTTON" horizontal_alignment = 1 +[node name="Label3" type="Label" parent="RemapPopup"] +layout_mode = 0 +offset_top = 75.0 +offset_right = 372.0 +offset_bottom = 98.0 +text = "CONTROLS_CHOOSE_TEXT_KEYBOARD" +horizontal_alignment = 1 + [node name="Label2" type="Label" parent="RemapPopup"] layout_mode = 0 offset_top = 111.0 From 7a45cb7158bd690962c41cbdf6149e76701dbea2 Mon Sep 17 00:00:00 2001 From: LifeHckr Date: Mon, 28 Apr 2025 21:05:47 -0700 Subject: [PATCH 2/2] Added messages for inaccessible inputs Also added better checking for inputs we don't have images for. --- Globals/Translations/Translations.csv | 2 ++ README.md | 1 - Scenes/UI/Remapping/ControlSettings.cs | 13 ++++++++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Globals/Translations/Translations.csv b/Globals/Translations/Translations.csv index 00db3b30..fb7ac379 100644 --- a/Globals/Translations/Translations.csv +++ b/Globals/Translations/Translations.csv @@ -19,6 +19,8 @@ CONTROLS_CHOOSE_SCHEME,Choose Control Scheme,选择控制方式 CONTROLS_CHOOSE_BUTTON,Choose new button,选择输入按钮 CONTROLS_CHOOSE_TEXT_KEYBOARD,"Press Escape to close","按下 Escape 键关闭" CONTROLS_CHOOSE_TEXT_CONTROLLER,"Press Start to close","按下 Start 键关闭" +CONTROLS_CHOOSE_INVALID,"System input, can't be used!",预留输入,无法重定向! +CONTROLS_CHOOSE_DUPLICATE,"Input already set, can't be used again!",输入冲突,无法继续! ESCAPE_MENU_RESUME,Resume,继续 ESCAPE_MENU_QUIT,Quit,退出 ESCAPE_MENU_TITLE,Quit to Title,返回标题 diff --git a/README.md b/README.md index 1f0f4ecc..daeef2f7 100644 --- a/README.md +++ b/README.md @@ -47,4 +47,3 @@ We now have a Steam page! The repository license **does not** apply to any music or image files in this repository, including but not limited to `.wav`, `.mp3`, `.ogg`, `.png`, `.jpg`, and other media formats. These assets are **not licensed** for use, private or public, without prior written consent from the team. All source code and documentation files are licensed under the **GNU Affero General Public License v3.0 (AGPL-3.0)**. - diff --git a/Scenes/UI/Remapping/ControlSettings.cs b/Scenes/UI/Remapping/ControlSettings.cs index 2efbae50..78dbb994 100644 --- a/Scenes/UI/Remapping/ControlSettings.cs +++ b/Scenes/UI/Remapping/ControlSettings.cs @@ -21,6 +21,8 @@ public partial class ControlSettings : Node2D, IFocusableMenu private Label _remapLabel; private string _keyboardRemap = "CONTROLS_CHOOSE_TEXT_KEYBOARD"; private string _controllerRemap = "CONTROLS_CHOOSE_TEXT_CONTROLLER"; + private string _invalidMessage = "CONTROLS_CHOOSE_INVALID"; + private string _duplicateInput = "CONTROLS_CHOOSE_DUPLICATE"; [Export] private Label _remapDescription; @@ -303,8 +305,14 @@ private void HandleRemapInput(InputEvent @event) { case true when @event is InputEventKey keyEvent: { - if (_invalidKeys.Contains(keyEvent.Keycode)) + if ( + _invalidKeys.Contains(keyEvent.Keycode) + || !FileAccess.FileExists($"{IconPath}{CleanKeyboardText(@event.AsText())}.png") + ) + { + _remapDescription.Text = Tr(_invalidMessage); return; + } string action = KeyboardPrefix + _chosenKey; InputMap.ActionEraseEvents(action); @@ -433,7 +441,10 @@ evt is InputEventKey keyEvent && CleanKeyboardText(keyEvent.AsText()) == keyText ) || (evt is InputEventJoypadButton padEvent && padEvent.AsText() == keyText) ) + { + _remapDescription.Text = Tr(_duplicateInput); return false; + } } } return true;