Maraiah/source/tycho/editor.rs

71 lines
1.5 KiB
Rust

//! 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 MapEditorState
{
/// Creates a new empty map.
pub fn new() -> MapEditorState
{
MapEditorState::default()
}
/// Draws the "no map" screen.
pub fn draw_none<D, I>(d: &D, im: &I)
where D: DrawArea<NativeImage = I>,
I: CacheImage
{
d.clear(Color16::new(0, 0, 0));
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), "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), "CAS.qterm//CyberAcme Systems Inc.", CR_RED);
}
/// Draws the currently open map.
pub fn draw_some(&self, d: &impl DrawArea)
{
d.clear(Color16::new(0, 0, 0));
}
}
impl Default for Tool
{
fn default() -> Tool {Tool::Points}
}
/// Copyable map state.
#[derive(Clone, Default)]
pub struct MapEditorStateBlock
{
info: map::Minf,
}
/// The state of a map editor.
#[derive(Default)]
pub struct MapEditorState
{
edit_stack: Vec<MapEditorStateBlock>,
tool: Tool,
}
/// A tool in the map editor.
pub enum Tool
{
Points,
Lines,
Polygons,
}
// EOF