aboutsummaryrefslogtreecommitdiff
path: root/uml/class_diagram.uml
blob: 91df5690ef0f58f51e21879982f47e1b664e81b1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
@startuml

skinparam linetype ortho

skinparam entity {
	BackgroundColor<<struct>> PaleRed
	BorderColor<<struct>> DarkRed
}

skinparam interface {
	BackgroundColor<<trait>> PaleBlue
	BorderColor<<trait>> Blue
}

entity Editor <<struct>> {
	- 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<f64>, mouse_blocked: bool)
	+ draw(&self, rld: &mut RaylibDrawHandle, transform: &Transform)
	.. Getters ..
	+ active(&self) -> ToolType
	+ map_data(&self) -> &MapData
}

entity MapData <<struct>> {
	- rooms: Vec<Rect<f64>>
	- polygons: Vec<Polygon<f64>>
	- walls: Vec<LineSegment<f64>
	- icons: Vec<IconInfo>
	-- Associated functions --
	+ new() -> Self
	+ load_file(&mut self, path: AsRef<Path>) -> io::Result<()>
	+ write_file(&self, path: AsRef<Path>) -> io::Result<()>
	.. Attribute access ..
	+ rooms(&self) -> &Vec<Rect<f64>>
	+ rooms_mut(&mut self) -> &mut Vec<Rect<f64>>
	+ polygons(&self) -> &Vec<Polygon<f64>>
	+ polygons_mut(&mut self) -> &mut Vec<Polygon<f64>>
	+ walls(&self) -> &Vec<LineSegment<f64>>
	+ walls_mut(&mut self) -> &mut Vec<LineSegment<f64>>
	+ icons(&self) -> &Vec<IconInfo>
	+ icons_mut(&mut self) -> &mut Vec<IconInfo>
}

interface Tool <<trait>> {
	+ activate(&mut self)
	+ deactivate(&mut self)
	# update(&mut self, map: &MapData, mouse_pos_m: &Vec2<f64>)
	# 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<f64>, Vec2<f64>)>
		-- 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<f32>) -> bool
		+ draw(&self, screen_height: u16, rld: &mut impl RaylibDrawGui, editor: &mut Editor)
	}
}

package "Tools" #ff5555-ffaaaa {
	entity DeletionTool <<struct>> {
		- deletion_rect: Option<(Vec2<f64>, Vec2<f64>)>
		-- Tool implementation --
		deactivate(&mut self)
		update(&mut self, mouse_pos_m: &Vec2<f64>)
		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 <<struct>> {
		- keybindings: IconToolKeybindings
		- icon_id: usize
		- icon_pos: Vec2<f64>
		- icon_rotation: f64
		-- Tool implementation --
		update(&mut self, mouse_pos_m: &Vec2<f64>)
		draw(&self, rld: &mut RaylibDrawHandle, transform: &Transform)
		place_single(&mut self, map: &mutMapData)
		on_button_pressed(&mut self, button: Button)
	}

	entity PolygonRoomTool <<struct>> {
		-- Tool implementation --
		activate(&mut self)
		update(&mut self, mouse_pos_m: &Vec2<f64>)
		draw(&self, rld: &mut RaylibDrawHandle, transform: &Transform)
		place_single(&mut self, &mut MapData)
		finish(&mut self, map: &mut MapData)
		abort(&mut self)
	}
	entity UnfinishedPolygon <<struct>> {
		+ corners: Vec<Vec2<f64>>
		+ working_corner: Vec2<f64>
		-- Associated functions --
		+ check_validity_completed(&self) -> Result<(), PolygonError<f64>>
		+ check_validity_all(&self) -> Result<(), PolygonError<f64>>
		+ try_into_completed(&mut self) -> Option<Polygon<f64>>
		+ try_into_all(&mut self) -> Option<Polygon<f64>>
		+ try_push_working(&mut self) -> Result<(), PolygonError<f64>>
	}
	PolygonRoomTool "1" -l-> "1" UnfinishedPolygon

	entity RoomTool <<struct>> {
		rect: Option<(Vec2<f64>, Vec2<f64>)>
		-- Tool implementation --
		deactivate(&mut self)
		update(&mut self, mouse_pos_m: &Vec2<f64>)
		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 <<struct>> {
		wall: Option<LineSegment<f64>>
		-- Tool implementation --
		deactivate(&mut self)
		update(&mut self, mouse_pos_m: &Vec2<f64>)
		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