From 32d80dc0a39b436f84812398f88b37ecdb3ae742 Mon Sep 17 00:00:00 2001 From: Sofia Date: Wed, 22 Jul 2026 22:20:00 +0300 Subject: [PATCH] Add some sort of summary view to ending screen --- godot/scenes/game_finished.tscn | 21 ++++++++++++++- godot/scenes/ui/player_listing.tscn | 31 +++++++++++++++++++++ rust/src/game_manager.rs | 2 +- rust/src/ui/game_finished_screen.rs | 42 +++++++++++++++++++++++++++-- rust/src/ui/mod.rs | 1 + rust/src/ui/player_listing.rs | 7 +++++ 6 files changed, 100 insertions(+), 4 deletions(-) create mode 100644 godot/scenes/ui/player_listing.tscn create mode 100644 rust/src/ui/player_listing.rs diff --git a/godot/scenes/game_finished.tscn b/godot/scenes/game_finished.tscn index 05920fa..e8e5c44 100644 --- a/godot/scenes/game_finished.tscn +++ b/godot/scenes/game_finished.tscn @@ -1,8 +1,12 @@ [gd_scene format=3 uid="uid://df84sctteh4kw"] -[node name="game_finished" type="GameFinishedScreen" unique_id=700430082 node_paths=PackedStringArray("title_container", "back_button")] +[ext_resource type="PackedScene" uid="uid://2sfy0vq0fqt3" path="res://scenes/ui/player_listing.tscn" id="1_ou354"] + +[node name="game_finished" type="GameFinishedScreen" unique_id=700430082 node_paths=PackedStringArray("title_container", "back_button", "players_hbox")] title_container = NodePath("title_container") back_button = NodePath("button") +players_hbox = NodePath("player_listings") +player_listing_scene = ExtResource("1_ou354") anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 @@ -36,3 +40,18 @@ grow_horizontal = 2 grow_vertical = 0 theme_override_font_sizes/font_size = 32 text = "Back" + +[node name="player_listings" type="HBoxContainer" parent="." unique_id=588134370] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -186.0 +offset_top = -193.0 +offset_right = 186.0 +offset_bottom = -153.0 +grow_horizontal = 2 +grow_vertical = 2 +alignment = 1 diff --git a/godot/scenes/ui/player_listing.tscn b/godot/scenes/ui/player_listing.tscn new file mode 100644 index 0000000..bd5ff61 --- /dev/null +++ b/godot/scenes/ui/player_listing.tscn @@ -0,0 +1,31 @@ +[gd_scene format=3 uid="uid://2sfy0vq0fqt3"] + +[node name="player_listing" type="PlayerListing" unique_id=965142972] + +[node name="name" type="Label" parent="." unique_id=1361759955] +custom_minimum_size = Vector2(200, 0) +custom_maximum_size = Vector2(200, -1) +clip_contents = true +layout_mode = 2 +text = "Player Name" + +[node name="kills" type="Label" parent="." unique_id=690390687] +custom_minimum_size = Vector2(30, 0) +custom_maximum_size = Vector2(30, -1) +layout_mode = 2 +text = "0" +horizontal_alignment = 1 + +[node name="deaths" type="Label" parent="." unique_id=1615203485] +custom_minimum_size = Vector2(30, 0) +custom_maximum_size = Vector2(30, -1) +layout_mode = 2 +text = "0" +horizontal_alignment = 1 + +[node name="ping" type="Label" parent="." unique_id=1700548535] +custom_minimum_size = Vector2(100, 0) +custom_maximum_size = Vector2(100, -1) +layout_mode = 2 +text = "0ms" +horizontal_alignment = 1 diff --git a/rust/src/game_manager.rs b/rust/src/game_manager.rs index 0232414..f4cbc07 100644 --- a/rust/src/game_manager.rs +++ b/rust/src/game_manager.rs @@ -111,7 +111,7 @@ impl Default for GameOptions { opts.insert(GameOption::AllowAnyMap, GameOptionValue::Boolean(false)); opts.insert(GameOption::AllowAnyTeam, GameOptionValue::Boolean(false)); opts.insert(GameOption::FriendlyFire, GameOptionValue::Boolean(true)); - opts.insert(GameOption::GoalsNeededToWin, GameOptionValue::Number(10.)); + opts.insert(GameOption::GoalsNeededToWin, GameOptionValue::Number(1.)); Self { values: opts } } } diff --git a/rust/src/ui/game_finished_screen.rs b/rust/src/ui/game_finished_screen.rs index e3d7112..c942985 100644 --- a/rust/src/ui/game_finished_screen.rs +++ b/rust/src/ui/game_finished_screen.rs @@ -1,9 +1,12 @@ use godot::{ - classes::{Button, HBoxContainer, IPanel, Label, Panel}, + classes::{Button, HBoxContainer, IPanel, Label, Panel, VBoxContainer}, prelude::*, }; -use crate::game_manager::{Game, GameManager}; +use crate::{ + game_manager::{Game, GameManager}, + ui::player_listing::PlayerListing, +}; #[derive(GodotClass)] #[class(base=Panel, init)] @@ -12,6 +15,10 @@ pub struct GameFinishedScreen { title_container: Option>, #[export] back_button: Option>, + #[export] + players_hbox: Option>, + #[export] + player_listing_scene: Option>, base: Base, } @@ -20,6 +27,7 @@ pub struct GameFinishedScreen { impl IPanel for GameFinishedScreen { fn ready(&mut self) { self.produce_title(); + self.produce_player_listings(); if let Some(back) = &self.back_button { back.signals().pressed().connect_other(self, |_| { if let Some(mut game) = Game::singleton() { @@ -32,6 +40,36 @@ impl IPanel for GameFinishedScreen { } impl GameFinishedScreen { + fn produce_player_listings(&mut self) { + if let Some(game) = Game::singleton() { + for (id, team) in game.bind().get_teams().iter_shared().enumerate() { + let mut vbox = VBoxContainer::new_alloc(); + + let mut team_label = Label::new_alloc(); + team_label.set_modulate(team.bind().color); + team_label.set_text(&team.bind().name); + vbox.add_child(&team_label); + + if let Some(listing_scene) = &self.player_listing_scene { + let game = game.bind(); + let players = game + .players + .iter() + .filter(|p| p.data.team == id as u8) + .collect::>(); + for player in players { + let listing = listing_scene.instantiate_as::(); + vbox.add_child(&listing); + } + } + + if let Some(hbox) = &mut self.players_hbox { + hbox.add_child(&vbox); + } + } + } + } + fn produce_title(&mut self) { if let Some(game) = Game::singleton() { let max_goals = game diff --git a/rust/src/ui/mod.rs b/rust/src/ui/mod.rs index 7eaa545..52c2c76 100644 --- a/rust/src/ui/mod.rs +++ b/rust/src/ui/mod.rs @@ -3,4 +3,5 @@ pub mod game_finished_screen; pub mod lobby; pub mod lobby_player_listing; pub mod net_stats; +pub mod player_listing; pub mod simple_score_view; diff --git a/rust/src/ui/player_listing.rs b/rust/src/ui/player_listing.rs new file mode 100644 index 0000000..e146719 --- /dev/null +++ b/rust/src/ui/player_listing.rs @@ -0,0 +1,7 @@ +use godot::{classes::HBoxContainer, prelude::*}; + +#[derive(GodotClass)] +#[class(base=HBoxContainer, init)] +pub struct PlayerListing { + base: Base, +}