summaryrefslogtreecommitdiff
path: root/client/menu
diff options
context:
space:
mode:
Diffstat (limited to 'client/menu')
-rw-r--r--client/menu/controller_buttons/a.svg6
-rw-r--r--client/menu/controller_buttons/a.svg.import37
-rw-r--r--client/menu/controller_buttons/controller_button.gd39
-rw-r--r--client/menu/controller_buttons/controller_button.tscn9
-rw-r--r--client/menu/game.gd18
-rw-r--r--client/menu/game.tscn6
-rw-r--r--client/menu/lobby.gd76
-rw-r--r--client/menu/lobby.tscn110
-rw-r--r--client/menu/lobby/player.gd22
-rw-r--r--client/menu/lobby/player.tscn43
-rw-r--r--client/menu/menu.gd4
-rw-r--r--client/menu/theme/lobby_panel_override.tres4
-rw-r--r--client/menu/user.webpbin0 -> 15122 bytes
-rw-r--r--client/menu/user.webp.import34
14 files changed, 405 insertions, 3 deletions
diff --git a/client/menu/controller_buttons/a.svg b/client/menu/controller_buttons/a.svg
new file mode 100644
index 00000000..3b660d91
--- /dev/null
+++ b/client/menu/controller_buttons/a.svg
@@ -0,0 +1,6 @@
+<svg width="64" height="64" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <defs/>
+ <g>
+ <path stroke="none" fill="#7DB700" d="M56 32 Q56 42 48.95 48.95 42 56 32 56 22.05 56 15 48.95 8 42 8 32 8 22.05 15 15 22.05 8 32 8 42 8 48.95 15 56 22.05 56 32 M38 42 L42 42 34 22 30 22 22 42 26 42 27.6 38 36.4 38 38 42 M32 27 L34.8 34 29.2 34 32 27"/>
+ </g>
+</svg> \ No newline at end of file
diff --git a/client/menu/controller_buttons/a.svg.import b/client/menu/controller_buttons/a.svg.import
new file mode 100644
index 00000000..236e085f
--- /dev/null
+++ b/client/menu/controller_buttons/a.svg.import
@@ -0,0 +1,37 @@
+[remap]
+
+importer="texture"
+type="CompressedTexture2D"
+uid="uid://bgkhnp15u1utp"
+path="res://.godot/imported/a.svg-207eeddefe74f1190424a9aa1808de8f.ctex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://menu/controller_buttons/a.svg"
+dest_files=["res://.godot/imported/a.svg-207eeddefe74f1190424a9aa1808de8f.ctex"]
+
+[params]
+
+compress/mode=0
+compress/high_quality=false
+compress/lossy_quality=0.7
+compress/hdr_compression=1
+compress/normal_map=0
+compress/channel_pack=0
+mipmaps/generate=false
+mipmaps/limit=-1
+roughness/mode=0
+roughness/src_normal=""
+process/fix_alpha_border=true
+process/premult_alpha=false
+process/normal_map_invert_y=false
+process/hdr_as_srgb=false
+process/hdr_clamp_exposure=false
+process/size_limit=0
+detect_3d/compress_to=1
+svg/scale=1.0
+editor/scale_with_editor_scale=false
+editor/convert_colors_with_editor_theme=false
diff --git a/client/menu/controller_buttons/controller_button.gd b/client/menu/controller_buttons/controller_button.gd
new file mode 100644
index 00000000..4fa70b5a
--- /dev/null
+++ b/client/menu/controller_buttons/controller_button.gd
@@ -0,0 +1,39 @@
+# Undercooked - a game about cooking
+# Copyright 2024 tpart
+#
+# 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 Button
+class_name ControllerButton
+
+@export var controller_texture: Texture2D
+@export var press_action: String
+
+func _ready():
+ set_texture_enabled(Global.using_joypad)
+ Global.using_joypad_change.connect(set_texture_enabled)
+
+func _input(event):
+ if press_action == null:
+ return
+ if not is_visible_in_tree():
+ return
+ if Input.is_action_just_pressed(press_action):
+ pressed.emit()
+
+func set_texture_enabled(b: bool):
+ if b:
+ icon = controller_texture
+ else:
+ icon = null
diff --git a/client/menu/controller_buttons/controller_button.tscn b/client/menu/controller_buttons/controller_button.tscn
new file mode 100644
index 00000000..c5d745ba
--- /dev/null
+++ b/client/menu/controller_buttons/controller_button.tscn
@@ -0,0 +1,9 @@
+[gd_scene load_steps=2 format=3 uid="uid://b1f7bgn65j7b5"]
+
+[ext_resource type="Script" path="res://menu/controller_buttons/controller_button.gd" id="1_p2m8i"]
+
+[node name="ControllerButton" type="Button"]
+offset_right = 8.0
+offset_bottom = 8.0
+focus_mode = 0
+script = ExtResource("1_p2m8i")
diff --git a/client/menu/game.gd b/client/menu/game.gd
index f2526645..c36fca86 100644
--- a/client/menu/game.gd
+++ b/client/menu/game.gd
@@ -1,3 +1,19 @@
+# Undercooked - a game about cooking
+# Copyright 2024 metamuffin
+# Copyright 2024 tpart
+#
+# 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 Menu
func _ready():
@@ -5,7 +21,7 @@ func _ready():
super()
func _input(_event):
- if Input.is_action_just_pressed("pause"):
+ if Input.is_action_just_pressed("ui_cancel"):
open_ingame_menu()
func open_ingame_menu():
diff --git a/client/menu/game.tscn b/client/menu/game.tscn
index 708adf74..af7f22a8 100644
--- a/client/menu/game.tscn
+++ b/client/menu/game.tscn
@@ -1,7 +1,8 @@
-[gd_scene load_steps=3 format=3 uid="uid://bbjwoxs71fnsk"]
+[gd_scene load_steps=4 format=3 uid="uid://bbjwoxs71fnsk"]
[ext_resource type="Script" path="res://menu/game.gd" id="1_cdpsh"]
[ext_resource type="PackedScene" uid="uid://c6krh36hoqfg8" path="res://game.tscn" id="2_uojcy"]
+[ext_resource type="PackedScene" uid="uid://bc50la65ntifb" path="res://menu/lobby.tscn" id="3_udxby"]
[node name="GameMenu" type="Control"]
layout_mode = 3
@@ -14,3 +15,6 @@ script = ExtResource("1_cdpsh")
auto_anim = false
[node name="Game" parent="." instance=ExtResource("2_uojcy")]
+
+[node name="Lobby" parent="." instance=ExtResource("3_udxby")]
+layout_mode = 1
diff --git a/client/menu/lobby.gd b/client/menu/lobby.gd
new file mode 100644
index 00000000..e96e11c4
--- /dev/null
+++ b/client/menu/lobby.gd
@@ -0,0 +1,76 @@
+# Undercooked - a game about cooking
+# Copyright 2024 tpart
+#
+# 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
+
+const PLAYER = preload("res://menu/lobby/player.tscn")
+
+var selected_map := 0
+var selected_map_name: String
+
+@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 prev_map = $VBoxContainer/Bottom/MarginContainer/VBoxContainer/HBoxContainer/Left
+@onready var next_map = $VBoxContainer/Bottom/MarginContainer/VBoxContainer/HBoxContainer/Right
+
+func _ready():
+ game.update_players.connect(update_players)
+ initialize()
+ game.data_updated.connect(initialize)
+
+func initialize():
+ map_count = game.map_names.size()
+ select_map(0)
+
+func select_map(i: int):
+ if i >= game.map_names.size():
+ return
+ selected_map = i
+ var map_name: String = game.map_names[i]
+ map_name_label.text = map_name
+ selected_map_name = map_name
+
+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].name)
+
+func _input(event):
+ if not visible:
+ return
+
+ if Input.is_action_just_pressed("previous"):
+ prev_map.emit_signal("pressed")
+ elif Input.is_action_just_pressed("next"):
+ 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_controller_button_pressed():
+ if selected_map_name != null:
+ game.mp.send_chat("/start %s" % selected_map_name)
diff --git a/client/menu/lobby.tscn b/client/menu/lobby.tscn
new file mode 100644
index 00000000..38b2a5b9
--- /dev/null
+++ b/client/menu/lobby.tscn
@@ -0,0 +1,110 @@
+[gd_scene load_steps=10 format=3 uid="uid://bc50la65ntifb"]
+
+[ext_resource type="Theme" uid="uid://b0qmvo504e457" path="res://menu/theme/theme.tres" id="1_u18ke"]
+[ext_resource type="Script" path="res://menu/lobby.gd" id="2_7657i"]
+[ext_resource type="StyleBox" uid="uid://de80aw86emnql" path="res://menu/theme/lobby_panel_override.tres" id="3_6iqoe"]
+[ext_resource type="Texture2D" uid="uid://35rd5gamtyqm" path="res://menu/arrow.svg" id="3_jxleg"]
+[ext_resource type="Texture2D" uid="uid://j75dbytlbju" path="res://menu/arrow_pressed.svg" id="4_eapmn"]
+[ext_resource type="Texture2D" uid="uid://b33qmctbpf48g" path="res://menu/arrow_hover.svg" id="5_odwav"]
+[ext_resource type="Texture2D" uid="uid://by3qsrpxnfq4w" path="res://menu/arrow_focus.svg" id="6_tulu3"]
+[ext_resource type="PackedScene" uid="uid://b1f7bgn65j7b5" path="res://menu/controller_buttons/controller_button.tscn" id="7_t6mox"]
+[ext_resource type="Texture2D" uid="uid://bgkhnp15u1utp" path="res://menu/controller_buttons/a.svg" id="8_chn2q"]
+
+[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="VBoxContainer" type="VBoxContainer" parent="."]
+layout_mode = 1
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+
+[node name="Top" type="PanelContainer" parent="VBoxContainer"]
+layout_mode = 2
+theme_override_styles/panel = ExtResource("3_6iqoe")
+
+[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer/Top"]
+layout_mode = 2
+
+[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/Top/MarginContainer"]
+layout_mode = 2
+theme_override_constants/separation = 24
+
+[node name="Players" type="HBoxContainer" parent="VBoxContainer/Top/MarginContainer/VBoxContainer"]
+layout_mode = 2
+alignment = 1
+
+[node name="Spacer" type="Control" parent="VBoxContainer"]
+layout_mode = 2
+size_flags_vertical = 3
+mouse_filter = 2
+
+[node name="Bottom" type="PanelContainer" parent="VBoxContainer"]
+layout_mode = 2
+theme_override_styles/panel = ExtResource("3_6iqoe")
+
+[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer/Bottom"]
+layout_mode = 2
+
+[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/Bottom/MarginContainer"]
+layout_mode = 2
+theme_override_constants/separation = 24
+
+[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/Bottom/MarginContainer/VBoxContainer"]
+layout_mode = 2
+alignment = 1
+
+[node name="Left" type="TextureButton" parent="VBoxContainer/Bottom/MarginContainer/VBoxContainer/HBoxContainer"]
+custom_minimum_size = Vector2(19, 0)
+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="MapSelection" type="Label" parent="VBoxContainer/Bottom/MarginContainer/VBoxContainer/HBoxContainer"]
+custom_minimum_size = Vector2(264, 0)
+layout_mode = 2
+text = "Map"
+horizontal_alignment = 1
+vertical_alignment = 1
+
+[node name="Right" type="TextureButton" parent="VBoxContainer/Bottom/MarginContainer/VBoxContainer/HBoxContainer"]
+custom_minimum_size = Vector2(19, 0)
+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="CenterContainer" type="CenterContainer" parent="VBoxContainer/Bottom/MarginContainer/VBoxContainer"]
+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"
+icon = ExtResource("8_chn2q")
+expand_icon = true
+controller_texture = ExtResource("8_chn2q")
+press_action = "ui_accept"
+
+[connection signal="pressed" from="VBoxContainer/Bottom/MarginContainer/VBoxContainer/HBoxContainer/Left" to="." method="_on_left_pressed"]
+[connection signal="pressed" from="VBoxContainer/Bottom/MarginContainer/VBoxContainer/HBoxContainer/Right" to="." method="_on_right_pressed"]
+[connection signal="pressed" from="VBoxContainer/Bottom/MarginContainer/VBoxContainer/CenterContainer/ControllerButton" to="." method="_on_controller_button_pressed"]
diff --git a/client/menu/lobby/player.gd b/client/menu/lobby/player.gd
new file mode 100644
index 00000000..c5c05eb4
--- /dev/null
+++ b/client/menu/lobby/player.gd
@@ -0,0 +1,22 @@
+# Undercooked - a game about cooking
+# Copyright 2024 tpart
+#
+# 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/menu/lobby/player.tscn b/client/menu/lobby/player.tscn
new file mode 100644
index 00000000..964bc4fb
--- /dev/null
+++ b/client/menu/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://menu/theme/theme.tres" id="1_flfqn"]
+[ext_resource type="Texture2D" uid="uid://222w1wha75od" path="res://menu/user.webp" id="2_mnaqt"]
+[ext_resource type="Script" path="res://menu/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
diff --git a/client/menu/menu.gd b/client/menu/menu.gd
index 7ae7f3a0..51f0cf6b 100644
--- a/client/menu/menu.gd
+++ b/client/menu/menu.gd
@@ -67,6 +67,8 @@ func replace_menu(path: String):
var focus_auto_changed := false
func focus_first(node: Node) -> bool:
focus_auto_changed = true
+ if node.is_in_group("no_auto_focus"):
+ return false
if node is Button or node is LineEdit:
node.grab_focus()
print("Node %s (%s) was selected for focus" % [node.name, node])
@@ -77,7 +79,7 @@ func focus_first(node: Node) -> bool:
return false
func connect_button_sounds(node: Node):
- if node is Button:
+ if node is Button or node is TextureButton:
if not node.is_in_group("no_click_sound"):
node.pressed.connect(Sound.play_click)
if node is Button or node is LineEdit or node is Slider:
diff --git a/client/menu/theme/lobby_panel_override.tres b/client/menu/theme/lobby_panel_override.tres
new file mode 100644
index 00000000..04fd16b0
--- /dev/null
+++ b/client/menu/theme/lobby_panel_override.tres
@@ -0,0 +1,4 @@
+[gd_resource type="StyleBoxFlat" format=3 uid="uid://de80aw86emnql"]
+
+[resource]
+bg_color = Color(0.0941176, 0.0941176, 0.0941176, 1)
diff --git a/client/menu/user.webp b/client/menu/user.webp
new file mode 100644
index 00000000..5bba0540
--- /dev/null
+++ b/client/menu/user.webp
Binary files differ
diff --git a/client/menu/user.webp.import b/client/menu/user.webp.import
new file mode 100644
index 00000000..112cf9b8
--- /dev/null
+++ b/client/menu/user.webp.import
@@ -0,0 +1,34 @@
+[remap]
+
+importer="texture"
+type="CompressedTexture2D"
+uid="uid://222w1wha75od"
+path="res://.godot/imported/user.webp-257e5395baacd6a382811f4f2dd7cd93.ctex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://menu/user.webp"
+dest_files=["res://.godot/imported/user.webp-257e5395baacd6a382811f4f2dd7cd93.ctex"]
+
+[params]
+
+compress/mode=0
+compress/high_quality=false
+compress/lossy_quality=0.7
+compress/hdr_compression=1
+compress/normal_map=0
+compress/channel_pack=0
+mipmaps/generate=false
+mipmaps/limit=-1
+roughness/mode=0
+roughness/src_normal=""
+process/fix_alpha_border=true
+process/premult_alpha=false
+process/normal_map_invert_y=false
+process/hdr_as_srgb=false
+process/hdr_clamp_exposure=false
+process/size_limit=0
+detect_3d/compress_to=1