Maraiah/source/rozinante/editor/state.rs

51 lines
733 B
Rust

//! Map editor state.
use super::block;
impl OpenMap
{
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 OpenMap
{
#[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 OpenMap
{
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