diff options
| author | Arne Dußin | 2021-01-11 12:10:16 +0100 |
|---|---|---|
| committer | Arne Dußin | 2021-01-11 12:10:16 +0100 |
| commit | ec071d5bc677101c0168b5fb3065f2d928234ed9 (patch) | |
| tree | 963ae90a6563c1f08d8e52078afd62db32e182f0 /src/map/rect_room.rs | |
| parent | ad1e79a517ce64eda7b06bb1567d3df070813dca (diff) | |
| download | graf_karto-ec071d5bc677101c0168b5fb3065f2d928234ed9.tar.gz graf_karto-ec071d5bc677101c0168b5fb3065f2d928234ed9.zip | |
Rect rooms are now normal polygon rooms in data
Before there was an extra data type for rectangular rooms. This is now
changed, with the rectangle tool remaining, to create these often
required rooms faster, but the data type is just a normal polygon that
is generated from a rect to reduce redundancy.
Diffstat (limited to 'src/map/rect_room.rs')
| -rw-r--r-- | src/map/rect_room.rs | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/src/map/rect_room.rs b/src/map/rect_room.rs deleted file mode 100644 index ae10327..0000000 --- a/src/map/rect_room.rs +++ /dev/null @@ -1,68 +0,0 @@ -//! Deprecated simple rectangular room type. - -use crate::colours::DEFAULT_COLOURS; -use crate::map::Mappable; -use crate::math::Rect; -use crate::transform::Transform; -use raylib::drawing::{RaylibDraw, RaylibDrawHandle}; -use serde::Serialize; -use std::ops::{Deref, DerefMut}; - -#[allow(missing_docs)] -pub type RectRoomData = Rect<f64>; - -#[allow(missing_docs)] -#[derive(Serialize)] -pub struct RectRoom { - data: RectRoomData, - selected: bool, -} - -impl RectRoom { - #[allow(missing_docs)] - pub fn from_data(data: RectRoomData) -> Self { - RectRoom { - data, - selected: false, - } - } -} - -impl Mappable for RectRoom { - fn draw(&self, rld: &mut RaylibDrawHandle, transform: &Transform) { - rld.draw_rectangle_rec( - transform.rect_m_to_px(&self.data), - 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> { - self.data - } -} - -impl Deref for RectRoom { - type Target = RectRoomData; - - fn deref(&self) -> &Self::Target { - &self.data - } -} - -impl DerefMut for RectRoom { - fn deref_mut(&mut self) -> &mut Self::Target { - &mut self.data - } -} |
