aboutsummaryrefslogtreecommitdiff
path: root/src/tool/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/tool/mod.rs')
-rw-r--r--src/tool/mod.rs49
1 files changed, 33 insertions, 16 deletions
diff --git a/src/tool/mod.rs b/src/tool/mod.rs
index f503d2b..aeabf19 100644
--- a/src/tool/mod.rs
+++ b/src/tool/mod.rs
@@ -1,46 +1,63 @@
pub mod deletion_tool;
pub mod icon_tool;
pub mod polygon_room_tool;
-pub mod room_tool;
+pub mod rect_room_tool;
+pub mod selection_tool;
pub mod wall_tool;
pub use deletion_tool::DeletionTool;
pub use icon_tool::IconTool;
pub use polygon_room_tool::PolygonRoomTool;
-pub use room_tool::RoomTool;
+pub use rect_room_tool::RectRoomTool;
+pub use selection_tool::SelectionTool;
pub use wall_tool::WallTool;
use crate::button::Button;
-use crate::map_data::MapData;
+use crate::map::Map;
+use crate::math::Vec2;
use crate::transform::Transform;
use raylib::core::drawing::RaylibDrawHandle;
-use raylib::RaylibHandle;
-#[derive(Copy, Clone, Debug, PartialEq)]
+#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
#[repr(u8)]
pub enum ToolType {
- RoomTool,
+ RectRoomTool,
PolygonRoomTool,
WallTool,
IconTool,
DeletionTool,
+ SelectionTool,
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) {}
- fn update(&mut self, _map: &MapData, _rl: &RaylibHandle, _transform: &Transform) {}
- fn active_update(
- &mut self,
- map: &mut MapData,
- rl: &RaylibHandle,
- transform: &Transform,
- mouse_blocked: bool,
- );
+ /// Called on each frame when this tool is active.
+ fn update(&mut self, map: &Map, mouse_pos_m: &Vec2<f64>);
- fn draw(&self, _map: &MapData, _rld: &mut RaylibDrawHandle, _transform: &Transform) {}
+ /// 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);
- fn activation_key(&self) -> Button;
+ /// Generic keybinding.
+ /// Code to place a single node for this tool.
+ fn place_single(&mut self, _map: &mut Map, _mouse_pos_m: &Vec2<f64>) {}
+
+ /// 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) {}
}