Skip to content

Commit 85dfe67

Browse files
committed
feat: implement help modal in main menu
1 parent 7671115 commit 85dfe67

File tree

2 files changed

+61
-8
lines changed

2 files changed

+61
-8
lines changed

scenes/menu.tscn

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
[ext_resource path="res://scripts/border.gd" type="Script" id=3]
66

77
[node name="Viewport" type="MarginContainer"]
8-
anchor_right = 1.0
9-
anchor_bottom = 1.0
8+
anchor_left = 0.00078125
9+
anchor_top = 0.00138889
10+
anchor_right = 1.00078
11+
anchor_bottom = 1.00139
1012
theme = ExtResource( 2 )
1113
custom_constants/margin_right = 40
1214
custom_constants/margin_top = 30
@@ -39,35 +41,76 @@ __meta__ = {
3941
"_edit_use_anchors_": false
4042
}
4143

44+
[node name="Instructions" type="MarginContainer" parent="MainMenu/Display"]
45+
visible = false
46+
margin_left = 480.0
47+
margin_top = 201.0
48+
margin_right = 720.0
49+
margin_bottom = 397.0
50+
size_flags_horizontal = 4
51+
size_flags_vertical = 4
52+
script = ExtResource( 3 )
53+
54+
[node name="VBoxContainer" type="VBoxContainer" parent="MainMenu/Display/Instructions"]
55+
margin_left = 20.0
56+
margin_top = 20.0
57+
margin_right = 220.0
58+
margin_bottom = 176.0
59+
60+
[node name="Label" type="Label" parent="MainMenu/Display/Instructions/VBoxContainer"]
61+
margin_right = 200.0
62+
margin_bottom = 129.0
63+
size_flags_horizontal = 4
64+
text = "W - bigger
65+
A - slower
66+
S - smaller
67+
D - faster
68+
M - toggle sound
69+
F - big preview mode"
70+
71+
[node name="Button" type="Button" parent="MainMenu/Display/Instructions/VBoxContainer"]
72+
margin_top = 137.0
73+
margin_right = 200.0
74+
margin_bottom = 156.0
75+
text = "OK"
76+
4277
[node name="Spacing" type="Control" parent="MainMenu"]
4378
margin_top = 633.0
4479
margin_right = 1200.0
4580
margin_bottom = 633.0
4681

4782
[node name="Buttons" type="HBoxContainer" parent="MainMenu"]
48-
margin_left = 290.0
83+
margin_left = 20.0
4984
margin_top = 641.0
50-
margin_right = 910.0
85+
margin_right = 1180.0
5186
margin_bottom = 660.0
5287
size_flags_horizontal = 4
5388
custom_constants/separation = 500
5489

90+
[node name="Help" type="Button" parent="MainMenu/Buttons"]
91+
margin_right = 40.0
92+
margin_bottom = 19.0
93+
text = "HELP"
94+
5595
[node name="Start" type="Button" parent="MainMenu/Buttons"]
56-
margin_right = 50.0
96+
margin_left = 540.0
97+
margin_right = 590.0
5798
margin_bottom = 19.0
5899
size_flags_horizontal = 4
59100
text = "START"
60101
flat = true
61102

62103
[node name="Credits" type="Button" parent="MainMenu/Buttons"]
63-
margin_left = 550.0
64-
margin_right = 620.0
104+
margin_left = 1090.0
105+
margin_right = 1160.0
65106
margin_bottom = 19.0
66107
text = "CREDITS"
67108

68109
[node name="Timer" type="Timer" parent="."]
69110
wait_time = 0.25
70111
autostart = true
112+
[connection signal="pressed" from="MainMenu/Display/Instructions/VBoxContainer/Button" to="MainMenu" method="_on_Button_pressed"]
113+
[connection signal="pressed" from="MainMenu/Buttons/Help" to="MainMenu" method="_on_Help_pressed"]
71114
[connection signal="pressed" from="MainMenu/Buttons/Start" to="MainMenu" method="_on_Start_pressed"]
72115
[connection signal="pressed" from="MainMenu/Buttons/Credits" to="MainMenu" method="_on_Credits_pressed"]
73116
[connection signal="timeout" from="Timer" to="MainMenu" method="_on_Timer_timeout"]

scripts/menu.gd

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,28 @@ var _level = BogoSort.new(ArrayModel.new())
55
func _ready():
66
$Buttons/Start.grab_focus()
77
randomize()
8-
$Display.add_child(ArrayView.new(_level))
8+
$Display.add_child(ArrayView.new(_level), true)
99

1010
func _on_Start_pressed():
1111
GlobalScene.change_scene("res://scenes/levels_redesign.tscn")
1212

1313
func _on_Credits_pressed():
1414
GlobalScene.change_scene("res://scenes/credits.tscn")
1515

16+
func _on_Help_pressed():
17+
$Display/Instructions.show()
18+
$Display/HBoxContainer.hide()
19+
$Display/Instructions/VBoxContainer/Button.grab_focus()
20+
1621
func _on_Timer_timeout():
1722
_level.next(null)
1823

1924
func _input(event):
2025
# If not in a browser, close the app
2126
if event.is_action_pressed("ui_cancel") and OS.get_name() != "HTML5":
2227
get_tree().quit()
28+
29+
func _on_Button_pressed():
30+
$Display/Instructions.hide()
31+
$Display/HBoxContainer.show()
32+
$Buttons/Start.grab_focus()

0 commit comments

Comments
 (0)