diff --git a/Cargo.lock b/Cargo.lock index be15cf2..45985ae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,12 +2,12 @@ name = "athena_editor" version = "0.1.0" dependencies = [ - "gfx 0.5.2 (git+https://github.com/gfx-rs/gfx-rs)", - "gfx_device_gl 0.3.1 (git+https://github.com/gfx-rs/gfx_device_gl)", - "gfx_window_glutin 0.1.1 (git+https://github.com/gfx-rs/gfx_window_glutin)", - "glutin 0.1.6 (git+https://github.com/tomaka/glutin)", + "gfx 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "gfx_device_gl 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gfx_window_glutin 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "glutin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "phosphorus 0.0.1 (git+https://github.com/athena-org/phosphorus.git?branch=develop)", - "rustc-serialize 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -20,6 +20,11 @@ name = "bitflags" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "bitflags" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "byteorder" version = "0.3.10" @@ -28,19 +33,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cgmath" version = "0.2.0" -source = "git+https://github.com/bjz/cgmath-rs#aebe5fd9bfb2daa468754a19a1eac02aa8f959e8" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", + "num 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "color_quant" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "draw_state" -version = "0.0.7" -source = "git+https://github.com/gfx-rs/draw_state#44a0aed11abccbf970fc7efbe84b6482f0548248" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -56,54 +66,54 @@ name = "enum_primitive" version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", + "num 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "freetype-rs" -version = "0.0.9" -source = "git+https://github.com/PistonDevelopers/freetype-rs#686a4d7ff99eddfc64fbe7d2c3a19832ee564614" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "freetype-sys 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "freetype-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "freetype-sys" -version = "0.0.5" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "libz-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libz-sys 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "gdi32-sys" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "gfx" -version = "0.5.2" -source = "git+https://github.com/gfx-rs/gfx-rs#876ee8aa69524c6e81656fec0a20a4fe16b129ee" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "draw_state 0.0.7 (git+https://github.com/gfx-rs/draw_state)", + "bitflags 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "draw_state 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "num 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", + "num 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "gfx_device_gl" -version = "0.3.1" -source = "git+https://github.com/gfx-rs/gfx_device_gl#4e6b7dc048650316c64af4ab79579686e58e4024" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gfx 0.5.2 (git+https://github.com/gfx-rs/gfx-rs)", + "gfx 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "gfx_gl 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -122,22 +132,30 @@ dependencies = [ [[package]] name = "gfx_text" -version = "0.0.0" -source = "git+https://github.com/PistonDevelopers/gfx_text#00c2a2a5b9ae429f7e74ea16c91f67e4386037eb" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "freetype-rs 0.0.9 (git+https://github.com/PistonDevelopers/freetype-rs)", - "gfx 0.5.2 (git+https://github.com/gfx-rs/gfx-rs)", - "log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "freetype-rs 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gfx 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "gfx_window_glutin" -version = "0.1.1" -source = "git+https://github.com/gfx-rs/gfx_window_glutin#be7f4331b5b299b2d8e6074efeae16704db18fae" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gfx 0.5.2 (git+https://github.com/gfx-rs/gfx-rs)", - "gfx_device_gl 0.3.1 (git+https://github.com/gfx-rs/gfx_device_gl)", - "glutin 0.1.6 (git+https://github.com/tomaka/glutin)", + "gfx 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "gfx_device_gl 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "glutin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "gif" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "color_quant 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lzw 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -158,35 +176,40 @@ dependencies = [ "xml-rs 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "glob" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "glutin" version = "0.1.6" -source = "git+https://github.com/tomaka/glutin#e5f888e19a0396b62c2e2a776ddc86652792defb" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "android_glue 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "gdi32-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gdi32-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "gl_common 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "gl_generator 0.0.26 (registry+https://github.com/rust-lang/crates.io-index)", - "glutin_cocoa 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "glutin_cocoa 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "glutin_core_foundation 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "glutin_core_graphics 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "kernel32-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "kernel32-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "khronos_api 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "objc 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "osmesa-sys 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "shared_library 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "user32-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "wayland-client 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "wayland-client 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "wayland-kbd 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", "x11-dl 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "glutin_cocoa" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -213,25 +236,23 @@ dependencies = [ [[package]] name = "image" -version = "0.3.9" -source = "git+https://github.com/PistonDevelopers/image#75f9b791d6b030bc975ec737e9a2d78de39331af" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)", "enum_primitive 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "num 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", + "gif 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "glob 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "num 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "jade" -version = "0.0.1" -source = "git+https://github.com/athena-org/jade-rs?branch=develop#4f255255873f4b4559df43936b551c81e3f22964" - [[package]] name = "kernel32-sys" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-build 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -241,7 +262,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "lazy_static" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -251,7 +272,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libz-sys" -version = "0.1.3" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -266,6 +287,11 @@ dependencies = [ "libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "lzw" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "malloc_buf" version = "0.0.5" @@ -285,11 +311,11 @@ dependencies = [ [[package]] name = "num" -version = "0.1.24" +version = "0.1.25" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rand 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -313,29 +339,28 @@ dependencies = [ [[package]] name = "phosphorus" version = "0.0.1" -source = "git+https://github.com/athena-org/phosphorus.git?branch=develop#53e6df76cc30c6f01c0520a2252e595653b0da80" +source = "git+https://github.com/athena-org/phosphorus.git?branch=develop#d8956d906068e5ccaccc68431880f2299ab81c15" dependencies = [ - "cgmath 0.2.0 (git+https://github.com/bjz/cgmath-rs)", - "gfx 0.5.2 (git+https://github.com/gfx-rs/gfx-rs)", - "gfx_text 0.0.0 (git+https://github.com/PistonDevelopers/gfx_text)", - "jade 0.0.1 (git+https://github.com/athena-org/jade-rs?branch=develop)", - "piston-gfx_texture 0.0.6 (git+https://github.com/PistonDevelopers/gfx_texture)", + "cgmath 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gfx 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "gfx_text 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "piston-gfx_texture 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "piston-gfx_texture" -version = "0.0.6" -source = "git+https://github.com/PistonDevelopers/gfx_texture#910fc5fedd52291c01c29196ba67f02e92b317ce" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gfx 0.5.2 (git+https://github.com/gfx-rs/gfx-rs)", - "image 0.3.9 (git+https://github.com/PistonDevelopers/image)", - "piston-texture 0.0.1 (git+https://github.com/PistonDevelopers/texture)", + "gfx 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "image 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", + "piston-texture 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "piston-texture" -version = "0.0.1" -source = "git+https://github.com/PistonDevelopers/texture#3cc4cddc3f8c51c36ea11dd2f63d70aa887f53fb" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "pkg-config" @@ -352,7 +377,7 @@ dependencies = [ [[package]] name = "rustc-serialize" -version = "0.3.14" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -360,7 +385,7 @@ name = "shared_library" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -377,17 +402,17 @@ name = "user32-sys" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", "winapi-build 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wayland-client" -version = "0.1.6" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -397,15 +422,15 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "mmap 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "wayland-client 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "wayland-client 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "winapi" -version = "0.1.18" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -430,6 +455,6 @@ name = "xml-rs" version = "0.1.25" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/Cargo.toml b/Cargo.toml index 8a80014..701c59f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,24 +1,16 @@ [package] name = "athena_editor" -version = "0.1.0" +version = "0.1.1" authors = ["The Athena Developers"] license = "Apache-2.0" [dependencies] -rustc-serialize = "*" +glutin = "0.1.6" +gfx = "0.6.4" +gfx_device_gl = "0.4.0" +gfx_window_glutin = "0.2.0" +rustc-serialize = "0.3.14" [dependencies.phosphorus] git = "https://github.com/athena-org/phosphorus.git" branch = "develop" - -[dependencies.gfx] -git = "https://github.com/gfx-rs/gfx-rs" - -[dependencies.gfx_device_gl] -git = "https://github.com/gfx-rs/gfx_device_gl" - -[dependencies.gfx_window_glutin] -git = "https://github.com/gfx-rs/gfx_window_glutin" - -[dependencies.glutin] -git = "https://github.com/tomaka/glutin" diff --git a/src/main.rs b/src/main.rs index 04c1cf2..074962f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -38,15 +38,20 @@ struct SharedData { } #[derive(RustcDecodable, RustcEncodable, Clone)] -struct EntityEntry; +struct EntityEntry { + x: f32, + y: f32, + z: f32 +} #[derive(RustcDecodable, RustcEncodable, Clone)] struct WorldModel { - entities: Vec + entities: Vec>> } #[derive(RustcDecodable, RustcEncodable, Clone)] struct Model { + current_entity: Option>>, worlds: Vec } @@ -62,29 +67,35 @@ fn main() { } }; + // Make sure it's a zeus project + let mut toml_path = PathBuf::from(path.clone()); + toml_path.push("Zeus.toml"); + if !toml_path.exists() { display_error("Not a zeus project!"); return; } + // Get the actual path of the data file - let mut path = PathBuf::from(path); - path.push("editor.json"); + let mut editor_path = PathBuf::from(path); + editor_path.push("editor.json"); - let model = Rc::new(RefCell::new(if !path.exists() { + let model = Rc::new(RefCell::new(if !editor_path.exists() { println!("Creating new editor.json..."); - let model = Model { worlds: vec![] }; + let model = Model { current_entity: None, worlds: vec![] }; - save_model(&path, &model); + save_model(&editor_path, &model); model } else { println!("Loading in editor.json..."); - let mut file = File::open(path.clone()).unwrap(); + let mut file = File::open(editor_path.clone()).unwrap(); let mut file_data = String::new(); file.read_to_string(&mut file_data).unwrap(); json::decode::(&file_data).unwrap() })); + model.borrow_mut().current_entity = None; // Set up our Phosphorus UI let data = Rc::new(RefCell::new(SharedData { canceled: false, queued_layout: None })); - let layout = generate_view(path, data.clone(), model); + let layout = generate_view(editor_path, data.clone(), model); data.borrow_mut().queued_layout = Some(layout); @@ -92,16 +103,21 @@ fn main() { } fn save_model(proj_path: &PathBuf, model: &Model){ - let mut file = File::create(proj_path).unwrap(); + let mut file = match File::create(proj_path) { + Ok(f) => f, + Err(e) => panic!(format!("Folder does not exist or is not accessable, error: {:?}", e)) + }; file.write_all(&json::encode(&model).unwrap().as_bytes()).unwrap(); } fn generate_view(proj_path: PathBuf, data: Rc>, model: Rc>) -> Layout { + // Save our model before generating so the file's always up-to-date with what's visible save_model(&proj_path, &model.borrow()); let mut builder = LayoutBuilder::::new() .with_background_color([21, 23, 24]); + // Show all of our worlds let mut wnum = 0; for world in &model.borrow_mut().worlds { builder = builder @@ -109,15 +125,32 @@ fn generate_view(proj_path: PathBuf, data: Rc>, model: Rc>, model: Rc, + path: &PathBuf, data: &Rc>, model: &Rc>, rc_entity: &Rc>, + text: &'static str, adder: Box) + -> LayoutBuilder +{ + let tmp_model = model.clone(); + let tmp_data = data.clone(); + let tmp_path = path.clone(); + let tmp_entity = rc_entity.clone(); + builder = builder + .with_widget(ButtonBuilder::new() + .with_text(text) + .with_callback(Box::new(move || { + { + let mut entity = tmp_entity.borrow_mut(); + adder(&mut entity); + } + + tmp_data.borrow_mut().queued_layout = Some(generate_view(tmp_path.clone(), tmp_data.clone(), tmp_model.clone())); + })) + .build_boxed() + ); + + builder } fn display_error(text: &str) { @@ -181,15 +276,12 @@ fn display_gui(data: Rc>) let window = glutin::WindowBuilder::new() .with_vsync() .with_dimensions(600, 500) - .with_title(String::from("Phosphorus Widgets")) + .with_title(String::from("Athena Editor")) .build_strict().unwrap(); gfx_window_glutin::init(window) }; - let mut gui = Gui::new( - &mut device, - data.borrow_mut().queued_layout.take().unwrap(), - |d: &mut gfx_device_gl::Device| d.spawn_factory()); + let mut gui = Gui::new(&mut device, &mut factory, data.borrow_mut().queued_layout.take().unwrap()); // Run our actual UI loop 'main: loop {