diff --git a/rust/src/replay.rs b/rust/src/replay.rs index 48e7023..4bbf342 100644 --- a/rust/src/replay.rs +++ b/rust/src/replay.rs @@ -153,6 +153,8 @@ pub struct ReplayPlayback { pub finished: bool, + pub running_goals: HashMap, + base: Base, } @@ -187,6 +189,7 @@ impl INode for ReplayPlayback { && frame.time <= self.current_time { self.player_data = frame.player_data.clone(); + self.running_goals = frame.goals.clone(); if let ReplayBall::World(ball_state) = &frame.ball_data { if let Some(ball) = &mut self.ball { diff --git a/rust/src/ui/simple_score_view.rs b/rust/src/ui/simple_score_view.rs index 8e182ba..18b16e0 100644 --- a/rust/src/ui/simple_score_view.rs +++ b/rust/src/ui/simple_score_view.rs @@ -5,7 +5,7 @@ use godot::{ prelude::*, }; -use crate::game_manager::Game; +use crate::{game_manager::Game, replay::StandaloneReplayManager}; #[derive(GodotClass)] #[class(base=HBoxContainer, init)] @@ -35,6 +35,23 @@ impl IHBoxContainer for SimpleScoreView { game.signals() .on_goal() .connect_other(s, |s| s.update_goals()); + } else if let Some(playback) = &StandaloneReplayManager::singleton().bind().playback { + for (id, team) in playback.bind().replay.teams.iter().enumerate() { + let mut goals_label = Label::new_alloc(); + goals_label.set_modulate(team.color.clone().into()); + goals_label.set_text("0"); + if !s.team_goals.is_empty() { + let mut dash = Label::new_alloc(); + dash.set_text(" - "); + s.base_mut().add_child(&dash); + } + s.base_mut().add_child(&goals_label); + s.team_goals.insert(id as u8, goals_label); + } + playback + .signals() + .on_data_changed() + .connect_other(s, |s| s.update_goals()); } s.update_goals(); }); @@ -51,6 +68,14 @@ impl SimpleScoreView { label.set_text(&goals.to_string()); } } + } else if let Some(playback) = &StandaloneReplayManager::singleton().bind().playback { + for (id, _) in playback.bind().replay.teams.iter().enumerate() { + if let Some(goals) = playback.bind().running_goals.get(&(id as u8)) + && let Some(label) = self.team_goals.get_mut(&(id as u8)) + { + label.set_text(&goals.to_string()); + } + } } } }