rozinante
parent
1d057d66af
commit
892efbdb13
|
@ -52,5 +52,6 @@
|
|||
#[macro_use]
|
||||
pub mod durandal;
|
||||
pub mod marathon;
|
||||
pub mod rozinante;
|
||||
|
||||
// EOF
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
//! Color presets.
|
||||
|
||||
use crate::durandal::image::Color16;
|
||||
|
||||
pub const CR_RED: Color16 = Color16::new(0xFFFF, 0, 0);
|
||||
pub const CR_DARK_RED: Color16 = Color16::new(0x4700, 0, 0);
|
||||
|
||||
// EOF
|
|
@ -1,4 +1,6 @@
|
|||
use maraiah::durandal::image::*;
|
||||
//! GUI drawing capabilities.
|
||||
|
||||
use crate::durandal::image::Color;
|
||||
|
||||
pub trait CacheImage
|
||||
{
|
||||
|
@ -15,7 +17,7 @@ pub trait DrawArea
|
|||
|
||||
fn clear(&self, cr: impl Color);
|
||||
fn rect(&self, rect: Rect, cr: impl Color);
|
||||
fn text(&self, pos: Point, cr: impl Color, text: &str);
|
||||
fn text(&self, pos: Point, text: &str, cr: impl Color);
|
||||
fn image(&self, pos: Point, im: &Self::NativeImage);
|
||||
}
|
||||
|
||||
|
@ -25,7 +27,4 @@ pub type Point = (Coord, Coord);
|
|||
#[derive(Copy, Clone, Debug)]
|
||||
pub struct Rect {pub x: Coord, pub y: Coord, pub w: Coord, pub h: Coord}
|
||||
|
||||
pub const CR_RED: Color16 = Color16::new(0xFFFF, 0, 0);
|
||||
pub const CR_DARK_RED: Color16 = Color16::new(0x4700, 0, 0);
|
||||
|
||||
// EOF
|
|
@ -0,0 +1,6 @@
|
|||
//! Library for GUI programs.
|
||||
|
||||
pub mod color;
|
||||
pub mod draw;
|
||||
|
||||
// EOF
|
|
@ -1,5 +1,6 @@
|
|||
use crate::stoneage::*;
|
||||
use maraiah::durandal::image::*;
|
||||
use maraiah::marathon::*;
|
||||
use maraiah::rozinante::{color::*, draw::*};
|
||||
|
||||
pub fn draw_map_none<D, I>(d: &D, im: &I)
|
||||
where D: DrawArea<NativeImage = I>,
|
||||
|
@ -10,10 +11,30 @@ pub fn draw_map_none<D, I>(d: &D, im: &I)
|
|||
d.image((d.w() / 2 - im.w() / 2, d.h() / 2 - im.h() / 2), im);
|
||||
|
||||
d.rect(Rect{x: 0, y: 0, w: d.w(), h: 18}, CR_DARK_RED);
|
||||
d.text((4, 14), CR_RED, "Map Required To Proceed");
|
||||
d.text((4, 14), "Map Required To Proceed", CR_RED);
|
||||
|
||||
d.rect(Rect{x: 0, y: d.h() - 18, w: d.w(), h: 18}, CR_DARK_RED);
|
||||
d.text((4, d.h() - 4), CR_RED, "CAS.qterm//CyberAcme Systems Inc.");
|
||||
d.text((4, d.h() - 4), "CAS.qterm//CyberAcme Systems Inc.", CR_RED);
|
||||
}
|
||||
|
||||
pub fn new_map() -> MapState
|
||||
{
|
||||
let info = Default::default();
|
||||
|
||||
let ed = EditorState{};
|
||||
let ma = MapState{ed, info};
|
||||
|
||||
ma
|
||||
}
|
||||
|
||||
pub struct EditorState
|
||||
{
|
||||
}
|
||||
|
||||
pub struct MapState
|
||||
{
|
||||
ed: EditorState,
|
||||
info: map::Minf,
|
||||
}
|
||||
|
||||
// EOF
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
mod hiddenprotocol;
|
||||
mod noroom;
|
||||
mod stoneage;
|
||||
|
||||
use crate::hiddenprotocol::*;
|
||||
use crate::noroom::*;
|
||||
|
@ -21,7 +20,7 @@ fn mk_draw_area(b: >k::Builder)
|
|||
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");
|
||||
let im = CairoPixbuf(load_img("/net/greyserv/maraiah/tycho/tycho1"));
|
||||
|
||||
area.connect_draw(move |area, cr| {
|
||||
let w = f64::from(area.get_allocated_width());
|
||||
|
@ -90,7 +89,7 @@ fn get_obj<T>(b: >k::Builder, name: &str) -> T
|
|||
fn main() -> ResultS<()>
|
||||
{
|
||||
// get jacked, punk. opaque data structures are for nerds.
|
||||
const RESOURCE_DATA: &'static [u8] = include_bytes!("data/tycho.res");
|
||||
const RESOURCE_DATA: &[u8] = include_bytes!("data/tycho.res");
|
||||
|
||||
let mut static_resource =
|
||||
gio_sys::GStaticResource{data: RESOURCE_DATA.as_ptr(),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::stoneage::*;
|
||||
use maraiah::rozinante::draw::*;
|
||||
use maraiah::durandal::image::*;
|
||||
|
||||
fn flt_color(cr: impl Color) -> (f64, f64, f64)
|
||||
|
@ -8,10 +8,10 @@ fn flt_color(cr: impl Color) -> (f64, f64, f64)
|
|||
(flt_color(cr.r()), flt_color(cr.g()), flt_color(cr.b()))
|
||||
}
|
||||
|
||||
impl CacheImage for gdk_pixbuf::Pixbuf
|
||||
impl CacheImage for CairoPixbuf
|
||||
{
|
||||
fn w(&self) -> Coord {self.get_width() as Coord}
|
||||
fn h(&self) -> Coord {self.get_height() as Coord}
|
||||
fn w(&self) -> Coord {self.0.get_width() as Coord}
|
||||
fn h(&self) -> Coord {self.0.get_height() as Coord}
|
||||
}
|
||||
|
||||
impl CairoDrawArea
|
||||
|
@ -24,7 +24,7 @@ impl CairoDrawArea
|
|||
|
||||
impl DrawArea for CairoDrawArea
|
||||
{
|
||||
type NativeImage = gdk_pixbuf::Pixbuf;
|
||||
type NativeImage = CairoPixbuf;
|
||||
|
||||
fn w(&self) -> Coord {self.w}
|
||||
fn h(&self) -> Coord {self.h}
|
||||
|
@ -53,7 +53,7 @@ impl DrawArea for CairoDrawArea
|
|||
self.ctx.fill();
|
||||
}
|
||||
|
||||
fn text(&self, pos: Point, cr: impl Color, text: &str)
|
||||
fn text(&self, pos: Point, text: &str, cr: impl Color)
|
||||
{
|
||||
let (r, g, b) = flt_color(cr);
|
||||
|
||||
|
@ -65,11 +65,13 @@ impl DrawArea for CairoDrawArea
|
|||
fn image(&self, pos: Point, im: &Self::NativeImage)
|
||||
{
|
||||
use gdk::prelude::*;
|
||||
self.ctx.set_source_pixbuf(im, f64::from(pos.0), f64::from(pos.1));
|
||||
self.ctx.set_source_pixbuf(&im.0, f64::from(pos.0), f64::from(pos.1));
|
||||
self.ctx.paint();
|
||||
}
|
||||
}
|
||||
|
||||
pub struct CairoPixbuf(pub gdk_pixbuf::Pixbuf);
|
||||
|
||||
pub struct CairoDrawArea
|
||||
{
|
||||
ctx: cairo::Context,
|
||||
|
|
Loading…
Reference in New Issue