move editor to rozinante
parent
b427f4c99d
commit
d56b3db1fe
|
@ -50,6 +50,11 @@ impl CStringVec
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for CStringVec
|
||||
{
|
||||
fn default() -> Self {Self::new()}
|
||||
}
|
||||
|
||||
/// An owned null-terminated string vector.
|
||||
#[derive(Debug)]
|
||||
pub struct CStringVec
|
||||
|
|
|
@ -2,5 +2,6 @@
|
|||
|
||||
pub mod color;
|
||||
pub mod draw;
|
||||
pub mod editor;
|
||||
|
||||
// EOF
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
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);
|
||||
pub const RED: Color16 = Color16::new(0xFFFF, 0, 0);
|
||||
pub const DARK_RED: Color16 = Color16::new(0x4700, 0, 0);
|
||||
|
||||
// EOF
|
||||
|
|
|
@ -4,9 +4,11 @@
|
|||
//! state and human interactions with it, but is otherwise not permitted to
|
||||
//! directly edit it.
|
||||
|
||||
use maraiah::{durandal::image::*,
|
||||
marathon::map,
|
||||
rozinante::{color::*, draw::*}};
|
||||
pub mod block;
|
||||
pub mod state;
|
||||
|
||||
use crate::durandal::image::*;
|
||||
use super::{color, draw::*};
|
||||
|
||||
impl MapEditor
|
||||
{
|
||||
|
@ -21,7 +23,7 @@ impl MapEditor
|
|||
#[inline]
|
||||
pub fn open_new(&mut self)
|
||||
{
|
||||
*self = MapEditor::Opened(MapEditorState::default());
|
||||
*self = MapEditor::Opened(state::State::default());
|
||||
}
|
||||
|
||||
/// Draws the screen for this editor state.
|
||||
|
@ -43,21 +45,20 @@ impl MapEditor
|
|||
|
||||
d.image((dw / 2 - iw / 2, dh / 2 - ih / 2), im);
|
||||
|
||||
d.rect(Rect{x: 0, y: 0, w: dw, h: 18}, CR_DARK_RED);
|
||||
d.text((4, 14), tx_top, CR_RED);
|
||||
d.rect(Rect{x: 0, y: 0, w: dw, h: 18}, color::DARK_RED);
|
||||
d.text((4, 14), tx_top, color::RED);
|
||||
|
||||
d.rect(Rect{x: 0, y: dh - 18, w: dw, h: 18}, CR_DARK_RED);
|
||||
d.text((4, dh - 4), tx_bot, CR_RED);
|
||||
d.rect(Rect{x: 0, y: dh - 18, w: dw, h: 18}, color::DARK_RED);
|
||||
d.text((4, dh - 4), tx_bot, color::RED);
|
||||
}
|
||||
MapEditor::Opened(st) => {
|
||||
d.clear(Color16::new(0, 0, 0));
|
||||
d.text((dw/2, dh/2), &format!("tool: {:?}", st.tool), CR_RED);
|
||||
d.text((dw/2, dh/2), &format!("tool: {:?}", st.tool), color::RED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns `true` if `self` is closed.
|
||||
#[allow(dead_code)]
|
||||
#[inline]
|
||||
pub fn is_closed(&self) -> bool
|
||||
{
|
||||
|
@ -68,7 +69,6 @@ impl MapEditor
|
|||
}
|
||||
|
||||
/// Returns `true` if `self` is opened.
|
||||
#[allow(dead_code)]
|
||||
#[inline]
|
||||
pub fn is_opened(&self) -> bool
|
||||
{
|
||||
|
@ -79,40 +79,17 @@ impl MapEditor
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for Tool
|
||||
impl Default for MapEditor
|
||||
{
|
||||
fn default() -> Tool {Tool::Points}
|
||||
}
|
||||
|
||||
/// Copyable map state.
|
||||
#[derive(Clone, Default)]
|
||||
pub struct MapEditorStateBlock
|
||||
{
|
||||
info: map::Minf,
|
||||
}
|
||||
|
||||
/// The state of an opened map editor.
|
||||
#[derive(Default)]
|
||||
pub struct MapEditorState
|
||||
{
|
||||
edit_stack: Vec<MapEditorStateBlock>,
|
||||
tool: Tool,
|
||||
#[inline]
|
||||
fn default() -> Self {Self::new_closed()}
|
||||
}
|
||||
|
||||
/// An entire map editor, which may be opened or closed.
|
||||
pub enum MapEditor
|
||||
{
|
||||
Closed,
|
||||
Opened(MapEditorState),
|
||||
}
|
||||
|
||||
/// A tool in the map editor.
|
||||
#[derive(Debug)]
|
||||
pub enum Tool
|
||||
{
|
||||
Points,
|
||||
Lines,
|
||||
Polygons,
|
||||
Opened(state::State),
|
||||
}
|
||||
|
||||
// EOF
|
|
@ -0,0 +1,19 @@
|
|||
use crate::marathon::map;
|
||||
|
||||
impl Default for Block
|
||||
{
|
||||
#[inline]
|
||||
fn default() -> Self
|
||||
{
|
||||
Self{info: map::Minf::default()}
|
||||
}
|
||||
}
|
||||
|
||||
/// Copyable map state.
|
||||
#[derive(Clone)]
|
||||
pub struct Block
|
||||
{
|
||||
info: map::Minf,
|
||||
}
|
||||
|
||||
// EOF
|
|
@ -0,0 +1,48 @@
|
|||
use super::block;
|
||||
|
||||
impl State
|
||||
{
|
||||
fn cur_block(&self) -> &block::Block
|
||||
{
|
||||
self.blocks.last().unwrap()
|
||||
}
|
||||
|
||||
fn cur_block_mut(&mut self) -> &mut block::Block
|
||||
{
|
||||
self.blocks.last_mut().unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for State
|
||||
{
|
||||
#[inline]
|
||||
fn default() -> Self
|
||||
{
|
||||
Self{blocks: vec![block::Block::default()],
|
||||
tool: Tool::default()}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Tool
|
||||
{
|
||||
#[inline]
|
||||
fn default() -> Self {Tool::Points}
|
||||
}
|
||||
|
||||
/// The state of an opened map editor.
|
||||
pub struct State
|
||||
{
|
||||
pub(super) blocks: Vec<block::Block>,
|
||||
pub(super) tool: Tool,
|
||||
}
|
||||
|
||||
/// A tool in the map editor.
|
||||
#[derive(Debug)]
|
||||
pub(super) enum Tool
|
||||
{
|
||||
Points,
|
||||
Lines,
|
||||
Polygons,
|
||||
}
|
||||
|
||||
// EOF
|
|
@ -1,4 +1,3 @@
|
|||
mod editor;
|
||||
mod interfaces;
|
||||
|
||||
use crate::interfaces::*;
|
||||
|
@ -8,10 +7,10 @@ use gio_sys::*;
|
|||
use glib_sys::*;
|
||||
use gobject_sys::*;
|
||||
use gtk_sys::*;
|
||||
use maraiah::{c_str, durandal::ffi};
|
||||
use maraiah::{c_str, durandal::ffi, rozinante::editor};
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
|
||||
/// Called whne the application activates in order to set everything up.
|
||||
/// Called when the application activates in order to set everything up.
|
||||
unsafe extern "C" fn app_activate(app: *mut GtkApplication, edit: gpointer)
|
||||
{
|
||||
// this ref will be cloned around a bit, but will ultimately be dropped at
|
||||
|
|
Loading…
Reference in New Issue