blob: ae103277d09db0f8d90591072aa32a6929dd16e3 (
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
|
//! 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
}
}
|