Add button functionality to Main Menu, About, How to Play, Select Stage, Pause, and Defeat UI

This commit is contained in:
Moe Poi ~ 2023-10-18 11:09:00 +07:00
parent d3ccdcc644
commit f2086f6360
12 changed files with 107 additions and 19 deletions

View file

@ -1,4 +1,6 @@
[gd_scene format=3 uid="uid://cmafth1g3e7fq"]
[gd_scene load_steps=2 format=3 uid="uid://cmafth1g3e7fq"]
[ext_resource type="Script" path="res://scripts/ui/about.gd" id="1_3w66n"]
[node name="About" type="Control"]
layout_mode = 3
@ -7,6 +9,7 @@ anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_3w66n")
[node name="Panel" type="Panel" parent="."]
layout_mode = 1
@ -41,7 +44,7 @@ size_flags_horizontal = 2
size_flags_vertical = 0
text = "About"
[node name="Button" type="Button" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer"]
[node name="Back" type="Button" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 10
size_flags_vertical = 0
@ -65,3 +68,5 @@ autowrap_mode = 3
[node name="HBoxContainer3" type="HBoxContainer" parent="Panel/MarginContainer/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 3
[connection signal="pressed" from="Panel/MarginContainer/VBoxContainer/HBoxContainer/Back" to="." method="_on_back_pressed"]

View file

@ -1,6 +1,7 @@
[gd_scene load_steps=2 format=3 uid="uid://wywjvwp7ausj"]
[gd_scene load_steps=3 format=3 uid="uid://wywjvwp7ausj"]
[ext_resource type="Texture2D" uid="uid://b3sb2q80p1fbd" path="res://assets/icons/defeat.png" id="1_bioyr"]
[ext_resource type="Script" path="res://scripts/ui/defeat.gd" id="1_sbbw3"]
[node name="Defeat" type="Control"]
layout_mode = 3
@ -9,6 +10,7 @@ anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_sbbw3")
[node name="Panel" type="Panel" parent="."]
layout_mode = 1
@ -40,8 +42,10 @@ layout_mode = 2
size_flags_horizontal = 4
texture = ExtResource("1_bioyr")
[node name="Button" type="Button" parent="Panel/MarginContainer/VBoxContainer"]
[node name="MainMenu" type="Button" parent="Panel/MarginContainer/VBoxContainer"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 6
text = "Main Menu"
[connection signal="pressed" from="Panel/MarginContainer/VBoxContainer/MainMenu" to="." method="_on_main_menu_pressed"]

View file

@ -1,5 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://cjvppmi07xul8"]
[gd_scene load_steps=3 format=3 uid="uid://cjvppmi07xul8"]
[ext_resource type="Script" path="res://scripts/ui/how_to_play.gd" id="1_7kvq7"]
[ext_resource type="Texture2D" uid="uid://eebavmfljotl" path="res://assets/icons/not-found.png" id="1_331sn"]
[node name="HowToPlay" type="Control"]
@ -9,6 +10,7 @@ anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_7kvq7")
[node name="Panel" type="Panel" parent="."]
layout_mode = 1
@ -43,7 +45,7 @@ size_flags_horizontal = 2
size_flags_vertical = 0
text = "How to Play"
[node name="Button" type="Button" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer"]
[node name="Back" type="Button" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 10
size_flags_vertical = 0
@ -58,3 +60,5 @@ layout_mode = 2
size_flags_horizontal = 6
size_flags_vertical = 4
texture = ExtResource("1_331sn")
[connection signal="pressed" from="Panel/MarginContainer/VBoxContainer/HBoxContainer/Back" to="." method="_on_back_pressed"]

View file

@ -1,6 +1,7 @@
[gd_scene load_steps=3 format=3 uid="uid://b8pdp1x331u5c"]
[gd_scene load_steps=4 format=3 uid="uid://b8pdp1x331u5c"]
[ext_resource type="Texture2D" uid="uid://c1qbpse383sys" path="res://assets/backgrounds/main-bg.png" id="1_28cjd"]
[ext_resource type="Script" path="res://scripts/ui/main_menu.gd" id="1_6741p"]
[ext_resource type="Texture2D" uid="uid://dm8ug0o5361wn" path="res://assets/icons/logo-main.png" id="2_l26fo"]
[node name="MainMenu" type="Control"]
@ -10,6 +11,7 @@ anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_6741p")
[node name="TextureRect" type="TextureRect" parent="."]
layout_mode = 1
@ -79,3 +81,8 @@ text = "About"
layout_mode = 2
size_flags_horizontal = 10
text = "Exit"
[connection signal="pressed" from="TextureRect/Panel/MarginContainer/VBoxContainer/VBoxContainer/StartGame" to="." method="_on_start_game_pressed"]
[connection signal="pressed" from="TextureRect/Panel/MarginContainer/VBoxContainer/VBoxContainer/HowToPlay" to="." method="_on_how_to_play_pressed"]
[connection signal="pressed" from="TextureRect/Panel/MarginContainer/VBoxContainer/HBoxContainer/About" to="." method="_on_about_pressed"]
[connection signal="pressed" from="TextureRect/Panel/MarginContainer/VBoxContainer/HBoxContainer/Exit" to="." method="_on_exit_pressed"]

View file

@ -61,7 +61,7 @@ size_flags_vertical = 3
layout_mode = 2
size_flags_horizontal = 3
[node name="TextureButton" type="TextureButton" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer/VBoxContainer"]
[node name="Resume" type="TextureButton" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer/VBoxContainer"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 6
@ -78,7 +78,7 @@ justification_flags = 162
layout_mode = 2
size_flags_horizontal = 3
[node name="TextureButton" type="TextureButton" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer/VBoxContainer2"]
[node name="MainMenu" type="TextureButton" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer/VBoxContainer2"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 6
@ -91,4 +91,5 @@ size_flags_vertical = 6
text = "Main Menu"
horizontal_alignment = 1
[connection signal="pressed" from="Panel/MarginContainer/VBoxContainer/HBoxContainer/VBoxContainer/TextureButton" to="." method="_on_resume_button_pressed"]
[connection signal="pressed" from="Panel/MarginContainer/VBoxContainer/HBoxContainer/VBoxContainer/Resume" to="." method="_on_resume_button_pressed"]
[connection signal="pressed" from="Panel/MarginContainer/VBoxContainer/HBoxContainer/VBoxContainer2/MainMenu" to="." method="_on_main_menu_pressed"]

View file

@ -1,4 +1,6 @@
[gd_scene format=3 uid="uid://cwf2fhvjfq7xg"]
[gd_scene load_steps=2 format=3 uid="uid://cwf2fhvjfq7xg"]
[ext_resource type="Script" path="res://scripts/ui/select_stage.gd" id="1_t86bq"]
[node name="SelectStage" type="Control"]
layout_mode = 3
@ -7,6 +9,7 @@ anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_t86bq")
[node name="Panel" type="Panel" parent="."]
layout_mode = 1
@ -41,7 +44,7 @@ size_flags_horizontal = 2
size_flags_vertical = 0
text = "Select Stage"
[node name="Button" type="Button" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer"]
[node name="Back" type="Button" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 10
size_flags_vertical = 0
@ -59,7 +62,7 @@ theme_override_constants/margin_top = 10
theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 10
[node name="Button" type="Button" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer2/MarginContainer"]
[node name="Stage 1" type="Button" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer2/MarginContainer"]
layout_mode = 2
text = "1"
@ -71,7 +74,7 @@ theme_override_constants/margin_top = 10
theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 10
[node name="Button" type="Button" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer2/MarginContainer2"]
[node name="Stage 2" type="Button" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer2/MarginContainer2"]
layout_mode = 2
text = "2"
@ -83,7 +86,7 @@ theme_override_constants/margin_top = 10
theme_override_constants/margin_right = 20
theme_override_constants/margin_bottom = 10
[node name="Button" type="Button" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer2/MarginContainer3"]
[node name="Stage 3" type="Button" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer2/MarginContainer3"]
layout_mode = 2
text = "3"
@ -99,7 +102,7 @@ theme_override_constants/margin_top = 10
theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 20
[node name="Button" type="Button" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer3/MarginContainer"]
[node name="Stage 4" type="Button" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer3/MarginContainer"]
layout_mode = 2
text = "4"
@ -111,7 +114,7 @@ theme_override_constants/margin_top = 10
theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 20
[node name="Button" type="Button" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer3/MarginContainer2"]
[node name="Stage 5" type="Button" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer3/MarginContainer2"]
layout_mode = 2
text = "5"
@ -123,6 +126,14 @@ theme_override_constants/margin_top = 10
theme_override_constants/margin_right = 20
theme_override_constants/margin_bottom = 20
[node name="Button" type="Button" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer3/MarginContainer3"]
[node name="Stage 6" type="Button" parent="Panel/MarginContainer/VBoxContainer/HBoxContainer3/MarginContainer3"]
layout_mode = 2
text = "6"
[connection signal="pressed" from="Panel/MarginContainer/VBoxContainer/HBoxContainer/Back" to="." method="_on_back_pressed"]
[connection signal="pressed" from="Panel/MarginContainer/VBoxContainer/HBoxContainer2/MarginContainer/Stage 1" to="." method="_on_stage_1_pressed"]
[connection signal="pressed" from="Panel/MarginContainer/VBoxContainer/HBoxContainer2/MarginContainer2/Stage 2" to="." method="_on_stage_2_pressed"]
[connection signal="pressed" from="Panel/MarginContainer/VBoxContainer/HBoxContainer2/MarginContainer3/Stage 3" to="." method="_on_stage_3_pressed"]
[connection signal="pressed" from="Panel/MarginContainer/VBoxContainer/HBoxContainer3/MarginContainer/Stage 4" to="." method="_on_stage_4_pressed"]
[connection signal="pressed" from="Panel/MarginContainer/VBoxContainer/HBoxContainer3/MarginContainer2/Stage 5" to="." method="_on_stage_5_pressed"]
[connection signal="pressed" from="Panel/MarginContainer/VBoxContainer/HBoxContainer3/MarginContainer3/Stage 6" to="." method="_on_stage_6_pressed"]

5
scripts/ui/about.gd Normal file
View file

@ -0,0 +1,5 @@
extends Control
func _on_back_pressed():
get_tree().change_scene_to_file("res://scenes/ui/main_menu.tscn")

5
scripts/ui/defeat.gd Normal file
View file

@ -0,0 +1,5 @@
extends Control
func _on_main_menu_pressed():
get_tree().change_scene_to_file("res://scenes/ui/main_menu.tscn")

View file

@ -0,0 +1,5 @@
extends Control
func _on_back_pressed():
get_tree().change_scene_to_file("res://scenes/ui/main_menu.tscn")

14
scripts/ui/main_menu.gd Normal file
View file

@ -0,0 +1,14 @@
extends Control
func _on_start_game_pressed():
get_tree().change_scene_to_file("res://scenes/ui/select_stage.tscn")
func _on_how_to_play_pressed():
get_tree().change_scene_to_file("res://scenes/ui/how_to_play.tscn")
func _on_about_pressed():
get_tree().change_scene_to_file("res://scenes/ui/about.tscn")
func _on_exit_pressed():
get_tree().quit()

View file

@ -9,4 +9,8 @@ func hide_menu():
hide()
func _on_resume_button_pressed():
on_resume.emit()
on_resume.emit()
func _on_main_menu_pressed():
on_resume.emit()
get_tree().change_scene_to_file("res://scenes/ui/main_menu.tscn")

View file

@ -0,0 +1,23 @@
extends Control
func _on_back_pressed():
get_tree().change_scene_to_file("res://scenes/ui/main_menu.tscn")
func _on_stage_1_pressed():
get_tree().change_scene_to_file("res://scenes/stages/stage_1.tscn")
func _on_stage_2_pressed():
get_tree().change_scene_to_file("res://scenes/stages/stage_2.tscn")
func _on_stage_3_pressed():
get_tree().change_scene_to_file("res://scenes/stages/stage_3.tscn")
func _on_stage_4_pressed():
get_tree().change_scene_to_file("res://scenes/stages/stage_4.tscn")
func _on_stage_5_pressed():
get_tree().change_scene_to_file("res://scenes/stages/stage_5.tscn")
func _on_stage_6_pressed():
get_tree().change_scene_to_file("res://scenes/stages/stage_6.tscn")