diff --git a/Cargo.toml b/Cargo.toml index a0ebcbc..2d8c3a9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,14 +22,20 @@ serde = {version = "1.0", features = ["derive"]} serde_yaml = "0.8" # note: these have to be updated all at once, check the gtk crate for versions -atk = "0.6" -cairo-rs = "0.6" -gdk = "0.10" -gdk-pixbuf = "0.6" -gtk = "0.6" -gio = "0.6" -glib = "0.7" -pango = "0.6" +atk = "0.6" +cairo-rs = "0.6" +cairo-sys-rs = "0.8" +gdk = "0.10" +gdk-pixbuf = "0.6" +gio = "0.6" +gio-sys = "0.8" +glib = "0.7" +glib-sys = "0.8" +gobject-sys = "0.8" +gtk = "0.6" +gtk-sys = "0.8" +pango = "0.6" +pango-sys = "0.8" [profile.dev] opt-level = 1 diff --git a/data/icons.psd b/data/icons.psd new file mode 100644 index 0000000..cb007c9 Binary files /dev/null and b/data/icons.psd differ diff --git a/data/lines.png b/data/lines.png new file mode 100644 index 0000000..a611345 Binary files /dev/null and b/data/lines.png differ diff --git a/data/points.png b/data/points.png new file mode 100644 index 0000000..43d8652 Binary files /dev/null and b/data/points.png differ diff --git a/data/polys.png b/data/polys.png new file mode 100644 index 0000000..285871e Binary files /dev/null and b/data/polys.png differ diff --git a/data/tycho.xml b/data/tycho.xml index 4459934..16fd650 100644 --- a/data/tycho.xml +++ b/data/tycho.xml @@ -33,14 +33,131 @@ Author: Alison Sanderson + + True + False + /net/greyserv/maraiah/tycho/lines + + + True + False + /net/greyserv/maraiah/tycho/points + + + True + False + /net/greyserv/maraiah/tycho/polys + + + False + Tool Palette + 250 + True + True + + + + + + True + False + vertical + + + True + False + Geometry + + + True + False + Points + True + im_points + + + Points Tool + The tool that modifies points in the map. + push-button + + + + + True + + + + + True + False + Lines + True + im_lines + + + Lines Tool + The tool which modifies line segments on the map. + push-button + + + + + True + 1 + + + + + True + False + Polygons + True + im_polys + + + Polygon Tool + The tool which modifies polygon shapes on the map. + push-button + + + + + True + 2 + + + + + Geometry Collection + All of the tools which modify map geometry. + column-header + + + + + True + + + + + + + Tycho Tool Palette + Tycho's tool palette window. + window + + + False + True + True dialog - Tycho - 2018-2019 Alison Sanderson + Tycho Map Editor + Copyright © 2018-2019 Alison Sanderson greetigs i am tico the of superior ai to durdumbal go shoot my soldiers because its funny or ill put you in space - Website - resource:///net/greyserv/maraiah/tycho/tycho2.png + Home Page + image-loading mit-x11 @@ -66,253 +183,180 @@ Author: Alison Sanderson + + + About Screen + The about screen for Tycho. + dialog + + - + False - 440 + Tycho 250 + True - + True False - vertical + ttb - + True False - - + _File + True + + True False - _File - True - - + + + gtk-new True False - - - gtk-new - True - False - True - True - - - - - gtk-open - True - False - True - True - - - - - gtk-save - True - False - True - True - - - - - gtk-save-as - True - False - True - True - - - - - True - False - - - - - gtk-quit - True - False - True - True - - + True + True - - - - - True - False - _Edit - True - - + + + gtk-open True False - - - gtk-cut - True - False - True - True - - - - - gtk-copy - True - False - True - True - - - - - gtk-paste - True - False - True - True - - - - - gtk-delete - True - False - True - True - - + True + True - - - - - True - False - _View - True - - - - - True - False - _Help - True - - + + + gtk-save True False - - - gtk-about - True - False - True - True - - + True + True + + + + + gtk-save-as + True + False + True + True + + + + + True + False + + + + + gtk-quit + True + False + True + True - - False - True - 0 - - + True False - - + _Edit + True + + True False - vertical - + + gtk-cut True False - - - True - False - Points - True - gtk-media-play - - + True + True - - False - - - - - False - True - 0 - - - - - True - False - - - False - True - 1 - - - - - True - True - vertical - - - + + gtk-copy + True + False + True + True + + + + + gtk-paste + True + False + True + True + + + + + gtk-delete + True + False + True + True + + + + + + + + + True + False + _View + True + + + + + True + False + + + + + True + False + True + _Info + True + + + True + False + + + gtk-about + True + False + True + True + - - True - True - 2 - - - True - True - 1 - - - - - - Tycho Map Editor - The main window of the Tycho map editor. - window diff --git a/data/tycho_res.xml b/data/tycho_res.xml index a0417ec..b0892a8 100644 --- a/data/tycho_res.xml +++ b/data/tycho_res.xml @@ -1,7 +1,11 @@ - data/tycho1.png - data/tycho2.png + data/tycho1.png + data/tycho2.png + data/polys.png + data/lines.png + data/points.png + data/tycho.xml diff --git a/src/tycho/main.rs b/src/tycho/main.rs index b43a770..9d00d3a 100644 --- a/src/tycho/main.rs +++ b/src/tycho/main.rs @@ -2,54 +2,101 @@ use gtk::prelude::*; use gio::prelude::*; use maraiah::durandal::err::*; -// TODO: add detached draw area mode, make everything detachable - -const RESOURCE: &'static [u8] = - include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/data/tycho.res")); - -const XML: &'static str = - include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/data/tycho.xml")); - -fn run_app(app: >k::Application) +fn run_app(app: >k::Application) -> ResultS<()> { - let b = gtk::Builder::new_from_string(XML); - - let win: gtk::Window = b.get_object("win_tycho").unwrap(); - let abt: gtk::AboutDialog = b.get_object("win_about").unwrap(); - let bt_abt: gtk::MenuItem = b.get_object("btn_about").unwrap(); - - abt.set_authors(&env!("CARGO_PKG_AUTHORS").split(';').collect::>()); - abt.set_version(env!("CARGO_PKG_VERSION")); - abt.set_website(env!("CARGO_PKG_HOMEPAGE")); - + fn load_img(path: &'static str) -> ResultS { - let abt = abt.clone(); - bt_abt.connect_activate(move |_| { - abt.run(); - abt.hide(); - }); + Ok(gdk_pixbuf::Pixbuf::new_from_resource(path)?) } - win.set_application(app); - win.show_all(); + fn get_obj(b: >k::Builder, name: &str) -> ResultS + where T: glib::object::IsA + { + match b.get_object(name) { + Some(w) => Ok(w), + None => Err(err_msg("no object")), + } + } + + let b = gtk::Builder::new_from_resource("/net/greyserv/maraiah/tycho/ui"); + + let win_menus: gtk::Window = get_obj(&b, "win_menus")?; + let win_tools: gtk::Window = get_obj(&b, "win_tools")?; + let win_about: gtk::AboutDialog = get_obj(&b, "win_about")?; + let btn_about: gtk::MenuItem = get_obj(&b, "btn_about")?; + //t draw_area: gtk::DrawingArea = get_obj(&b, "draw_area")?; + //t btn_point: gtk::ToolButton = get_obj(&b, "btn_point")?; + //t btn_lines: gtk::ToolButton = get_obj(&b, "btn_lines")?; + //t btn_polys: gtk::ToolButton = get_obj(&b, "btn_polys")?; + + let authors: Vec<_> = env!("CARGO_PKG_AUTHORS").split(';').collect(); + + win_about.set_authors(&authors); + win_about.set_version(env!("CARGO_PKG_VERSION")); + win_about.set_website(env!("CARGO_PKG_HOMEPAGE")); + win_about.set_logo(&load_img("/net/greyserv/maraiah/tycho/tycho2")?); + + btn_about.connect_activate(move |_| { + win_about.run(); + win_about.hide(); + }); + + win_tools.set_deletable(false); + win_tools.show_all(); + + win_menus.set_application(app); + win_menus.show_all(); + + Ok(()) } fn main() -> ResultS<()> { - let rsrc = glib::Bytes::from(&RESOURCE[..]); - let rsrc = gio::Resource::new_from_data(&rsrc)?; - gio::resources_register(&rsrc); + // get jacked, punk. opaque data structures are for nerds. + const RESOURCE_DATA: &'static [u8] = + include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/data/tycho.res")); + + let mut static_resource = + gio_sys::GStaticResource{data: RESOURCE_DATA.as_ptr(), + data_len: RESOURCE_DATA.len(), + resource: std::ptr::null_mut(), + next: std::ptr::null_mut(), + padding: std::ptr::null_mut()}; + + unsafe { + gio_sys::g_static_resource_init(&mut static_resource); + } let app = gtk::Application::new("net.greyserv.maraiah.tycho", gio::ApplicationFlags::empty())?; - app.connect_activate(run_app); + app.connect_activate(|app| { + match run_app(app) { + Ok(()) => (), + Err(e) => { + // print out an error if init failed somehow, otherwise the main + // loop will proceed as normal (this is just to prevent panics in + // weird circumstances such as breaking the builder while devving) + gtk::MessageDialog::new(None::<>k::Window>, + gtk::DialogFlags::empty(), + gtk::MessageType::Error, + gtk::ButtonsType::Ok, + &format!("{:?}", e)).run(); + } + } + }); - if app.run(&[]) == 0 { + let ret = if app.run(&[]) == 0 { Ok(()) } else { Err(err_msg("bad return")) + }; + + unsafe { + gio_sys::g_static_resource_fini(&mut static_resource); } + + ret } // EOF