changes UI to a global singleton
This commit is contained in:
parent
aa4afc4c4b
commit
e3aec75404
16 changed files with 371 additions and 119 deletions
|
|
@ -1,16 +1,35 @@
|
|||
extends CanvasLayer
|
||||
class_name UI
|
||||
extends Node
|
||||
|
||||
@onready var ingame_menu: MarginContainer = %IngameMenu
|
||||
# these two signals come from the MainMenu and start / continue the game
|
||||
# gets sent to the main.gd scene
|
||||
signal on_new_game_started
|
||||
signal on_game_continued
|
||||
|
||||
@onready var root: CanvasLayer = $/root/Game/UI
|
||||
@onready var main_menu: Control = $/root/Game/UI/MainMenu
|
||||
@onready var ingame_controls: MarginContainer = $/root/Game/UI/IngameControls
|
||||
@onready var ingame_menu: Control = $/root/Game/UI/IngameMenu
|
||||
@onready var camera_control_area : Control = $/root/Game/UI/CameraControlArea
|
||||
@onready var save_ui : Control = $/root/Game/UI/SaveUI
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
main_menu.connect("on_game_continued", _on_main_menu_on_game_continued)
|
||||
main_menu.connect("on_new_game_started", _on_main_menu_on_new_game_started)
|
||||
|
||||
ingame_controls.connect("menu_button_clicked", _on_ingame_controls_menu_button_clicked)
|
||||
ingame_controls.connect("save_button_clicked", _on_ingame_controls_save_button_clicked)
|
||||
ingame_controls.connect("save_button_released", _on_ingame_controls_save_button_released)
|
||||
ingame_controls.connect("save_timer_incremented", _on_ingame_controls_save_timer_incremented)
|
||||
ingame_controls.connect("save_timer_reached", _on_ingame_controls_save_timer_reached)
|
||||
|
||||
pass
|
||||
|
||||
func show_main_menu(p_visible = true) -> void:
|
||||
main_menu.visible = p_visible
|
||||
|
||||
func show_ingame_controls(p_visible = true) -> void:
|
||||
ingame_controls.visible = p_visible
|
||||
|
||||
func _on_ingame_controls_menu_button_clicked() -> void:
|
||||
ingame_menu.visible = true
|
||||
|
||||
|
|
@ -26,19 +45,28 @@ func _update_ui() -> void:
|
|||
|
||||
|
||||
func _on_ingame_controls_save_button_clicked() -> void:
|
||||
%SaveUI.visible = true
|
||||
save_ui.visible = true
|
||||
|
||||
func _on_ingame_controls_save_button_released() -> void:
|
||||
%SaveUI.visible = false
|
||||
save_ui.visible = false
|
||||
|
||||
func _on_ingame_controls_save_timer_incremented(value) -> void:
|
||||
%SavePercentage.text = str(value)
|
||||
save_ui.get_node("SavePercentage").text = str(value)
|
||||
|
||||
|
||||
func _on_ingame_controls_save_timer_reached() -> void:
|
||||
%SavePercentage.text = "Saved!"
|
||||
%IngameControls.disable_save_button()
|
||||
save_ui.get_node("SavePercentage").text = "Saved!"
|
||||
ingame_controls.disable_save_button()
|
||||
await get_tree().create_timer(1.0).timeout
|
||||
%IngameControls.enable_save_button()
|
||||
$SaveUI.visible = false
|
||||
%SavePercentage.text = "0%"
|
||||
ingame_controls.enable_save_button()
|
||||
save_ui.visible = false
|
||||
save_ui.get_node("SavePercentage").text = "0%"
|
||||
|
||||
|
||||
# sends the signal from the MainMenu node up to the main.gd scene
|
||||
func _on_main_menu_on_new_game_started() -> void:
|
||||
on_new_game_started.emit()
|
||||
|
||||
# sends the signal from the MainMenu node up to the main.gd scene
|
||||
func _on_main_menu_on_game_continued() -> void:
|
||||
on_game_continued.emit()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue