Compare commits

...

3 Commits

Author SHA1 Message Date
an 87bfe2869a move bin targets to workspace fragments 2019-02-25 15:27:05 -05:00
an 1371e6c7fa more code for tycho 2019-02-25 14:33:13 -05:00
an d9151a53dd begin work on Tycho 2019-02-25 07:06:11 -05:00
15 changed files with 542 additions and 8 deletions

1
.gitignore vendored
View File

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

View File

@ -11,15 +11,14 @@ license = "MIT"
edition = "2018"
publish = false
[workspace]
members = ["src/leela", "src/tycho"]
[dependencies]
argparse = "0.2"
bitflags = "1.0"
failure = "0.1"
generic-array = "0.12"
#gtk = "0.4"
memmap = "0.6"
serde = {version = "1.0", features = ["derive"]}
serde_yaml = "0.8"
[profile.dev]
opt-level = 1
@ -31,7 +30,3 @@ lto = true
[lib]
name = "maraiah"
path = "src/lib.rs"
[[bin]]
name = "leela"
path = "src/leela/main.rs"

18
src/leela/Cargo.toml Normal file
View File

@ -0,0 +1,18 @@
[package]
name = "maraiah-leela"
version = "0.1.0"
authors = ["Alison Sanderson <marrub@greyserv.net>"]
description = "Maraiah testbed program."
edition = "2018"
[dependencies]
argparse = "0.2"
maraiah = {path = "../.."}
memmap = "0.7"
serde = "1.0"
serde_yaml = "0.8"
[[bin]]
name = "leela"
path = "main.rs"

31
src/tycho/Cargo.toml Normal file
View File

@ -0,0 +1,31 @@
[package]
name = "maraiah-tycho"
version = "0.1.0"
authors = ["Alison Sanderson <marrub@greyserv.net>"]
description = "Tycho map editor."
edition = "2018"
build = "build.rs"
[dependencies]
maraiah = {path = "../.."}
# note: these have to be updated all at once, check the gtk crate for versions
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"
[[bin]]
name = "tycho"
path = "main.rs"

14
src/tycho/build.rs Normal file
View File

@ -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

BIN
src/tycho/data/icons.psd Normal file

Binary file not shown.

BIN
src/tycho/data/lines.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 B

BIN
src/tycho/data/points.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B

BIN
src/tycho/data/polys.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 538 B

BIN
src/tycho/data/tycho.res Normal file

Binary file not shown.

363
src/tycho/data/tycho.xml Normal file
View File

@ -0,0 +1,363 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1
The MIT License (MIT)
Copyright (c) 2018-2019 Alison Sanderson
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Author: Alison Sanderson
-->
<interface>
<requires lib="gtk+" version="3.10"/>
<!-- interface-license-type mit -->
<!-- interface-name Maraiah Tycho -->
<!-- interface-description Tycho map editor for Maraiah. -->
<!-- interface-copyright 2018-2019 Alison Sanderson -->
<!-- interface-authors Alison Sanderson -->
<object class="GtkImage" id="im_lines">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="resource">/net/greyserv/maraiah/tycho/lines</property>
</object>
<object class="GtkImage" id="im_points">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="resource">/net/greyserv/maraiah/tycho/points</property>
</object>
<object class="GtkImage" id="im_polys">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="resource">/net/greyserv/maraiah/tycho/polys</property>
</object>
<object class="GtkWindow" id="win_tools">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Tool Palette</property>
<property name="default_height">250</property>
<property name="skip_taskbar_hint">True</property>
<property name="has_resize_grip">True</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkToolPalette">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkToolItemGroup">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Geometry</property>
<child>
<object class="GtkToolButton" id="btn_point">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Points</property>
<property name="use_underline">True</property>
<property name="icon_widget">im_points</property>
<child internal-child="accessible">
<object class="AtkObject" id="btn_point-atkobject">
<property name="AtkObject::accessible-name" translatable="yes">Points Tool</property>
<property name="AtkObject::accessible-description" translatable="yes">The tool that modifies points in the map.</property>
<property name="AtkObject::accessible-role" translatable="yes">push-button</property>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="btn_lines">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Lines</property>
<property name="use_underline">True</property>
<property name="icon_widget">im_lines</property>
<child internal-child="accessible">
<object class="AtkObject" id="btn_lines-atkobject">
<property name="AtkObject::accessible-name" translatable="yes">Lines Tool</property>
<property name="AtkObject::accessible-description" translatable="yes">The tool which modifies line segments on the map.</property>
<property name="AtkObject::accessible-role" translatable="yes">push-button</property>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="btn_polys">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Polygons</property>
<property name="use_underline">True</property>
<property name="icon_widget">im_polys</property>
<child internal-child="accessible">
<object class="AtkObject" id="btn_polys-atkobject">
<property name="AtkObject::accessible-name" translatable="yes">Polygon Tool</property>
<property name="AtkObject::accessible-description" translatable="yes">The tool which modifies polygon shapes on the map.</property>
<property name="AtkObject::accessible-role" translatable="yes">push-button</property>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="position">2</property>
</packing>
</child>
<child internal-child="accessible">
<object class="AtkObject">
<property name="AtkObject::accessible-name" translatable="yes">Geometry Collection</property>
<property name="AtkObject::accessible-description" translatable="yes">All of the tools which modify map geometry.</property>
<property name="AtkObject::accessible-role" translatable="yes">column-header</property>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
</packing>
</child>
</object>
</child>
<child internal-child="accessible">
<object class="AtkObject" id="win_tools-atkobject">
<property name="AtkObject::accessible-name" translatable="yes">Tycho Tool Palette</property>
<property name="AtkObject::accessible-description" translatable="yes">Tycho's tool palette window.</property>
<property name="AtkObject::accessible-role" translatable="yes">window</property>
</object>
</child>
</object>
<object class="GtkAboutDialog" id="win_about">
<property name="can_focus">False</property>
<property name="modal">True</property>
<property name="destroy_with_parent">True</property>
<property name="type_hint">dialog</property>
<property name="program_name">Tycho Map Editor</property>
<property name="copyright" translatable="yes">Copyright © 2018-2019 Alison Sanderson</property>
<property name="comments" translatable="yes">greetigs i am tico the of superior ai to durdumbal go shoot my soldiers because its funny or ill put you in space</property>
<property name="website_label" translatable="yes">Home Page</property>
<property name="logo_icon_name">image-loading</property>
<property name="license_type">mit-x11</property>
<child>
<placeholder/>
</child>
<child internal-child="vbox">
<object class="GtkBox">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can_focus">False</property>
<property name="layout_style">end</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
<child internal-child="accessible">
<object class="AtkObject" id="win_about-atkobject">
<property name="AtkObject::accessible-name" translatable="yes">About Screen</property>
<property name="AtkObject::accessible-description" translatable="yes">The about screen for Tycho.</property>
<property name="AtkObject::accessible-role" translatable="yes">dialog</property>
</object>
</child>
</object>
<object class="GtkWindow" id="win_menus">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Tycho</property>
<property name="default_height">250</property>
<property name="has_resize_grip">True</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkMenuBar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pack_direction">ttb</property>
<child>
<object class="GtkMenuItem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_File</property>
<property name="use_underline">True</property>
<child type="submenu">
<object class="GtkMenu">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-new</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-open</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-save</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-save-as</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
<child>
<object class="GtkSeparatorMenuItem">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-quit</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkMenuItem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_Edit</property>
<property name="use_underline">True</property>
<child type="submenu">
<object class="GtkMenu">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-cut</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-copy</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-paste</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-delete</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkMenuItem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_View</property>
<property name="use_underline">True</property>
</object>
</child>
<child>
<object class="GtkSeparatorMenuItem">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
</child>
<child>
<object class="GtkMenuItem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="right_justified">True</property>
<property name="label" translatable="yes">_Info</property>
<property name="use_underline">True</property>
<child type="submenu">
<object class="GtkMenu">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImageMenuItem" id="btn_about">
<property name="label">gtk-about</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</interface>

BIN
src/tycho/data/tycho1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

BIN
src/tycho/data/tycho2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/net/greyserv/maraiah/tycho">
<file compressed="true" alias="tycho1">data/tycho1.png</file>
<file compressed="true" alias="tycho2">data/tycho2.png</file>
<file compressed="true" alias="polys">data/polys.png</file>
<file compressed="true" alias="lines">data/lines.png</file>
<file compressed="true" alias="points">data/points.png</file>
<file compressed="true" preprocess="xml-stripblanks" alias="ui">data/tycho.xml</file>
</gresource>
</gresources>

101
src/tycho/main.rs Normal file
View File

@ -0,0 +1,101 @@
use gtk::prelude::*;
use gio::prelude::*;
use maraiah::durandal::err::*;
fn run_app(app: &gtk::Application) -> ResultS<()>
{
fn load_img(path: &'static str) -> ResultS<gdk_pixbuf::Pixbuf>
{
Ok(gdk_pixbuf::Pixbuf::new_from_resource(path)?)
}
fn get_obj<T>(b: &gtk::Builder, name: &str) -> ResultS<T>
where T: glib::object::IsA<glib::object::Object>
{
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<()>
{
// get jacked, punk. opaque data structures are for nerds.
const RESOURCE_DATA: &'static [u8] = include_bytes!("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(|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::<&gtk::Window>,
gtk::DialogFlags::empty(),
gtk::MessageType::Error,
gtk::ButtonsType::Ok,
&format!("{:?}", e)).run();
}
}
});
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