From cc8f6b059dacb3e182e3899e3b6640d3cedac6c7 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Sat, 18 Jan 2025 01:32:45 -0800 Subject: [PATCH] SessionControlInstruction::LoadIntoReplayState (J) --- strafe-client/src/session.rs | 13 +++++++++++++ strafe-client/src/window.rs | 1 + 2 files changed, 14 insertions(+) diff --git a/strafe-client/src/session.rs b/strafe-client/src/session.rs index 18d6f2e..2a5b4b6 100644 --- a/strafe-client/src/session.rs +++ b/strafe-client/src/session.rs @@ -46,6 +46,7 @@ pub enum SessionControlInstruction{ CopyRecordingIntoReplayAndSpectate, StopSpectate, SaveReplay, + LoadIntoReplayState, } pub enum SessionPlaybackInstruction{ SkipForward, @@ -299,6 +300,18 @@ impl InstructionConsumer> for Session{ } _=self.simulation.timer.set_paused(ins.time,false); }, + Instruction::Control(SessionControlInstruction::LoadIntoReplayState)=>{ + // Bind: J + let view_state=core::mem::replace(&mut self.view_state,ViewState::Play); + match view_state{ + ViewState::Play=>(), + ViewState::Replay(bot_id)=>if let Some(replay)=self.replays.remove(&bot_id){ + self.recording.instructions=replay.recording.instructions.into_iter().take(replay.next_instruction_id).collect(); + self.simulation=replay.simulation; + }, + } + _=self.simulation.timer.set_paused(ins.time,false); + }, Instruction::Playback(SessionPlaybackInstruction::IncreaseTimescale)=>{ match &self.view_state{ ViewState::Play=>{ diff --git a/strafe-client/src/window.rs b/strafe-client/src/window.rs index 6af6911..6c8719c 100644 --- a/strafe-client/src/window.rs +++ b/strafe-client/src/window.rs @@ -156,6 +156,7 @@ impl WindowContext<'_>{ "B"|"b"=>session_ctrl!(CopyRecordingIntoReplayAndSpectate,s), "X"|"x"=>session_ctrl!(StopSpectate,s), "N"|"n"=>session_ctrl!(SaveReplay,s), + "J"|"j"=>session_ctrl!(LoadIntoReplayState,s), _=>None, }, _=>None,