Skip to content

Commit a1977fd

Browse files
committed
input_hud: Divide hints between left and right margins
Using a spacer control that expands to fill any spare space in its HBox, push some controls to the right margin. Pack everything inside a MarginContainer to add a small amount of padding to the right-hand side. This is because the text directly abuts the right edge of the container, whereas on the left-hand side the icons have a bit of padding built in. I picked the number 8 by inspecting the keyboard arrows and joypad dpad icons, which they have 8px of margin on the left. For normal gameplay, keep movement, running, and interact on the left-hand side. Move repel & grapple to the right. This means that the interact hint, which appears and disappears as you move around the level, does not cause the position of the other actions to change. For Sokoban, put the movement hints on the left, and the actions on the right. Move Skip before the other two so that when it appears it does not affect the position of the other hints. Fix a typo in the name of the Skip node. Access nodes by unique name, following the style documented in our Contributing page. https://github.com/endlessm/threadbare/wiki/Contributing#use-unique-names-to-reference-nodes-in-scripts
1 parent a1fbcd7 commit a1977fd

3 files changed

Lines changed: 47 additions & 23 deletions

File tree

scenes/ui_elements/input_hints/components/input_hud.gd

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ extends CanvasLayer
44

55
var player: Player
66

7-
@onready var normal_controls: HBoxContainer = $TabContainer/NormalControls
8-
@onready var repel_input_hint: HBoxContainer = $TabContainer/NormalControls/RepelInputHint
9-
@onready var aim_input_hint: HBoxContainer = $TabContainer/NormalControls/AimInputHint
10-
@onready var throw_input_hint: HBoxContainer = $TabContainer/NormalControls/ThrowInputHint
11-
@onready var sokoban_controls: HBoxContainer = $TabContainer/SokobanControls
12-
@onready var skip_input_hint: HBoxContainer = $TabContainer/SokobanControls/SkiptInputHint
13-
@onready var interact_input_hint: HBoxContainer = $TabContainer/NormalControls/InteractInputHint
7+
@onready var normal_controls := %NormalControls
8+
@onready var interact_input_hint := %InteractInputHint
9+
@onready var aim_input_hint := %AimInputHint
10+
@onready var throw_input_hint := %ThrowInputHint
11+
@onready var repel_input_hint := %RepelInputHint
12+
13+
@onready var sokoban_controls := %SokobanControls
14+
@onready var skip_input_hint := %SkipInputHint
1415

1516

1617
func _ready() -> void:

scenes/ui_elements/input_hints/input_hud.tscn

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,58 +15,81 @@
1515
layer = 36
1616
script = ExtResource("1_bewlk")
1717

18-
[node name="TabContainer" type="TabContainer" parent="." unique_id=2133091109]
19-
self_modulate = Color(1, 1, 1, 0)
18+
[node name="MarginContainer" type="MarginContainer" parent="." unique_id=176382299]
19+
editor_description = "The 8px right margin is chosen to match the 8px margin in the dpad & keyboard-arrows icons."
2020
anchors_preset = 12
2121
anchor_top = 1.0
2222
anchor_right = 1.0
2323
anchor_bottom = 1.0
24+
offset_top = -64.0
2425
grow_horizontal = 2
2526
grow_vertical = 0
27+
theme_override_constants/margin_right = 8
28+
29+
[node name="TabContainer" type="TabContainer" parent="MarginContainer" unique_id=2133091109]
30+
self_modulate = Color(1, 1, 1, 0)
31+
layout_mode = 2
2632
current_tab = 1
2733
tabs_visible = false
2834

29-
[node name="NormalControls" type="HBoxContainer" parent="TabContainer" unique_id=2094239495]
35+
[node name="NormalControls" type="HBoxContainer" parent="MarginContainer/TabContainer" unique_id=2094239495]
36+
unique_name_in_owner = true
3037
visible = false
3138
z_index = 38
3239
layout_mode = 2
3340
metadata/_tab_index = 0
3441

35-
[node name="MovementInputHint" parent="TabContainer/NormalControls" unique_id=30281671 instance=ExtResource("2_bewlk")]
42+
[node name="MovementInputHint" parent="MarginContainer/TabContainer/NormalControls" unique_id=30281671 instance=ExtResource("2_bewlk")]
3643
layout_mode = 2
3744

38-
[node name="RunInputHint" parent="TabContainer/NormalControls" unique_id=204428787 instance=ExtResource("4_i3pcn")]
45+
[node name="RunInputHint" parent="MarginContainer/TabContainer/NormalControls" unique_id=204428787 instance=ExtResource("4_i3pcn")]
3946
layout_mode = 2
4047

41-
[node name="InteractInputHint" parent="TabContainer/NormalControls" unique_id=1438993105 instance=ExtResource("4_ae80x")]
48+
[node name="InteractInputHint" parent="MarginContainer/TabContainer/NormalControls" unique_id=1438993105 instance=ExtResource("4_ae80x")]
49+
unique_name_in_owner = true
4250
visible = false
4351
layout_mode = 2
4452

45-
[node name="RepelInputHint" parent="TabContainer/NormalControls" unique_id=1938432601 instance=ExtResource("3_xu7en")]
53+
[node name="Spacer" type="Control" parent="MarginContainer/TabContainer/NormalControls" unique_id=1059909765]
54+
editor_description = "This empty control expands to fill the center of the hbox, pushing any controls packed after it to the right margin."
55+
layout_mode = 2
56+
size_flags_horizontal = 3
57+
58+
[node name="AimInputHint" parent="MarginContainer/TabContainer/NormalControls" unique_id=2095395309 instance=ExtResource("1_u1put")]
59+
unique_name_in_owner = true
4660
visible = false
4761
layout_mode = 2
4862

49-
[node name="AimInputHint" parent="TabContainer/NormalControls" unique_id=2095395309 instance=ExtResource("1_u1put")]
63+
[node name="ThrowInputHint" parent="MarginContainer/TabContainer/NormalControls" unique_id=1113313011 instance=ExtResource("5_ke286")]
64+
unique_name_in_owner = true
5065
visible = false
5166
layout_mode = 2
5267

53-
[node name="ThrowInputHint" parent="TabContainer/NormalControls" unique_id=1113313011 instance=ExtResource("5_ke286")]
68+
[node name="RepelInputHint" parent="MarginContainer/TabContainer/NormalControls" unique_id=1938432601 instance=ExtResource("3_xu7en")]
69+
unique_name_in_owner = true
5470
visible = false
5571
layout_mode = 2
5672

57-
[node name="SokobanControls" type="HBoxContainer" parent="TabContainer" unique_id=1543053795]
73+
[node name="SokobanControls" type="HBoxContainer" parent="MarginContainer/TabContainer" unique_id=1543053795]
74+
unique_name_in_owner = true
5875
layout_mode = 2
5976
metadata/_tab_index = 1
6077

61-
[node name="MovementInputHints" parent="TabContainer/SokobanControls" unique_id=1797965313 instance=ExtResource("2_bewlk")]
78+
[node name="MovementInputHints" parent="MarginContainer/TabContainer/SokobanControls" unique_id=1797965313 instance=ExtResource("2_bewlk")]
6279
layout_mode = 2
6380

64-
[node name="UndoInputHint" parent="TabContainer/SokobanControls" unique_id=1063563018 instance=ExtResource("7_ke286")]
81+
[node name="Spacer" type="Control" parent="MarginContainer/TabContainer/SokobanControls" unique_id=1667129251]
82+
editor_description = "This empty control expands to fill the center of the hbox, pushing any controls packed after it to the right margin."
6583
layout_mode = 2
84+
size_flags_horizontal = 3
6685

67-
[node name="ResetInputHint" parent="TabContainer/SokobanControls" unique_id=1042096726 instance=ExtResource("8_ae80x")]
86+
[node name="SkipInputHint" parent="MarginContainer/TabContainer/SokobanControls" unique_id=2102034377 instance=ExtResource("9_ofrnu")]
87+
unique_name_in_owner = true
88+
visible = false
6889
layout_mode = 2
6990

70-
[node name="SkiptInputHint" parent="TabContainer/SokobanControls" unique_id=2102034377 instance=ExtResource("9_ofrnu")]
71-
visible = false
91+
[node name="ResetInputHint" parent="MarginContainer/TabContainer/SokobanControls" unique_id=1042096726 instance=ExtResource("8_ae80x")]
92+
layout_mode = 2
93+
94+
[node name="UndoInputHint" parent="MarginContainer/TabContainer/SokobanControls" unique_id=1063563018 instance=ExtResource("7_ke286")]
7295
layout_mode = 2

scenes/ui_elements/input_hints/skip_input_hint.tscn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
[ext_resource type="Texture2D" uid="uid://dn8vx333yunpe" path="res://assets/third_party/inputs/atlas_kenney_input_prompts_1.4/steam-deck/steamdeck_button_y_outline.tres" id="6_bj40i"]
99
[ext_resource type="Theme" uid="uid://cvitou84ni7qe" path="res://scenes/ui_elements/components/theme.tres" id="7_3w1ni"]
1010

11-
[node name="SkiptInputHint" type="HBoxContainer" unique_id=2102034377]
11+
[node name="SkipInputHint" type="HBoxContainer" unique_id=2102034377]
1212
texture_filter = 2
1313
custom_minimum_size = Vector2(64, 64)
1414
size_flags_horizontal = 0

0 commit comments

Comments
 (0)