summaryrefslogtreecommitdiff
path: root/client/menu/lobby.gd
diff options
context:
space:
mode:
Diffstat (limited to 'client/menu/lobby.gd')
-rw-r--r--client/menu/lobby.gd42
1 files changed, 22 insertions, 20 deletions
diff --git a/client/menu/lobby.gd b/client/menu/lobby.gd
index 0dca6f4c..d595444e 100644
--- a/client/menu/lobby.gd
+++ b/client/menu/lobby.gd
@@ -52,8 +52,8 @@ func _ready():
game.update_players.connect(update_players)
initialize()
game.data_updated.connect(initialize)
- game.joined.connect(_on_game_joined)
- game.left.connect(_on_game_left)
+ game.join_state_updated.connect(_on_game_join_state_updated)
+ _on_game_join_state_updated(game.join_state)
check_for_music()
func initialize():
@@ -145,18 +145,6 @@ func _input(_event):
elif Input.is_action_just_pressed("next") and not next_map.disabled:
next_map.emit_signal("pressed")
-func _on_game_joined():
- map_selector.show()
- map_list.show()
- bots_container.show()
- start_button.disabled = false
-
-func _on_game_left():
- map_selector.hide()
- map_list.hide()
- bots_container.hide()
- start_button.disabled = true
-
func _on_left_pressed():
selected_map = (selected_map - 1) % map_count
select_map(selected_map)
@@ -177,13 +165,27 @@ func _on_controller_button_pressed():
game.mp.send_chat(game.player_id, start_msg)
Sound.play_music("stop") # TODO: Game music enter
+func _on_game_join_state_updated(state: Game.JoinState):
+ match state:
+ Game.JoinState.JOINED:
+ map_selector.show()
+ map_list.show()
+ bots_container.show()
+ start_button.disabled = false
+ join_spectate.disabled = false
+ join_spectate.text = tr("c.menu.ingame.spectate")
+ Game.JoinState.SPECTATING:
+ map_selector.hide()
+ map_list.hide()
+ bots_container.hide()
+ start_button.disabled = true
+ join_spectate.disabled = false
+ join_spectate.text = tr("c.menu.ingame.join")
+ Game.JoinState.WAITING:
+ join_spectate.disabled = true
+
func _on_join_spectate_pressed():
- if game.is_joined:
- game.leave()
- join_spectate.text = tr("c.menu.ingame.join")
- elif not game.join_sent:
- game.join()
- join_spectate.text = tr("c.menu.ingame.spectate")
+ game.toggle_join()
func check_for_music():
if visible: