output resources to the correct directory and handle errors

gui-branch
an 2019-03-21 21:17:30 -04:00
parent 708f2e106c
commit aa0f6cf537
6 changed files with 48 additions and 128 deletions

2
.gitignore vendored
View File

@ -1,6 +1,6 @@
/target /target
/out /out
*.res
**/*.rs.bk **/*.rs.bk
Cargo.lock Cargo.lock
perf.data* perf.data*
*.bat

View File

@ -1,13 +1,23 @@
use std::process::Command; 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"); println!("cargo:rerun-if-changed=data");
Command::new("glib-compile-resources").arg("data/tycho_res.xml") let o = Command::new("glib-compile-resources").arg("data/resources.xml")
.arg("--target=data/tycho.res") .arg(out_file)
.status() .output()
.unwrap(); .unwrap();
if !o.status.success() {
dbg!(o);
Err(std::io::Error::new(std::io::ErrorKind::Other, "failed to compile resources"))
} else {
Ok(())
}
} }
// EOF // EOF

View File

@ -6,7 +6,7 @@
<file compressed="true" alias="polys">data/polys.png</file> <file compressed="true" alias="polys">data/polys.png</file>
<file compressed="true" alias="lines">data/lines.png</file> <file compressed="true" alias="lines">data/lines.png</file>
<file compressed="true" alias="points">data/points.png</file> <file compressed="true" alias="points">data/points.png</file>
<file compressed="true" preprocess="xml-stripblanks" alias="ui">data/tycho.xml</file> <file compressed="true" alias="css">data/styles.css</file>
<file compressed="true" alias="css">data/tycho.css</file> <file compressed="true" preprocess="xml-stripblanks" alias="ui">data/ui.xml</file>
</gresource> </gresource>
</gresources> </gresources>

View File

@ -98,7 +98,6 @@ Author: Alison Sanderson
<object class="GtkFrame"> <object class="GtkFrame">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">The name of the map. Unicode symbols that are supported by the Mac OS Roman encoding are converted automatically when saved.</property>
<property name="label_xalign">0</property> <property name="label_xalign">0</property>
<property name="shadow_type">none</property> <property name="shadow_type">none</property>
<child> <child>
@ -110,6 +109,7 @@ Author: Alison Sanderson
<object class="GtkEntry" id="ent-map-name"> <object class="GtkEntry" id="ent-map-name">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes">The name of the map. Unicode symbols that are supported by the Mac OS Roman encoding are converted automatically when saved.</property>
</object> </object>
</child> </child>
</object> </object>
@ -144,7 +144,6 @@ Author: Alison Sanderson
<object class="GtkFrame"> <object class="GtkFrame">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">The texture collection to use for the map. This is one of five bitmap collections stored in the Shapes file.</property>
<property name="label_xalign">0</property> <property name="label_xalign">0</property>
<property name="shadow_type">none</property> <property name="shadow_type">none</property>
<child> <child>
@ -159,6 +158,7 @@ Author: Alison Sanderson
<object class="GtkComboBoxText"> <object class="GtkComboBoxText">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">The texture collection to use for the map. This is one of five bitmap collections stored in the Shapes file.</property>
<property name="active">0</property> <property name="active">0</property>
<items> <items>
<item translatable="yes">Water</item> <item translatable="yes">Water</item>
@ -189,7 +189,6 @@ Author: Alison Sanderson
<object class="GtkFrame"> <object class="GtkFrame">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">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.</property>
<property name="label_xalign">0</property> <property name="label_xalign">0</property>
<property name="shadow_type">none</property> <property name="shadow_type">none</property>
<child> <child>
@ -204,6 +203,7 @@ Author: Alison Sanderson
<object class="GtkComboBoxText"> <object class="GtkComboBoxText">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">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.</property>
<property name="active">0</property> <property name="active">0</property>
<items> <items>
<item translatable="yes">Lh'owon Day</item> <item translatable="yes">Lh'owon Day</item>
@ -627,96 +627,41 @@ Author: Alison Sanderson
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<property name="spacing">5</property> <property name="spacing">5</property>
<child> <child>
<object class="GtkBox"> <object class="GtkFrame">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child> <child>
<object class="GtkFrame"> <object class="GtkAlignment">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="label_xalign">0</property> <property name="xalign">0</property>
<property name="shadow_type">none</property> <property name="yalign">0</property>
<property name="xscale">0</property>
<property name="yscale">0</property>
<property name="left_padding">12</property>
<child> <child>
<object class="GtkAlignment"> <object class="GtkSpinButton">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">True</property>
<property name="xalign">0</property> <property name="tooltip_text" translatable="yes">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.</property>
<property name="yalign">0</property> <property name="text" translatable="yes">0</property>
<property name="xscale">0</property> <property name="truncate_multiline">True</property>
<property name="yscale">0</property> <property name="adjustment">adj-phys-id</property>
<property name="left_padding">12</property> <property name="snap_to_ticks">True</property>
<child> <property name="numeric">True</property>
<object class="GtkSpinButton"> <property name="wrap">True</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes">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.</property>
<property name="text" translatable="yes">0</property>
<property name="truncate_multiline">True</property>
<property name="adjustment">adj-phys-id</property>
<property name="snap_to_ticks">True</property>
<property name="numeric">True</property>
<property name="wrap">True</property>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Physics ID</property>
</object> </object>
</child> </child>
</object> </object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child> </child>
<child> <child type="label">
<object class="GtkFrame"> <object class="GtkLabel">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">This field overrides the Landscape value, since Marathon 1 used that field for the music number.</property> <property name="label" translatable="yes">Physics ID</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<property name="xscale">0</property>
<property name="yscale">0</property>
<property name="left_padding">12</property>
<child>
<object class="GtkSpinButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="text" translatable="yes">0</property>
<property name="truncate_multiline">True</property>
<property name="adjustment">adj-phys-id</property>
<property name="snap_to_ticks">True</property>
<property name="numeric">True</property>
<property name="wrap">True</property>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Song ID</property>
</object>
</child>
</object> </object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child> </child>
</object> </object>
<packing> <packing>
@ -734,6 +679,7 @@ Author: Alison Sanderson
<object class="GtkFrame"> <object class="GtkFrame">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">These flags were added by Aleph One but are hidden and probably not meant to be used.</property>
<property name="label_xalign">0</property> <property name="label_xalign">0</property>
<property name="shadow_type">in</property> <property name="shadow_type">in</property>
<child> <child>
@ -799,7 +745,7 @@ Author: Alison Sanderson
<object class="GtkLabel"> <object class="GtkLabel">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="label" translatable="yes">Aleph Mission Flags</property> <property name="label" translatable="yes">Hidden Mission Flags</property>
</object> </object>
</child> </child>
</object> </object>
@ -813,6 +759,7 @@ Author: Alison Sanderson
<object class="GtkFrame"> <object class="GtkFrame">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">These flags were added by Aleph One but are hidden and probably not meant to be used.</property>
<property name="label_xalign">0</property> <property name="label_xalign">0</property>
<property name="shadow_type">in</property> <property name="shadow_type">in</property>
<child> <child>
@ -938,7 +885,7 @@ Author: Alison Sanderson
<object class="GtkLabel"> <object class="GtkLabel">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="label" translatable="yes">Aleph Environment Flags</property> <property name="label" translatable="yes">Hidden Environment Flags</property>
</object> </object>
</child> </child>
</object> </object>
@ -1132,44 +1079,6 @@ Author: Alison Sanderson
</object> </object>
</child> </child>
</object> </object>
<object class="GtkWindow" id="win-first-start">
<property name="can_focus">False</property>
<property name="title" translatable="yes">First Startup</property>
<property name="resizable">False</property>
<child>
<object class="GtkAlignment">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="top_padding">10</property>
<property name="bottom_padding">10</property>
<property name="left_padding">10</property>
<property name="right_padding">10</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">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</property>
<property name="angle">4</property>
</object>
</child>
</object>
</child>
<style>
<class name="first-start-window"/>
</style>
</object>
<object class="GtkWindow" id="win-main"> <object class="GtkWindow" id="win-main">
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="title" translatable="yes">Tycho</property> <property name="title" translatable="yes">Tycho</property>

View File

@ -110,7 +110,8 @@ fn get_obj<T>(b: &gtk::Builder, name: &str) -> T
fn main() -> ResultS<()> fn main() -> ResultS<()>
{ {
// get jacked, punk. opaque data structures are for nerds. // 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 // first we create the static resource header, which is really simple
let mut static_resource = let mut static_resource =