diff --git a/godot/scenes/game_finished.tscn b/godot/scenes/game_finished.tscn index b948dff..87b3671 100644 --- a/godot/scenes/game_finished.tscn +++ b/godot/scenes/game_finished.tscn @@ -82,6 +82,7 @@ offset_bottom = 133.0 grow_horizontal = 2 [node name="save_dialog" type="FileDialog" parent="." unique_id=1637714468] +access = 2 filters = PackedStringArray("*.replay") [connection signal="pressed" from="save_replay" to="." method="open_file_dialog"] diff --git a/godot/scenes/main.tscn b/godot/scenes/main.tscn index c939377..2627ddc 100644 --- a/godot/scenes/main.tscn +++ b/godot/scenes/main.tscn @@ -254,6 +254,7 @@ text = "Ok" [node name="open_replay_dialog" type="FileDialog" parent="." unique_id=925465558] title = "Open a File" file_mode = 0 +access = 2 filters = PackedStringArray("*.replay") [connection signal="pressed" from="main_panel/v_box_container/host" to="." method="go_to_host_game"] diff --git a/rust/src/replay.rs b/rust/src/replay.rs index 29e5bcd..84dba8b 100644 --- a/rust/src/replay.rs +++ b/rust/src/replay.rs @@ -108,6 +108,7 @@ impl StandaloneReplayManager { #[class(base=Node, init)] pub struct ReplayPlayback { pub replay: Replay, + pub player_data: HashMap, pub current_map: Option>, current_frame_idx: usize, player_characters: HashMap>, @@ -152,6 +153,8 @@ impl INode for ReplayPlayback { while let Some(frame) = self.replay.frames.get(self.current_frame_idx) && frame.time <= self.current_time { + self.player_data = frame.player_data.clone(); + if let ReplayBall::World(ball_state) = &frame.ball_data { if let Some(ball) = &mut self.ball { ball.bind_mut().apply_sync(BallSync { @@ -319,6 +322,8 @@ impl INode for ReplayRecorder { name: player.data.name.clone(), color: team.bind().color.into(), team: player.data.team, + kills: 0, + deaths: 0, }, ); } @@ -381,6 +386,10 @@ impl ReplayRecorder { if let Some(state) = player.get_state() { player_data.insert(player.id(), state); } + if let Some(replay_player) = self.replay.players.get_mut(&player.id()) { + replay_player.kills = player.data.kills; + replay_player.deaths = player.data.deaths; + } } ball_data = if let Some(ball) = &game.bind().world_ball { ReplayBall::World(ReplayBallData { @@ -439,6 +448,8 @@ pub struct ReplayPlayer { pub name: String, pub color: ReplayColor, pub team: u8, + pub kills: u16, + pub deaths: u16, } #[derive(Debug, Clone, Serialize, Deserialize)] @@ -504,11 +515,18 @@ pub struct ReplayPlayerState { pub look_up: f32, pub current_weapon: WeaponType, pub is_dead: bool, + pub kills: u16, + pub deaths: u16, } impl Player { pub fn get_state(&self) -> Option { - if let Some(character) = &self.character { + if let Some(character) = &self.character + && let Some(game) = Game::singleton() + && let Some(player) = game + .bind() + .find_player(character.dyn_bind().get_player_id().unwrap_or(0)) + { Some(ReplayPlayerState { transform: character.dyn_bind().get_transform(), movement_dir: character.dyn_bind().get_movement_dir().into(), @@ -519,6 +537,8 @@ impl Player { .map(|w| w.dyn_bind().get_type()) .unwrap_or(WeaponType::Raygun), is_dead: character.dyn_bind().is_dead(), + kills: player.data.kills, + deaths: player.data.deaths, }) } else { None diff --git a/rust/src/ui/player_listing.rs b/rust/src/ui/player_listing.rs index e9cbd71..971a545 100644 --- a/rust/src/ui/player_listing.rs +++ b/rust/src/ui/player_listing.rs @@ -98,6 +98,12 @@ impl PlayerListing { if let Some(name_label) = &mut self.name_label { name_label.set_text(&player.name); } + if let Some(kills_label) = &mut self.kills_label { + kills_label.set_text(&player.kills.to_string()); + } + if let Some(deaths_label) = &mut self.deaths_label { + deaths_label.set_text(&player.deaths.to_string()); + } } else { if let Some(name_label) = &mut self.name_label { name_label.set_text("Name");