diff options
Diffstat (limited to 'client/gui/menus/map_selector')
| -rw-r--r-- | client/gui/menus/map_selector/map_details_selector.gd | 120 | ||||
| -rw-r--r-- | client/gui/menus/map_selector/map_details_selector.gd.uid | 1 | ||||
| -rw-r--r-- | client/gui/menus/map_selector/map_details_selector.tscn | 112 | ||||
| -rw-r--r-- | client/gui/menus/map_selector/map_list_item.gd | 28 | ||||
| -rw-r--r-- | client/gui/menus/map_selector/map_list_item.gd.uid | 1 | ||||
| -rw-r--r-- | client/gui/menus/map_selector/map_list_item.tscn | 59 | ||||
| -rw-r--r-- | client/gui/menus/map_selector/map_selector.gd | 43 | ||||
| -rw-r--r-- | client/gui/menus/map_selector/map_selector.gd.uid | 1 | ||||
| -rw-r--r-- | client/gui/menus/map_selector/map_selector.tscn | 76 |
9 files changed, 441 insertions, 0 deletions
diff --git a/client/gui/menus/map_selector/map_details_selector.gd b/client/gui/menus/map_selector/map_details_selector.gd new file mode 100644 index 00000000..250c299b --- /dev/null +++ b/client/gui/menus/map_selector/map_details_selector.gd @@ -0,0 +1,120 @@ +# Hurry Curry! - a game about cooking +# Copyright (C) 2026 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 Menu +class_name MapDetailsSelector + +const MAX_BOT_COUNT_PER_TYPE: int = 3 + +var two_handed: bool +var default_two_handed: bool +var bots_enabled := false +var bot_counts: Dictionary[String, int] = {} + +var bot_reset_buttons: Dictionary[String, Button] = {} +var bot_inc_buttons: Dictionary[String, Button] = {} +var bot_dec_buttons: Dictionary[String, Button] = {} + +@onready var game: Game = $"../../Game" # TODO + +@onready var title_label: Label = $OuterMargin/Panel/InnerMargin/VBoxContainer/Title +@onready var bots_container: VBoxContainer = $OuterMargin/Panel/InnerMargin/VBoxContainer/VBoxContainer/Bots +@onready var bot_settings: Control = $OuterMargin/Panel/InnerMargin/VBoxContainer/VBoxContainer/Bots/ScrollContainerCustom/BotSettings +@onready var bot_settings_container: Control = $OuterMargin/Panel/InnerMargin/VBoxContainer/VBoxContainer/Bots/ScrollContainerCustom +@onready var start_button: Button = $OuterMargin/Panel/InnerMargin/VBoxContainer/HBoxContainer/Start +@onready var two_handed_button: CheckButton = $OuterMargin/Panel/InnerMargin/VBoxContainer/VBoxContainer/TwoHanded +@onready var custom_game_warning: Label = $OuterMargin/Panel/InnerMargin/VBoxContainer/CustomGameWarning + +func _ready() -> void: + title_label.text = data[0]["display_name"] + default_two_handed = false if data[0]["hand_count"] == 1. else true + two_handed = default_two_handed + two_handed_button.button_pressed = two_handed + + var bot_algos: Array = data[1] + for algo: String in bot_algos: + bot_counts[algo] = 0 + + var h := HBoxContainer.new() + h.name = algo + 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] = reset + bot_inc_buttons[algo] = add + bot_dec_buttons[algo] = remove + update_bot_reset_text(algo) + add.pressed.connect(increase_bot_count.bind(algo)) + reset.pressed.connect(reset_bot_count.bind(algo)) + remove.pressed.connect(decrease_bot_count.bind(algo)) + h.add_child(remove) + h.add_child(reset) + h.add_child(add) + bot_settings.add_child(h) + + super() + start_button.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): + if bot_counts[algo_id] == 0: bot_counts[algo_id] = 1 + else: 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]] + set_disabled(bot_reset_buttons[algo_id], false) + set_disabled(bot_inc_buttons[algo_id], not bot_counts[algo_id] < MAX_BOT_COUNT_PER_TYPE) + set_disabled(bot_dec_buttons[algo_id], not bot_counts[algo_id] > 0) + +func _on_enable_bots_toggled(toggled_on: bool) -> void: + bots_enabled = toggled_on + bot_settings_container.visible = toggled_on + update_warning() + +func _on_two_handed_toggled(toggled_on: bool) -> void: + two_handed = toggled_on + update_warning() + +func _on_back_pressed() -> void: + exit(false) + +func _on_start_pressed() -> void: + var selected_map_name: String = data[0]["name"] + var hand_count: int = 2 if two_handed else 1 + + var selected_bots: Array[String] = [] + if bots_enabled: + for k in bot_counts.keys(): + for i in range(bot_counts[k]): + selected_bots.append(k) + + @warning_ignore("incompatible_ternary") + game.mp.send_start_game_vote(game.my_player_id, selected_map_name, hand_count if two_handed != default_two_handed else null, selected_bots if bots_enabled else null) + exit(true) + +func update_warning(): + custom_game_warning.visible = two_handed != default_two_handed or bots_enabled diff --git a/client/gui/menus/map_selector/map_details_selector.gd.uid b/client/gui/menus/map_selector/map_details_selector.gd.uid new file mode 100644 index 00000000..7a32eb14 --- /dev/null +++ b/client/gui/menus/map_selector/map_details_selector.gd.uid @@ -0,0 +1 @@ +uid://cntuh7y15r4uy diff --git a/client/gui/menus/map_selector/map_details_selector.tscn b/client/gui/menus/map_selector/map_details_selector.tscn new file mode 100644 index 00000000..750f6d57 --- /dev/null +++ b/client/gui/menus/map_selector/map_details_selector.tscn @@ -0,0 +1,112 @@ +[gd_scene format=3 uid="uid://bx0n0h6jh7hrd"] + +[ext_resource type="Script" uid="uid://cntuh7y15r4uy" path="res://gui/menus/map_selector/map_details_selector.gd" id="1_jsc2p"] +[ext_resource type="Script" uid="uid://byshs20og68tn" path="res://gui/components/smart_margin_container.gd" id="2_ksn3m"] +[ext_resource type="Material" uid="uid://beea1pc5nt67r" path="res://gui/resources/materials/dark_blur_material.tres" id="3_f0rsd"] +[ext_resource type="Script" uid="uid://cmncjc06kadpe" path="res://gui/components/blur_setup.gd" id="4_d3ya2"] +[ext_resource type="Script" uid="uid://bd7bylb2t2m0" path="res://gui/components/touch_scroll_container.gd" id="6_dxk78"] + +[node name="MapDetailsSelector" type="Control" unique_id=510306535] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_jsc2p") +support_anim = false + +[node name="OuterMargin" type="MarginContainer" parent="." unique_id=869412596] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/margin_left = 50 +theme_override_constants/margin_top = 50 +theme_override_constants/margin_right = 50 +theme_override_constants/margin_bottom = 50 +script = ExtResource("2_ksn3m") + +[node name="Panel" type="Panel" parent="OuterMargin" unique_id=1557970649] +material = ExtResource("3_f0rsd") +layout_mode = 2 +script = ExtResource("4_d3ya2") + +[node name="InnerMargin" type="MarginContainer" parent="OuterMargin/Panel" unique_id=2023236197] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/margin_left = 50 +theme_override_constants/margin_top = 50 +theme_override_constants/margin_right = 50 +theme_override_constants/margin_bottom = 50 + +[node name="VBoxContainer" type="VBoxContainer" parent="OuterMargin/Panel/InnerMargin" unique_id=2137087020] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="Title" type="Label" parent="OuterMargin/Panel/InnerMargin/VBoxContainer" unique_id=1471975030] +layout_mode = 2 +theme_override_font_sizes/font_size = 36 +text = "Map name" +horizontal_alignment = 1 + +[node name="VBoxContainer" type="VBoxContainer" parent="OuterMargin/Panel/InnerMargin/VBoxContainer" unique_id=1831622843] +layout_mode = 2 +size_flags_vertical = 3 + +[node name="TwoHanded" type="CheckButton" parent="OuterMargin/Panel/InnerMargin/VBoxContainer/VBoxContainer" unique_id=1928176691] +layout_mode = 2 +text = "c.menu.map_selector.two_handed" + +[node name="Bots" type="VBoxContainer" parent="OuterMargin/Panel/InnerMargin/VBoxContainer/VBoxContainer" unique_id=1569430044] +layout_mode = 2 +size_flags_vertical = 3 + +[node name="EnableBots" type="CheckButton" parent="OuterMargin/Panel/InnerMargin/VBoxContainer/VBoxContainer/Bots" unique_id=1715103927] +layout_mode = 2 +text = "c.menu.map_selector.enable_bots" + +[node name="ScrollContainerCustom" type="ScrollContainer" parent="OuterMargin/Panel/InnerMargin/VBoxContainer/VBoxContainer/Bots" unique_id=1499397868] +visible = false +layout_mode = 2 +size_flags_vertical = 3 +script = ExtResource("6_dxk78") +metadata/_custom_type_script = "uid://bd7bylb2t2m0" + +[node name="BotSettings" type="VBoxContainer" parent="OuterMargin/Panel/InnerMargin/VBoxContainer/VBoxContainer/Bots/ScrollContainerCustom" unique_id=101347071] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 + +[node name="CustomGameWarning" type="Label" parent="OuterMargin/Panel/InnerMargin/VBoxContainer" unique_id=557709694] +visible = false +layout_mode = 2 +theme_override_colors/font_color = Color(1, 0.9019608, 0.49803922, 1) +text = "s.custom_game_warn" +horizontal_alignment = 1 + +[node name="HBoxContainer" type="HBoxContainer" parent="OuterMargin/Panel/InnerMargin/VBoxContainer" unique_id=2025174871] +layout_mode = 2 + +[node name="Back" type="Button" parent="OuterMargin/Panel/InnerMargin/VBoxContainer/HBoxContainer" unique_id=2006434901] +layout_mode = 2 +text = "c.menu.back" + +[node name="Spacer" type="Control" parent="OuterMargin/Panel/InnerMargin/VBoxContainer/HBoxContainer" unique_id=399194568] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="Start" type="Button" parent="OuterMargin/Panel/InnerMargin/VBoxContainer/HBoxContainer" unique_id=1675695981] +layout_mode = 2 +text = "c.menu.map_selector.start" + +[connection signal="toggled" from="OuterMargin/Panel/InnerMargin/VBoxContainer/VBoxContainer/TwoHanded" to="." method="_on_two_handed_toggled"] +[connection signal="toggled" from="OuterMargin/Panel/InnerMargin/VBoxContainer/VBoxContainer/Bots/EnableBots" to="." method="_on_enable_bots_toggled"] +[connection signal="pressed" from="OuterMargin/Panel/InnerMargin/VBoxContainer/HBoxContainer/Back" to="." method="_on_back_pressed"] +[connection signal="pressed" from="OuterMargin/Panel/InnerMargin/VBoxContainer/HBoxContainer/Start" to="." method="_on_start_pressed"] diff --git a/client/gui/menus/map_selector/map_list_item.gd b/client/gui/menus/map_selector/map_list_item.gd new file mode 100644 index 00000000..7775c079 --- /dev/null +++ b/client/gui/menus/map_selector/map_list_item.gd @@ -0,0 +1,28 @@ +# Hurry Curry! - a game about cooking +# Copyright (C) 2026 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/>. +# +class_name MapListItem +extends PanelContainer + +@onready var button: Button = $Button + +@onready var name_label: Label = $MarginContainer/VBoxContainer/Name +@onready var difficulty_label: Label = $MarginContainer/VBoxContainer/HBoxContainer/Difficulty +@onready var recommended_players_label: Label = $MarginContainer/VBoxContainer/HBoxContainer/RecommendedPlayers + +func setup(name_: String, difficulty: int, recommended_players: int): + name_label.text = name_ + difficulty_label.text = tr("c.map.difficulty.%d" % (difficulty - 1)) + recommended_players_label.text = tr("c.map.players_recommended").format([recommended_players]) diff --git a/client/gui/menus/map_selector/map_list_item.gd.uid b/client/gui/menus/map_selector/map_list_item.gd.uid new file mode 100644 index 00000000..41f512a7 --- /dev/null +++ b/client/gui/menus/map_selector/map_list_item.gd.uid @@ -0,0 +1 @@ +uid://di7j0scdcg2ox diff --git a/client/gui/menus/map_selector/map_list_item.tscn b/client/gui/menus/map_selector/map_list_item.tscn new file mode 100644 index 00000000..65736fc7 --- /dev/null +++ b/client/gui/menus/map_selector/map_list_item.tscn @@ -0,0 +1,59 @@ +[gd_scene format=3 uid="uid://buyelb8w7edpe"] + +[ext_resource type="Script" uid="uid://di7j0scdcg2ox" path="res://gui/menus/map_selector/map_list_item.gd" id="1_fywrp"] +[ext_resource type="StyleBox" uid="uid://d1xhwgrptnlli" path="res://gui/resources/style/panel_button_backround_style.tres" id="2_3fooa"] + +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_1n1yg"] + +[node name="ServerListItem" type="PanelContainer" unique_id=2062705951] +offset_right = 400.0 +offset_bottom = 40.0 +size_flags_horizontal = 3 +theme_override_styles/panel = SubResource("StyleBoxEmpty_1n1yg") +script = ExtResource("1_fywrp") + +[node name="Panel" type="Panel" parent="." unique_id=485329348] +layout_mode = 2 +theme_override_styles/panel = ExtResource("2_3fooa") + +[node name="Button" type="Button" parent="." unique_id=1213365601] +layout_mode = 2 + +[node name="MarginContainer" type="MarginContainer" parent="." unique_id=1363186299] +layout_mode = 2 +mouse_filter = 2 +theme_override_constants/margin_left = 10 +theme_override_constants/margin_top = 10 +theme_override_constants/margin_right = 10 +theme_override_constants/margin_bottom = 10 + +[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer" unique_id=1686608173] +layout_mode = 2 +mouse_filter = 2 + +[node name="Name" type="Label" parent="MarginContainer/VBoxContainer" unique_id=27759863] +layout_mode = 2 +theme_override_colors/font_color = Color(0.87451, 0.87451, 0.87451, 1) +theme_override_font_sizes/font_size = 18 +text = "Example Map" +text_overrun_behavior = 3 + +[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer" unique_id=1537690218] +layout_mode = 2 +mouse_filter = 2 +theme_override_constants/separation = 16 + +[node name="Difficulty" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer" unique_id=741851992] +layout_mode = 2 +theme_override_colors/font_color = Color(0.749781, 0.74978, 0.74978, 1) +theme_override_font_sizes/font_size = 14 +text = "Medium" + +[node name="RecommendedPlayers" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer" unique_id=1214181115] +layout_mode = 2 +size_flags_horizontal = 3 +theme_override_colors/font_color = Color(0.749781, 0.74978, 0.74978, 1) +theme_override_font_sizes/font_size = 14 +text = "5 players recommended" +horizontal_alignment = 2 +text_overrun_behavior = 3 diff --git a/client/gui/menus/map_selector/map_selector.gd b/client/gui/menus/map_selector/map_selector.gd new file mode 100644 index 00000000..9190b8f3 --- /dev/null +++ b/client/gui/menus/map_selector/map_selector.gd @@ -0,0 +1,43 @@ +# Hurry Curry! - a game about cooking +# Copyright (C) 2026 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 Menu +class_name MapSelector + +const MAP_LIST_ITEM = preload("res://gui/menus/map_selector/map_list_item.tscn") + +@onready var map_container: VBoxContainer = $OuterMargin/Panel/InnerMargin/VBoxContainer/ScrollContainer/VBoxContainer + +func _ready() -> void: + var maps: Array = data[0] + for m in maps: + var item: MapListItem = MAP_LIST_ITEM.instantiate() + item.name = m["name"] + map_container.add_child(item) + item.setup(m["display_name"], int(m["difficulty"]), int(m["players"])) + item.button.pressed.connect(select_map.bind(m)) + super() + +func select_map(map): + var algos: Array = data[1] + var success = await submenu("res://gui/menus/map_selector/map_details_selector.tscn", [map, algos]) + if success: exit() + +func _menu_cover(state: bool): + # TODO: Find a better way to hide this menu without hiding submenu, this feels hacky + $OuterMargin.visible = not state + +func _on_back_pressed() -> void: + exit() diff --git a/client/gui/menus/map_selector/map_selector.gd.uid b/client/gui/menus/map_selector/map_selector.gd.uid new file mode 100644 index 00000000..64f6e6d9 --- /dev/null +++ b/client/gui/menus/map_selector/map_selector.gd.uid @@ -0,0 +1 @@ +uid://dgl836r2uwjfw diff --git a/client/gui/menus/map_selector/map_selector.tscn b/client/gui/menus/map_selector/map_selector.tscn new file mode 100644 index 00000000..b88ec0ea --- /dev/null +++ b/client/gui/menus/map_selector/map_selector.tscn @@ -0,0 +1,76 @@ +[gd_scene format=3 uid="uid://b26sufndh0pm5"] + +[ext_resource type="Script" uid="uid://dgl836r2uwjfw" path="res://gui/menus/map_selector/map_selector.gd" id="1_37to6"] +[ext_resource type="Script" uid="uid://byshs20og68tn" path="res://gui/components/smart_margin_container.gd" id="2_5vs08"] +[ext_resource type="Material" uid="uid://beea1pc5nt67r" path="res://gui/resources/materials/dark_blur_material.tres" id="3_txniv"] +[ext_resource type="Script" uid="uid://cmncjc06kadpe" path="res://gui/components/blur_setup.gd" id="4_kobpr"] +[ext_resource type="Script" uid="uid://bd7bylb2t2m0" path="res://gui/components/touch_scroll_container.gd" id="6_7xmra"] + +[node name="MapSelector" type="Control" unique_id=510306535] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_37to6") +support_anim = false + +[node name="OuterMargin" type="MarginContainer" parent="." unique_id=869412596] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/margin_left = 50 +theme_override_constants/margin_top = 50 +theme_override_constants/margin_right = 50 +theme_override_constants/margin_bottom = 50 +script = ExtResource("2_5vs08") + +[node name="Panel" type="Panel" parent="OuterMargin" unique_id=1557970649] +material = ExtResource("3_txniv") +layout_mode = 2 +script = ExtResource("4_kobpr") + +[node name="InnerMargin" type="MarginContainer" parent="OuterMargin/Panel" unique_id=2023236197] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/margin_left = 50 +theme_override_constants/margin_top = 50 +theme_override_constants/margin_right = 50 +theme_override_constants/margin_bottom = 50 + +[node name="VBoxContainer" type="VBoxContainer" parent="OuterMargin/Panel/InnerMargin" unique_id=2137087020] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="Title" type="Label" parent="OuterMargin/Panel/InnerMargin/VBoxContainer" unique_id=1471975030] +layout_mode = 2 +theme_override_font_sizes/font_size = 36 +text = "c.map.select" +horizontal_alignment = 1 + +[node name="ScrollContainer" type="ScrollContainer" parent="OuterMargin/Panel/InnerMargin/VBoxContainer" unique_id=394287120] +layout_mode = 2 +size_flags_vertical = 3 +script = ExtResource("6_7xmra") + +[node name="VBoxContainer" type="VBoxContainer" parent="OuterMargin/Panel/InnerMargin/VBoxContainer/ScrollContainer" unique_id=1798845933] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 + +[node name="HBoxContainer" type="HBoxContainer" parent="OuterMargin/Panel/InnerMargin/VBoxContainer" unique_id=1907231166] +layout_mode = 2 + +[node name="Back" type="Button" parent="OuterMargin/Panel/InnerMargin/VBoxContainer/HBoxContainer" unique_id=1801916460] +layout_mode = 2 +text = "c.menu.back" + +[connection signal="pressed" from="OuterMargin/Panel/InnerMargin/VBoxContainer/HBoxContainer/Back" to="." method="_on_back_pressed"] |