From bff1955c38480f2dffd0a10c16ef46dc11320752 Mon Sep 17 00:00:00 2001 From: Arne Dußin Date: Fri, 20 Nov 2020 23:41:46 +0100 Subject: 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. --- src/map_data.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/map_data.rs') 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>, + polygons: Vec>, walls: Vec<(Vec2, Vec2)>, icons: Vec, } @@ -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> { + &self.polygons + } + pub fn polygons_mut(&mut self) -> &mut Vec> { + &mut self.polygons + } + pub fn walls(&self) -> &Vec<(Vec2, Vec2)> { &self.walls } -- cgit v1.2.3-70-g09d2