aboutsummaryrefslogtreecommitdiff
path: root/game/src/GameSession/GameSpeedPanel.gd
diff options
context:
space:
mode:
author Hop311 <hop3114@gmail.com>2023-04-23 20:49:01 +0200
committer Hop311 <hop3114@gmail.com>2023-04-23 20:49:01 +0200
commitd3f3187209cb4085f27f95ce8ad2a77af25704fd (patch)
tree60971db586e78761341f2b48110d149b1ba0db9d /game/src/GameSession/GameSpeedPanel.gd
parent1084a5d64df5d3465ef90b3b85fe3374636a3fe8 (diff)
C++ refactoring + simulation prototype
Diffstat (limited to 'game/src/GameSession/GameSpeedPanel.gd')
-rw-r--r--game/src/GameSession/GameSpeedPanel.gd29
1 files changed, 17 insertions, 12 deletions
diff --git a/game/src/GameSession/GameSpeedPanel.gd b/game/src/GameSession/GameSpeedPanel.gd
index 8dc35d7..c203032 100644
--- a/game/src/GameSession/GameSpeedPanel.gd
+++ b/game/src/GameSession/GameSpeedPanel.gd
@@ -7,27 +7,32 @@ extends PanelContainer
@export var _decrease_speed_button : Button
@export var _increase_speed_button : Button
-var is_game_paused : bool = true
-
# Called when the node enters the scene tree for the first time.
func _ready():
- _update_playpause_button()
+ GameSingleton.state_updated.connect(_update_buttons)
+ _update_buttons()
+
+func _update_buttons():
+ _play_pause_display_button.text = "⏸️" if GameSingleton.is_paused() else "▶"
+
+ _increase_speed_button.disabled = not GameSingleton.can_increase_speed()
+ _decrease_speed_button.disabled = not GameSingleton.can_decrease_speed()
-func _update_playpause_button():
- _play_pause_display_button.text = "⏸️" if is_game_paused else "▶"
- print("Game is paused" if is_game_paused else "Game is advancing")
+ _longform_date_button.text = GameSingleton.get_longform_date()
func _on_decrease_speed_button_pressed():
- print("Decrease speed")
+ GameSingleton.decrease_speed()
+ _update_buttons()
func _on_increase_speed_button_pressed():
- print("Increase speed")
+ GameSingleton.increase_speed()
+ _update_buttons()
func _on_play_pause_display_button_pressed():
- is_game_paused = !is_game_paused
- _update_playpause_button()
+ GameSingleton.toggle_paused()
+ _update_buttons()
func _on_longform_date_label_pressed():
- is_game_paused = !is_game_paused
- _update_playpause_button()
+ GameSingleton.toggle_paused()
+ _update_buttons()