aboutsummaryrefslogtreecommitdiff
path: root/src/map/polygon_room.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/polygon_room.rs')
-rw-r--r--src/map/polygon_room.rs25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/map/polygon_room.rs b/src/map/polygon_room.rs
index 12c480b..a209a7c 100644
--- a/src/map/polygon_room.rs
+++ b/src/map/polygon_room.rs
@@ -1,9 +1,9 @@
use super::Mappable;
-use crate::math::{self, Rect, Polygon, Triangle, Vec2};
+use crate::colours::DEFAULT_COLOURS;
+use crate::math::{self, Polygon, Rect, Triangle, Vec2};
use crate::scaleable::Scaleable;
use crate::transform::Transform;
use raylib::drawing::{RaylibDraw, RaylibDrawHandle};
-use raylib::ffi::Color;
pub type PolygonRoomData = Polygon<f64>;
@@ -11,13 +11,15 @@ pub struct PolygonRoom {
data: PolygonRoomData,
// The polygon shape, but in triangles, so the polygon does not have to be triangulated every frame.
triangulated: Vec<Triangle<f64>>,
+ selected: bool,
}
impl PolygonRoom {
pub fn from_data(data: PolygonRoomData) -> Self {
Self {
data: data.clone(),
- triangulated: math::triangulate(data)
+ triangulated: math::triangulate(data),
+ selected: false,
}
}
@@ -33,16 +35,23 @@ impl Mappable for PolygonRoom {
transform.point_m_to_px(&triangle.corners()[0]),
transform.point_m_to_px(&triangle.corners()[1]),
transform.point_m_to_px(&triangle.corners()[2]),
- Color {
- r: 180,
- g: 180,
- b: 180,
- a: 255,
+ if self.selected() {
+ DEFAULT_COLOURS.room_selected
+ } else {
+ DEFAULT_COLOURS.room_normal
},
)
}
}
+ fn set_selected(&mut self, selected: bool) {
+ self.selected = selected;
+ }
+
+ fn selected(&self) -> bool {
+ self.selected
+ }
+
fn bounding_rect(&self) -> Rect<f64> {
Rect::bounding_rect_n(&self.data.corners())
}