diff options
-rw-r--r-- | client/game.gd | 4 | ||||
-rw-r--r-- | client/menu/popup_message.gd | 32 |
2 files changed, 34 insertions, 2 deletions
diff --git a/client/game.gd b/client/game.gd index aedfd5f7..ccc72e11 100644 --- a/client/game.gd +++ b/client/game.gd @@ -224,9 +224,9 @@ func _ready(): map.autobake = true if in_lobby_: - popup_message.stop_game_hints() + popup_message.lobby() else: - popup_message.start_game_hints() + popup_message.ingame() else: map.autobake = false await get_parent().menu_anim_exit() diff --git a/client/menu/popup_message.gd b/client/menu/popup_message.gd index d37343c3..921e3647 100644 --- a/client/menu/popup_message.gd +++ b/client/menu/popup_message.gd @@ -16,6 +16,9 @@ extends MarginContainer class_name PopupMessage +var is_ingame := false +var is_joined := false + @onready var server_msg = $VBox/ServerMessage @onready var hint_msg = $VBox/HintMessage @@ -29,6 +32,34 @@ class_name PopupMessage @onready var reset_timer = $Reset +@onready var game: Game = get_parent() + +func _ready(): + game.joined.connect( + func player_joined(): + is_joined = true + update_state() + ) + game.left.connect( + func player_joined(): + is_joined = false + update_state() + ) + +func ingame(): + is_ingame = true + update_state() + +func lobby(): + is_ingame = false + update_state() + +func update_state(): + if is_ingame and is_joined: + start_game_hints() + else: + stop_game_hints() + func display_server_msg(msg: String): server_msg.show() server_msg_label.text = msg @@ -53,6 +84,7 @@ func stop_game_hints(): _on_hint_timer_timeout() for c: Timer in auto_hint_timers.get_children(): c.stop() + reset_timer.stop() func _input(_event): if Input.is_action_just_pressed("boost"): |