aboutsummaryrefslogtreecommitdiff
path: root/client/gui/menus/rating
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-09-04 23:47:24 +0200
committermetamuffin <metamuffin@disroot.org>2025-09-05 23:07:07 +0200
commit81deaf81c800900e30046cb927be1c9d91ae61b8 (patch)
tree20ce9898465e8d4c49eeff12a9ea55572517ea7b /client/gui/menus/rating
parentfd80142282fcef628466a18e3ea62f0d1372d807 (diff)
downloadhurrycurry-81deaf81c800900e30046cb927be1c9d91ae61b8.tar
hurrycurry-81deaf81c800900e30046cb927be1c9d91ae61b8.tar.bz2
hurrycurry-81deaf81c800900e30046cb927be1c9d91ae61b8.tar.zst
reorganize client gui files
Diffstat (limited to 'client/gui/menus/rating')
-rw-r--r--client/gui/menus/rating/desaturate.gdshader7
-rw-r--r--client/gui/menus/rating/desaturate.gdshader.uid1
-rw-r--r--client/gui/menus/rating/rating.gd65
-rw-r--r--client/gui/menus/rating/rating.gd.uid1
-rw-r--r--client/gui/menus/rating/rating.tscn168
5 files changed, 242 insertions, 0 deletions
diff --git a/client/gui/menus/rating/desaturate.gdshader b/client/gui/menus/rating/desaturate.gdshader
new file mode 100644
index 00000000..e6861560
--- /dev/null
+++ b/client/gui/menus/rating/desaturate.gdshader
@@ -0,0 +1,7 @@
+shader_type canvas_item;
+
+uniform float t : hint_range(0.0, 1.0);
+
+void fragment() {
+ COLOR.rgb = mix(vec3(pow((COLOR.r+COLOR.g+COLOR.b)/3.,3.)),COLOR.rgb,t);
+}
diff --git a/client/gui/menus/rating/desaturate.gdshader.uid b/client/gui/menus/rating/desaturate.gdshader.uid
new file mode 100644
index 00000000..621837a6
--- /dev/null
+++ b/client/gui/menus/rating/desaturate.gdshader.uid
@@ -0,0 +1 @@
+uid://cekkkqsvd7rvw
diff --git a/client/gui/menus/rating/rating.gd b/client/gui/menus/rating/rating.gd
new file mode 100644
index 00000000..023c1333
--- /dev/null
+++ b/client/gui/menus/rating/rating.gd
@@ -0,0 +1,65 @@
+# Hurry Curry! - a game about cooking
+# Copyright (C) 2025 Hurry Curry! contributors
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, version 3 of the License only.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+#
+extends Menu
+
+const PARTICLE_AMOUNTS = [1, 6, 32, 128]
+
+@onready var game: Game = $"../Game"
+@onready var title: Label = $MarginContainer/PanelContainer/VBoxContainer/Text/Title
+@onready var subtitle: Label = $MarginContainer/PanelContainer/VBoxContainer/Text/Subtitle
+@onready var stars = $MarginContainer/PanelContainer/VBoxContainer/Stars.get_children()
+@onready var star_timer = $StarTimer
+@onready var particles = $Control/Particles
+@onready var close_button: Button = $MarginContainer/PanelContainer/VBoxContainer/HBoxContainer/Close
+
+func _ready():
+ super()
+ show_rating(data[0], data[1])
+ close_button.disabled = true # Disable for short time period to prevent accidental button press
+
+func _process(_delta):
+ particles.emission_rect_extents = get_viewport_rect().size * Vector2(0.5, 0.5)
+
+func show_rating(stars_: int, points: int):
+ match stars_:
+ 0: title.text = tr("c.score.poor")
+ 1: title.text = tr("c.score.acceptable")
+ 2: title.text = tr("c.score.good")
+ 3: title.text = tr("c.score.excellent")
+
+ subtitle.text = tr("c.score.points_par").format([points])
+
+ for i in range(0, stars_):
+ var star: TextureRect = stars[i]
+ star_timer.start()
+ await star_timer.timeout
+ star.material.set_shader_parameter("t", 1)
+ star.get_node("Sound").play()
+
+ particles.amount = PARTICLE_AMOUNTS[stars_]
+
+ if stars_ > 1:
+ particles.emitting = true
+
+func _on_close_pressed():
+ exit()
+
+func _on_button_timer_timeout() -> void:
+ close_button.disabled = false
+
+func _on_scoreboard_pressed() -> void:
+ exit()
+ game.mp.send_chat(game.my_player_id, "/scoreboard %s" % Global.last_map_name)
diff --git a/client/gui/menus/rating/rating.gd.uid b/client/gui/menus/rating/rating.gd.uid
new file mode 100644
index 00000000..fd729d8f
--- /dev/null
+++ b/client/gui/menus/rating/rating.gd.uid
@@ -0,0 +1 @@
+uid://5tmklxkaa6e0
diff --git a/client/gui/menus/rating/rating.tscn b/client/gui/menus/rating/rating.tscn
new file mode 100644
index 00000000..062dcca2
--- /dev/null
+++ b/client/gui/menus/rating/rating.tscn
@@ -0,0 +1,168 @@
+[gd_scene load_steps=12 format=3 uid="uid://buu3cdpigs8qq"]
+
+[ext_resource type="Texture2D" uid="uid://b10goh4dsa3b0" path="res://player/particles/satisfied/star.webp" id="1_7qv7r"]
+[ext_resource type="Shader" uid="uid://cekkkqsvd7rvw" path="res://gui/menus/rating/desaturate.gdshader" id="1_pddsm"]
+[ext_resource type="Theme" uid="uid://b0qmvo504e457" path="res://gui/resources/theme/theme.tres" id="1_uwajf"]
+[ext_resource type="Script" uid="uid://5tmklxkaa6e0" path="res://gui/menus/rating/rating.gd" id="2_cq0se"]
+[ext_resource type="Material" uid="uid://beea1pc5nt67r" path="res://gui/resources/materials/dark_blur_material.tres" id="4_hdurb"]
+[ext_resource type="AudioStream" uid="uid://camy77x26mmpv" path="res://gui/resources/sounds/success.ogg" id="5_tutpj"]
+
+[sub_resource type="ShaderMaterial" id="ShaderMaterial_oi7xd"]
+shader = ExtResource("1_pddsm")
+shader_parameter/t = 0.0
+
+[sub_resource type="ShaderMaterial" id="ShaderMaterial_ney6s"]
+shader = ExtResource("1_pddsm")
+shader_parameter/t = 0.0
+
+[sub_resource type="ShaderMaterial" id="ShaderMaterial_27tx1"]
+shader = ExtResource("1_pddsm")
+shader_parameter/t = 0.0
+
+[sub_resource type="Curve" id="Curve_dqga7"]
+_data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(0.0954774, 1), 0.262418, 0.0, 0, 0]
+point_count = 2
+
+[sub_resource type="Gradient" id="Gradient_majwe"]
+offsets = PackedFloat32Array(0, 0.0584795, 1)
+colors = PackedColorArray(1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0)
+
+[node name="Rating" type="Control"]
+layout_mode = 3
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+theme = ExtResource("1_uwajf")
+script = ExtResource("2_cq0se")
+support_anim = false
+
+[node name="MarginContainer" type="MarginContainer" parent="."]
+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 = 128
+theme_override_constants/margin_top = 64
+theme_override_constants/margin_right = 128
+theme_override_constants/margin_bottom = 64
+
+[node name="PanelContainer" type="PanelContainer" parent="MarginContainer"]
+material = ExtResource("4_hdurb")
+layout_mode = 2
+
+[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/PanelContainer"]
+layout_mode = 2
+theme_override_constants/separation = 64
+alignment = 1
+
+[node name="Text" type="VBoxContainer" parent="MarginContainer/PanelContainer/VBoxContainer"]
+layout_mode = 2
+
+[node name="Title" type="Label" parent="MarginContainer/PanelContainer/VBoxContainer/Text"]
+layout_mode = 2
+theme_override_font_sizes/font_size = 48
+text = "Title here"
+horizontal_alignment = 1
+
+[node name="Subtitle" type="Label" parent="MarginContainer/PanelContainer/VBoxContainer/Text"]
+layout_mode = 2
+theme_override_font_sizes/font_size = 24
+text = "Subtitle here"
+horizontal_alignment = 1
+
+[node name="Stars" type="HBoxContainer" parent="MarginContainer/PanelContainer/VBoxContainer"]
+layout_mode = 2
+alignment = 1
+
+[node name="Star1" type="TextureRect" parent="MarginContainer/PanelContainer/VBoxContainer/Stars"]
+material = SubResource("ShaderMaterial_oi7xd")
+custom_minimum_size = Vector2(128, 128)
+layout_mode = 2
+texture = ExtResource("1_7qv7r")
+expand_mode = 1
+stretch_mode = 5
+
+[node name="Sound" type="AudioStreamPlayer" parent="MarginContainer/PanelContainer/VBoxContainer/Stars/Star1"]
+stream = ExtResource("5_tutpj")
+pitch_scale = 1.5
+
+[node name="Star2" type="TextureRect" parent="MarginContainer/PanelContainer/VBoxContainer/Stars"]
+material = SubResource("ShaderMaterial_ney6s")
+custom_minimum_size = Vector2(128, 128)
+layout_mode = 2
+texture = ExtResource("1_7qv7r")
+expand_mode = 1
+stretch_mode = 5
+
+[node name="Sound" type="AudioStreamPlayer" parent="MarginContainer/PanelContainer/VBoxContainer/Stars/Star2"]
+stream = ExtResource("5_tutpj")
+pitch_scale = 1.65
+
+[node name="Star3" type="TextureRect" parent="MarginContainer/PanelContainer/VBoxContainer/Stars"]
+material = SubResource("ShaderMaterial_27tx1")
+custom_minimum_size = Vector2(128, 128)
+layout_mode = 2
+texture = ExtResource("1_7qv7r")
+expand_mode = 1
+stretch_mode = 5
+
+[node name="Sound" type="AudioStreamPlayer" parent="MarginContainer/PanelContainer/VBoxContainer/Stars/Star3"]
+stream = ExtResource("5_tutpj")
+pitch_scale = 1.9
+
+[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/PanelContainer/VBoxContainer"]
+layout_mode = 2
+theme_override_constants/separation = 64
+alignment = 1
+
+[node name="Scoreboard" type="Button" parent="MarginContainer/PanelContainer/VBoxContainer/HBoxContainer"]
+layout_mode = 2
+text = "c.menu.scoreboard.button"
+
+[node name="Close" type="Button" parent="MarginContainer/PanelContainer/VBoxContainer/HBoxContainer"]
+layout_mode = 2
+text = "c.menu.accept"
+
+[node name="StarTimer" type="Timer" parent="."]
+wait_time = 0.5
+one_shot = true
+
+[node name="ButtonTimer" type="Timer" parent="."]
+one_shot = true
+autostart = true
+
+[node name="Control" type="Control" parent="."]
+layout_mode = 1
+anchors_preset = 8
+anchor_left = 0.5
+anchor_top = 0.5
+anchor_right = 0.5
+anchor_bottom = 0.5
+grow_horizontal = 2
+grow_vertical = 2
+
+[node name="Particles" type="CPUParticles2D" parent="Control"]
+emitting = false
+amount = 32
+texture = ExtResource("1_7qv7r")
+emission_shape = 3
+emission_rect_extents = Vector2(512, 256)
+direction = Vector2(0, -1)
+initial_velocity_min = 256.0
+initial_velocity_max = 256.0
+angular_velocity_min = -30.0
+angular_velocity_max = 30.0
+angle_min = -20.0
+angle_max = 20.0
+scale_amount_min = 0.1
+scale_amount_max = 0.2
+scale_amount_curve = SubResource("Curve_dqga7")
+color_ramp = SubResource("Gradient_majwe")
+
+[connection signal="pressed" from="MarginContainer/PanelContainer/VBoxContainer/HBoxContainer/Scoreboard" to="." method="_on_scoreboard_pressed"]
+[connection signal="pressed" from="MarginContainer/PanelContainer/VBoxContainer/HBoxContainer/Close" to="." method="_on_close_pressed"]
+[connection signal="timeout" from="ButtonTimer" to="." method="_on_button_timer_timeout"]