//! Main map editor module. //! //! The entry point is responsible for maintaining the lifetime of the editor //! state and human interactions with it, but is otherwise not permitted to //! directly edit it. use maraiah::{durandal::image::*, marathon::map, rozinante::{color::*, draw::*}}; impl MapEditor { /// Creates a closed map editor. #[inline] pub const fn new_closed() -> Self { MapEditor::Closed } /// Creates a new empty map. #[inline] pub fn new_opened() -> Self { MapEditor::Opened(MapEditorState::default()) } /// Draws the screen for this editor state. pub fn draw(&self, d: &D, im: &I) where D: DrawArea, I: CacheImage { match self { MapEditor::Closed => { d.clear(Color16::new(0, 0, 0)); d.image((d.w() / 2 - im.w() / 2, d.h() / 2 - im.h() / 2), im); let text = "Map Required To Proceed"; d.rect(Rect{x: 0, y: 0, w: d.w(), h: 18}, CR_DARK_RED); d.text((4, 14), text, CR_RED); let text = "CAS.qterm//CyberAcme Systems Inc."; d.rect(Rect{x: 0, y: d.h() - 18, w: d.w(), h: 18}, CR_DARK_RED); d.text((4, d.h() - 4), text, CR_RED); } MapEditor::Opened(_st) => { d.clear(Color16::new(0, 0, 0)); } } } /// Returns `true` if `self` is closed. #[inline] pub fn is_closed(&self) -> bool { match self { MapEditor::Closed => true, MapEditor::Opened(_) => false, } } /// Returns `true` if `self` is opened. #[inline] pub fn is_opened(&self) -> bool { match self { MapEditor::Closed => false, MapEditor::Opened(_) => true, } } } impl Default for Tool { 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, tool: Tool, } /// An entire map editor, which may be opened or closed. pub enum MapEditor { Closed, Opened(MapEditorState), } /// A tool in the map editor. pub enum Tool { Points, Lines, Polygons, } // EOF