diff --git a/interface/game_ui.gd b/interface/game_ui.gd index 26f93c8..5717b98 100644 --- a/interface/game_ui.gd +++ b/interface/game_ui.gd @@ -1,2 +1,21 @@ extends VBoxContainer class_name GameUI + +## Emitted when the Score button is pressed. +signal score_button_pressed + +## Emitted when the Spawn button is pressed. +signal spawn_button_pressed + +## Emitted when the Shop button is presesd. +signal shop_button_pressed + + +func _on_score_button_pressed(): + score_button_pressed.emit() + +func _on_spawn_button_pressed(): + spawn_button_pressed.emit() + +func _on_shop_button_pressed(): + shop_button_pressed.emit() diff --git a/interface/game_ui.tscn b/interface/game_ui.tscn index 0ae256a..13b44fb 100644 --- a/interface/game_ui.tscn +++ b/interface/game_ui.tscn @@ -45,3 +45,7 @@ layout_mode = 2 size_flags_horizontal = 8 text = "Shop" alignment = 2 + +[connection signal="pressed" from="UpperButtons/ScoreButton" to="." method="_on_score_button_pressed"] +[connection signal="pressed" from="UpperButtons/SpawnButton" to="." method="_on_spawn_button_pressed"] +[connection signal="pressed" from="UpperButtons/ShopButton" to="." method="_on_shop_button_pressed"] diff --git a/root.gd b/root.gd index 7b2d3f7..d48e6e9 100644 --- a/root.gd +++ b/root.gd @@ -1,2 +1,49 @@ extends Node class_name Root + + +@onready var tree: SceneTree = get_tree() +@onready var game_ui: GameUI = $UI/GameUI +@onready var shop_ui: ShopUI = $UI/ShopUI + + +enum UIState { + GAME, + SHOP, + SCORE, +} + +@export var ui_state: UIState: + get: + return ui_state + set(value): + match value: + UIState.GAME: + tree.paused = false + game_ui.show() + shop_ui.hide() + UIState.SHOP: + tree.paused = true + game_ui.hide() + shop_ui.show() + UIState.SCORE: + pass + + +func _on_game_ui_score_button_pressed(): + ui_state = UIState.SCORE + +func _on_shop_ui_back_button_pressed(): + ui_state = UIState.GAME + +func _on_shop_ui_delete_button_pressed(): + ui_state = UIState.GAME + +func _on_shop_ui_score_button_pressed(): + ui_state = UIState.SCORE + +func _on_game_ui_shop_button_pressed(): + ui_state = UIState.SHOP + +func _on_game_ui_spawn_button_pressed(): + pass # Replace with function body. diff --git a/root.tscn b/root.tscn index 11054fb..e2b50af 100644 --- a/root.tscn +++ b/root.tscn @@ -1,11 +1,13 @@ -[gd_scene load_steps=5 format=3 uid="uid://cbccs6kwwf265"] +[gd_scene load_steps=6 format=3 uid="uid://cbccs6kwwf265"] +[ext_resource type="Script" path="res://root.gd" id="1_8jrhk"] [ext_resource type="Theme" uid="uid://ba5utvfhnxa5i" path="res://interface/interface_theme.tres" id="1_h26ax"] [ext_resource type="PackedScene" uid="uid://mfa1v4fsnupp" path="res://interface/game_container.tscn" id="1_xjgvu"] [ext_resource type="PackedScene" uid="uid://cklkdygv61bny" path="res://interface/shop_ui.tscn" id="3_lvefk"] [ext_resource type="PackedScene" uid="uid://bo5unrhqpoyim" path="res://interface/game_ui.tscn" id="5_2cc15"] [node name="Root" type="Node"] +script = ExtResource("1_8jrhk") [node name="UI" type="Control" parent="."] texture_filter = 1 @@ -19,11 +21,20 @@ size_flags_vertical = 8 theme = ExtResource("1_h26ax") [node name="GameContainer" parent="UI" instance=ExtResource("1_xjgvu")] +process_mode = 1 layout_mode = 1 [node name="GameUI" parent="UI" instance=ExtResource("5_2cc15")] +process_mode = 3 layout_mode = 1 [node name="ShopUI" parent="UI" instance=ExtResource("3_lvefk")] -visible = false +process_mode = 3 layout_mode = 1 + +[connection signal="score_button_pressed" from="UI/GameUI" to="." method="_on_game_ui_score_button_pressed"] +[connection signal="shop_button_pressed" from="UI/GameUI" to="." method="_on_game_ui_shop_button_pressed"] +[connection signal="spawn_button_pressed" from="UI/GameUI" to="." method="_on_game_ui_spawn_button_pressed"] +[connection signal="back_button_pressed" from="UI/ShopUI" to="." method="_on_shop_ui_back_button_pressed"] +[connection signal="delete_button_pressed" from="UI/ShopUI" to="." method="_on_shop_ui_delete_button_pressed"] +[connection signal="score_button_pressed" from="UI/ShopUI" to="." method="_on_shop_ui_score_button_pressed"]