diff options
author | 2019-08-27 03:32:23 +0200 | |
---|---|---|
committer | 2019-08-27 03:32:23 +0200 | |
commit | 5da6bc7f2be4f2f1e08c58f83c0d001f0f4ad756 (patch) | |
tree | 46a388913355eb1326aeb2e8863c914533a45d52 /examples/ggez | |
parent | 23bc2627e1015901a1caddc0089930d9ed706edc (diff) | |
parent | 55a74a09ce3302a2a2ac8d4a3ff21f1de37f2190 (diff) | |
download | iced-5da6bc7f2be4f2f1e08c58f83c0d001f0f4ad756.tar.gz iced-5da6bc7f2be4f2f1e08c58f83c0d001f0f4ad756.tar.bz2 iced-5da6bc7f2be4f2f1e08c58f83c0d001f0f4ad756.zip |
Merge pull request #3 from hecrj/fix/ggez-resources
Mount `examples/resources` in `ggez::filesystem`
Diffstat (limited to 'examples/ggez')
-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 => { |