diff options
author | 2019-08-27 03:21:24 +0200 | |
---|---|---|
committer | 2019-08-27 03:21:24 +0200 | |
commit | 55a74a09ce3302a2a2ac8d4a3ff21f1de37f2190 (patch) | |
tree | 3cec1aa1391e0ee72184399fb09f469641f13dc0 /examples | |
parent | d59d3f033de9bd1bd81d730486d75a1dbb589eb3 (diff) | |
download | iced-55a74a09ce3302a2a2ac8d4a3ff21f1de37f2190.tar.gz iced-55a74a09ce3302a2a2ac8d4a3ff21f1de37f2190.tar.bz2 iced-55a74a09ce3302a2a2ac8d4a3ff21f1de37f2190.zip |
Mount `examples/resources` in `ggez::filesystem`
Diffstat (limited to 'examples')
-rw-r--r-- | examples/ggez/main.rs | 33 | ||||
-rw-r--r-- | examples/ggez/renderer.rs | 2 | ||||
-rw-r--r-- | examples/ggez/tour.rs | 4 |
3 files changed, 23 insertions, 16 deletions
diff --git a/examples/ggez/main.rs b/examples/ggez/main.rs index 75bc3a0d..ad9051ff 100644 --- a/examples/ggez/main.rs +++ b/examples/ggez/main.rs @@ -8,20 +8,33 @@ use widget::Column; use ggez; use ggez::event; +use ggez::filesystem; use ggez::graphics; use ggez::input::mouse; pub fn main() -> ggez::GameResult { - let cb = ggez::ContextBuilder::new("iced", "ggez").window_mode( - ggez::conf::WindowMode { - width: 1280.0, - height: 1024.0, - ..ggez::conf::WindowMode::default() - }, + let (context, event_loop) = { + &mut ggez::ContextBuilder::new("iced", "ggez") + .window_mode(ggez::conf::WindowMode { + width: 1280.0, + height: 1024.0, + ..ggez::conf::WindowMode::default() + }) + .build()? + }; + + filesystem::mount( + context, + std::path::Path::new(&format!( + "{}/examples/resources", + env!("CARGO_MANIFEST_DIR") + )), + true, ); - let (ctx, event_loop) = &mut cb.build()?; - let state = &mut Game::new(ctx)?; - event::run(ctx, event_loop, state) + + let state = &mut Game::new(context)?; + + event::run(context, event_loop, state) } struct Game { @@ -115,8 +128,6 @@ impl event::EventHandler for Game { fn draw(&mut self, context: &mut ggez::Context) -> ggez::GameResult { graphics::clear(context, [0.3, 0.3, 0.6, 1.0].into()); - self.tour.draw(context).expect("Draw tour"); - let screen = graphics::screen_coordinates(context); let (messages, cursor) = { diff --git a/examples/ggez/renderer.rs b/examples/ggez/renderer.rs index 2e2e4cb4..1d15eb5f 100644 --- a/examples/ggez/renderer.rs +++ b/examples/ggez/renderer.rs @@ -43,5 +43,5 @@ impl Renderer<'_> { impl iced::Renderer for Renderer<'_> { type Color = Color; - fn explain(&mut self, layout: &iced::Layout<'_>, color: Color) {} + fn explain(&mut self, _layout: &iced::Layout<'_>, _color: Color) {} } diff --git a/examples/ggez/tour.rs b/examples/ggez/tour.rs index 3808fdda..19982aa4 100644 --- a/examples/ggez/tour.rs +++ b/examples/ggez/tour.rs @@ -20,10 +20,6 @@ impl Tour { } } - pub fn draw(&mut self, context: &mut ggez::Context) -> ggez::GameResult { - Ok(()) - } - pub fn react(&mut self, event: Message) { match event { Message::BackPressed => { |