Mount examples/resources in ggez::filesystem

This commit is contained in:
Héctor Ramón Jiménez 2019-08-27 03:21:24 +02:00
parent d59d3f033d
commit 55a74a09ce
3 changed files with 23 additions and 16 deletions

View file

@ -8,20 +8,33 @@ use widget::Column;
use ggez; use ggez;
use ggez::event; use ggez::event;
use ggez::filesystem;
use ggez::graphics; use ggez::graphics;
use ggez::input::mouse; use ggez::input::mouse;
pub fn main() -> ggez::GameResult { pub fn main() -> ggez::GameResult {
let cb = ggez::ContextBuilder::new("iced", "ggez").window_mode( let (context, event_loop) = {
ggez::conf::WindowMode { &mut ggez::ContextBuilder::new("iced", "ggez")
width: 1280.0, .window_mode(ggez::conf::WindowMode {
height: 1024.0, width: 1280.0,
..ggez::conf::WindowMode::default() 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)?; let state = &mut Game::new(context)?;
event::run(ctx, event_loop, state)
event::run(context, event_loop, state)
} }
struct Game { struct Game {
@ -115,8 +128,6 @@ impl event::EventHandler for Game {
fn draw(&mut self, context: &mut ggez::Context) -> ggez::GameResult { fn draw(&mut self, context: &mut ggez::Context) -> ggez::GameResult {
graphics::clear(context, [0.3, 0.3, 0.6, 1.0].into()); 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 screen = graphics::screen_coordinates(context);
let (messages, cursor) = { let (messages, cursor) = {

View file

@ -43,5 +43,5 @@ impl Renderer<'_> {
impl iced::Renderer for Renderer<'_> { impl iced::Renderer for Renderer<'_> {
type Color = Color; type Color = Color;
fn explain(&mut self, layout: &iced::Layout<'_>, color: Color) {} fn explain(&mut self, _layout: &iced::Layout<'_>, _color: Color) {}
} }

View file

@ -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) { pub fn react(&mut self, event: Message) {
match event { match event {
Message::BackPressed => { Message::BackPressed => {