diff options
author | metamuffin <metamuffin@disroot.org> | 2024-06-29 23:06:20 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-06-29 23:06:20 +0200 |
commit | 12b06f3b8769467b957986e2b2601f6dfb7f9dc6 (patch) | |
tree | 9422a0cab2e8991de04c01813136d9c4e1ef25e1 | |
parent | b93a28ee71f25061d473777565549d90b6325996 (diff) | |
parent | ebf98091026017e7c410e8c2aeaa5e7c7d326a6c (diff) | |
download | hurrycurry-12b06f3b8769467b957986e2b2601f6dfb7f9dc6.tar hurrycurry-12b06f3b8769467b957986e2b2601f6dfb7f9dc6.tar.bz2 hurrycurry-12b06f3b8769467b957986e2b2601f6dfb7f9dc6.tar.zst |
Merge branch 'master' of https://codeberg.org/metamuffin/undercooked
-rw-r--r-- | client/audio/sound.gd | 19 | ||||
-rw-r--r-- | client/audio/sound.tscn | 16 | ||||
-rw-r--r-- | client/global.gd | 31 | ||||
-rw-r--r-- | client/map/items/grass.gd | 23 | ||||
-rw-r--r-- | client/map/tiles/grass.tscn | 6 | ||||
-rw-r--r-- | client/map/tiles/grass_generation.gd | 15 | ||||
-rw-r--r-- | client/menu/ingame_menu.gd | 3 | ||||
-rw-r--r-- | client/menu/ingame_menu.tscn | 1 | ||||
-rw-r--r-- | client/menu/menu_manager.gd | 17 | ||||
-rw-r--r-- | client/menu/menu_manager.tscn | 10 | ||||
-rw-r--r-- | client/menu/overlay.tscn | 9 | ||||
-rw-r--r-- | client/menu/settings_menu.gd | 1 | ||||
-rw-r--r-- | client/menu/settings_menu.tscn | 2 | ||||
-rw-r--r-- | client/menu/settings_row.gd | 5 | ||||
-rw-r--r-- | client/player/follow_camera.gd | 6 | ||||
-rw-r--r-- | client/project.godot | 16 |
16 files changed, 127 insertions, 53 deletions
diff --git a/client/audio/sound.gd b/client/audio/sound.gd new file mode 100644 index 00000000..ddb610c5 --- /dev/null +++ b/client/audio/sound.gd @@ -0,0 +1,19 @@ +extends Node + +@onready var click_sound = $UI/Click +@onready var hover_sound = $UI/Hover + +func play_click(): + click_sound.play() + +func play_hover(): + hover_sound.play() + +func play_hover_maybe(element): + if Global.focus_auto_changed: + Global.focus_auto_changed = false + return + if element is Button: + if element.is_hovered(): + return + play_hover() diff --git a/client/audio/sound.tscn b/client/audio/sound.tscn new file mode 100644 index 00000000..7c0458dc --- /dev/null +++ b/client/audio/sound.tscn @@ -0,0 +1,16 @@ +[gd_scene load_steps=4 format=3 uid="uid://d3h243yic44rr"] + +[ext_resource type="Script" path="res://audio/sound.gd" id="1_b0qb1"] +[ext_resource type="AudioStream" uid="uid://cpyn511c5mtni" path="res://menu/sounds/click.ogg" id="2_mhrce"] +[ext_resource type="AudioStream" uid="uid://dtr1khfyqr56o" path="res://menu/sounds/hover.ogg" id="3_qft2s"] + +[node name="Sound" type="Node"] +script = ExtResource("1_b0qb1") + +[node name="UI" type="Node" parent="."] + +[node name="Click" type="AudioStreamPlayer" parent="UI"] +stream = ExtResource("2_mhrce") + +[node name="Hover" type="AudioStreamPlayer" parent="UI"] +stream = ExtResource("3_qft2s") diff --git a/client/global.gd b/client/global.gd index 31a07ed34..10468645 100644 --- a/client/global.gd +++ b/client/global.gd @@ -34,6 +34,11 @@ var default_profile := { } var default_settings := { + "fullscreen": { + "type": "toggle", + "value": false, + "description": tr("Fullscreen") + }, "interpolate_camera_rotation": { "type": "toggle", "value": true, @@ -113,12 +118,26 @@ var settings: Dictionary var server_url = "" var error_message = "" +var focus_auto_changed := false + var fade_next := false # Set true when transitioning from another scene (fade in requried) func _init(): profile = load_dict("user://profile", default_profile) settings = load_dict("user://settings", default_settings) - print("DONE LOADING") + update_fullscreen() + +func _input(event): + if Input.is_action_just_pressed("fullscreen"): + settings["fullscreen"]["value"] = !settings["fullscreen"]["value"] + save_settings() + update_fullscreen() + +func update_fullscreen(): + if settings["fullscreen"]["value"]: + DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN) + else: + DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED) func save_profile(): save_dict("user://profile", profile) @@ -148,6 +167,8 @@ func on_vulkan() -> bool: return ProjectSettings.get_setting("rendering/rendering_device/driver") == "vulkan" func focus_first_button(node: Node) -> bool: + focus_auto_changed = true + if node is Button: node.grab_focus() print("Node %s (%s) was selected for focus" % [node.name, node]) @@ -157,6 +178,14 @@ func focus_first_button(node: Node) -> bool: return true return false +func connect_button_sounds(node: Node): + if node is Button: + node.pressed.connect(Sound.play_click) + if node is Button or node is LineEdit or node is Slider: + node.mouse_entered.connect(Sound.play_hover) + for c in node.get_children(): + connect_button_sounds(c) + func add_missing_keys(dict: Dictionary, reference: Dictionary): for k in reference.keys(): if !dict.has(k): diff --git a/client/map/items/grass.gd b/client/map/items/grass.gd index d303f8c7..1222f767 100644 --- a/client/map/items/grass.gd +++ b/client/map/items/grass.gd @@ -1,23 +1,36 @@ # Undercooked - a game about cooking # Copyright 2024 nokoe -# +# 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/>. -# +# class_name Grass extends Tile +const GRASS_SIDE: PackedScene = preload("res://map/tiles/grass_side.tscn") +const GRASS_COUNT: int = 16 + func _init(rename: String, _neighbors: Array): super(rename, _neighbors) - var grass_tile = load("res://map/tiles/grass.tscn").instantiate() + var grass_tile = preload("res://map/tiles/grass.tscn").instantiate() grass_tile.position += Vector3(0.5, 0, 0.5) add_child(grass_tile) + + var random = RandomNumberGenerator.new() + random.seed = rename.hash() + + for _i in Global.settings["grass_amount"]["value"]: + var g: Node3D = GRASS_SIDE.instantiate() + grass_tile.add_child(g) + g.position = Vector3(random.randf_range(-.5, .5), 0, random.randf_range(-.5, .5)) + g.rotation = Vector3(0, random.randf_range(0, PI), 0) diff --git a/client/map/tiles/grass.tscn b/client/map/tiles/grass.tscn index dd0ef53c..31ff6a69 100644 --- a/client/map/tiles/grass.tscn +++ b/client/map/tiles/grass.tscn @@ -1,10 +1,8 @@ -[gd_scene load_steps=3 format=3 uid="uid://ce14cj7exkvas"] +[gd_scene load_steps=2 format=3 uid="uid://bi6o7lbvhunj1"] -[ext_resource type="ArrayMesh" uid="uid://dyu8iuolwqr5l" path="res://map/tiles/grass.res" id="1_pjjrj"] -[ext_resource type="Script" path="res://map/tiles/grass_generation.gd" id="1_u7p1u"] +[ext_resource type="ArrayMesh" path="res://map/tiles/grass.res" id="1_pjjrj"] [node name="Grass" type="Node3D"] -script = ExtResource("1_u7p1u") [node name="Mesh" type="MeshInstance3D" parent="."] transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0) diff --git a/client/map/tiles/grass_generation.gd b/client/map/tiles/grass_generation.gd deleted file mode 100644 index 02f9bf83..00000000 --- a/client/map/tiles/grass_generation.gd +++ /dev/null @@ -1,15 +0,0 @@ -extends Node3D - -const GRASS_COUNT = 16 - -@onready var grass_side = preload("res://map/tiles/grass_side.tscn") - -func _ready(): - var random = RandomNumberGenerator.new() - random.randomize() - - for _i in Global.settings["grass_amount"]["value"]: - var g: Node3D = grass_side.instantiate() - add_child(g) - g.position = Vector3(random.randf_range(-.5, .5), 0, random.randf_range(-.5, .5)) - g.rotation = Vector3(0, random.randf_range(0, PI), 0) diff --git a/client/menu/ingame_menu.gd b/client/menu/ingame_menu.gd index 73f4dbb3..6fa83a55 100644 --- a/client/menu/ingame_menu.gd +++ b/client/menu/ingame_menu.gd @@ -3,6 +3,9 @@ extends Control @onready var anim = $AnimationPlayer @onready var options = $Side/Margin/Options +func _ready(): + Global.connect_button_sounds(self) + func act(): show() anim.play("activate") diff --git a/client/menu/ingame_menu.tscn b/client/menu/ingame_menu.tscn index ee537720..1e9a2f46 100644 --- a/client/menu/ingame_menu.tscn +++ b/client/menu/ingame_menu.tscn @@ -72,6 +72,7 @@ anchors_preset = 9 anchor_bottom = 1.0 offset_left = -400.0 offset_right = -90.0 +offset_bottom = 648.0 grow_vertical = 2 [node name="Margin" type="MarginContainer" parent="Side"] diff --git a/client/menu/menu_manager.gd b/client/menu/menu_manager.gd index a695cbdc..bba074f6 100644 --- a/client/menu/menu_manager.gd +++ b/client/menu/menu_manager.gd @@ -24,17 +24,15 @@ class_name MenuManager } @onready var transition: SceneTransition = $SceneTransition -@onready var hover_sound = $Hover -@onready var click_sound = $Click - var menu_stack = ["main"] func _ready(): if not Global.settings["setup_complete"]["value"]: return transition.instant_to("res://menu/setup_menu.tscn") + get_viewport().gui_focus_changed.connect(Sound.play_hover_maybe) Global.focus_first_button(menus[menu_stack.back()]) for m in menus.values(): - connect_button_sounds(m) + Global.connect_button_sounds(m) if Global.fade_next: Global.fade_next = false @@ -42,7 +40,7 @@ func _ready(): func _input(_event): if Input.is_action_just_pressed("ui_cancel") && menu_stack.size() > 1: - play_click() + Sound.play_click() go_back() func goto(menu_name: String): @@ -68,12 +66,3 @@ func show_menu(menu_name: String): else: menus[k].hide() await transition.fade_in() - -func connect_button_sounds(node: Node): - if node is Button: - node.pressed.connect(play_click) - for c in node.get_children(): - connect_button_sounds(c) - -func play_click(): - click_sound.play() diff --git a/client/menu/menu_manager.tscn b/client/menu/menu_manager.tscn index c6959407..56cc6442 100644 --- a/client/menu/menu_manager.tscn +++ b/client/menu/menu_manager.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=9 format=3 uid="uid://cd52sr1cmo8oj"] +[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"] @@ -6,8 +6,6 @@ [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"] -[ext_resource type="AudioStream" uid="uid://dtr1khfyqr56o" path="res://menu/sounds/hover.ogg" id="7_82cmi"] -[ext_resource type="AudioStream" uid="uid://cpyn511c5mtni" path="res://menu/sounds/click.ogg" id="8_qwknj"] [node name="MenuManager" type="Control"] layout_mode = 3 @@ -34,9 +32,3 @@ layout_mode = 1 [node name="SceneTransition" parent="." instance=ExtResource("6_p4u45")] visible = false layout_mode = 1 - -[node name="Hover" type="AudioStreamPlayer" parent="."] -stream = ExtResource("7_82cmi") - -[node name="Click" type="AudioStreamPlayer" parent="."] -stream = ExtResource("8_qwknj") diff --git a/client/menu/overlay.tscn b/client/menu/overlay.tscn index d0f002db..66e2a9f3 100644 --- a/client/menu/overlay.tscn +++ b/client/menu/overlay.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=7 format=3 uid="uid://bpikve6wlsjfl"] +[gd_scene load_steps=8 format=3 uid="uid://bpikve6wlsjfl"] [ext_resource type="Theme" uid="uid://b0qmvo504e457" path="res://menu/theme/theme.tres" id="1_4kujw"] [ext_resource type="Script" path="res://menu/overlay.gd" id="2_kbjds"] +[ext_resource type="FontFile" uid="uid://bo4vh5xkpvrh1" path="res://menu/theme/font-sansita-swashed.woff2" id="3_u54fv"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_04ujj"] bg_color = Color(0, 0, 0, 0) @@ -70,6 +71,7 @@ layout_mode = 2 [node name="Label" type="Label" parent="Control/Paper/Margin/Lines/Line1"] layout_mode = 2 theme_override_colors/font_color = Color(0, 0, 0, 1) +theme_override_fonts/font = ExtResource("3_u54fv") theme_override_font_sizes/font_size = 25 text = "Completed" @@ -81,6 +83,7 @@ size_flags_horizontal = 3 custom_minimum_size = Vector2(100, 0) layout_mode = 2 theme_override_colors/font_color = Color(0, 0.278431, 0, 1) +theme_override_fonts/font = ExtResource("3_u54fv") theme_override_font_sizes/font_size = 35 text = "0" horizontal_alignment = 1 @@ -91,6 +94,7 @@ layout_mode = 2 [node name="Label" type="Label" parent="Control/Paper/Margin/Lines/Line2"] layout_mode = 2 theme_override_colors/font_color = Color(0, 0, 0, 1) +theme_override_fonts/font = ExtResource("3_u54fv") theme_override_font_sizes/font_size = 25 text = "Failed" @@ -102,6 +106,7 @@ size_flags_horizontal = 3 custom_minimum_size = Vector2(100, 0) layout_mode = 2 theme_override_colors/font_color = Color(0.505882, 0, 0, 1) +theme_override_fonts/font = ExtResource("3_u54fv") theme_override_font_sizes/font_size = 35 text = "0" horizontal_alignment = 1 @@ -112,6 +117,7 @@ layout_mode = 2 [node name="Label" type="Label" parent="Control/Paper/Margin/Lines/Line3"] layout_mode = 2 theme_override_colors/font_color = Color(0, 0, 0, 1) +theme_override_fonts/font = ExtResource("3_u54fv") theme_override_font_sizes/font_size = 35 text = "Points" @@ -123,6 +129,7 @@ size_flags_horizontal = 3 custom_minimum_size = Vector2(100, 0) layout_mode = 2 theme_override_colors/font_color = Color(0, 0, 0, 1) +theme_override_fonts/font = ExtResource("3_u54fv") theme_override_font_sizes/font_size = 45 text = "0" horizontal_alignment = 1 diff --git a/client/menu/settings_menu.gd b/client/menu/settings_menu.gd index 68f3f2fc..e593caa0 100644 --- a/client/menu/settings_menu.gd +++ b/client/menu/settings_menu.gd @@ -24,6 +24,7 @@ func _on_back_pressed(): for k in settings.keys(): Global.settings[k]["value"] = settings[k].get_value() Global.save_settings() + Global.update_fullscreen() menu_manager.go_back() func _ready(): diff --git a/client/menu/settings_menu.tscn b/client/menu/settings_menu.tscn index 9be24d86..ecaea17c 100644 --- a/client/menu/settings_menu.tscn +++ b/client/menu/settings_menu.tscn @@ -59,6 +59,6 @@ size_flags_vertical = 3 [node name="Back" type="Button" parent="OuterGap/Panel/InnerGap/VBoxContainer"] layout_mode = 2 size_flags_vertical = 8 -text = "Back to Main Menu" +text = "Save & Apply" [connection signal="pressed" from="OuterGap/Panel/InnerGap/VBoxContainer/Back" to="." method="_on_back_pressed"] diff --git a/client/menu/settings_row.gd b/client/menu/settings_row.gd index 879fb363..30b1fd67 100644 --- a/client/menu/settings_row.gd +++ b/client/menu/settings_row.gd @@ -21,7 +21,10 @@ func setup(key: String, dict: Dictionary, defaults: Dictionary): "line": value_node = LineEdit.new() value_node.text = value - value_node.placeholder_text = default + if default != "": + value_node.placeholder_text = default + else: + value_node.placeholder_text = description "dropdown": value_node = OptionButton.new() for i in setting["options"]: diff --git a/client/player/follow_camera.gd b/client/player/follow_camera.gd index f0d5700d..e3ba5e92 100644 --- a/client/player/follow_camera.gd +++ b/client/player/follow_camera.gd @@ -50,6 +50,12 @@ func _process(delta): if target != null: follow(delta) +func _input(event): + if Input.is_action_just_pressed("reset"): + angle_target = 0 + angle_up_target = 1 + camera_distance_target = 10 + func follow(delta): angle_target += Input.get_axis("rotate_left", "rotate_right") * ROTATE_SPEED * delta angle = lerp_angle(angle, angle_target, delta * ROTATE_WEIGHT) diff --git a/client/project.godot b/client/project.godot index d595d655..df51e9d9 100644 --- a/client/project.godot +++ b/client/project.godot @@ -21,6 +21,7 @@ config/icon="res://icon.png" Global="*res://global.gd" Server="*res://server.gd" +Sound="*res://audio/sound.tscn" [input] @@ -105,14 +106,14 @@ boost={ ] } zoom_in={ -"deadzone": 0.5, +"deadzone": 0.25, "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194323,"key_label":0,"unicode":0,"echo":false,"script":null) , Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194437,"key_label":0,"unicode":43,"echo":false,"script":null) , Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":5,"axis_value":1.0,"script":null) ] } zoom_out={ -"deadzone": 0.5, +"deadzone": 0.25, "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194324,"key_label":0,"unicode":0,"echo":false,"script":null) , Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194435,"key_label":0,"unicode":45,"echo":false,"script":null) , Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":4,"axis_value":1.0,"script":null) @@ -124,6 +125,17 @@ chat={ , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":4,"pressure":0.0,"pressed":true,"script":null) ] } +reset={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":82,"key_label":0,"unicode":114,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":3,"pressure":0.0,"pressed":true,"script":null) +] +} +fullscreen={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194343,"key_label":0,"unicode":0,"echo":false,"script":null) +] +} [internationalization] |