aboutsummaryrefslogtreecommitdiff
path: root/client/gui/menus/rating/rating.gd
diff options
context:
space:
mode:
Diffstat (limited to 'client/gui/menus/rating/rating.gd')
-rw-r--r--client/gui/menus/rating/rating.gd65
1 files changed, 65 insertions, 0 deletions
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)