Skip to content

Commit 1197066

Browse files
cornerloanLifeHckr
andauthored
Now only escape and start close the popup (#166) (#171)
* 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. * Added messages for inaccessible inputs Also added better checking for inputs we don't have images for. --------- Co-authored-by: LifeHckr <jarodthereal@gmail.com>
1 parent 619060a commit 1197066

File tree

4 files changed

+35
-4
lines changed

4 files changed

+35
-4
lines changed

Globals/Translations/Translations.csv

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ CONTROLS_ARROW_BUTTON,Arrow Keys,箭头键
1717
CONTROLS_RETURN_BUTTON,Return,返回
1818
CONTROLS_CHOOSE_SCHEME,Choose Control Scheme,选择控制方式
1919
CONTROLS_CHOOSE_BUTTON,Choose new button,选择输入按钮
20+
CONTROLS_CHOOSE_TEXT_KEYBOARD,"Press Escape to close","按下 Escape 键关闭"
21+
CONTROLS_CHOOSE_TEXT_CONTROLLER,"Press Start to close","按下 Start 键关闭"
22+
CONTROLS_CHOOSE_INVALID,"System input, can't be used!",预留输入,无法重定向!
23+
CONTROLS_CHOOSE_DUPLICATE,"Input already set, can't be used again!",输入冲突,无法继续!
2024
ESCAPE_MENU_RESUME,Resume,继续
2125
ESCAPE_MENU_QUIT,Quit,退出
2226
ESCAPE_MENU_TITLE,Quit to Title,返回标题

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,3 @@ We now have a Steam page!
4747
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.
4848

4949
All source code and documentation files are licensed under the **GNU Affero General Public License v3.0 (AGPL-3.0)**.
50-

Scenes/UI/Remapping/ControlSettings.cs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ public partial class ControlSettings : Node2D, IFocusableMenu
1919

2020
[Export]
2121
private Label _remapLabel;
22+
private string _keyboardRemap = "CONTROLS_CHOOSE_TEXT_KEYBOARD";
23+
private string _controllerRemap = "CONTROLS_CHOOSE_TEXT_CONTROLLER";
24+
private string _invalidMessage = "CONTROLS_CHOOSE_INVALID";
25+
private string _duplicateInput = "CONTROLS_CHOOSE_DUPLICATE";
26+
27+
[Export]
28+
private Label _remapDescription;
2229

2330
[Export]
2431
private Timer _remapTimer;
@@ -122,6 +129,8 @@ public override void _Ready()
122129
? 0
123130
: 1;
124131

132+
_remapDescription.Text = Tr(_remapTabs.CurrentTab == 0 ? _keyboardRemap : _controllerRemap);
133+
125134
_remapTimer.Timeout += OnTimerEnd;
126135
_remapTabs.TabChanged += (_) => ChangeInputType();
127136
_closeButton.Pressed += ReturnToPrev;
@@ -197,6 +206,7 @@ private void ChangeInputType()
197206
SaveSystem.ConfigSettings.InputType,
198207
_remapTabs.CurrentTab == 0 ? KeyboardPrefix : JoyPrefix
199208
);
209+
_remapDescription.Text = Tr(_remapTabs.CurrentTab == 0 ? _keyboardRemap : _controllerRemap);
200210
}
201211

202212
/// <summary>
@@ -255,7 +265,7 @@ public override void _Input(InputEvent @event)
255265
{
256266
if (_remapPopup.Visible)
257267
{
258-
if (@event.IsActionPressed("ui_cancel"))
268+
if (@event.IsActionPressed("Pause"))
259269
{
260270
_remapTimer.Stop();
261271
OnTimerEnd();
@@ -295,8 +305,14 @@ private void HandleRemapInput(InputEvent @event)
295305
{
296306
case true when @event is InputEventKey keyEvent:
297307
{
298-
if (_invalidKeys.Contains(keyEvent.Keycode))
308+
if (
309+
_invalidKeys.Contains(keyEvent.Keycode)
310+
|| !FileAccess.FileExists($"{IconPath}{CleanKeyboardText(@event.AsText())}.png")
311+
)
312+
{
313+
_remapDescription.Text = Tr(_invalidMessage);
299314
return;
315+
}
300316

301317
string action = KeyboardPrefix + _chosenKey;
302318
InputMap.ActionEraseEvents(action);
@@ -425,7 +441,10 @@ evt is InputEventKey keyEvent
425441
&& CleanKeyboardText(keyEvent.AsText()) == keyText
426442
) || (evt is InputEventJoypadButton padEvent && padEvent.AsText() == keyText)
427443
)
444+
{
445+
_remapDescription.Text = Tr(_duplicateInput);
428446
return false;
447+
}
429448
}
430449
}
431450
return true;

Scenes/UI/Remapping/Remap.tscn

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@
1919
[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"]
2020
[ext_resource type="Texture2D" uid="uid://djd6iw2g84bba" path="res://Scenes/UI/Assets/UI_CenterFrame.png" id="18_8iace"]
2121

22-
[node name="Remap" type="Node2D" node_paths=PackedStringArray("_closeButton", "_remapPopup", "_remapLabel", "_remapTimer", "_remapTabs")]
22+
[node name="Remap" type="Node2D" node_paths=PackedStringArray("_closeButton", "_remapPopup", "_remapLabel", "_remapDescription", "_remapTimer", "_remapTabs")]
2323
process_mode = 3
2424
script = ExtResource("1_ir12b")
2525
_closeButton = NodePath("Panel/TitleButton")
2626
_remapPopup = NodePath("RemapPopup")
2727
_remapLabel = NodePath("RemapPopup/Label2")
28+
_remapDescription = NodePath("RemapPopup/Label3")
2829
_remapTimer = NodePath("RemapPopup/Timer")
2930
_remapTabs = NodePath("Panel/TabContainer")
3031

@@ -580,6 +581,14 @@ offset_bottom = 59.0
580581
text = "CONTROLS_CHOOSE_BUTTON"
581582
horizontal_alignment = 1
582583

584+
[node name="Label3" type="Label" parent="RemapPopup"]
585+
layout_mode = 0
586+
offset_top = 75.0
587+
offset_right = 372.0
588+
offset_bottom = 98.0
589+
text = "CONTROLS_CHOOSE_TEXT_KEYBOARD"
590+
horizontal_alignment = 1
591+
583592
[node name="Label2" type="Label" parent="RemapPopup"]
584593
layout_mode = 0
585594
offset_top = 111.0

0 commit comments

Comments
 (0)