From aa0f6cf5379cf039c07de563cb48ffb227f7765d Mon Sep 17 00:00:00 2001 From: Marrub Date: Thu, 21 Mar 2019 21:17:30 -0400 Subject: [PATCH] output resources to the correct directory and handle errors --- .gitignore | 2 +- source/tycho/build.rs | 20 ++- .../data/{tycho_res.xml => resources.xml} | 4 +- source/tycho/data/{tycho.css => styles.css} | 0 source/tycho/data/{tycho.xml => ui.xml} | 147 ++++-------------- source/tycho/main.rs | 3 +- 6 files changed, 48 insertions(+), 128 deletions(-) rename source/tycho/data/{tycho_res.xml => resources.xml} (85%) rename source/tycho/data/{tycho.css => styles.css} (100%) rename source/tycho/data/{tycho.xml => ui.xml} (90%) diff --git a/.gitignore b/.gitignore index c445795..79ee3fb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ /target /out -*.res **/*.rs.bk Cargo.lock perf.data* +*.bat diff --git a/source/tycho/build.rs b/source/tycho/build.rs index e0c9e2f..43d44fe 100644 --- a/source/tycho/build.rs +++ b/source/tycho/build.rs @@ -1,13 +1,23 @@ use std::process::Command; -fn main() +fn main() -> std::io::Result<()> { + let out_file = std::env::var("OUT_DIR").unwrap(); + let out_file = format!("--target={}/resources", out_file); + println!("cargo:rerun-if-changed=data"); - Command::new("glib-compile-resources").arg("data/tycho_res.xml") - .arg("--target=data/tycho.res") - .status() - .unwrap(); + let o = Command::new("glib-compile-resources").arg("data/resources.xml") + .arg(out_file) + .output() + .unwrap(); + + if !o.status.success() { + dbg!(o); + Err(std::io::Error::new(std::io::ErrorKind::Other, "failed to compile resources")) + } else { + Ok(()) + } } // EOF diff --git a/source/tycho/data/tycho_res.xml b/source/tycho/data/resources.xml similarity index 85% rename from source/tycho/data/tycho_res.xml rename to source/tycho/data/resources.xml index 1fdc56d..c001e59 100644 --- a/source/tycho/data/tycho_res.xml +++ b/source/tycho/data/resources.xml @@ -6,7 +6,7 @@ data/polys.png data/lines.png data/points.png - data/tycho.xml - data/tycho.css + data/styles.css + data/ui.xml diff --git a/source/tycho/data/tycho.css b/source/tycho/data/styles.css similarity index 100% rename from source/tycho/data/tycho.css rename to source/tycho/data/styles.css diff --git a/source/tycho/data/tycho.xml b/source/tycho/data/ui.xml similarity index 90% rename from source/tycho/data/tycho.xml rename to source/tycho/data/ui.xml index 6e17d50..0a0a75c 100644 --- a/source/tycho/data/tycho.xml +++ b/source/tycho/data/ui.xml @@ -98,7 +98,6 @@ 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 @@ -110,6 +109,7 @@ 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,7 +144,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 none @@ -159,6 +158,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 Water @@ -189,7 +189,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 none @@ -204,6 +203,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 Lh'owon Day @@ -627,96 +627,41 @@ Author: Alison Sanderson vertical 5 - + True False + 0 + none - + True False - 0 - none + 0 + 0 + 0 + 0 + 12 - + 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 + 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 - True - 0 - - - + + True False - 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 - - + Physics ID - - True - True - 1 - @@ -734,6 +679,7 @@ Author: Alison Sanderson True False + These flags were added by Aleph One but are hidden and probably not meant to be used. 0 in @@ -799,7 +745,7 @@ Author: Alison Sanderson True False - Aleph Mission Flags + Hidden Mission Flags @@ -813,6 +759,7 @@ Author: Alison Sanderson True False + These flags were added by Aleph One but are hidden and probably not meant to be used. 0 in @@ -938,7 +885,7 @@ Author: Alison Sanderson True False - Aleph Environment Flags + Hidden Environment Flags @@ -1132,44 +1079,6 @@ 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/main.rs b/source/tycho/main.rs index 24e4902..0b3c339 100644 --- a/source/tycho/main.rs +++ b/source/tycho/main.rs @@ -110,7 +110,8 @@ fn get_obj(b: >k::Builder, name: &str) -> T fn main() -> ResultS<()> { // get jacked, punk. opaque data structures are for nerds. - const RESOURCE_DATA: &[u8] = include_bytes!("data/tycho.res"); + const RESOURCE_DATA: &[u8] = + include_bytes!(concat!(env!("OUT_DIR"), "/resources")); // first we create the static resource header, which is really simple let mut static_resource =