diff --git a/source/tycho/data/tycho.css b/source/tycho/data/tycho.css new file mode 100644 index 0000000..4b94238 --- /dev/null +++ b/source/tycho/data/tycho.css @@ -0,0 +1,5 @@ +.first-start-window { + background-color: #000000; + color: #AAAAAA; + font: 16px "FixedSys", "Monospace"; +} diff --git a/source/tycho/data/tycho.xml b/source/tycho/data/tycho.xml index 0a0a75c..6e17d50 100644 --- a/source/tycho/data/tycho.xml +++ b/source/tycho/data/tycho.xml @@ -98,6 +98,7 @@ Author: Alison Sanderson True False + The name of the map. Unicode symbols that are supported by the Mac OS Roman encoding are converted automatically when saved. 0 none @@ -109,7 +110,6 @@ Author: Alison Sanderson True True - The name of the map. Unicode symbols that are supported by the Mac OS Roman encoding are converted automatically when saved. @@ -144,6 +144,7 @@ Author: Alison Sanderson True False + The texture collection to use for the map. This is one of five bitmap collections stored in the Shapes file. 0 none @@ -158,7 +159,6 @@ Author: Alison Sanderson True False - The texture collection to use for the map. This is one of five bitmap collections stored in the Shapes file. 0 Water @@ -189,6 +189,7 @@ Author: Alison Sanderson True False + The sky to display on sides which are marked as "Landscape." This is the sole bitmap of one of four collections in the Shapes file. 0 none @@ -203,7 +204,6 @@ Author: Alison Sanderson True False - The sky to display on sides which are marked as "Landscape." This is the sole bitmap of one of four collections in the Shapes file. 0 Lh'owon Day @@ -627,41 +627,96 @@ Author: Alison Sanderson vertical 5 - + True False - 0 - none - + True False - 0 - 0 - 0 - 0 - 12 + 0 + none - + True - True - This field is unused and must be either 0 or 1. It used to be used to give different physics to the map editor and low gravity before it was made into an environment flag. - 0 - True - adj-phys-id - True - True - True + False + 0 + 0 + 0 + 0 + 12 + + + True + True + This field is unused and must be either 0 or 1. It used to be used to give different physics to the map editor and low gravity before it was made into an environment flag. + 0 + True + adj-phys-id + True + True + True + + + + + + + True + False + Physics ID + + True + True + 0 + - - + + True False - Physics ID + This field overrides the Landscape value, since Marathon 1 used that field for the music number. + 0 + none + + + True + False + 0 + 0 + 0 + 0 + 12 + + + True + True + 0 + True + adj-phys-id + True + True + True + + + + + + + True + False + Song ID + + + + True + True + 1 + @@ -679,7 +734,6 @@ Author: Alison Sanderson True False - These flags were added by Aleph One but are hidden and probably not meant to be used. 0 in @@ -745,7 +799,7 @@ Author: Alison Sanderson True False - Hidden Mission Flags + Aleph Mission Flags @@ -759,7 +813,6 @@ Author: Alison Sanderson True False - These flags were added by Aleph One but are hidden and probably not meant to be used. 0 in @@ -885,7 +938,7 @@ Author: Alison Sanderson True False - Hidden Environment Flags + Aleph Environment Flags @@ -1079,6 +1132,44 @@ Author: Alison Sanderson + + False + First Startup + False + + + True + False + 10 + 10 + 10 + 10 + + + True + False + II. A word from the Programmer: + + This entire program was written in Vim. Emacs users beware, +IDEs beware, all beware! For I have the power of Vim! Hahahaha +hahahahahaha! Anyway, hopefully you enjoy the program. It's +my first serious effort at writing a GUI program. This toolset +is made to encourage people to try out Marathon and hopefully +start making stuff. Modding should be a fun journey for +every one just as it has helped me to further my abilities at +many things, including programming. + + Also, 3 space tabs win. --- Alison Sanderson + Programmer of Maraiah + 4 + + + + + + False Tycho diff --git a/source/tycho/data/tycho_res.xml b/source/tycho/data/tycho_res.xml index b0892a8..1fdc56d 100644 --- a/source/tycho/data/tycho_res.xml +++ b/source/tycho/data/tycho_res.xml @@ -7,5 +7,6 @@ data/lines.png data/points.png data/tycho.xml + data/tycho.css diff --git a/source/tycho/hiddenprotocol.rs b/source/tycho/hiddenprotocol.rs index 85b9bf7..622d0f7 100644 --- a/source/tycho/hiddenprotocol.rs +++ b/source/tycho/hiddenprotocol.rs @@ -17,23 +17,22 @@ pub fn draw_map_none(d: &D, im: &I) d.text((4, d.h() - 4), "CAS.qterm//CyberAcme Systems Inc.", CR_RED); } -pub fn new_map() -> MapState +pub fn new_map() -> MapEditorState { let info = Default::default(); - let ed = EditorState{}; - let ma = MapState{ed, info}; + let ed = MapEditorState{info}; - ma + ed } -pub struct EditorState +impl Drop for MapEditorState { + fn drop(&mut self) {eprintln!("dropping MapEditorState");} } -pub struct MapState +pub struct MapEditorState { - ed: EditorState, info: map::Minf, } diff --git a/source/tycho/main.rs b/source/tycho/main.rs index efaea64..24e4902 100644 --- a/source/tycho/main.rs +++ b/source/tycho/main.rs @@ -5,6 +5,9 @@ use crate::{hiddenprotocol::*, noroom::*}; use gio::prelude::*; use gtk::prelude::*; use maraiah::durandal::err::*; +use std::{os::raw::c_char, rc::Rc}; + +const DATA_NAME: *const c_char = b"tycho data\0".as_ptr() as *const c_char; fn hide_on_delete(win: >k::Window, _: &gdk::Event) -> Inhibit { @@ -43,9 +46,20 @@ fn run_app(app: >k::Application) { let b = >k::Builder::new_from_resource("/net/greyserv/maraiah/tycho/ui"); - let app_ = app.clone(); + let prv = gtk::CssProvider::new(); + prv.load_from_resource("/net/greyserv/maraiah/tycho/css"); + + let scr = gdk::Screen::get_default().expect("no screen found"); + let pri = gtk::STYLE_PROVIDER_PRIORITY_APPLICATION; + gtk::StyleContext::add_provider_for_screen(&scr, &prv, pri); + + let app_ = app.downgrade(); let btn: gtk::MenuItem = get_obj(b, "btn-quit"); - btn.connect_activate(move |_| app_.quit()); + btn.connect_activate(move |_| { + if let Some(app) = app_.upgrade() { + app.quit(); + } + }); let btn: gtk::MenuItem = get_obj(b, "btn-about"); let win: gtk::AboutDialog = get_obj(b, "win-about"); @@ -74,6 +88,9 @@ fn run_app(app: >k::Application) win.set_website(env!("CARGO_PKG_HOMEPAGE")); win.set_logo(&load_img("/net/greyserv/maraiah/tycho/tycho2")); + let win: gtk::Window = get_obj(b, "win-first-start"); + win.show_all(); + let win: gtk::Window = get_obj(b, "win-main"); win.set_application(app); win.show_all(); @@ -95,6 +112,7 @@ fn main() -> ResultS<()> // get jacked, punk. opaque data structures are for nerds. const RESOURCE_DATA: &[u8] = include_bytes!("data/tycho.res"); + // first we create the static resource header, which is really simple let mut static_resource = gio_sys::GStaticResource{data: RESOURCE_DATA.as_ptr(), data_len: RESOURCE_DATA.len(), @@ -102,21 +120,54 @@ fn main() -> ResultS<()> next: std::ptr::null_mut(), padding: std::ptr::null_mut()}; + // init it, now we can use it throughout the entire app without copying! unsafe { gio_sys::g_static_resource_init(&mut static_resource); } - let app = gtk::Application::new("net.greyserv.maraiah.tycho", - gio::ApplicationFlags::empty())?; + let ret = { + // create the application first + let app = gtk::Application::new("net.greyserv.maraiah.tycho", + gio::ApplicationFlags::empty())?; - app.connect_activate(run_app); + app.connect_activate(run_app); - let ret = if app.run(&[]) == 0 { - Ok(()) - } else { - Err(err_msg("bad return")) + // then we can attach the editor state to the app's hashtable + let app_ptr = app.clone().upcast::().as_ptr(); + + let dat = Rc::new(None::); + + unsafe { + // this ref will be dropped after the app is run + let ptr = Rc::into_raw(dat.clone()) as glib_sys::gpointer; + + gobject_sys::g_object_set_data(app_ptr, DATA_NAME, ptr); + } + + // run the application and save the return + let ret = if app.run(&[]) == 0 { + Ok(()) + } else { + Err(err_msg("bad return")) + }; + + // unref the editor state so it will go away + unsafe { + let ptr = gobject_sys::g_object_get_data(app_ptr, DATA_NAME); + let ptr = Rc::from_raw(ptr); + + std::mem::drop(ptr); + } + + // destroy the editor state first, and make sure there are no dangling + // references to the application. + std::mem::drop(dat); + assert_eq!(app.ref_count(), 1); + + ret }; + // finally, deinit the "static" data, and everything will be done unsafe { gio_sys::g_static_resource_fini(&mut static_resource); }