diff options
Diffstat (limited to 'client/menu/ingame.gd')
-rw-r--r-- | client/menu/ingame.gd | 39 |
1 files changed, 15 insertions, 24 deletions
diff --git a/client/menu/ingame.gd b/client/menu/ingame.gd index 7052f237..ba365f8e 100644 --- a/client/menu/ingame.gd +++ b/client/menu/ingame.gd @@ -26,19 +26,16 @@ extends Menu var opened func _ready(): opened = Time.get_ticks_msec() - game.joined.connect(_on_game_joined) - game.left.connect(_on_game_left) - update_button_text() - game.joined.connect(update_lobby_button) - game.left.connect(update_lobby_button) + game.join_state_updated.connect(_on_game_join_state_changed) + _on_game_join_state_changed(game.join_state) update_lobby_button() super() func update_lobby_button(): - lobby_button.disabled = game.in_lobby or not game.is_joined + lobby_button.disabled = game.in_lobby or game.join_state == Game.JoinState.SPECTATING if game.in_lobby: lobby_button.tooltip_text = "Cannot cancel game since no game is running." - elif not game.is_joined: + elif not game.join_state == Game.JoinState.JOINED: lobby_button.tooltip_text = "You must join in order to be able to cancel the current game." else: lobby_button.tooltip_text = "" @@ -71,21 +68,15 @@ func _on_lobby_pressed(): exit() func _on_leave_pressed(): - if game.is_joined: - game.mp.send_leave(game.player_id) - elif not game.join_sent: - leave_button.disabled = true - game.join() + game.toggle_join() -func _on_game_joined(): - leave_button.disabled = false - update_button_text() - -func _on_game_left(): - update_button_text() - -func update_button_text(): - if game.is_joined: - leave_button.text = tr("c.menu.ingame.leave") - else: - leave_button.text = tr("c.menu.ingame.join") +func _on_game_join_state_changed(state: Game.JoinState): + match state: + Game.JoinState.JOINED: + leave_button.disabled = false + leave_button.text = tr("c.menu.ingame.leave") + Game.JoinState.SPECTATING: + leave_button.disabled = false + leave_button.text = tr("c.menu.ingame.join") + Game.JoinState.WAITING: + leave_button.disabled = true |