aboutsummaryrefslogtreecommitdiff
path: root/src/map_data.rs
diff options
context:
space:
mode:
authorArne Dußin2020-11-20 23:41:46 +0100
committerArne Dußin2020-11-20 23:41:46 +0100
commitbff1955c38480f2dffd0a10c16ef46dc11320752 (patch)
treee69403752aa05f22b5474ef07997092c65dc694e /src/map_data.rs
parentd6a0708b995b6c0e12ed8890c678c180f859de51 (diff)
downloadgraf_karto-bff1955c38480f2dffd0a10c16ef46dc11320752.tar.gz
graf_karto-bff1955c38480f2dffd0a10c16ef46dc11320752.zip
Add unfinished polygon room tool
When adding the polygon room tool, a problem with drawing polygons arised. Drawing a simple, but nonregular polygon is not something that is supported by raylib, so further additions to the math library are needed.
Diffstat (limited to 'src/map_data.rs')
-rw-r--r--src/map_data.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/map_data.rs b/src/map_data.rs
index e1a9c0b..b17d779 100644
--- a/src/map_data.rs
+++ b/src/map_data.rs
@@ -1,4 +1,4 @@
-use crate::math::{Rect, Vec2};
+use crate::math::{Polygon, Rect, Vec2};
use crate::tool::icon_tool::IconInfo;
use ron::de::from_reader;
use ron::ser::{to_string_pretty, PrettyConfig};
@@ -13,6 +13,7 @@ use std::path::Path;
#[derive(Serialize, Deserialize)]
pub struct MapData {
rooms: Vec<Rect<f32>>,
+ polygons: Vec<Polygon<f32>>,
walls: Vec<(Vec2<f32>, Vec2<f32>)>,
icons: Vec<IconInfo>,
}
@@ -22,6 +23,7 @@ impl MapData {
pub fn new() -> Self {
Self {
rooms: Vec::new(),
+ polygons: Vec::new(),
walls: Vec::new(),
icons: Vec::new(),
}
@@ -40,6 +42,7 @@ impl MapData {
* future)
*/
self.rooms.append(&mut data.rooms);
+ self.polygons.append(&mut data.polygons);
self.walls.append(&mut data.walls);
self.icons.append(&mut data.icons);
@@ -71,6 +74,13 @@ impl MapData {
&mut self.rooms
}
+ pub fn polygons(&self) -> &Vec<Polygon<f32>> {
+ &self.polygons
+ }
+ pub fn polygons_mut(&mut self) -> &mut Vec<Polygon<f32>> {
+ &mut self.polygons
+ }
+
pub fn walls(&self) -> &Vec<(Vec2<f32>, Vec2<f32>)> {
&self.walls
}