diff --git a/strafe-client/src/file.rs b/strafe-client/src/file.rs index 3adc397..6380e32 100644 --- a/strafe-client/src/file.rs +++ b/strafe-client/src/file.rs @@ -59,10 +59,13 @@ impl std::fmt::Display for LoadError{ } impl std::error::Error for LoadError{} -pub fn load>(path:P)->Result{ +pub fn load_file>(path:P)->Result{ //blocking because it's simpler... let file=std::fs::File::open(path).map_err(LoadError::File)?; - match read(file).map_err(LoadError::ReadError)?{ + load(file) +} +pub fn load(reader:R)->Result{ + match read(reader).map_err(LoadError::ReadError)?{ #[cfg(feature="snf")] DataStructure::StrafesNET(map)=>Ok(map), #[cfg(feature="roblox")] diff --git a/strafe-client/src/setup.rs b/strafe-client/src/setup.rs index ee8b256..cfa6eed 100644 --- a/strafe-client/src/setup.rs +++ b/strafe-client/src/setup.rs @@ -211,13 +211,13 @@ pub async fn setup_and_start(title:String){ setup_context, ); - if let Some(arg)=std::env::args().nth(1){ - let path=std::path::PathBuf::from(arg); + //if let Some(arg)=std::env::args().nth(1){ + //let path=std::path::PathBuf::from(arg); window_thread.send(TimedInstruction{ time:integer::Time::ZERO, - instruction:WindowInstruction::WindowEvent(winit::event::WindowEvent::DroppedFile(path)), + instruction:WindowInstruction::WindowEvent(winit::event::WindowEvent::DroppedFile("".into())), }).unwrap(); - }; + //}; println!("Entering event loop..."); let root_time=chrono::Utc::now(); diff --git a/strafe-client/src/window.rs b/strafe-client/src/window.rs index 523e45d..c24d5a8 100644 --- a/strafe-client/src/window.rs +++ b/strafe-client/src/window.rs @@ -25,8 +25,10 @@ impl WindowContext<'_>{ } fn window_event(&mut self,time:integer::Time,event:winit::event::WindowEvent){ match event{ - winit::event::WindowEvent::DroppedFile(path)=>{ - match crate::file::load(path.as_path()){ + winit::event::WindowEvent::DroppedFile(_path)=>{ + //match crate::file::load_file(path.as_path()){ + let data=include_bytes!("/run/media/quat/Files/Documents/map-files/verify-scripts/maps/bhop_snfm/5692113331.snfm"); + match crate::file::load(std::io::Cursor::new(data.as_slice())){ Ok(map)=>self.physics_thread.send(TimedInstruction{time,instruction:crate::physics_worker::Instruction::ChangeMap(map)}).unwrap(), Err(e)=>println!("Failed to load map: {e}"), }