@startuml skinparam linetype ortho skinparam entity { BackgroundColor<> PaleRed BorderColor<> DarkRed } skinparam interface { BackgroundColor<> PaleBlue BorderColor<> Blue } entity Editor <> { - active: usize -- Associated functions -- + new(rl: &mut RaylibHandle, rlt: &RaylibThread, config: Config) -> Self + set_active(&mut self, tool: ToolType) + update(&mut self, mouse_pos_m: &Vec2, mouse_blocked: bool) + draw(&self, rld: &mut RaylibDrawHandle, transform: &Transform) .. Getters .. + active(&self) -> ToolType + map_data(&self) -> &MapData } entity MapData <> { - rooms: Vec> - polygons: Vec> - walls: Vec - icons: Vec -- Associated functions -- + new() -> Self + load_file(&mut self, path: AsRef) -> io::Result<()> + write_file(&self, path: AsRef) -> io::Result<()> .. Attribute access .. + rooms(&self) -> &Vec> + rooms_mut(&mut self) -> &mut Vec> + polygons(&self) -> &Vec> + polygons_mut(&mut self) -> &mut Vec> + walls(&self) -> &Vec> + walls_mut(&mut self) -> &mut Vec> + icons(&self) -> &Vec + icons_mut(&mut self) -> &mut Vec } interface Tool <> { + activate(&mut self) + deactivate(&mut self) # update(&mut self, map: &MapData, mouse_pos_m: &Vec2) # draw(&self, rld: &mut RaylibDrawHandle, transform: &Transform) .. Common keybinding handlers .. + place_single(&mut self, map: &mut MapData) + finish(&mut self, map: &mut MapData) + abort(&mut self) .. Special keybinding handler .. + on_button_pressed(&mut self, map: &mut MapData, button: Button) } package "GUI" #55ff55-aaffaa { entity Dimensions { - dimension_lines: Vec<(Vec2, Vec2)> -- Associated functions -- + new() -> Self + update(&self, editor: &mut Editor) + draw(&self, rld: &mut impl RaylibDraw, transform: &Transform) } entity ToolSidebar { - button_texture: Texture2D -- Associated functions -- + new(rl: &mut RaylibHandle, rlt: &RaylibThread) -> Self + mouse_captured(screen_height: u16, mouse_pos_px: Vec2) -> bool + draw(&self, screen_height: u16, rld: &mut impl RaylibDrawGui, editor: &mut Editor) } } package "Tools" #ff5555-ffaaaa { entity DeletionTool <> { - deletion_rect: Option<(Vec2, Vec2)> -- Tool implementation -- deactivate(&mut self) update(&mut self, mouse_pos_m: &Vec2) draw(&self, rld: &mut RaylibDrawHandle, transform: &Transform) place_single(&mut self, map: &mut MapData) finish(&mut self, map: &mut MapData) abort(&mut self) } entity IconTool <> { - keybindings: IconToolKeybindings - icon_id: usize - icon_pos: Vec2 - icon_rotation: f64 -- Tool implementation -- update(&mut self, mouse_pos_m: &Vec2) draw(&self, rld: &mut RaylibDrawHandle, transform: &Transform) place_single(&mut self, map: &mutMapData) on_button_pressed(&mut self, button: Button) } entity PolygonRoomTool <> { -- Tool implementation -- activate(&mut self) update(&mut self, mouse_pos_m: &Vec2) draw(&self, rld: &mut RaylibDrawHandle, transform: &Transform) place_single(&mut self, &mut MapData) finish(&mut self, map: &mut MapData) abort(&mut self) } entity UnfinishedPolygon <> { + corners: Vec> + working_corner: Vec2 -- Associated functions -- + check_validity_completed(&self) -> Result<(), PolygonError> + check_validity_all(&self) -> Result<(), PolygonError> + try_into_completed(&mut self) -> Option> + try_into_all(&mut self) -> Option> + try_push_working(&mut self) -> Result<(), PolygonError> } PolygonRoomTool "1" -l-> "1" UnfinishedPolygon entity RoomTool <> { rect: Option<(Vec2, Vec2)> -- Tool implementation -- deactivate(&mut self) update(&mut self, mouse_pos_m: &Vec2) draw(&self, rld: &mut RaylibDrawHandle, transform: &Transform) place_single(&mut self, map: &mut MapData) finish(&mut self, map: &mut MapData) abort(&mut self) } entity WallTool <> { wall: Option> -- Tool implementation -- deactivate(&mut self) update(&mut self, mouse_pos_m: &Vec2) draw(&self, rld: &mut RaylibDrawHandle, transform: &Transform) place_single(&mut self, map: &mut MapData) finish(&mut self, map: &mut MapData) abort(&mut self) on_button_pressed(&mut self, map: &mut MapData, button: Button) } } ' Alignment help so all tools are drawn from top to bottom DeletionTool -d[hidden]- IconTool IconTool -d[hidden]- PolygonRoomTool PolygonRoomTool -d[hidden]- RoomTool RoomTool -d[hidden]- WallTool GUI -[hidden]d- Editor ToolSidebar -[hidden]r- Dimensions ToolSidebar ..d..> Editor Dimensions ..d..> Editor ' The tools should be to the left of the tool trait Tools -r[Hidden]- Tool DeletionTool ..r..> Tool : implements IconTool ..r..> Tool : implements PolygonRoomTool ..r..> Tool : implements RoomTool ..r..> Tool : implements WallTool ..r..> Tool : implements Editor "1" ---l---> "NumTools" Tool : tools Editor "1" -d-> "1" MapData : map_data @enduml