diff options
author | nokoe <nokoe@mailbox.org> | 2024-07-08 14:24:34 +0200 |
---|---|---|
committer | nokoe <nokoe@mailbox.org> | 2024-07-08 14:24:34 +0200 |
commit | 535db64a8fc2ed95393eb5ca7facedcf179b8f63 (patch) | |
tree | 33860ace7c4f90b69de58f0d91cd522944b43bea /client/menu | |
parent | 3eb17b6d3e5a95e997d1dfd38eaac56cbf169177 (diff) | |
download | hurrycurry-535db64a8fc2ed95393eb5ca7facedcf179b8f63.tar hurrycurry-535db64a8fc2ed95393eb5ca7facedcf179b8f63.tar.bz2 hurrycurry-535db64a8fc2ed95393eb5ca7facedcf179b8f63.tar.zst |
add join button
Diffstat (limited to 'client/menu')
-rw-r--r-- | client/menu/lobby.gd | 25 | ||||
-rw-r--r-- | client/menu/lobby.tscn | 3 |
2 files changed, 23 insertions, 5 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() diff --git a/client/menu/lobby.tscn b/client/menu/lobby.tscn index df58915c..8510b995 100644 --- a/client/menu/lobby.tscn +++ b/client/menu/lobby.tscn @@ -60,6 +60,7 @@ layout_mode = 2 theme_override_constants/separation = 24 [node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/Bottom/MarginContainer/VBoxContainer"] +visible = false layout_mode = 2 alignment = 1 @@ -99,7 +100,7 @@ layout_mode = 2 [node name="ControllerButton" parent="VBoxContainer/Bottom/MarginContainer/VBoxContainer/CenterContainer" instance=ExtResource("7_t6mox")] custom_minimum_size = Vector2(148, 0) layout_mode = 2 -text = "Start Game" +text = "Join Game" expand_icon = true controller_texture = ExtResource("9_q14bw") press_action = "start_game" |