make pain code smaller

This commit is contained in:
Quaternions 2025-01-14 01:45:09 -08:00
parent 90f6437817
commit 93277c042b

View File

@ -38,43 +38,29 @@ pub fn new<'a>(
} }
macro_rules! run_graphics_worker_instruction{ macro_rules! run_graphics_worker_instruction{
($instruction:expr)=>{ ($instruction:expr)=>{
if let Some(instruction)=$instruction{ graphics_worker.send($instruction).unwrap();
graphics_worker.send(instruction).unwrap();
}
}; };
} }
match ins.instruction{ match ins.instruction{
Instruction::Input(unbuffered_instruction)=>{ Instruction::Input(unbuffered_instruction)=>{
let ins_session=SessionInstruction::Input(unbuffered_instruction); run_session_instruction!(ins.time,SessionInstruction::Input(unbuffered_instruction));
run_session_instruction!(ins.time,ins_session);
let ins_graphics=None;
run_graphics_worker_instruction!(ins_graphics);
}, },
Instruction::SetPaused(paused)=>{ Instruction::SetPaused(paused)=>{
let ins_session=SessionInstruction::SetPaused(paused); run_session_instruction!(ins.time,SessionInstruction::SetPaused(paused));
run_session_instruction!(ins.time,ins_session);
let ins_graphics=None;
run_graphics_worker_instruction!(ins_graphics);
}, },
Instruction::Render=>{ Instruction::Render=>{
let ins_session=SESSION_INSTRUCTION_IDLE; run_session_instruction!(ins.time,SESSION_INSTRUCTION_IDLE);
run_session_instruction!(ins.time,ins_session);
let frame_state=session.get_frame_state(ins.time); let frame_state=session.get_frame_state(ins.time);
let ins_graphics=Some(GraphicsInstruction::Render(frame_state)); run_graphics_worker_instruction!(GraphicsInstruction::Render(frame_state));
run_graphics_worker_instruction!(ins_graphics);
}, },
Instruction::Resize(physical_size)=>{ Instruction::Resize(physical_size)=>{
let ins_session=SESSION_INSTRUCTION_IDLE; run_session_instruction!(ins.time,SESSION_INSTRUCTION_IDLE);
run_session_instruction!(ins.time,ins_session);
let user_settings=session.user_settings().clone(); let user_settings=session.user_settings().clone();
let ins_graphics=Some(GraphicsInstruction::Resize(physical_size,user_settings)); run_graphics_worker_instruction!(GraphicsInstruction::Resize(physical_size,user_settings));
run_graphics_worker_instruction!(ins_graphics);
}, },
Instruction::ChangeMap(complete_map)=>{ Instruction::ChangeMap(complete_map)=>{
let ins_session=SessionInstruction::ChangeMap(&complete_map); run_session_instruction!(ins.time,SessionInstruction::ChangeMap(&complete_map));
run_session_instruction!(ins.time,ins_session); run_graphics_worker_instruction!(GraphicsInstruction::ChangeMap(complete_map));
let ins_graphics=Some(GraphicsInstruction::ChangeMap(complete_map));
run_graphics_worker_instruction!(ins_graphics);
}, },
} }
}) })