diff --git a/.gitignore b/.gitignore index 86fe16e..ed1e5e0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /target /out +data/*.res **/*.rs.bk Cargo.lock perf.data* diff --git a/Cargo.toml b/Cargo.toml index 4ff4556..a0ebcbc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,17 +10,27 @@ license = "MIT" edition = "2018" publish = false +build = "src/build.rs" [dependencies] argparse = "0.2" bitflags = "1.0" failure = "0.1" generic-array = "0.12" -#gtk = "0.4" -memmap = "0.6" +memmap = "0.7" 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" + [profile.dev] opt-level = 1 @@ -35,3 +45,7 @@ path = "src/lib.rs" [[bin]] name = "leela" path = "src/leela/main.rs" + +[[bin]] +name = "tycho" +path = "src/tycho/main.rs" diff --git a/data/tycho.xml b/data/tycho.xml new file mode 100644 index 0000000..4459934 --- /dev/null +++ b/data/tycho.xml @@ -0,0 +1,319 @@ + + + + + + + + + + + False + dialog + Tycho + 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 + mit-x11 + + + + + + False + vertical + 2 + + + False + end + + + False + False + 0 + + + + + + + + + + False + 440 + 250 + + + + + + True + False + vertical + + + True + False + + + True + False + _File + True + + + 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 + False + _Edit + True + + + 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 + False + _View + True + + + + + True + False + _Help + True + + + True + False + + + gtk-about + True + False + True + True + + + + + + + + + False + True + 0 + + + + + True + False + + + True + False + vertical + + + True + False + + + True + False + Points + True + gtk-media-play + + + + + False + + + + + False + True + 0 + + + + + True + False + + + False + True + 1 + + + + + True + True + vertical + + + + + + + + + True + True + 2 + + + + + True + True + 1 + + + + + + + Tycho Map Editor + The main window of the Tycho map editor. + window + + + + diff --git a/data/tycho1.png b/data/tycho1.png new file mode 100644 index 0000000..19db8cf Binary files /dev/null and b/data/tycho1.png differ diff --git a/data/tycho2.png b/data/tycho2.png new file mode 100644 index 0000000..fb6f43e Binary files /dev/null and b/data/tycho2.png differ diff --git a/data/tycho_res.xml b/data/tycho_res.xml new file mode 100644 index 0000000..a0417ec --- /dev/null +++ b/data/tycho_res.xml @@ -0,0 +1,7 @@ + + + + data/tycho1.png + data/tycho2.png + + diff --git a/src/build.rs b/src/build.rs new file mode 100644 index 0000000..30c29dd --- /dev/null +++ b/src/build.rs @@ -0,0 +1,14 @@ +use std::process::Command; + +fn main() +{ + println!("cargo:rerun-if-changed=data"); + + Command::new("glib-compile-resources") + .arg("data/tycho_res.xml") + .arg("--target=data/tycho.res") + .status() + .unwrap(); +} + +// EOF diff --git a/src/tycho/main.rs b/src/tycho/main.rs new file mode 100644 index 0000000..b43a770 --- /dev/null +++ b/src/tycho/main.rs @@ -0,0 +1,55 @@ +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) +{ + 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")); + + { + let abt = abt.clone(); + bt_abt.connect_activate(move |_| { + abt.run(); + abt.hide(); + }); + } + + win.set_application(app); + win.show_all(); +} + +fn main() -> ResultS<()> +{ + let rsrc = glib::Bytes::from(&RESOURCE[..]); + let rsrc = gio::Resource::new_from_data(&rsrc)?; + gio::resources_register(&rsrc); + + let app = gtk::Application::new("net.greyserv.maraiah.tycho", + gio::ApplicationFlags::empty())?; + + app.connect_activate(run_app); + + if app.run(&[]) == 0 { + Ok(()) + } else { + Err(err_msg("bad return")) + } +} + +// EOF