From b9e1a3d3f6099700d230eff91990ba03a4b3aaa8 Mon Sep 17 00:00:00 2001 From: Marrub Date: Sat, 2 Mar 2019 18:26:55 -0500 Subject: [PATCH] move sources to source/ --- Cargo.toml | 4 +- {src => source}/durandal/bin.rs | 0 {src => source}/durandal/cenum.rs | 0 {src => source}/durandal/crc.rs | 0 {src => source}/durandal/err.rs | 0 {src => source}/durandal/file.rs | 0 {src => source}/durandal/fixed.rs | 0 {src => source}/durandal/image.rs | 0 {src => source}/durandal/mod.rs | 0 {src => source}/durandal/sound.rs | 0 {src => source}/durandal/text.rs | 0 {src => source}/leela/Cargo.toml | 0 {src => source}/leela/main.rs | 0 {src => source}/lib.rs | 0 {src => source}/marathon/machdr.rs | 0 {src => source}/marathon/map.rs | 0 {src => source}/marathon/mod.rs | 0 {src => source}/marathon/phy.rs | 0 {src => source}/marathon/pict.rs | 0 {src => source}/marathon/shp.rs | 0 {src => source}/marathon/snd.rs | 0 {src => source}/marathon/trm.rs | 0 {src => source}/marathon/wad.rs | 0 {src => source}/marathon/xfer.rs | 0 {src => source}/tycho/Cargo.toml | 0 {src => source}/tycho/build.rs | 0 {src => source}/tycho/data/icons.psd | Bin {src => source}/tycho/data/lines.png | Bin {src => source}/tycho/data/points.png | Bin {src => source}/tycho/data/polys.png | Bin {src => source}/tycho/data/tycho.xml | 0 {src => source}/tycho/data/tycho1.png | Bin {src => source}/tycho/data/tycho2.png | Bin {src => source}/tycho/data/tycho_res.xml | 0 source/tycho/hiddenprotocol.rs | 20 +++ source/tycho/main.rs | 173 +++++++++++++++++++++++ source/tycho/noroom.rs | 65 +++++++++ source/tycho/stoneage.rs | 73 ++++++++++ src/tycho/buttons.rs | 48 ------- src/tycho/main.rs | 72 ---------- src/tycho/map_draw.rs | 71 ---------- src/tycho/windows.rs | 39 ----- 42 files changed, 333 insertions(+), 232 deletions(-) rename {src => source}/durandal/bin.rs (100%) rename {src => source}/durandal/cenum.rs (100%) rename {src => source}/durandal/crc.rs (100%) rename {src => source}/durandal/err.rs (100%) rename {src => source}/durandal/file.rs (100%) rename {src => source}/durandal/fixed.rs (100%) rename {src => source}/durandal/image.rs (100%) rename {src => source}/durandal/mod.rs (100%) rename {src => source}/durandal/sound.rs (100%) rename {src => source}/durandal/text.rs (100%) rename {src => source}/leela/Cargo.toml (100%) rename {src => source}/leela/main.rs (100%) rename {src => source}/lib.rs (100%) rename {src => source}/marathon/machdr.rs (100%) rename {src => source}/marathon/map.rs (100%) rename {src => source}/marathon/mod.rs (100%) rename {src => source}/marathon/phy.rs (100%) rename {src => source}/marathon/pict.rs (100%) rename {src => source}/marathon/shp.rs (100%) rename {src => source}/marathon/snd.rs (100%) rename {src => source}/marathon/trm.rs (100%) rename {src => source}/marathon/wad.rs (100%) rename {src => source}/marathon/xfer.rs (100%) rename {src => source}/tycho/Cargo.toml (100%) rename {src => source}/tycho/build.rs (100%) rename {src => source}/tycho/data/icons.psd (100%) rename {src => source}/tycho/data/lines.png (100%) rename {src => source}/tycho/data/points.png (100%) rename {src => source}/tycho/data/polys.png (100%) rename {src => source}/tycho/data/tycho.xml (100%) rename {src => source}/tycho/data/tycho1.png (100%) rename {src => source}/tycho/data/tycho2.png (100%) rename {src => source}/tycho/data/tycho_res.xml (100%) create mode 100644 source/tycho/hiddenprotocol.rs create mode 100644 source/tycho/main.rs create mode 100644 source/tycho/noroom.rs create mode 100644 source/tycho/stoneage.rs delete mode 100644 src/tycho/buttons.rs delete mode 100644 src/tycho/main.rs delete mode 100644 src/tycho/map_draw.rs delete mode 100644 src/tycho/windows.rs diff --git a/Cargo.toml b/Cargo.toml index 6716f09..ce934b8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ edition = "2018" publish = false [workspace] -members = ["src/leela", "src/tycho"] +members = ["source/leela", "source/tycho"] [dependencies] bitflags = "1.0" @@ -28,4 +28,4 @@ lto = true [lib] name = "maraiah" -path = "src/lib.rs" +path = "source/lib.rs" diff --git a/src/durandal/bin.rs b/source/durandal/bin.rs similarity index 100% rename from src/durandal/bin.rs rename to source/durandal/bin.rs diff --git a/src/durandal/cenum.rs b/source/durandal/cenum.rs similarity index 100% rename from src/durandal/cenum.rs rename to source/durandal/cenum.rs diff --git a/src/durandal/crc.rs b/source/durandal/crc.rs similarity index 100% rename from src/durandal/crc.rs rename to source/durandal/crc.rs diff --git a/src/durandal/err.rs b/source/durandal/err.rs similarity index 100% rename from src/durandal/err.rs rename to source/durandal/err.rs diff --git a/src/durandal/file.rs b/source/durandal/file.rs similarity index 100% rename from src/durandal/file.rs rename to source/durandal/file.rs diff --git a/src/durandal/fixed.rs b/source/durandal/fixed.rs similarity index 100% rename from src/durandal/fixed.rs rename to source/durandal/fixed.rs diff --git a/src/durandal/image.rs b/source/durandal/image.rs similarity index 100% rename from src/durandal/image.rs rename to source/durandal/image.rs diff --git a/src/durandal/mod.rs b/source/durandal/mod.rs similarity index 100% rename from src/durandal/mod.rs rename to source/durandal/mod.rs diff --git a/src/durandal/sound.rs b/source/durandal/sound.rs similarity index 100% rename from src/durandal/sound.rs rename to source/durandal/sound.rs diff --git a/src/durandal/text.rs b/source/durandal/text.rs similarity index 100% rename from src/durandal/text.rs rename to source/durandal/text.rs diff --git a/src/leela/Cargo.toml b/source/leela/Cargo.toml similarity index 100% rename from src/leela/Cargo.toml rename to source/leela/Cargo.toml diff --git a/src/leela/main.rs b/source/leela/main.rs similarity index 100% rename from src/leela/main.rs rename to source/leela/main.rs diff --git a/src/lib.rs b/source/lib.rs similarity index 100% rename from src/lib.rs rename to source/lib.rs diff --git a/src/marathon/machdr.rs b/source/marathon/machdr.rs similarity index 100% rename from src/marathon/machdr.rs rename to source/marathon/machdr.rs diff --git a/src/marathon/map.rs b/source/marathon/map.rs similarity index 100% rename from src/marathon/map.rs rename to source/marathon/map.rs diff --git a/src/marathon/mod.rs b/source/marathon/mod.rs similarity index 100% rename from src/marathon/mod.rs rename to source/marathon/mod.rs diff --git a/src/marathon/phy.rs b/source/marathon/phy.rs similarity index 100% rename from src/marathon/phy.rs rename to source/marathon/phy.rs diff --git a/src/marathon/pict.rs b/source/marathon/pict.rs similarity index 100% rename from src/marathon/pict.rs rename to source/marathon/pict.rs diff --git a/src/marathon/shp.rs b/source/marathon/shp.rs similarity index 100% rename from src/marathon/shp.rs rename to source/marathon/shp.rs diff --git a/src/marathon/snd.rs b/source/marathon/snd.rs similarity index 100% rename from src/marathon/snd.rs rename to source/marathon/snd.rs diff --git a/src/marathon/trm.rs b/source/marathon/trm.rs similarity index 100% rename from src/marathon/trm.rs rename to source/marathon/trm.rs diff --git a/src/marathon/wad.rs b/source/marathon/wad.rs similarity index 100% rename from src/marathon/wad.rs rename to source/marathon/wad.rs diff --git a/src/marathon/xfer.rs b/source/marathon/xfer.rs similarity index 100% rename from src/marathon/xfer.rs rename to source/marathon/xfer.rs diff --git a/src/tycho/Cargo.toml b/source/tycho/Cargo.toml similarity index 100% rename from src/tycho/Cargo.toml rename to source/tycho/Cargo.toml diff --git a/src/tycho/build.rs b/source/tycho/build.rs similarity index 100% rename from src/tycho/build.rs rename to source/tycho/build.rs diff --git a/src/tycho/data/icons.psd b/source/tycho/data/icons.psd similarity index 100% rename from src/tycho/data/icons.psd rename to source/tycho/data/icons.psd diff --git a/src/tycho/data/lines.png b/source/tycho/data/lines.png similarity index 100% rename from src/tycho/data/lines.png rename to source/tycho/data/lines.png diff --git a/src/tycho/data/points.png b/source/tycho/data/points.png similarity index 100% rename from src/tycho/data/points.png rename to source/tycho/data/points.png diff --git a/src/tycho/data/polys.png b/source/tycho/data/polys.png similarity index 100% rename from src/tycho/data/polys.png rename to source/tycho/data/polys.png diff --git a/src/tycho/data/tycho.xml b/source/tycho/data/tycho.xml similarity index 100% rename from src/tycho/data/tycho.xml rename to source/tycho/data/tycho.xml diff --git a/src/tycho/data/tycho1.png b/source/tycho/data/tycho1.png similarity index 100% rename from src/tycho/data/tycho1.png rename to source/tycho/data/tycho1.png diff --git a/src/tycho/data/tycho2.png b/source/tycho/data/tycho2.png similarity index 100% rename from src/tycho/data/tycho2.png rename to source/tycho/data/tycho2.png diff --git a/src/tycho/data/tycho_res.xml b/source/tycho/data/tycho_res.xml similarity index 100% rename from src/tycho/data/tycho_res.xml rename to source/tycho/data/tycho_res.xml diff --git a/source/tycho/hiddenprotocol.rs b/source/tycho/hiddenprotocol.rs new file mode 100644 index 0000000..b0bd036 --- /dev/null +++ b/source/tycho/hiddenprotocol.rs @@ -0,0 +1,20 @@ +use crate::stoneage::*; + +pub fn draw_map_none(d: &impl DrawArea) +{ + // TODO: draw middle image + + // draw top border (these are separate so the bottom draws over the top) + d.rect(Rect{x: 0, y: 0, w: d.w(), h: 18}, CR_DARK_RED); + + // draw top text + d.text((4, 14), CR_RED, "Map Required To Proceed"); + + // draw bottom border + d.rect(Rect{x: 0, y: d.h() - 18, w: d.w(), h: 18}, CR_DARK_RED); + + // draw bottom text + d.text((4, d.h() - 4), CR_RED, "CAS.qterm//CyberAcme Systems Inc."); +} + +// EOF diff --git a/source/tycho/main.rs b/source/tycho/main.rs new file mode 100644 index 0000000..1982d6e --- /dev/null +++ b/source/tycho/main.rs @@ -0,0 +1,173 @@ +mod hiddenprotocol; +mod noroom; +mod stoneage; + +use crate::hiddenprotocol::*; +use crate::noroom::*; +use crate::stoneage::*; +//use gdk::prelude::*; +use gio::prelude::*; +use gtk::prelude::*; +use maraiah::durandal::err::*; +use maraiah::durandal::image::*; + +fn hide_on_delete(win: >k::Window, _: &gdk::Event) -> Inhibit +{ + win.hide(); + Inhibit(true) +} + +fn mk_draw_area(b: >k::Builder) +{ + let area: gtk::DrawingArea = get_obj(b, "draw-area"); + + let ax: gtk::Adjustment = get_obj(b, "adj-map-horz"); + let ay: gtk::Adjustment = get_obj(b, "adj-map-vert"); + + area.connect_draw(move |area, cr| { + let w = f64::from(area.get_allocated_width()); + let h = f64::from(area.get_allocated_height()); + + ax.set_lower(0.0); + ax.set_upper(w); + + ay.set_lower(0.0); + ay.set_upper(h); + + let d = CairoDrawArea::new(cr.clone(), w, h); + + d.clear(Color16::new(0, 0, 0)); + draw_map_none(&d); + + Inhibit(true) + }); +} + +fn mk_win_map_tools(b: >k::Builder) +{ + let win: gtk::Window = get_obj(b, "win-map-tools"); + + win.connect_delete_event(hide_on_delete); +} + +fn mk_win_map_view(b: >k::Builder) +{ + let win: gtk::Window = get_obj(b, "win-map-view"); + + win.connect_delete_event(hide_on_delete); +} + +fn mk_win_about(b: >k::Builder) +{ + let win: gtk::AboutDialog = get_obj(b, "win-about"); + + win.set_authors(&env!("CARGO_PKG_AUTHORS").split(';').collect::>()); + win.set_version(env!("CARGO_PKG_VERSION")); + win.set_website(env!("CARGO_PKG_HOMEPAGE")); + win.set_logo(&load_img("/net/greyserv/maraiah/tycho/tycho2")); +} + +fn mk_win_main(b: >k::Builder, app: >k::Application) +{ + let win: gtk::Window = get_obj(b, "win-main"); + + win.set_application(app); + win.show_all(); +} + +fn mk_btn_quit(b: >k::Builder, app: gtk::Application) +{ + let btn: gtk::MenuItem = get_obj(b, "btn-quit"); + + btn.connect_activate(move |_| app.quit()); +} + +fn mk_btn_about(b: >k::Builder) +{ + let btn: gtk::MenuItem = get_obj(b, "btn-about"); + let win: gtk::AboutDialog = get_obj(b, "win-about"); + + btn.connect_activate(move |_| { + win.run(); + win.hide(); + }); +} + +fn mk_btn_show_map_view(b: >k::Builder) +{ + let btn: gtk::MenuItem = get_obj(b, "btn-show-map-view"); + let win: gtk::Window = get_obj(b, "win-map-view"); + + btn.connect_activate(move |_| win.show_all()); +} + +fn mk_btn_show_map_tools(b: >k::Builder) +{ + let btn: gtk::MenuItem = get_obj(b, "btn-show-map-tools"); + let win: gtk::Window = get_obj(b, "win-map-tools"); + + btn.connect_activate(move |_| win.show_all()); +} + +fn run_app(app: >k::Application) +{ + // one fallible call, which should never fail anyhow + let b = gtk::Builder::new_from_resource("/net/greyserv/maraiah/tycho/ui"); + + mk_btn_quit(&b, app.clone()); + mk_btn_about(&b); + mk_btn_show_map_view(&b); + mk_btn_show_map_tools(&b); + mk_draw_area(&b); + mk_win_map_tools(&b); + mk_win_map_view(&b); + mk_win_about(&b); + mk_win_main(&b, app); +} + +fn load_img(path: &'static str) -> gdk_pixbuf::Pixbuf +{ + gdk_pixbuf::Pixbuf::new_from_resource(path).unwrap() +} + +fn get_obj(b: >k::Builder, name: &str) -> T + where T: glib::object::IsA +{ + b.get_object(name).unwrap() +} + +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(run_app); + + 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 diff --git a/source/tycho/noroom.rs b/source/tycho/noroom.rs new file mode 100644 index 0000000..11379f3 --- /dev/null +++ b/source/tycho/noroom.rs @@ -0,0 +1,65 @@ +use crate::stoneage::*; +use maraiah::durandal::image::*; + +fn flt_color(cr: impl Color) -> (f64, f64, f64) +{ + fn flt_color(n: u16) -> f64 {f64::from(n) / f64::from(u16::max_value())} + + (flt_color(cr.r()), flt_color(cr.g()), flt_color(cr.b())) +} + +impl CairoDrawArea +{ + pub const fn new(ctx: cairo::Context, w: f64, h: f64) -> Self + { + CairoDrawArea{ctx, w: w as u32, h: h as u32} + } +} + +impl DrawArea for CairoDrawArea +{ + fn w(&self) -> u32 {self.w} + fn h(&self) -> u32 {self.h} + + fn clear(&self, cr: impl Color) + { + use cairo::{FontSlant, FontWeight}; + + self.rect(Rect{x: 0, y: 0, w: self.w(), h: self.h()}, cr); + + self.ctx.select_font_face("Sans", FontSlant::Normal, FontWeight::Normal); + self.ctx.set_font_size(14.0); + } + + fn rect(&self, rect: Rect, cr: impl Color) + { + let x1 = f64::from(rect.x); + let y1 = f64::from(rect.y); + let x2 = f64::from(rect.w) + x1; + let y2 = f64::from(rect.h) + y1; + + let (r, g, b) = flt_color(cr); + + self.ctx.set_source_rgb(r, g, b); + self.ctx.rectangle(x1, y1, x2, y2); + self.ctx.fill(); + } + + fn text(&self, pos: Point, cr: impl Color, text: &str) + { + let (r, g, b) = flt_color(cr); + + self.ctx.set_source_rgb(r, g, b); + self.ctx.move_to(f64::from(pos.0), f64::from(pos.1)); + self.ctx.show_text(text); + } +} + +pub struct CairoDrawArea +{ + ctx: cairo::Context, + w: u32, + h: u32, +} + +// EOF diff --git a/source/tycho/stoneage.rs b/source/tycho/stoneage.rs new file mode 100644 index 0000000..309d33f --- /dev/null +++ b/source/tycho/stoneage.rs @@ -0,0 +1,73 @@ +use maraiah::durandal::image::*; +use std::collections::HashMap; + +#[derive(Copy, Clone, Debug)] +pub struct Rect {pub x: u32, pub y: u32, pub w: u32, pub h: u32} + +pub type Point = (u32, u32); + +pub trait DrawArea +{ + fn w(&self) -> u32; + fn h(&self) -> u32; + + fn clear(&self, cr: impl Color); + fn rect(&self, rect: Rect, cr: impl Color); + fn text(&self, pos: Point, cr: impl Color, text: &str); +} + +pub trait Resource +{ + fn as_dir(&self) -> Option<&ResDir> {None} + fn as_file(&self) -> Option<&ResFile> {None} +} + +impl ResDir +{ + pub fn new() -> ResDir + { + ResDir{hash: HashMap::new()} + } + + pub fn insert(&mut self, name: &str, res: Box) + { + self.hash.insert(name.to_string(), res); + } + + pub fn get(&self, name: &str) -> Option<&Box> + { + self.hash.get(name) + } +} + +impl Resource for ResDir +{ + fn as_dir(&self) -> Option<&ResDir> {Some(self)} +} + +impl Resource for ResFile +{ + fn as_file(&self) -> Option<&ResFile> {Some(self)} +} + +pub struct ResDir +{ + hash: HashMap>, +} + +struct ResFile +{ +} + +pub const CR_RED: Color16 = Color16::new(0xFFFF, 0, 0); +pub const CR_DARK_RED: Color16 = Color16::new(0x4700, 0, 0); + +#[test] +fn resources() +{ + let mut top = ResDir::new(); + top.insert(":basic_sub:resource", Box::new(ResFile{})); + top.get(":basic_sub:resource").unwrap(); +} + +// EOF diff --git a/src/tycho/buttons.rs b/src/tycho/buttons.rs deleted file mode 100644 index e38e715..0000000 --- a/src/tycho/buttons.rs +++ /dev/null @@ -1,48 +0,0 @@ -fn mk_btn_new(b: >k::Builder) -{ - let btn: gtk::MenuItem = get_obj(b, "btn-new"); - let tools: gtk::Window = get_obj(b, "win-map-tools"); - let view: gtk::Window = get_obj(b, "win-map-view"); - - btn.connect_activate(move |_| { - // TODO: actually make a new document - tools.show_all(); - view.show_all(); - }); -} - -fn mk_btn_quit(b: >k::Builder, app: gtk::Application) -{ - let btn: gtk::MenuItem = get_obj(b, "btn-quit"); - - btn.connect_activate(move |_| app.quit()); -} - -fn mk_btn_about(b: >k::Builder) -{ - let btn: gtk::MenuItem = get_obj(b, "btn-about"); - let win: gtk::AboutDialog = get_obj(b, "win-about"); - - btn.connect_activate(move |_| { - win.run(); - win.hide(); - }); -} - -fn mk_btn_show_map_view(b: >k::Builder) -{ - let btn: gtk::MenuItem = get_obj(b, "btn-show-map-view"); - let win: gtk::Window = get_obj(b, "win-map-view"); - - btn.connect_activate(move |_| win.show_all()); -} - -fn mk_btn_show_map_tools(b: >k::Builder) -{ - let btn: gtk::MenuItem = get_obj(b, "btn-show-map-tools"); - let win: gtk::Window = get_obj(b, "win-map-tools"); - - btn.connect_activate(move |_| win.show_all()); -} - -// EOF diff --git a/src/tycho/main.rs b/src/tycho/main.rs deleted file mode 100644 index 54680c1..0000000 --- a/src/tycho/main.rs +++ /dev/null @@ -1,72 +0,0 @@ -use gdk::prelude::*; -use gio::prelude::*; -use gtk::prelude::*; -use maraiah::durandal::err::*; - -include!("windows.rs"); -include!("buttons.rs"); -include!("map_draw.rs"); - -fn run_app(app: >k::Application) -{ - // one fallible call, which should never fail anyhow - let b = gtk::Builder::new_from_resource("/net/greyserv/maraiah/tycho/ui"); - - mk_btn_new(&b); - mk_btn_quit(&b, app.clone()); - mk_btn_about(&b); - mk_btn_show_map_view(&b); - mk_btn_show_map_tools(&b); - mk_draw_area(&b); - mk_win_map_tools(&b); - mk_win_map_view(&b); - mk_win_about(&b); - mk_win_main(&b, app); -} - -fn load_img(path: &'static str) -> gdk_pixbuf::Pixbuf -{ - gdk_pixbuf::Pixbuf::new_from_resource(path).unwrap() -} - -fn get_obj(b: >k::Builder, name: &str) -> T - where T: glib::object::IsA -{ - b.get_object(name).unwrap() -} - -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(run_app); - - 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 diff --git a/src/tycho/map_draw.rs b/src/tycho/map_draw.rs deleted file mode 100644 index 626c3c5..0000000 --- a/src/tycho/map_draw.rs +++ /dev/null @@ -1,71 +0,0 @@ -fn draw_clear(cr: &cairo::Context, w: f64, h: f64) -{ - use cairo::{FontSlant, FontWeight}; - - // set up for text - cr.select_font_face("Sans", FontSlant::Normal, FontWeight::Normal); - cr.set_font_size(14.0); - - // clear view - cr.set_source_rgb(0.0, 0.0, 0.0); - cr.rectangle(0.0, 0.0, w, h); - cr.fill(); -} - -fn draw_map_none(cr: &cairo::Context, im: &gdk_pixbuf::Pixbuf, w: f64, h: f64) -{ - let im_w = f64::from(im.get_width()); - let im_h = f64::from(im.get_height()); - - // draw middle image - cr.set_source_pixbuf(im, w / 2.0 - im_w / 2.0, h / 2.0 - im_h / 2.0); - cr.paint(); - - // draw top border (these are separate so the bottom draws over the top) - cr.set_source_rgb(0.28, 0.0, 0.0); - cr.rectangle(0.0, 0.0, w, 18.0); - cr.fill(); - - // draw top text - cr.set_source_rgb(1.0, 0.0, 0.0); - cr.move_to(4.0, 14.0); - cr.show_text("Map Required To Proceed"); - - // draw bottom border - cr.set_source_rgb(0.28, 0.0, 0.0); - cr.rectangle(0.0, h - 18.0, w, h); - cr.fill(); - - // draw bottom text - cr.set_source_rgb(1.0, 0.0, 0.0); - cr.move_to(4.0, h - 4.0); - cr.show_text("CAS.qterm//CyberAcme Systems Inc."); -} - -fn mk_draw_area(b: >k::Builder) -{ - let area: gtk::DrawingArea = get_obj(b, "draw-area"); - - let ax: gtk::Adjustment = get_obj(b, "adj-map-horz"); - let ay: gtk::Adjustment = get_obj(b, "adj-map-vert"); - - let im = load_img("/net/greyserv/maraiah/tycho/tycho1"); - - area.connect_draw(move |area, cr| { - let w = f64::from(area.get_allocated_width()); - let h = f64::from(area.get_allocated_height()); - - ax.set_lower(0.0); - ax.set_upper(w); - - ay.set_lower(0.0); - ay.set_upper(h); - - draw_clear(&cr, w, h); - draw_map_none(&cr, &im, w, h); - - Inhibit(true) - }); -} - -// EOF diff --git a/src/tycho/windows.rs b/src/tycho/windows.rs deleted file mode 100644 index a995238..0000000 --- a/src/tycho/windows.rs +++ /dev/null @@ -1,39 +0,0 @@ -fn hide_on_delete(win: >k::Window, _: &gdk::Event) -> Inhibit -{ - win.hide(); - Inhibit(true) -} - -fn mk_win_map_tools(b: >k::Builder) -{ - let win: gtk::Window = get_obj(b, "win-map-tools"); - - win.connect_delete_event(hide_on_delete); -} - -fn mk_win_map_view(b: >k::Builder) -{ - let win: gtk::Window = get_obj(b, "win-map-view"); - - win.connect_delete_event(hide_on_delete); -} - -fn mk_win_about(b: >k::Builder) -{ - let win: gtk::AboutDialog = get_obj(b, "win-about"); - - win.set_authors(&env!("CARGO_PKG_AUTHORS").split(';').collect::>()); - win.set_version(env!("CARGO_PKG_VERSION")); - win.set_website(env!("CARGO_PKG_HOMEPAGE")); - win.set_logo(&load_img("/net/greyserv/maraiah/tycho/tycho2")); -} - -fn mk_win_main(b: >k::Builder, app: >k::Application) -{ - let win: gtk::Window = get_obj(b, "win-main"); - - win.set_application(app); - win.show_all(); -} - -// EOF