aboutsummaryrefslogtreecommitdiff
path: root/client/gui/overlays/lobby
diff options
context:
space:
mode:
Diffstat (limited to 'client/gui/overlays/lobby')
-rw-r--r--client/gui/overlays/lobby/lobby.gd204
-rw-r--r--client/gui/overlays/lobby/lobby.gd.uid1
-rw-r--r--client/gui/overlays/lobby/lobby.tscn191
-rw-r--r--client/gui/overlays/lobby/player.gd22
-rw-r--r--client/gui/overlays/lobby/player.gd.uid1
-rw-r--r--client/gui/overlays/lobby/player.tscn43
6 files changed, 462 insertions, 0 deletions
diff --git a/client/gui/overlays/lobby/lobby.gd b/client/gui/overlays/lobby/lobby.gd
new file mode 100644
index 00000000..3971dbb3
--- /dev/null
+++ b/client/gui/overlays/lobby/lobby.gd
@@ -0,0 +1,204 @@
+# Hurry Curry! - a game about cooking
+# Copyright (C) 2025 Hurry Curry! contributors
+#
+# 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
+# the Free Software Foundation, version 3 of the License only.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+#
+extends Control
+class_name Lobby
+
+const MAX_BOT_COUNT_PER_TYPE: int = 3
+const PLAYER = preload("res://gui/overlays/lobby/player.tscn")
+
+var map_count
+var selected_map := 0
+var selected_map_name: String
+
+var bots_enabled := false
+var bot_counts := {}
+var bot_reset_buttons := {}
+var bot_inc_buttons := {}
+var bot_dec_buttons := {}
+
+@onready var game: Game = $"../Game"
+@onready var player_container = $PlayerList/VBoxContainer/Players
+
+@onready var map_name_label = $Sidebar/Bottom/MarginContainer/VBoxContainer/HBoxContainer/Map/Name
+@onready var map_player_label = $Sidebar/Bottom/MarginContainer/VBoxContainer/HBoxContainer/Map/Players
+@onready var map_difficulty_label = $Sidebar/Bottom/MarginContainer/VBoxContainer/HBoxContainer/Map/Difficulty
+@onready var map_list_container = $Sidebar/Bottom/MarginContainer/VBoxContainer/MapList/VBoxContainer
+@onready var map_list = $Sidebar/Bottom/MarginContainer/VBoxContainer/MapList
+
+@onready var map_selector = $Sidebar/Bottom/MarginContainer/VBoxContainer/HBoxContainer
+@onready var prev_map = $Sidebar/Bottom/MarginContainer/VBoxContainer/HBoxContainer/VBoxContainer/Left
+@onready var next_map = $Sidebar/Bottom/MarginContainer/VBoxContainer/HBoxContainer/VBoxContainer2/Right
+
+@onready var bots_container = $Sidebar/Bottom/MarginContainer/VBoxContainer/Bots
+@onready var bot_settings = $Sidebar/Bottom/MarginContainer/VBoxContainer/Bots/ScrollContainerCustom/BotSettings
+@onready var bot_settings_conainer = $Sidebar/Bottom/MarginContainer/VBoxContainer/Bots/ScrollContainerCustom
+
+@onready var join_spectate = $Sidebar/Bottom/MarginContainer/VBoxContainer/VBoxContainer/JoinSpectate
+@onready var start_button = $Sidebar/Bottom/MarginContainer/VBoxContainer/VBoxContainer/Start
+
+func _ready():
+ game.update_players.connect(update_players)
+ initialize()
+ game.data_updated.connect(initialize)
+ game.join_state_updated.connect(_on_game_join_state_updated)
+ _on_game_join_state_updated(game.join_state)
+ check_for_music()
+
+func initialize():
+ map_count = game.maps.size()
+
+ for c in map_list_container.get_children():
+ c.queue_free()
+ for c in bot_settings.get_children():
+ c.queue_free()
+
+ var i := 0
+ for m in game.maps:
+ var b := Button.new()
+ b.name = m[0]
+ b.text = "%s (%d)" % [m[1]["name"], m[1]["players"]]
+ b.pressed.connect(select_map.bind(i))
+ b.focus_entered.connect(select_map.bind(i))
+ map_list_container.add_child(b)
+ i += 1
+ select_map(0)
+
+ for algo_id: String in game.bot_algos:
+ if algo_id == "customer" or algo_id == "test":
+ continue
+
+ bot_counts[algo_id] = 0
+
+ var h := HBoxContainer.new()
+ h.name = algo_id
+ var add := Button.new()
+ add.text = "+"
+ var reset := Button.new()
+ reset.size_flags_horizontal = SIZE_EXPAND_FILL
+ var remove := Button.new()
+ remove.text = "-"
+ bot_reset_buttons[algo_id] = reset
+ bot_inc_buttons[algo_id] = add
+ bot_dec_buttons[algo_id] = remove
+ update_bot_reset_text(algo_id)
+ add.pressed.connect(increase_bot_count.bind(algo_id))
+ reset.pressed.connect(reset_bot_count.bind(algo_id))
+ remove.pressed.connect(decrease_bot_count.bind(algo_id))
+ h.add_child(remove)
+ h.add_child(reset)
+ h.add_child(add)
+ bot_settings.add_child(h)
+
+func select_map(i: int):
+ if i >= map_count:
+ return
+ selected_map = i
+ var map_data: Dictionary = game.maps[i][1]
+ map_name_label.text = map_data["name"]
+ map_player_label.text = tr("c.map.players_recommended").format([roundi(map_data["players"])])
+ map_difficulty_label.text = tr("c.map.difficulty.%d" % (map_data["difficulty"] - 1))
+ selected_map_name = game.maps[i][0]
+ if not game.menu.covered:
+ map_list_container.get_child(i).grab_focus()
+
+func increase_bot_count(algo_id: String):
+ bot_counts[algo_id] += 1
+ update_bot_reset_text(algo_id)
+
+func decrease_bot_count(algo_id: String):
+ bot_counts[algo_id] -= 1
+ update_bot_reset_text(algo_id)
+
+func reset_bot_count(algo_id: String):
+ bot_counts[algo_id] = 0
+ update_bot_reset_text(algo_id)
+
+func update_bot_reset_text(algo_id: String):
+ var display_name: String = tr("s.bot.%s" % algo_id)
+ bot_reset_buttons[algo_id].text = "%s (%d)" % [display_name, bot_counts[algo_id]]
+ bot_inc_buttons[algo_id].disabled = not bot_counts[algo_id] < MAX_BOT_COUNT_PER_TYPE
+ bot_dec_buttons[algo_id].disabled = not bot_counts[algo_id] > 0
+
+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)
+ p.setup(player_list[i].username)
+
+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_left_pressed():
+ selected_map = (selected_map - 1) % map_count
+ select_map(selected_map)
+
+func _on_right_pressed():
+ selected_map = (selected_map + 1) % map_count
+ select_map(selected_map)
+
+func _on_start_pressed():
+ if selected_map_name != null:
+ var start_msg := "/start %s" % selected_map_name
+
+ if bots_enabled:
+ for k in bot_counts.keys():
+ for i in range(bot_counts[k]):
+ start_msg += "\ncreate-bot %s" % k
+
+ game.mp.send_chat(game.my_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():
+ game.toggle_join()
+
+func check_for_music():
+ if visible:
+ Sound.play_music("Lobby")
+ else:
+ Sound.play_music("stop") # TODO: Game music enter
+
+func _on_enable_bots_toggled(toggled_on):
+ bots_enabled = toggled_on
+ bot_settings_conainer.visible = toggled_on
+ bots_container.size_flags_vertical = SIZE_EXPAND_FILL if toggled_on else SIZE_FILL
diff --git a/client/gui/overlays/lobby/lobby.gd.uid b/client/gui/overlays/lobby/lobby.gd.uid
new file mode 100644
index 00000000..b92e8681
--- /dev/null
+++ b/client/gui/overlays/lobby/lobby.gd.uid
@@ -0,0 +1 @@
+uid://bssjvsu44l0fn
diff --git a/client/gui/overlays/lobby/lobby.tscn b/client/gui/overlays/lobby/lobby.tscn
new file mode 100644
index 00000000..58ae2add
--- /dev/null
+++ b/client/gui/overlays/lobby/lobby.tscn
@@ -0,0 +1,191 @@
+[gd_scene load_steps=17 format=3 uid="uid://bc50la65ntifb"]
+
+[ext_resource type="Theme" uid="uid://b0qmvo504e457" path="res://gui/resources/theme/theme.tres" id="1_u18ke"]
+[ext_resource type="Script" uid="uid://bssjvsu44l0fn" path="res://gui/overlays/lobby/lobby.gd" id="2_7657i"]
+[ext_resource type="StyleBox" uid="uid://de80aw86emnql" path="res://gui/resources/style/lobby_panel_override.tres" id="3_6iqoe"]
+[ext_resource type="Material" uid="uid://beea1pc5nt67r" path="res://gui/resources/materials/dark_blur_material.tres" id="3_esmbx"]
+[ext_resource type="Texture2D" uid="uid://35rd5gamtyqm" path="res://gui/resources/icons/arrow.svg" id="3_jxleg"]
+[ext_resource type="Texture2D" uid="uid://j75dbytlbju" path="res://gui/resources/icons/arrow_pressed.svg" id="4_eapmn"]
+[ext_resource type="Script" uid="uid://cmncjc06kadpe" path="res://gui/components/blur_setup.gd" id="5_am8pt"]
+[ext_resource type="Texture2D" uid="uid://b33qmctbpf48g" path="res://gui/resources/icons/arrow_hover.svg" id="5_odwav"]
+[ext_resource type="Script" uid="uid://byshs20og68tn" path="res://gui/components/smart_margin_container.gd" id="6_7mu2u"]
+[ext_resource type="Texture2D" uid="uid://by3qsrpxnfq4w" path="res://gui/resources/icons/arrow_focus.svg" id="6_tulu3"]
+[ext_resource type="FontFile" uid="uid://5ixo6b3bd3km" path="res://gui/resources/fonts/font-josefin-sans.woff2" id="8_cwbpa"]
+[ext_resource type="Texture2D" uid="uid://bsx6fo7mv2u6a" path="res://gui/resources/icons/controller_x.svg" id="9_q14bw"]
+[ext_resource type="Script" uid="uid://bd7bylb2t2m0" path="res://gui/components/touch_scroll_container.gd" id="10_bgene"]
+[ext_resource type="Texture2D" uid="uid://cr2a6ide6vnnv" path="res://gui/resources/icons/controller_y.svg" id="11_5uugf"]
+[ext_resource type="Script" uid="uid://b1eomxildrq30" path="res://gui/components/controller_button.gd" id="12_7mu2u"]
+
+[sub_resource type="FontVariation" id="FontVariation_5xxr2"]
+base_font = ExtResource("8_cwbpa")
+variation_embolden = 1.5
+
+[node name="Lobby" type="Control" groups=["no_auto_focus"]]
+layout_mode = 3
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+theme = ExtResource("1_u18ke")
+script = ExtResource("2_7657i")
+
+[node name="PlayerList" type="MarginContainer" parent="."]
+layout_mode = 1
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+mouse_filter = 2
+theme_override_constants/margin_left = 342
+theme_override_constants/margin_top = 32
+theme_override_constants/margin_right = 342
+theme_override_constants/margin_bottom = 32
+
+[node name="VBoxContainer" type="VBoxContainer" parent="PlayerList"]
+layout_mode = 2
+
+[node name="Players" type="HBoxContainer" parent="PlayerList/VBoxContainer"]
+layout_mode = 2
+alignment = 1
+
+[node name="Sidebar" type="HBoxContainer" parent="."]
+layout_mode = 1
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+alignment = 2
+
+[node name="Bottom" type="PanelContainer" parent="Sidebar"]
+material = ExtResource("3_esmbx")
+layout_mode = 2
+theme_override_styles/panel = ExtResource("3_6iqoe")
+script = ExtResource("5_am8pt")
+
+[node name="MarginContainer" type="MarginContainer" parent="Sidebar/Bottom"]
+layout_mode = 2
+script = ExtResource("6_7mu2u")
+
+[node name="VBoxContainer" type="VBoxContainer" parent="Sidebar/Bottom/MarginContainer"]
+layout_mode = 2
+theme_override_constants/separation = 24
+
+[node name="HBoxContainer" type="HBoxContainer" parent="Sidebar/Bottom/MarginContainer/VBoxContainer"]
+layout_direction = 2
+layout_mode = 2
+alignment = 1
+
+[node name="VBoxContainer" type="VBoxContainer" parent="Sidebar/Bottom/MarginContainer/VBoxContainer/HBoxContainer"]
+layout_mode = 2
+alignment = 1
+
+[node name="Left" type="TextureButton" parent="Sidebar/Bottom/MarginContainer/VBoxContainer/HBoxContainer/VBoxContainer"]
+custom_minimum_size = Vector2(19, 28)
+layout_mode = 2
+focus_mode = 0
+texture_normal = ExtResource("3_jxleg")
+texture_pressed = ExtResource("4_eapmn")
+texture_hover = ExtResource("5_odwav")
+texture_focused = ExtResource("6_tulu3")
+ignore_texture_size = true
+stretch_mode = 4
+flip_h = true
+
+[node name="Map" type="VBoxContainer" parent="Sidebar/Bottom/MarginContainer/VBoxContainer/HBoxContainer"]
+layout_mode = 2
+
+[node name="Name" type="Label" parent="Sidebar/Bottom/MarginContainer/VBoxContainer/HBoxContainer/Map"]
+custom_minimum_size = Vector2(200, 0)
+layout_mode = 2
+theme_override_fonts/font = SubResource("FontVariation_5xxr2")
+theme_override_font_sizes/font_size = 24
+text = "Map name"
+horizontal_alignment = 1
+vertical_alignment = 1
+
+[node name="Players" type="Label" parent="Sidebar/Bottom/MarginContainer/VBoxContainer/HBoxContainer/Map"]
+layout_mode = 2
+text = "Players"
+horizontal_alignment = 1
+vertical_alignment = 1
+
+[node name="Difficulty" type="Label" parent="Sidebar/Bottom/MarginContainer/VBoxContainer/HBoxContainer/Map"]
+layout_mode = 2
+text = "Difficulty"
+horizontal_alignment = 1
+vertical_alignment = 1
+
+[node name="VBoxContainer2" type="VBoxContainer" parent="Sidebar/Bottom/MarginContainer/VBoxContainer/HBoxContainer"]
+layout_mode = 2
+alignment = 1
+
+[node name="Right" type="TextureButton" parent="Sidebar/Bottom/MarginContainer/VBoxContainer/HBoxContainer/VBoxContainer2"]
+custom_minimum_size = Vector2(19, 28)
+layout_mode = 2
+focus_mode = 0
+texture_normal = ExtResource("3_jxleg")
+texture_pressed = ExtResource("4_eapmn")
+texture_hover = ExtResource("5_odwav")
+texture_focused = ExtResource("6_tulu3")
+ignore_texture_size = true
+stretch_mode = 4
+
+[node name="MapList" type="ScrollContainer" parent="Sidebar/Bottom/MarginContainer/VBoxContainer"]
+layout_mode = 2
+size_flags_vertical = 3
+script = ExtResource("10_bgene")
+
+[node name="VBoxContainer" type="VBoxContainer" parent="Sidebar/Bottom/MarginContainer/VBoxContainer/MapList"]
+layout_mode = 2
+size_flags_horizontal = 3
+
+[node name="Bots" type="VBoxContainer" parent="Sidebar/Bottom/MarginContainer/VBoxContainer"]
+layout_mode = 2
+
+[node name="EnableBots" type="CheckButton" parent="Sidebar/Bottom/MarginContainer/VBoxContainer/Bots"]
+layout_mode = 2
+text = "c.menu.lobby.enable_bots"
+
+[node name="ScrollContainerCustom" type="ScrollContainer" parent="Sidebar/Bottom/MarginContainer/VBoxContainer/Bots"]
+visible = false
+layout_mode = 2
+size_flags_vertical = 3
+script = ExtResource("10_bgene")
+
+[node name="BotSettings" type="VBoxContainer" parent="Sidebar/Bottom/MarginContainer/VBoxContainer/Bots/ScrollContainerCustom"]
+layout_mode = 2
+size_flags_horizontal = 3
+size_flags_vertical = 3
+
+[node name="VBoxContainer" type="VBoxContainer" parent="Sidebar/Bottom/MarginContainer/VBoxContainer"]
+layout_mode = 2
+theme_override_constants/separation = 15
+alignment = 1
+
+[node name="JoinSpectate" type="Button" parent="Sidebar/Bottom/MarginContainer/VBoxContainer/VBoxContainer"]
+layout_mode = 2
+text = "c.menu.ingame.spectate"
+expand_icon = true
+script = ExtResource("12_7mu2u")
+controller_texture = ExtResource("11_5uugf")
+press_action = "join_spectate"
+metadata/_custom_type_script = "uid://b1eomxildrq30"
+
+[node name="Start" type="Button" parent="Sidebar/Bottom/MarginContainer/VBoxContainer/VBoxContainer"]
+layout_mode = 2
+text = "c.menu.lobby.start"
+expand_icon = true
+script = ExtResource("12_7mu2u")
+controller_texture = ExtResource("9_q14bw")
+press_action = "start_game"
+metadata/_custom_type_script = "uid://b1eomxildrq30"
+
+[connection signal="visibility_changed" from="." to="." method="check_for_music"]
+[connection signal="pressed" from="Sidebar/Bottom/MarginContainer/VBoxContainer/HBoxContainer/VBoxContainer/Left" to="." method="_on_left_pressed"]
+[connection signal="pressed" from="Sidebar/Bottom/MarginContainer/VBoxContainer/HBoxContainer/VBoxContainer2/Right" to="." method="_on_right_pressed"]
+[connection signal="toggled" from="Sidebar/Bottom/MarginContainer/VBoxContainer/Bots/EnableBots" to="." method="_on_enable_bots_toggled"]
+[connection signal="pressed" from="Sidebar/Bottom/MarginContainer/VBoxContainer/VBoxContainer/JoinSpectate" to="." method="_on_join_spectate_pressed"]
+[connection signal="pressed" from="Sidebar/Bottom/MarginContainer/VBoxContainer/VBoxContainer/Start" to="." method="_on_start_pressed"]
diff --git a/client/gui/overlays/lobby/player.gd b/client/gui/overlays/lobby/player.gd
new file mode 100644
index 00000000..175d6341
--- /dev/null
+++ b/client/gui/overlays/lobby/player.gd
@@ -0,0 +1,22 @@
+# Hurry Curry! - a game about cooking
+# Copyright (C) 2025 Hurry Curry! contributors
+#
+# 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
+# the Free Software Foundation, version 3 of the License only.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+#
+extends PanelContainer
+class_name PlayerTag
+
+@onready var name_label = $MarginContainer/HBoxContainer/Label
+
+func setup(player_name: String):
+ name_label.text = player_name
diff --git a/client/gui/overlays/lobby/player.gd.uid b/client/gui/overlays/lobby/player.gd.uid
new file mode 100644
index 00000000..b0971cdb
--- /dev/null
+++ b/client/gui/overlays/lobby/player.gd.uid
@@ -0,0 +1 @@
+uid://buxb488rr2ncs
diff --git a/client/gui/overlays/lobby/player.tscn b/client/gui/overlays/lobby/player.tscn
new file mode 100644
index 00000000..aa8997a1
--- /dev/null
+++ b/client/gui/overlays/lobby/player.tscn
@@ -0,0 +1,43 @@
+[gd_scene load_steps=6 format=3 uid="uid://gmldnel4xbxy"]
+
+[ext_resource type="Theme" uid="uid://b0qmvo504e457" path="res://gui/resources/theme/theme.tres" id="1_flfqn"]
+[ext_resource type="Texture2D" uid="uid://222w1wha75od" path="res://gui/resources/icons/user.webp" id="2_mnaqt"]
+[ext_resource type="Script" uid="uid://buxb488rr2ncs" path="res://gui/overlays/lobby/player.gd" id="2_w3lyk"]
+
+[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_1227j"]
+bg_color = Color(0, 0, 0, 1)
+corner_radius_top_left = 16
+corner_radius_top_right = 16
+corner_radius_bottom_right = 16
+corner_radius_bottom_left = 16
+
+[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_3yp6e"]
+content_margin_right = 8.0
+
+[node name="Player" type="PanelContainer"]
+offset_right = 40.0
+offset_bottom = 40.0
+theme = ExtResource("1_flfqn")
+theme_override_styles/panel = SubResource("StyleBoxFlat_1227j")
+script = ExtResource("2_w3lyk")
+
+[node name="MarginContainer" type="MarginContainer" parent="."]
+layout_mode = 2
+theme_override_constants/margin_left = 4
+theme_override_constants/margin_top = 4
+theme_override_constants/margin_right = 4
+theme_override_constants/margin_bottom = 4
+
+[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer"]
+layout_mode = 2
+
+[node name="Icon" type="TextureRect" parent="MarginContainer/HBoxContainer"]
+layout_mode = 2
+texture = ExtResource("2_mnaqt")
+expand_mode = 2
+
+[node name="Label" type="Label" parent="MarginContainer/HBoxContainer"]
+layout_mode = 2
+theme_override_styles/normal = SubResource("StyleBoxEmpty_3yp6e")
+text = "Player"
+vertical_alignment = 1