SessionControlInstruction::LoadIntoReplayState (J)

This commit is contained in:
Quaternions 2025-01-18 01:32:45 -08:00
parent 4cd287dbb8
commit cc8f6b059d
2 changed files with 14 additions and 0 deletions

View File

@ -46,6 +46,7 @@ pub enum SessionControlInstruction{
CopyRecordingIntoReplayAndSpectate,
StopSpectate,
SaveReplay,
LoadIntoReplayState,
}
pub enum SessionPlaybackInstruction{
SkipForward,
@ -299,6 +300,18 @@ impl InstructionConsumer<Instruction<'_>> 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=>{

View File

@ -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,