diff --git a/Globals/Translations/Translations.csv b/Globals/Translations/Translations.csv index 6f9346d4..fb7ac379 100644 --- a/Globals/Translations/Translations.csv +++ b/Globals/Translations/Translations.csv @@ -17,6 +17,10 @@ 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 键关闭" +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 279ebba4..78dbb994 100644 --- a/Scenes/UI/Remapping/ControlSettings.cs +++ b/Scenes/UI/Remapping/ControlSettings.cs @@ -19,6 +19,13 @@ public partial class ControlSettings : Node2D, IFocusableMenu [Export] 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; [Export] private Timer _remapTimer; @@ -122,6 +129,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 +206,7 @@ private void ChangeInputType() SaveSystem.ConfigSettings.InputType, _remapTabs.CurrentTab == 0 ? KeyboardPrefix : JoyPrefix ); + _remapDescription.Text = Tr(_remapTabs.CurrentTab == 0 ? _keyboardRemap : _controllerRemap); } /// @@ -255,7 +265,7 @@ public override void _Input(InputEvent @event) { if (_remapPopup.Visible) { - if (@event.IsActionPressed("ui_cancel")) + if (@event.IsActionPressed("Pause")) { _remapTimer.Stop(); OnTimerEnd(); @@ -295,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); @@ -425,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; 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