pub mod deletion_tool; pub mod icon_tool; pub mod polygon_room_tool; pub mod rect_room_tool; pub mod wall_tool; pub use deletion_tool::DeletionTool; pub use icon_tool::IconTool; pub use polygon_room_tool::PolygonRoomTool; pub use rect_room_tool::RectRoomTool; pub use wall_tool::WallTool; use crate::button::Button; use crate::map::Map; use crate::math::Vec2; use crate::transform::Transform; use raylib::core::drawing::RaylibDrawHandle; #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] #[repr(u8)] pub enum ToolType { RectRoomTool, PolygonRoomTool, WallTool, IconTool, DeletionTool, NumTools, } pub trait Tool { /// Code that needs to be called when this Tool is activated or reactivated goes here. fn activate(&mut self) {} /// Cleanup that needs to be done when the user switches from this tool to something else goes here. fn deactivate(&mut self) {} /// Called on each frame when this tool is active. fn update(&mut self, map: &Map, mouse_pos_m: &Vec2); /// Draw the contents of this tool. // TODO: Maybe make this tool mappable? This might make it easier to make things resizable while // it's still being drawn. fn draw(&self, rld: &mut RaylibDrawHandle, transform: &Transform); /// Generic keybinding. /// Code to place a single node for this tool. fn place_single(&mut self, _map: &mut Map, _mouse_pos_m: &Vec2) {} /// Generic keybinding. /// Code to finish whatever one is doing with this tool currently and trying to apply the /// changes to the map data. fn finish(&mut self, _map: &mut Map) {} /// Generic keybinding. /// Stop whatever one is doing with this tool and do not apply any changes to the map data. fn abort(&mut self) {} /// If there are any additional keybindings that need to be handled by this tool, these can be /// handled here. fn on_button_pressed(&mut self, _map: &mut Map, _button: Button) {} }