SessionControlInstruction::LoadIntoReplayState (J)
This commit is contained in:
parent
4cd287dbb8
commit
cc8f6b059d
@ -46,6 +46,7 @@ pub enum SessionControlInstruction{
|
|||||||
CopyRecordingIntoReplayAndSpectate,
|
CopyRecordingIntoReplayAndSpectate,
|
||||||
StopSpectate,
|
StopSpectate,
|
||||||
SaveReplay,
|
SaveReplay,
|
||||||
|
LoadIntoReplayState,
|
||||||
}
|
}
|
||||||
pub enum SessionPlaybackInstruction{
|
pub enum SessionPlaybackInstruction{
|
||||||
SkipForward,
|
SkipForward,
|
||||||
@ -299,6 +300,18 @@ impl InstructionConsumer<Instruction<'_>> for Session{
|
|||||||
}
|
}
|
||||||
_=self.simulation.timer.set_paused(ins.time,false);
|
_=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)=>{
|
Instruction::Playback(SessionPlaybackInstruction::IncreaseTimescale)=>{
|
||||||
match &self.view_state{
|
match &self.view_state{
|
||||||
ViewState::Play=>{
|
ViewState::Play=>{
|
||||||
|
@ -156,6 +156,7 @@ impl WindowContext<'_>{
|
|||||||
"B"|"b"=>session_ctrl!(CopyRecordingIntoReplayAndSpectate,s),
|
"B"|"b"=>session_ctrl!(CopyRecordingIntoReplayAndSpectate,s),
|
||||||
"X"|"x"=>session_ctrl!(StopSpectate,s),
|
"X"|"x"=>session_ctrl!(StopSpectate,s),
|
||||||
"N"|"n"=>session_ctrl!(SaveReplay,s),
|
"N"|"n"=>session_ctrl!(SaveReplay,s),
|
||||||
|
"J"|"j"=>session_ctrl!(LoadIntoReplayState,s),
|
||||||
_=>None,
|
_=>None,
|
||||||
},
|
},
|
||||||
_=>None,
|
_=>None,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user