aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-10-09 20:58:33 +0200
committermetamuffin <metamuffin@disroot.org>2025-10-09 20:58:36 +0200
commit0134c4163fc6aba1aad8e0e8a5800b4967143bdb (patch)
tree7c5531915481213c0c577fe1d59e3693cb22f10b
parent135f1288f023671be7d36610bb7d61bde3f1fc7b (diff)
downloadhurrycurry-0134c4163fc6aba1aad8e0e8a5800b4967143bdb.tar
hurrycurry-0134c4163fc6aba1aad8e0e8a5800b4967143bdb.tar.bz2
hurrycurry-0134c4163fc6aba1aad8e0e8a5800b4967143bdb.tar.zst
Add scoreboard menu
-rw-r--r--client/game.gd2
-rw-r--r--client/gui/menus/scoreboard.gd43
-rw-r--r--client/gui/menus/scoreboard.gd.uid1
-rw-r--r--client/gui/menus/scoreboard.tscn114
-rw-r--r--client/gui/overlays/popup_message/server_message.gd15
-rw-r--r--locale/en.ini6
-rw-r--r--server/protocol/src/lib.rs1
-rw-r--r--server/src/commands.rs42
-rw-r--r--test-client/protocol.ts1
9 files changed, 185 insertions, 40 deletions
diff --git a/client/game.gd b/client/game.gd
index 1316597e..731eceac 100644
--- a/client/game.gd
+++ b/client/game.gd
@@ -351,6 +351,8 @@ func handle_packet(p):
match p.menu:
"score":
menu.submenu("res://gui/menus/rating/rating.tscn", [p.data.stars, p.data.points])
+ "scoreboard":
+ menu.submenu("res://gui/menus/scoreboard.tscn", p.data)
"announce_start":
overlay_announce_title.announce_start()
"server_message":
diff --git a/client/gui/menus/scoreboard.gd b/client/gui/menus/scoreboard.gd
new file mode 100644
index 00000000..c04a3201
--- /dev/null
+++ b/client/gui/menus/scoreboard.gd
@@ -0,0 +1,43 @@
+# 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
+
+@onready var table: GridContainer = $OuterMargin/Panel/InnerMargin/VBoxContainer/ScrollContainer/Table
+@onready var title: Label = $OuterMargin/Panel/InnerMargin/VBoxContainer/Title
+@onready var play_count: Label = $OuterMargin/Panel/InnerMargin/VBoxContainer/PlayCount
+
+@export var font: Font
+
+func _ready() -> void:
+ super()
+ var i = 1
+ title.text = tr("c.menu.scoreboard.title").format([data.map])
+ play_count.text = tr("c.menu.scoreboard.finish_count").format([int(data.plays)])
+ for entry in data.best:
+ push_label("%d." % i)
+ push_label("%d" % entry.score.points)
+ push_label(", ".join(entry.players))
+ i += 1
+
+func push_label(text: String):
+ var label = Label.new()
+ label.add_theme_font_size_override("font_size", 21)
+ label.add_theme_font_override("font", font)
+ label.text = text
+ table.add_child(label)
+
+func _on_back_pressed() -> void:
+ exit()
diff --git a/client/gui/menus/scoreboard.gd.uid b/client/gui/menus/scoreboard.gd.uid
new file mode 100644
index 00000000..53f2b288
--- /dev/null
+++ b/client/gui/menus/scoreboard.gd.uid
@@ -0,0 +1 @@
+uid://d3dd83ooacgmw
diff --git a/client/gui/menus/scoreboard.tscn b/client/gui/menus/scoreboard.tscn
new file mode 100644
index 00000000..4d9f3bd2
--- /dev/null
+++ b/client/gui/menus/scoreboard.tscn
@@ -0,0 +1,114 @@
+[gd_scene load_steps=11 format=3 uid="uid://cgevgyr5out81"]
+
+[ext_resource type="Script" uid="uid://d3dd83ooacgmw" path="res://gui/menus/scoreboard.gd" id="1_8iwl3"]
+[ext_resource type="Script" uid="uid://byshs20og68tn" path="res://gui/components/smart_margin_container.gd" id="1_bfqap"]
+[ext_resource type="Material" uid="uid://beea1pc5nt67r" path="res://gui/resources/materials/dark_blur_material.tres" id="2_s6kc8"]
+[ext_resource type="Script" uid="uid://cmncjc06kadpe" path="res://gui/components/blur_setup.gd" id="3_8iwl3"]
+[ext_resource type="Script" uid="uid://bd7bylb2t2m0" path="res://gui/components/touch_scroll_container.gd" id="5_c3g22"]
+[ext_resource type="FontFile" uid="uid://5ixo6b3bd3km" path="res://gui/resources/fonts/font-josefin-sans.woff2" id="6_b3vhr"]
+[ext_resource type="FontVariation" uid="uid://cl6m4hqsnrpav" path="res://gui/resources/fonts/sansita-swashed-bold.tres" id="7_tlf07"]
+
+[sub_resource type="Theme" id="Theme_grptf"]
+
+[sub_resource type="FontVariation" id="FontVariation_t5x0r"]
+base_font = ExtResource("7_tlf07")
+variation_opentype = {
+2003265652: 800
+}
+
+[sub_resource type="FontVariation" id="FontVariation_tlf07"]
+base_font = ExtResource("6_b3vhr")
+variation_opentype = {
+2003265652: 700
+}
+
+[node name="Scoreboard" type="Control"]
+layout_mode = 3
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+theme = SubResource("Theme_grptf")
+script = ExtResource("1_8iwl3")
+support_anim = false
+
+[node name="OuterMargin" 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 = 50
+theme_override_constants/margin_top = 50
+theme_override_constants/margin_right = 50
+theme_override_constants/margin_bottom = 50
+script = ExtResource("1_bfqap")
+
+[node name="Panel" type="Panel" parent="OuterMargin"]
+material = ExtResource("2_s6kc8")
+layout_mode = 2
+script = ExtResource("3_8iwl3")
+
+[node name="InnerMargin" type="MarginContainer" parent="OuterMargin/Panel"]
+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"]
+layout_mode = 2
+size_flags_horizontal = 3
+
+[node name="Title" type="Label" parent="OuterMargin/Panel/InnerMargin/VBoxContainer"]
+layout_mode = 2
+theme_override_fonts/font = SubResource("FontVariation_t5x0r")
+theme_override_font_sizes/font_size = 48
+text = "Scoreboard for placeholder"
+horizontal_alignment = 1
+
+[node name="PlayCount" type="Label" parent="OuterMargin/Panel/InnerMargin/VBoxContainer"]
+layout_mode = 2
+text = "123 games were played on this map"
+horizontal_alignment = 1
+
+[node name="ScrollContainer" type="ScrollContainer" parent="OuterMargin/Panel/InnerMargin/VBoxContainer"]
+layout_mode = 2
+size_flags_vertical = 3
+script = ExtResource("5_c3g22")
+
+[node name="Table" type="GridContainer" parent="OuterMargin/Panel/InnerMargin/VBoxContainer/ScrollContainer"]
+layout_mode = 2
+columns = 3
+
+[node name="Rank" type="Label" parent="OuterMargin/Panel/InnerMargin/VBoxContainer/ScrollContainer/Table"]
+layout_mode = 2
+theme_override_fonts/font = SubResource("FontVariation_tlf07")
+theme_override_font_sizes/font_size = 21
+text = "c.menu.scoreboard.rank"
+
+[node name="Points" type="Label" parent="OuterMargin/Panel/InnerMargin/VBoxContainer/ScrollContainer/Table"]
+layout_mode = 2
+theme_override_fonts/font = SubResource("FontVariation_tlf07")
+theme_override_font_sizes/font_size = 21
+text = "c.score.points"
+
+[node name="Players" type="Label" parent="OuterMargin/Panel/InnerMargin/VBoxContainer/ScrollContainer/Table"]
+layout_mode = 2
+size_flags_horizontal = 3
+theme_override_fonts/font = SubResource("FontVariation_tlf07")
+theme_override_font_sizes/font_size = 21
+text = "c.menu.scoreboard.players"
+
+[node name="Back" type="Button" parent="OuterMargin/Panel/InnerMargin/VBoxContainer"]
+layout_mode = 2
+text = "c.menu.back"
+
+[connection signal="pressed" from="OuterMargin/Panel/InnerMargin/VBoxContainer/Back" to="." method="_on_back_pressed"]
diff --git a/client/gui/overlays/popup_message/server_message.gd b/client/gui/overlays/popup_message/server_message.gd
index a0688dc5..76ff9361 100644
--- a/client/gui/overlays/popup_message/server_message.gd
+++ b/client/gui/overlays/popup_message/server_message.gd
@@ -1,3 +1,18 @@
+# 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 BlurSetup
class_name ServerMessage
diff --git a/locale/en.ini b/locale/en.ini
index 55ec871d..62dd236b 100644
--- a/locale/en.ini
+++ b/locale/en.ini
@@ -99,8 +99,11 @@ c.menu.play.server_version_mismatch=Protocol version mismatch
c.menu.play=Play
c.menu.quit=Quit
c.menu.scoreboard.button=Show scoreboard
-c.menu.scoreboard.entry={0}. {1} points by {2}
+c.menu.scoreboard.title=Scoreboard for {0}
+c.menu.scoreboard.finish_count={0} total games were played on this map.
c.menu.scoreboard.no_finish=Nobody finished {0} yet.
+c.menu.scoreboard.players=Players
+c.menu.scoreboard.rank=Rank
c.menu.scoreboard=Scoreboard
c.menu.settings=Settings
c.score.acceptable=Acceptable service
@@ -108,6 +111,7 @@ c.score.completed=Completed
c.score.excellent=Excellent service
c.score.failed=Failed
c.score.good=Good service
+c.score.players=Players
c.score.points_par=You collected {0} points
c.score.points=Points
c.score.poor=Poor service
diff --git a/server/protocol/src/lib.rs b/server/protocol/src/lib.rs
index c2a7a758..dc9acfdb 100644
--- a/server/protocol/src/lib.rs
+++ b/server/protocol/src/lib.rs
@@ -327,6 +327,7 @@ pub struct Score {
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct Scoreboard {
+ pub map: Option<String>,
pub plays: usize,
pub best: Vec<ScoreboardEntry>,
}
diff --git a/server/src/commands.rs b/server/src/commands.rs
index 2f0902ba..5eda53b6 100644
--- a/server/src/commands.rs
+++ b/server/src/commands.rs
@@ -315,45 +315,9 @@ impl Server {
error: false,
});
} else {
- // replies.push(PacketC::Menu(Menu::Document(DocumentElement::Document {
- // es: vec![DocumentElement::Page {
- // es: vec![
- // DocumentElement::Par {
- // es: vec![DocumentElement::Text {
- // s: Message::Translation {
- // id: "c.menu.scoreboard".to_string(),
- // params: vec![],
- // },
- // size: 30.,
- // bold: false,
- // color: None,
- // font: None,
- // }],
- // },
- // DocumentElement::List {
- // es: board
- // .best
- // .iter()
- // .take(10)
- // .enumerate()
- // .map(|(place, entry)| DocumentElement::Text {
- // s: trm!(
- // "c.menu.scoreboard.entry",
- // s = (place + 1).to_string(),
- // s = entry.score.points.to_string(),
- // s = entry.players.clone().join(", ")
- // ),
- // size: 15.,
- // bold: false,
- // color: None,
- // font: None,
- // })
- // .collect(),
- // },
- // ],
- // background: None,
- // }],
- // })));
+ let mut board = board.to_owned();
+ board.map = Some(mapname.to_string());
+ replies.push(PacketC::Menu(Menu::Scoreboard(board)));
}
} else {
replies.push(PacketC::ServerMessage {
diff --git a/test-client/protocol.ts b/test-client/protocol.ts
index 9ac00927..2024c830 100644
--- a/test-client/protocol.ts
+++ b/test-client/protocol.ts
@@ -94,6 +94,7 @@ export interface MessageTimeout {
}
export interface Scoreboard {
+ map: string,
plays: number,
best: ScoreboardEntry
}