Add some sort of summary view to ending screen
This commit is contained in:
parent
92523ab199
commit
3226053094
@ -1,8 +1,12 @@
|
|||||||
[gd_scene format=3 uid="uid://df84sctteh4kw"]
|
[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")
|
title_container = NodePath("title_container")
|
||||||
back_button = NodePath("button")
|
back_button = NodePath("button")
|
||||||
|
players_hbox = NodePath("player_listings")
|
||||||
|
player_listing_scene = ExtResource("1_ou354")
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
@ -36,3 +40,18 @@ grow_horizontal = 2
|
|||||||
grow_vertical = 0
|
grow_vertical = 0
|
||||||
theme_override_font_sizes/font_size = 32
|
theme_override_font_sizes/font_size = 32
|
||||||
text = "Back"
|
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
|
||||||
|
|||||||
31
godot/scenes/ui/player_listing.tscn
Normal file
31
godot/scenes/ui/player_listing.tscn
Normal file
@ -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
|
||||||
@ -111,7 +111,7 @@ impl Default for GameOptions {
|
|||||||
opts.insert(GameOption::AllowAnyMap, GameOptionValue::Boolean(false));
|
opts.insert(GameOption::AllowAnyMap, GameOptionValue::Boolean(false));
|
||||||
opts.insert(GameOption::AllowAnyTeam, GameOptionValue::Boolean(false));
|
opts.insert(GameOption::AllowAnyTeam, GameOptionValue::Boolean(false));
|
||||||
opts.insert(GameOption::FriendlyFire, GameOptionValue::Boolean(true));
|
opts.insert(GameOption::FriendlyFire, GameOptionValue::Boolean(true));
|
||||||
opts.insert(GameOption::GoalsNeededToWin, GameOptionValue::Number(10.));
|
opts.insert(GameOption::GoalsNeededToWin, GameOptionValue::Number(1.));
|
||||||
Self { values: opts }
|
Self { values: opts }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,12 @@
|
|||||||
use godot::{
|
use godot::{
|
||||||
classes::{Button, HBoxContainer, IPanel, Label, Panel},
|
classes::{Button, HBoxContainer, IPanel, Label, Panel, VBoxContainer},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::game_manager::{Game, GameManager};
|
use crate::{
|
||||||
|
game_manager::{Game, GameManager},
|
||||||
|
ui::player_listing::PlayerListing,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(GodotClass)]
|
#[derive(GodotClass)]
|
||||||
#[class(base=Panel, init)]
|
#[class(base=Panel, init)]
|
||||||
@ -12,6 +15,10 @@ pub struct GameFinishedScreen {
|
|||||||
title_container: Option<Gd<HBoxContainer>>,
|
title_container: Option<Gd<HBoxContainer>>,
|
||||||
#[export]
|
#[export]
|
||||||
back_button: Option<Gd<Button>>,
|
back_button: Option<Gd<Button>>,
|
||||||
|
#[export]
|
||||||
|
players_hbox: Option<Gd<HBoxContainer>>,
|
||||||
|
#[export]
|
||||||
|
player_listing_scene: Option<Gd<PackedScene>>,
|
||||||
|
|
||||||
base: Base<Panel>,
|
base: Base<Panel>,
|
||||||
}
|
}
|
||||||
@ -20,6 +27,7 @@ pub struct GameFinishedScreen {
|
|||||||
impl IPanel for GameFinishedScreen {
|
impl IPanel for GameFinishedScreen {
|
||||||
fn ready(&mut self) {
|
fn ready(&mut self) {
|
||||||
self.produce_title();
|
self.produce_title();
|
||||||
|
self.produce_player_listings();
|
||||||
if let Some(back) = &self.back_button {
|
if let Some(back) = &self.back_button {
|
||||||
back.signals().pressed().connect_other(self, |_| {
|
back.signals().pressed().connect_other(self, |_| {
|
||||||
if let Some(mut game) = Game::singleton() {
|
if let Some(mut game) = Game::singleton() {
|
||||||
@ -32,6 +40,36 @@ impl IPanel for GameFinishedScreen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl 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::<Vec<_>>();
|
||||||
|
for player in players {
|
||||||
|
let listing = listing_scene.instantiate_as::<PlayerListing>();
|
||||||
|
vbox.add_child(&listing);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(hbox) = &mut self.players_hbox {
|
||||||
|
hbox.add_child(&vbox);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn produce_title(&mut self) {
|
fn produce_title(&mut self) {
|
||||||
if let Some(game) = Game::singleton() {
|
if let Some(game) = Game::singleton() {
|
||||||
let max_goals = game
|
let max_goals = game
|
||||||
|
|||||||
@ -3,4 +3,5 @@ pub mod game_finished_screen;
|
|||||||
pub mod lobby;
|
pub mod lobby;
|
||||||
pub mod lobby_player_listing;
|
pub mod lobby_player_listing;
|
||||||
pub mod net_stats;
|
pub mod net_stats;
|
||||||
|
pub mod player_listing;
|
||||||
pub mod simple_score_view;
|
pub mod simple_score_view;
|
||||||
|
|||||||
7
rust/src/ui/player_listing.rs
Normal file
7
rust/src/ui/player_listing.rs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
use godot::{classes::HBoxContainer, prelude::*};
|
||||||
|
|
||||||
|
#[derive(GodotClass)]
|
||||||
|
#[class(base=HBoxContainer, init)]
|
||||||
|
pub struct PlayerListing {
|
||||||
|
base: Base<HBoxContainer>,
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user