forked from StrafesNET/strafe-client
make load_file function
This commit is contained in:
parent
514c45fc21
commit
bf4560193d
@ -53,6 +53,7 @@ pub trait Example: 'static + Sized {
|
|||||||
);
|
);
|
||||||
fn update(&mut self, window: &winit::window::Window, device: &wgpu::Device, queue: &wgpu::Queue, event: WindowEvent);
|
fn update(&mut self, window: &winit::window::Window, device: &wgpu::Device, queue: &wgpu::Queue, event: WindowEvent);
|
||||||
fn device_event(&mut self, event: DeviceEvent);
|
fn device_event(&mut self, event: DeviceEvent);
|
||||||
|
fn load_file(&mut self, path:std::path::PathBuf, device: &wgpu::Device, queue: &wgpu::Queue);
|
||||||
fn render(
|
fn render(
|
||||||
&mut self,
|
&mut self,
|
||||||
view: &wgpu::TextureView,
|
view: &wgpu::TextureView,
|
||||||
|
14
src/main.rs
14
src/main.rs
@ -774,11 +774,8 @@ impl framework::Example for GraphicsData {
|
|||||||
return graphics;
|
return graphics;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::single_match)]
|
fn load_file(&mut self,path: std::path::PathBuf, device: &wgpu::Device, queue: &wgpu::Queue){
|
||||||
fn update(&mut self, window: &winit::window::Window, device: &wgpu::Device, queue: &wgpu::Queue, event: winit::event::WindowEvent) {
|
println!("Loading file: {:?}", &path);
|
||||||
match event {
|
|
||||||
winit::event::WindowEvent::DroppedFile(path) => {
|
|
||||||
println!("opening file: {:?}", &path);
|
|
||||||
//oh boy! let's load the map!
|
//oh boy! let's load the map!
|
||||||
if let Ok(file)=std::fs::File::open(path){
|
if let Ok(file)=std::fs::File::open(path){
|
||||||
let mut input = std::io::BufReader::new(file);
|
let mut input = std::io::BufReader::new(file);
|
||||||
@ -836,7 +833,12 @@ impl framework::Example for GraphicsData {
|
|||||||
}else{
|
}else{
|
||||||
println!("Could not open file");
|
println!("Could not open file");
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::single_match)]
|
||||||
|
fn update(&mut self, window: &winit::window::Window, device: &wgpu::Device, queue: &wgpu::Queue, event: winit::event::WindowEvent) {
|
||||||
|
match event {
|
||||||
|
winit::event::WindowEvent::DroppedFile(path) => self.load_file(path,device,queue),
|
||||||
winit::event::WindowEvent::KeyboardInput {
|
winit::event::WindowEvent::KeyboardInput {
|
||||||
input:winit::event::KeyboardInput{state, virtual_keycode,..},
|
input:winit::event::KeyboardInput{state, virtual_keycode,..},
|
||||||
..
|
..
|
||||||
|
Loading…
Reference in New Issue
Block a user