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.gd25
1 files changed, 21 insertions, 4 deletions
diff --git a/client/menu/lobby.gd b/client/menu/lobby.gd
index 976cefb6..a905e670 100644
--- a/client/menu/lobby.gd
+++ b/client/menu/lobby.gd
@@ -1,5 +1,6 @@
# Undercooked - a game about cooking
# Copyright 2024 tpart
+# Copyright 2024 nokoe
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
@@ -19,19 +20,24 @@ const PLAYER = preload("res://menu/lobby/player.tscn")
var selected_map := 0
var selected_map_name: String
+var joined := false
+var join_sent := false
@onready var game: Game = $"../Game"
@onready var map_count = game.map_names.size()
@onready var player_container = $VBoxContainer/Top/MarginContainer/VBoxContainer/Players
@onready var map_name_label = $VBoxContainer/Bottom/MarginContainer/VBoxContainer/HBoxContainer/MapSelection
+@onready var map_selector = $VBoxContainer/Bottom/MarginContainer/VBoxContainer/HBoxContainer
@onready var prev_map = $VBoxContainer/Bottom/MarginContainer/VBoxContainer/HBoxContainer/Left
@onready var next_map = $VBoxContainer/Bottom/MarginContainer/VBoxContainer/HBoxContainer/Right
+@onready var start_button = $VBoxContainer/Bottom/MarginContainer/VBoxContainer/CenterContainer/ControllerButton
func _ready():
game.update_players.connect(update_players)
initialize()
game.data_updated.connect(initialize)
+ game.joined.connect(_on_game_joined)
func initialize():
map_count = game.map_names.size()
@@ -48,7 +54,7 @@ func select_map(i: int):
func update_players(player_list: Dictionary):
for i in player_container.get_children():
i.queue_free()
-
+
for i in player_list.keys():
var p: PlayerTag = PLAYER.instantiate()
player_container.add_child(p)
@@ -57,12 +63,18 @@ func update_players(player_list: Dictionary):
func _input(event):
if not visible:
return
-
+
if Input.is_action_just_pressed("previous") and not prev_map.disabled:
prev_map.emit_signal("pressed")
elif Input.is_action_just_pressed("next") and not next_map.disabled:
next_map.emit_signal("pressed")
+func _on_game_joined():
+ map_selector.show()
+ start_button.text = tr("Start Game")
+ start_button.disabled = false
+ joined = true
+
func _on_left_pressed():
selected_map = (selected_map - 1) % map_count
select_map(selected_map)
@@ -72,5 +84,10 @@ func _on_right_pressed():
select_map(selected_map)
func _on_controller_button_pressed():
- if selected_map_name != null:
- game.mp.send_chat("/start %s" % selected_map_name)
+ if joined:
+ if selected_map_name != null:
+ game.mp.send_chat("/start %s" % selected_map_name)
+ elif not join_sent:
+ join_sent = true
+ start_button.disabled = true
+ game.join()