diff options
author | metamuffin <metamuffin@disroot.org> | 2024-06-26 16:53:14 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-06-26 16:53:14 +0200 |
commit | 1e88790bf75baefc48e2950529f0b6e930534830 (patch) | |
tree | d1acf176d8031947718e8bb00946af74967604f4 | |
parent | 2ca6ac7ab329036d0155de2de4b0a11f3a785414 (diff) | |
parent | 89310ea939d495274302d207be34cceae618768c (diff) | |
download | hurrycurry-1e88790bf75baefc48e2950529f0b6e930534830.tar hurrycurry-1e88790bf75baefc48e2950529f0b6e930534830.tar.bz2 hurrycurry-1e88790bf75baefc48e2950529f0b6e930534830.tar.zst |
Merge branch 'master' of https://codeberg.org/metamuffin/undercooked
28 files changed, 335 insertions, 128 deletions
diff --git a/client/game.gd b/client/game.gd index 3ee960f7..ab2cdfbd 100644 --- a/client/game.gd +++ b/client/game.gd @@ -154,7 +154,7 @@ func _ready(): p.bubble.set_text(item_names[item]) ) - mp.send_join(Global.settings["username"], Global.settings["character"]) + mp.send_join(Global.profile["username"], Global.profile["character"]) func _process(delta): marker.position = lerp(marker.position, marker_target, delta * 40.0) diff --git a/client/global.gd b/client/global.gd index 095deec8..6e12d0cf 100644 --- a/client/global.gd +++ b/client/global.gd @@ -17,36 +17,65 @@ # extends Node -const DEFAULT_SETTINGS := { +const DEFAULT_PROFILE := { "username": "Giovanni", "character": 0, "last_server_url": "" } -var settings := DEFAULT_SETTINGS.duplicate(true) +var default_settings := { + "interpolate_camera_rotation": { + "value": true, + "description": tr("Interpolate the camera rotation") + }, + "test": { + "value": "hehe", + "description": tr("Just a test value") + }, +} + +var profile: Dictionary +var settings: Dictionary var server_url = "" var error_message = "" func _ready(): - load_profile() + profile = load_dict("user://profile", DEFAULT_PROFILE) + settings = load_dict("user://settings", default_settings) func save_profile(): - var f = FileAccess.open("user://profile", FileAccess.WRITE) - f.store_var(settings.duplicate(true)) + save_dict("user://profile", profile) - print("Saved settings: ", settings) +func save_settings(): + save_dict("user://settings", settings) -func load_profile(): +func save_dict(path: String, dict: Dictionary): + var f = FileAccess.open(path, FileAccess.WRITE) + f.store_var(dict.duplicate(true)) + +func load_dict(path: String, default: Dictionary) -> Dictionary: # TOCTOU here. Godot docs says its fine. - if not FileAccess.file_exists("user://profile"): + if not FileAccess.file_exists(path): print("Skip profile load") - return - var f = FileAccess.open("user://profile", FileAccess.READ) - var saved_settings = f.get_var() - if saved_settings != null and saved_settings is Dictionary: - for i in DEFAULT_SETTINGS.keys(): - if saved_settings.has(i): - settings[i] = saved_settings[i] + return default + var f = FileAccess.open(path, FileAccess.READ) + var saved_dict = f.get_var() + var res: Dictionary = {} + if saved_dict != null and saved_dict is Dictionary: + for i in default.keys(): + if saved_dict.has(i): + res[i] = saved_dict[i] + + print("Loaded dict: ", res) + return res - print("Loaded settings: ", settings) +func focus_first_button(node: Node) -> bool: + if node is Button: + node.grab_focus() + print("Node %s (%s) was selected for focus" % [node.name, node]) + return true + for c in node.get_children(): + if focus_first_button(c): + return true + return false diff --git a/client/menu/character_menu.gd b/client/menu/character_menu.gd index f4b878be..3e535e71 100644 --- a/client/menu/character_menu.gd +++ b/client/menu/character_menu.gd @@ -19,21 +19,22 @@ extends Control @onready var num_hairstyles := character.hairstyles.keys().size() func _ready(): - $VBoxContainer/top_panel/a/username.text = Global.settings["username"] - character.select_hairstyle(Global.settings["character"]) + $VBoxContainer/top_panel/a/username.text = Global.profile["username"] + character.select_hairstyle(Global.profile["character"]) + Global.focus_first_button(self) func _on_back_pressed(): - $SceneTransition.transition_to("res://menu/main_menu.tscn") + $SceneTransition.transition_to("res://menu/menu_manager.tscn") func _on_username_text_changed(new_text): - Global.settings["username"] = new_text + Global.profile["username"] = new_text func _on_character_back_pressed(): - Global.settings["character"] = (Global.settings["character"] - 1) % num_hairstyles - character.select_hairstyle(Global.settings["character"]) + Global.profile["character"] = (Global.profile["character"] - 1) % num_hairstyles + character.select_hairstyle(Global.profile["character"]) Global.save_profile() func _on_character_forward_pressed(): - Global.settings["character"] = (Global.settings["character"] + 1) % num_hairstyles - character.select_hairstyle(Global.settings["character"]) + Global.profile["character"] = (Global.profile["character"] + 1) % num_hairstyles + character.select_hairstyle(Global.profile["character"]) Global.save_profile() diff --git a/client/menu/character_menu.tscn b/client/menu/character_menu.tscn index cad0cb35..b958cf9d 100644 --- a/client/menu/character_menu.tscn +++ b/client/menu/character_menu.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=7 format=3 uid="uid://1f7xpirm5d28"] -[ext_resource type="Theme" uid="uid://b0qmvo504e457" path="res://menu/theme.tres" id="1_ak2pw"] +[ext_resource type="Theme" uid="uid://b0qmvo504e457" path="res://menu/theme/theme.tres" id="1_ak2pw"] [ext_resource type="Script" path="res://menu/character_menu.gd" id="1_brhd1"] [ext_resource type="PackedScene" uid="uid://b3hhir2fvnunu" path="res://player/character/character.tscn" id="3_odq7n"] [ext_resource type="PackedScene" uid="uid://bg2d78ycorcqk" path="res://menu/scene_transition.tscn" id="4_c0ocf"] diff --git a/client/menu/credits_menu.gd b/client/menu/credits_menu.gd index e3ea4c51..2b481e47 100644 --- a/client/menu/credits_menu.gd +++ b/client/menu/credits_menu.gd @@ -21,9 +21,10 @@ var cc_by_3 := { "Glasses": "Jeremy Edelblut" } +@onready var menu_manager: MenuManager = get_parent() @onready var label = $Panel/MarginContainer/VBoxContainer/RichTextLabel -func _ready(): +func prepare(): contributors.shuffle() label.text = "[center][b]undercooked - a game about cooking[/b]\n\ndeveloped by\n\n[b]" label.text += ", ".join(contributors) @@ -34,6 +35,6 @@ func _ready(): label.text += "[b]\"%s\" %s[/b]\nLicensed under Creative Commons: By Attribution 3.0 License\nhttps://creativecommons.org/licenses/by/3.0/\n\n" % [k, v] label.text += "[b]Additional CC0 assets by:[/b]\n" + "\n".join(cc_0) - + func _on_back_pressed(): - $SceneTransition.transition_to("res://menu/main_menu.tscn") + menu_manager.go_back() diff --git a/client/menu/credits_menu.tscn b/client/menu/credits_menu.tscn index a6536e16..74d5cbc9 100644 --- a/client/menu/credits_menu.tscn +++ b/client/menu/credits_menu.tscn @@ -1,9 +1,7 @@ -[gd_scene load_steps=6 format=3 uid="uid://7mqbxa054bjv"] +[gd_scene load_steps=4 format=3 uid="uid://7mqbxa054bjv"] -[ext_resource type="Theme" uid="uid://b0qmvo504e457" path="res://menu/theme.tres" id="1_emk5o"] +[ext_resource type="Theme" uid="uid://b0qmvo504e457" path="res://menu/theme/theme.tres" id="1_emk5o"] [ext_resource type="Script" path="res://menu/credits_menu.gd" id="1_igs63"] -[ext_resource type="PackedScene" uid="uid://l4vm07dtda4j" path="res://menu/menu_background.tscn" id="2_k0853"] -[ext_resource type="PackedScene" uid="uid://bg2d78ycorcqk" path="res://menu/scene_transition.tscn" id="4_fbbdb"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_p2qmw"] bg_color = Color(0, 0, 0, 0.878431) @@ -18,8 +16,6 @@ grow_vertical = 2 theme = ExtResource("1_emk5o") script = ExtResource("1_igs63") -[node name="MenuBackground" parent="." instance=ExtResource("2_k0853")] - [node name="Panel" type="Panel" parent="."] layout_mode = 1 anchors_preset = 15 @@ -58,8 +54,4 @@ bbcode_enabled = true layout_mode = 2 text = "Back" -[node name="SceneTransition" parent="." instance=ExtResource("4_fbbdb")] -visible = false -layout_mode = 1 - [connection signal="pressed" from="Panel/MarginContainer/VBoxContainer/back" to="." method="_on_back_pressed"] diff --git a/client/menu/error_menu.gd b/client/menu/error_menu.gd index 9938ee9d..087261e5 100644 --- a/client/menu/error_menu.gd +++ b/client/menu/error_menu.gd @@ -1,7 +1,8 @@ extends Control func _ready(): + Global.focus_first_button(self) $Panel/contents/mesage.text = Global.error_message func _on_return_pressed(): - $SceneTransition.transition_to("res://menu/main_menu.tscn") + $SceneTransition.transition_to("res://menu/menu_manager.tscn") diff --git a/client/menu/error_menu.tscn b/client/menu/error_menu.tscn index 0b86cceb..ea01ddc3 100644 --- a/client/menu/error_menu.tscn +++ b/client/menu/error_menu.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=5 format=3 uid="uid://cimgn07lbcs4v"] -[ext_resource type="Theme" uid="uid://b0qmvo504e457" path="res://menu/theme.tres" id="1_cabdu"] +[ext_resource type="Theme" uid="uid://b0qmvo504e457" path="res://menu/theme/theme.tres" id="1_cabdu"] [ext_resource type="PackedScene" uid="uid://l4vm07dtda4j" path="res://menu/menu_background.tscn" id="2_5fxol"] [ext_resource type="Script" path="res://menu/error_menu.gd" id="2_dbe41"] [ext_resource type="PackedScene" uid="uid://bg2d78ycorcqk" path="res://menu/scene_transition.tscn" id="4_1nbt3"] diff --git a/client/menu/ingame_menu.gd b/client/menu/ingame_menu.gd index 21bfa8ac..4752c382 100644 --- a/client/menu/ingame_menu.gd +++ b/client/menu/ingame_menu.gd @@ -1,9 +1,20 @@ extends Control @onready var anim = $AnimationPlayer +@onready var options = $Side/Margin/Options + +func act(): + show() + anim.play("activate") + Global.focus_first_button(options) + +func deact(): + anim.play_backwards("activate") + await anim.animation_finished + hide() func _on_main_menu_pressed(): - get_parent().transition_to("res://menu/main_menu.tscn") + get_parent().transition_to("res://menu/menu_manager.tscn") func _on_quit_pressed(): get_parent().quit() diff --git a/client/menu/ingame_menu.tscn b/client/menu/ingame_menu.tscn index cf35a7e7..47b7cb54 100644 --- a/client/menu/ingame_menu.tscn +++ b/client/menu/ingame_menu.tscn @@ -1,16 +1,16 @@ [gd_scene load_steps=10 format=3 uid="uid://lxlgtjm8hw7v"] [ext_resource type="Script" path="res://menu/ingame_menu.gd" id="1_gd1i3"] +[ext_resource type="Theme" uid="uid://b0qmvo504e457" path="res://menu/theme/theme.tres" id="1_lb056"] [ext_resource type="Shader" path="res://menu/blur_mix.gdshader" id="1_o42mc"] -[ext_resource type="Theme" uid="uid://b0qmvo504e457" path="res://menu/theme.tres" id="1_tm331"] -[ext_resource type="FontFile" uid="uid://bo4vh5xkpvrh1" path="res://menu/font-sansita-swashed.woff2" id="2_4u0ox"] +[ext_resource type="FontFile" uid="uid://bo4vh5xkpvrh1" path="res://menu/theme/font-sansita-swashed.woff2" id="4_27kbu"] [sub_resource type="Animation" id="Animation_8sedy"] length = 0.001 tracks/0/type = "bezier" tracks/0/imported = false tracks/0/enabled = true -tracks/0/path = NodePath("side:position:x") +tracks/0/path = NodePath("Side:position:x") tracks/0/interp = 1 tracks/0/loop_wrap = true tracks/0/keys = { @@ -24,7 +24,7 @@ resource_name = "activate" tracks/0/type = "bezier" tracks/0/imported = false tracks/0/enabled = true -tracks/0/path = NodePath("side:position:x") +tracks/0/path = NodePath("Side:position:x") tracks/0/interp = 1 tracks/0/loop_wrap = true tracks/0/keys = { @@ -46,7 +46,7 @@ shader_parameter/mix_amount = 0.3 shader_parameter/color_over = null [sub_resource type="FontVariation" id="FontVariation_ud3l8"] -base_font = ExtResource("2_4u0ox") +base_font = ExtResource("4_27kbu") variation_embolden = 0.5 [node name="IngameMenu" type="Control"] @@ -56,7 +56,7 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -theme = ExtResource("1_tm331") +theme = ExtResource("1_lb056") script = ExtResource("1_gd1i3") [node name="AnimationPlayer" type="AnimationPlayer" parent="."] @@ -65,26 +65,27 @@ libraries = { } speed_scale = 8.0 -[node name="side" type="PanelContainer" parent="."] +[node name="Side" type="PanelContainer" parent="."] material = SubResource("ShaderMaterial_o2vtr") layout_mode = 1 anchors_preset = 9 anchor_bottom = 1.0 offset_left = -400.0 offset_right = -90.0 +offset_bottom = 1296.0 grow_vertical = 2 -[node name="margin" type="MarginContainer" parent="side"] +[node name="Margin" type="MarginContainer" parent="Side"] layout_mode = 2 theme_override_constants/margin_left = 20 theme_override_constants/margin_top = 20 theme_override_constants/margin_right = 20 theme_override_constants/margin_bottom = 20 -[node name="options" type="VBoxContainer" parent="side/margin"] +[node name="Options" type="VBoxContainer" parent="Side/Margin"] layout_mode = 2 -[node name="title" type="Label" parent="side/margin/options"] +[node name="Title" type="Label" parent="Side/Margin/Options"] layout_mode = 2 auto_translate = false theme_override_colors/font_outline_color = Color(0.566408, 0.208917, 0.266045, 1) @@ -93,25 +94,25 @@ theme_override_fonts/font = SubResource("FontVariation_ud3l8") theme_override_font_sizes/font_size = 48 text = "Undercooked" -[node name="spacer" type="Control" parent="side/margin/options"] +[node name="Spacer" type="Control" parent="Side/Margin/Options"] custom_minimum_size = Vector2(0, 10) layout_mode = 2 -[node name="reconnect" type="Button" parent="side/margin/options"] +[node name="Reconnect" type="Button" parent="Side/Margin/Options"] layout_mode = 2 text = "Reconnect" alignment = 0 -[node name="main_menu" type="Button" parent="side/margin/options"] +[node name="MainMenu" type="Button" parent="Side/Margin/Options"] layout_mode = 2 text = "Main Menu" alignment = 0 -[node name="quit" type="Button" parent="side/margin/options"] +[node name="Quit" type="Button" parent="Side/Margin/Options"] layout_mode = 2 text = "Quit" alignment = 0 -[connection signal="pressed" from="side/margin/options/reconnect" to="." method="_on_reconnect_pressed"] -[connection signal="pressed" from="side/margin/options/main_menu" to="." method="_on_main_menu_pressed"] -[connection signal="pressed" from="side/margin/options/quit" to="." method="_on_quit_pressed"] +[connection signal="pressed" from="Side/Margin/Options/Reconnect" to="." method="_on_reconnect_pressed"] +[connection signal="pressed" from="Side/Margin/Options/MainMenu" to="." method="_on_main_menu_pressed"] +[connection signal="pressed" from="Side/Margin/Options/Quit" to="." method="_on_quit_pressed"] diff --git a/client/menu/main_menu.gd b/client/menu/main_menu.gd index 31ca5462..28629e0d 100644 --- a/client/menu/main_menu.gd +++ b/client/menu/main_menu.gd @@ -16,26 +16,25 @@ # extends Control -@onready var transition = $SceneTransition -@onready var quick_connect = $side/margin/options/quick_connect +@onready var menu_manager: MenuManager = get_parent() + @onready var quit_button = $side/margin/options/quit @onready var connect_uri = $side/margin/options/connect/uri func _ready(): - quick_connect.grab_focus() if OS.has_feature("web"): quit_button.hide() - connect_uri.text = Global.settings["last_server_url"] + connect_uri.text = Global.profile["last_server_url"] func _on_quit_pressed(): - transition.quit() + menu_manager.transition.quit() func _on_credits_pressed(): - transition.transition_to("res://menu/credits_menu.tscn") + menu_manager.goto("credits") func _on_connect_pressed(): - var url = $side/margin/options/connect/uri.text - Global.settings["last_server_url"] = url + var url = connect_uri.text + Global.profile["last_server_url"] = url Global.save_profile() connect_to(url) @@ -52,10 +51,10 @@ func _on_quick_connect_pressed(): func connect_to(url): print("Connecting to %s" % url) Global.server_url = url - transition.transition_to("res://game.tscn") + menu_manager.transition.transition_to("res://game.tscn") func _on_change_character_pressed(): - transition.transition_to("res://menu/character_menu.tscn") + menu_manager.transition.transition_to("res://menu/character_menu.tscn") func _on_settings_pressed(): - transition.transition_to("res://menu/settings_menu.tscn") + menu_manager.goto("settings") diff --git a/client/menu/main_menu.tscn b/client/menu/main_menu.tscn index 0deeb748..76b55a1a 100644 --- a/client/menu/main_menu.tscn +++ b/client/menu/main_menu.tscn @@ -1,11 +1,9 @@ -[gd_scene load_steps=9 format=3 uid="uid://dbj8508whxgwv"] +[gd_scene load_steps=8 format=3 uid="uid://dbj8508whxgwv"] -[ext_resource type="Theme" uid="uid://b0qmvo504e457" path="res://menu/theme.tres" id="1_nlcpo"] +[ext_resource type="Theme" uid="uid://b0qmvo504e457" path="res://menu/theme/theme.tres" id="1_nlcpo"] [ext_resource type="Script" path="res://menu/main_menu.gd" id="2_qot2j"] [ext_resource type="Shader" path="res://menu/blur_mix.gdshader" id="4_050xu"] -[ext_resource type="FontFile" uid="uid://bo4vh5xkpvrh1" path="res://menu/font-sansita-swashed.woff2" id="4_mfs30"] -[ext_resource type="PackedScene" uid="uid://l4vm07dtda4j" path="res://menu/menu_background.tscn" id="4_ydj5p"] -[ext_resource type="PackedScene" uid="uid://bg2d78ycorcqk" path="res://menu/scene_transition.tscn" id="5_651nk"] +[ext_resource type="FontFile" uid="uid://bo4vh5xkpvrh1" path="res://menu/theme/font-sansita-swashed.woff2" id="4_mfs30"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_irdo3"] shader = ExtResource("4_050xu") @@ -13,6 +11,8 @@ shader_parameter/blur_amount = 3.5 shader_parameter/mix_amount = 0.3 shader_parameter/color_over = null +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_cm1nk"] + [sub_resource type="FontVariation" id="FontVariation_htgmg"] base_font = ExtResource("4_mfs30") variation_embolden = 0.5 @@ -27,8 +27,6 @@ grow_vertical = 2 theme = ExtResource("1_nlcpo") script = ExtResource("2_qot2j") -[node name="MenuBackground" parent="." instance=ExtResource("4_ydj5p")] - [node name="side" type="PanelContainer" parent="."] material = SubResource("ShaderMaterial_irdo3") layout_mode = 1 @@ -36,6 +34,7 @@ anchors_preset = 9 anchor_bottom = 1.0 offset_right = 340.0 grow_vertical = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_cm1nk") [node name="margin" type="MarginContainer" parent="side"] layout_mode = 2 @@ -98,10 +97,6 @@ layout_mode = 2 text = "Quit" alignment = 0 -[node name="SceneTransition" parent="." instance=ExtResource("5_651nk")] -visible = false -layout_mode = 1 - [connection signal="pressed" from="side/margin/options/quick_connect" to="." method="_on_quick_connect_pressed"] [connection signal="pressed" from="side/margin/options/connect/connect" to="." method="_on_connect_pressed"] [connection signal="pressed" from="side/margin/options/change_character" to="." method="_on_change_character_pressed"] diff --git a/client/menu/menu_manager.gd b/client/menu/menu_manager.gd new file mode 100644 index 00000000..69866377 --- /dev/null +++ b/client/menu/menu_manager.gd @@ -0,0 +1,36 @@ +extends Control +class_name MenuManager + +@onready var menus = { + "main": $MainMenu, + "credits": $CreditsMenu, + "settings": $SettingsMenu +} +@onready var transition = $SceneTransition + +var menu_stack = ["main"] + +func _ready(): + Global.focus_first_button(menus[menu_stack.back()]) + +func goto(menu_name: String): + show_menu(menu_name) + menu_stack.push_back(menu_name) + print("Go to called. Stack: " + str(menu_stack)) + +func go_back(): + menu_stack.pop_back() + if menu_stack.is_empty(): + Global.showError("Menu stack empty") + show_menu(menu_stack.back()) + print("Go back called. Stack: " + str(menu_stack)) + +func show_menu(menu_name: String): + for k in menus.keys(): + if k == menu_name: + menus[k].show() + if menus[k].has_method("prepare"): + menus[k].prepare() # Optionally run some code + Global.focus_first_button(menus[k]) + else: + menus[k].hide() diff --git a/client/menu/menu_manager.tscn b/client/menu/menu_manager.tscn new file mode 100644 index 00000000..6b2d7b33 --- /dev/null +++ b/client/menu/menu_manager.tscn @@ -0,0 +1,38 @@ +[gd_scene load_steps=7 format=3 uid="uid://cd52sr1cmo8oj"] + +[ext_resource type="Script" path="res://menu/menu_manager.gd" id="1_c0rjm"] +[ext_resource type="PackedScene" uid="uid://l4vm07dtda4j" path="res://menu/menu_background.tscn" id="2_nf7b6"] +[ext_resource type="PackedScene" uid="uid://dbj8508whxgwv" path="res://menu/main_menu.tscn" id="3_ccpur"] +[ext_resource type="PackedScene" uid="uid://7mqbxa054bjv" path="res://menu/credits_menu.tscn" id="4_xhcd8"] +[ext_resource type="PackedScene" uid="uid://8ic77jmadadj" path="res://menu/settings_menu.tscn" id="5_lifj8"] +[ext_resource type="PackedScene" uid="uid://bg2d78ycorcqk" path="res://menu/scene_transition.tscn" id="6_p4u45"] + +[node name="MenuManager" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_c0rjm") + +[node name="MenuBackground" parent="." instance=ExtResource("2_nf7b6")] + +[node name="MainMenu" parent="." instance=ExtResource("3_ccpur")] +layout_mode = 1 + +[node name="CreditsMenu" parent="." instance=ExtResource("4_xhcd8")] +visible = false +layout_mode = 1 + +[node name="SettingsMenu" parent="." instance=ExtResource("5_lifj8")] +visible = false +layout_mode = 1 + +[node name="SceneTransition" parent="." instance=ExtResource("6_p4u45")] +layout_mode = 0 +anchors_preset = 0 +anchor_right = 0.0 +anchor_bottom = 0.0 +grow_horizontal = 1 +grow_vertical = 1 diff --git a/client/menu/scene_transition.gd b/client/menu/scene_transition.gd index 8d9f38cf..87a1ec1b 100644 --- a/client/menu/scene_transition.gd +++ b/client/menu/scene_transition.gd @@ -45,9 +45,6 @@ func out(): func _process(_delta): if ingame: if not menu.visible and Input.is_action_just_pressed("pause"): - menu.visible = true - menu.anim.play("activate") + menu.act() elif menu.visible and Input.is_action_just_pressed("pause"): - menu.anim.play_backwards("activate") - await menu.anim.animation_finished - menu.visible = false + menu.deact() diff --git a/client/menu/settings_menu.gd b/client/menu/settings_menu.gd index a023cf36..6b2a7f60 100644 --- a/client/menu/settings_menu.gd +++ b/client/menu/settings_menu.gd @@ -15,5 +15,22 @@ # extends Control +@onready var options: VBoxContainer = $outer_gap/panel/inner_gap/options +@onready var menu_manager: MenuManager = get_parent() + +var settings: Dictionary + func _on_back_pressed(): - $SceneTransition.transition_to("res://menu/main_menu.tscn") + for k in settings.keys(): + Global.settings[k]["value"] = settings[k].get_value() + Global.save_settings() + menu_manager.go_back() + + +func _ready(): + for k in Global.settings.keys(): + var v = Global.settings[k] + var row: SettingsRow = preload("res://menu/settings_row.tscn").instantiate() + row.setup(v["description"], v["value"]) + options.add_child(row) + settings[k] = row diff --git a/client/menu/settings_menu.tscn b/client/menu/settings_menu.tscn index 18a32759..6ead9b8b 100644 --- a/client/menu/settings_menu.tscn +++ b/client/menu/settings_menu.tscn @@ -1,9 +1,7 @@ -[gd_scene load_steps=5 format=3 uid="uid://8ic77jmadadj"] +[gd_scene load_steps=3 format=3 uid="uid://8ic77jmadadj"] -[ext_resource type="Theme" uid="uid://b0qmvo504e457" path="res://menu/theme.tres" id="1_foq3a"] -[ext_resource type="PackedScene" uid="uid://l4vm07dtda4j" path="res://menu/menu_background.tscn" id="1_wi8ti"] +[ext_resource type="Theme" uid="uid://b0qmvo504e457" path="res://menu/theme/theme.tres" id="1_foq3a"] [ext_resource type="Script" path="res://menu/settings_menu.gd" id="2_3hgm8"] -[ext_resource type="PackedScene" uid="uid://bg2d78ycorcqk" path="res://menu/scene_transition.tscn" id="2_t0one"] [node name="SettingsMenu" type="Control"] layout_mode = 3 @@ -15,8 +13,6 @@ grow_vertical = 2 theme = ExtResource("1_foq3a") script = ExtResource("2_3hgm8") -[node name="MenuBackground" parent="." instance=ExtResource("1_wi8ti")] - [node name="outer_gap" type="MarginContainer" parent="."] layout_mode = 1 anchors_preset = 15 @@ -58,8 +54,4 @@ layout_mode = 2 size_flags_vertical = 8 text = "Back to Main Menu" -[node name="SceneTransition" parent="." instance=ExtResource("2_t0one")] -visible = false -layout_mode = 1 - [connection signal="pressed" from="outer_gap/panel/inner_gap/back" to="." method="_on_back_pressed"] diff --git a/client/menu/settings_row.gd b/client/menu/settings_row.gd new file mode 100644 index 00000000..ee4b8cb9 --- /dev/null +++ b/client/menu/settings_row.gd @@ -0,0 +1,36 @@ +class_name SettingsRow +extends PanelContainer + +@onready var value_parent = $HBoxContainer/BoxContainer +@onready var label = $HBoxContainer/Label + +var value_node +var description = tr("no value was given to the row") + +func setup(description_: String, value): + description = description_ + if value is bool: + value_node = CheckButton.new() + value_node.button_pressed = value + elif value is String: + value_node = LineEdit.new() + value_node.text = value + +func _ready(): + if value_node != null: + var c: Control = value_node + c.size_flags_vertical = Control.SIZE_EXPAND_FILL + c.size_flags_horizontal = Control.SIZE_EXPAND_FILL + label.text = description + value_parent.add_child(c) + +func get_value(): + if value_node != null: + if value_node is CheckButton: + return value_node.button_pressed + elif value_node is LineEdit: + return value_node.text + else: + return null + else: + return null diff --git a/client/menu/settings_row.tscn b/client/menu/settings_row.tscn new file mode 100644 index 00000000..b083d291 --- /dev/null +++ b/client/menu/settings_row.tscn @@ -0,0 +1,24 @@ +[gd_scene load_steps=2 format=3 uid="uid://o5e5vpem8w0k"] + +[ext_resource type="Script" path="res://menu/settings_row.gd" id="1_lxjnc"] + +[node name="SettingsRow" type="PanelContainer"] +offset_right = 105.0 +offset_bottom = 23.0 +size_flags_horizontal = 3 +script = ExtResource("1_lxjnc") + +[node name="HBoxContainer" type="HBoxContainer" parent="."] +layout_mode = 2 + +[node name="Label" type="Label" parent="HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="BoxContainer" type="BoxContainer" parent="HBoxContainer"] +custom_minimum_size = Vector2(300, 50) +layout_mode = 2 +alignment = 2 + +[node name="Button" type="Button" parent="HBoxContainer"] +layout_mode = 2 diff --git a/client/menu/theme/focus_style.tres b/client/menu/theme/focus_style.tres new file mode 100644 index 00000000..a01843fe --- /dev/null +++ b/client/menu/theme/focus_style.tres @@ -0,0 +1,17 @@ +[gd_resource type="StyleBoxFlat" format=3 uid="uid://b86kbd3pfkd5w"] + +[resource] +content_margin_left = 10.0 +content_margin_top = 10.0 +content_margin_right = 10.0 +content_margin_bottom = 10.0 +bg_color = Color(1, 1, 1, 0.0627451) +border_width_left = 2 +border_width_top = 2 +border_width_right = 2 +border_width_bottom = 2 +border_color = Color(0.818673, 0.926505, 1, 1) +corner_radius_top_left = 5 +corner_radius_top_right = 5 +corner_radius_bottom_right = 5 +corner_radius_bottom_left = 5 diff --git a/client/menu/font-josefin-sans.woff2 b/client/menu/theme/font-josefin-sans.woff2 Binary files differindex dce2708f..dce2708f 100644 --- a/client/menu/font-josefin-sans.woff2 +++ b/client/menu/theme/font-josefin-sans.woff2 diff --git a/client/menu/font-josefin-sans.woff2.import b/client/menu/theme/font-josefin-sans.woff2.import index 9bf40c47..5ecd872c 100644 --- a/client/menu/font-josefin-sans.woff2.import +++ b/client/menu/theme/font-josefin-sans.woff2.import @@ -3,12 +3,12 @@ importer="font_data_dynamic" type="FontFile" uid="uid://5ixo6b3bd3km" -path="res://.godot/imported/font-josefin-sans.woff2-8195d19f9e478a66f9d2ca31db663e15.fontdata" +path="res://.godot/imported/font-josefin-sans.woff2-e2c3f263d98e1132cfe6af3f4f0a3454.fontdata" [deps] -source_file="res://menu/font-josefin-sans.woff2" -dest_files=["res://.godot/imported/font-josefin-sans.woff2-8195d19f9e478a66f9d2ca31db663e15.fontdata"] +source_file="res://menu/theme/font-josefin-sans.woff2" +dest_files=["res://.godot/imported/font-josefin-sans.woff2-e2c3f263d98e1132cfe6af3f4f0a3454.fontdata"] [params] diff --git a/client/menu/font-sansita-swashed.woff2 b/client/menu/theme/font-sansita-swashed.woff2 Binary files differindex 5c665fb0..5c665fb0 100644 --- a/client/menu/font-sansita-swashed.woff2 +++ b/client/menu/theme/font-sansita-swashed.woff2 diff --git a/client/menu/font-sansita-swashed.woff2.import b/client/menu/theme/font-sansita-swashed.woff2.import index 54056a3c..faf840fa 100644 --- a/client/menu/font-sansita-swashed.woff2.import +++ b/client/menu/theme/font-sansita-swashed.woff2.import @@ -3,12 +3,12 @@ importer="font_data_dynamic" type="FontFile" uid="uid://bo4vh5xkpvrh1" -path="res://.godot/imported/font-sansita-swashed.woff2-259623c6db3c7be991207ff769c643a5.fontdata" +path="res://.godot/imported/font-sansita-swashed.woff2-323b4a2ee0671aba6e17a6f073f706f3.fontdata" [deps] -source_file="res://menu/font-sansita-swashed.woff2" -dest_files=["res://.godot/imported/font-sansita-swashed.woff2-259623c6db3c7be991207ff769c643a5.fontdata"] +source_file="res://menu/theme/font-sansita-swashed.woff2" +dest_files=["res://.godot/imported/font-sansita-swashed.woff2-323b4a2ee0671aba6e17a6f073f706f3.fontdata"] [params] diff --git a/client/menu/theme.tres b/client/menu/theme/theme.tres index c2ec3b12..96cdbb19 100644 --- a/client/menu/theme.tres +++ b/client/menu/theme/theme.tres @@ -1,10 +1,11 @@ -[gd_resource type="Theme" load_steps=8 format=3 uid="uid://b0qmvo504e457"] +[gd_resource type="Theme" load_steps=9 format=3 uid="uid://b0qmvo504e457"] -[ext_resource type="FontFile" uid="uid://5ixo6b3bd3km" path="res://menu/font-josefin-sans.woff2" id="1_go7fi"] -[ext_resource type="FontFile" uid="uid://bo4vh5xkpvrh1" path="res://menu/font-sansita-swashed.woff2" id="1_tneco"] +[ext_resource type="FontFile" uid="uid://5ixo6b3bd3km" path="res://menu/theme/font-josefin-sans.woff2" id="1_f8qb0"] +[ext_resource type="StyleBox" uid="uid://b86kbd3pfkd5w" path="res://menu/theme/focus_style.tres" id="2_brg2c"] +[ext_resource type="FontFile" uid="uid://bo4vh5xkpvrh1" path="res://menu/theme/font-sansita-swashed.woff2" id="3_8u6ww"] [sub_resource type="FontVariation" id="FontVariation_lyo8w"] -base_font = ExtResource("1_go7fi") +base_font = ExtResource("1_f8qb0") variation_embolden = 1.25 spacing_top = 5 @@ -39,25 +40,25 @@ grow_end = 0.0 thickness = 3 [sub_resource type="FontVariation" id="FontVariation_ff4nr"] -base_font = ExtResource("1_tneco") +base_font = ExtResource("3_8u6ww") variation_embolden = 0.7 [resource] Button/font_sizes/font_size = 18 Button/fonts/font = SubResource("FontVariation_lyo8w") Button/styles/disabled = SubResource("StyleBoxFlat_25x32") -Button/styles/focus = SubResource("StyleBoxFlat_25x32") +Button/styles/focus = ExtResource("2_brg2c") Button/styles/hover = SubResource("StyleBoxFlat_2fl8q") Button/styles/normal = SubResource("StyleBoxFlat_25x32") Button/styles/pressed = SubResource("StyleBoxFlat_25x32") HSeparator/styles/separator = SubResource("StyleBoxLine_emtvk") Label/font_sizes/font_size = 16 -Label/fonts/font = ExtResource("1_tneco") -LineEdit/styles/focus = SubResource("StyleBoxFlat_25x32") +Label/fonts/font = ExtResource("3_8u6ww") +LineEdit/styles/focus = ExtResource("2_brg2c") LineEdit/styles/normal = SubResource("StyleBoxFlat_25x32") LineEdit/styles/read_only = SubResource("StyleBoxFlat_25x32") RichTextLabel/fonts/bold_font = SubResource("FontVariation_ff4nr") RichTextLabel/fonts/bold_italics_font = null RichTextLabel/fonts/italics_font = null RichTextLabel/fonts/mono_font = null -RichTextLabel/fonts/normal_font = ExtResource("1_tneco") +RichTextLabel/fonts/normal_font = ExtResource("3_8u6ww") diff --git a/client/player/chat_message.tscn b/client/player/chat_message.tscn index 1ac82368..816c9c4f 100644 --- a/client/player/chat_message.tscn +++ b/client/player/chat_message.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=4 format=3 uid="uid://5rcfoyuiwuya"] -[ext_resource type="FontFile" uid="uid://5ixo6b3bd3km" path="res://menu/font-josefin-sans.woff2" id="1_3ximm"] +[ext_resource type="FontFile" uid="uid://5ixo6b3bd3km" path="res://menu/theme/font-josefin-sans.woff2" id="1_3ximm"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_dpele"] bg_color = Color(1, 1, 1, 1) diff --git a/client/po/de.po b/client/po/de.po index 1e71c03d..b99ffbd6 100644 --- a/client/po/de.po +++ b/client/po/de.po @@ -29,8 +29,8 @@ msgstr "Verbinden" msgid "My Chef" msgstr "Mein Koch" -#: menu/main_menu.tscn -msgid "Settings (todo)" +#: menu/main_menu.tscn menu/settings_menu.tscn +msgid "Settings" msgstr "Einstellungen" #: menu/main_menu.tscn @@ -42,8 +42,8 @@ msgid "Quit" msgstr "Verlassen" #: menu/character_menu.tscn -msgid "This textbox is useless." -msgstr "Diese Textbox ist nutzlos." +msgid "Username" +msgstr "Benutzername" #: menu/character_menu.tscn menu/credits_menu.tscn msgid "Back" @@ -53,21 +53,21 @@ msgstr "Zurück" msgid "" "[center][b]undercooked - a game about cooking[/b]\n" "\n" -"by\n" -"\n" -"[b]tpart, nokoe, metamuffin[/b]\n" +"developed by\n" "\n" -"using various models from kenney.nl\n" -"[/center]" +"[b]" msgstr "" "[center][b]undercooked - ein Spiel rund ums Kochen[/b]\n" "\n" -"von\n" +"entwickelt von\n" "\n" -"[b]tpart, nokoe, metamuffin[/b]\n" +"[b]" + +#: menu/credits_menu.tscn +msgid "" +"[/b]\n" "\n" -"verwendet verschiedenste Modelle von kenney.nl\n" -"[/center]" +msgstr "" #: menu/error_menu.tscn msgid "Error" @@ -82,5 +82,24 @@ msgid "Return to Main Menu" msgstr "Zurück zum Hauptmenü" #: menu/ingame_menu.tscn +msgid "Reconnect" +msgstr "Erneut verbinden" + +#: menu/ingame_menu.tscn msgid "Main Menu" msgstr "Hauptmenü" + +#: global.gd +msgid "Interpolate the camera rotation" +msgstr "Kameradrehung interpolieren" + +#: global.gd +msgid "Just a test value" +msgstr "" + +#: menu/settings_menu.tscn +msgid "Back to Main Menu" +msgstr "Zurück zum Hauptmenü" + +#~ msgid "This textbox is useless." +#~ msgstr "Diese Textbox ist nutzlos." diff --git a/client/project.godot b/client/project.godot index 679bd9e0..6c5d29f0 100644 --- a/client/project.godot +++ b/client/project.godot @@ -11,7 +11,7 @@ config_version=5 [application] config/name="undercooked" -run/main_scene="res://menu/main_menu.tscn" +run/main_scene="res://menu/menu_manager.tscn" config/features=PackedStringArray("4.2", "Forward Plus") boot_splash/bg_color=Color(0.282353, 0.141176, 0.141176, 1) boot_splash/image="res://icon.png" @@ -101,7 +101,7 @@ boost={ [internationalization] locale/translations=PackedStringArray("res://po/de.po") -locale/translations_pot_files=PackedStringArray("res://menu/main_menu.tscn", "res://menu/character_menu.tscn", "res://menu/credits_menu.tscn", "res://menu/error_menu.tscn", "res://menu/ingame_menu.tscn") +locale/translations_pot_files=PackedStringArray("res://menu/main_menu.tscn", "res://menu/character_menu.tscn", "res://menu/credits_menu.tscn", "res://menu/error_menu.tscn", "res://menu/ingame_menu.tscn", "res://global.gd", "res://menu/settings_menu.tscn") [rendering] |