2022-11-06 17:07:21 +01:00
|
|
|
use {crate::gui::WindowId, bevy::utils::HashSet, std::fmt::Display};
|
2022-09-06 20:40:27 +02:00
|
|
|
|
|
|
|
#[derive(Default, Debug)]
|
|
|
|
pub(crate) struct CursorMapPosition {
|
|
|
|
pub(crate) x: i32,
|
|
|
|
pub(crate) y: i32,
|
|
|
|
}
|
|
|
|
impl Display for CursorMapPosition {
|
|
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
|
|
f.write_fmt(format_args!("x: {}, y: {}", self.x, self.y))
|
|
|
|
}
|
|
|
|
}
|
2022-11-06 17:07:21 +01:00
|
|
|
|
|
|
|
#[derive(Default)]
|
|
|
|
pub(crate) struct OpenedWindows(HashSet<WindowId>);
|
|
|
|
|
|
|
|
impl OpenedWindows {
|
|
|
|
pub(crate) fn open(&mut self, id: WindowId) {
|
|
|
|
// Ignore opening already opened windows
|
|
|
|
_ = self.0.insert(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
pub(crate) fn close(&mut self, id: &WindowId) {
|
|
|
|
// Ignore closing already closed windows
|
|
|
|
_ = self.0.remove(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
pub(crate) fn is_open(&self, id: &WindowId) -> bool {
|
|
|
|
self.0.contains(id)
|
|
|
|
}
|
|
|
|
}
|