From 9f2a78259e1cdea83dfab729c15c9a684d92bb90 Mon Sep 17 00:00:00 2001 From: Aceeri Date: Thu, 19 Jan 2023 06:05:39 +0000 Subject: [PATCH] Remove unnecessary windows.rs file (#7277) # Objective Accidentally re-added this old file at some point during the Windows as Entities PR apparently ## Solution Removed the file, its unused --- crates/bevy_window/src/windows.rs | 88 ------------------------------- 1 file changed, 88 deletions(-) delete mode 100644 crates/bevy_window/src/windows.rs diff --git a/crates/bevy_window/src/windows.rs b/crates/bevy_window/src/windows.rs deleted file mode 100644 index 5ffbf524c1423c..00000000000000 --- a/crates/bevy_window/src/windows.rs +++ /dev/null @@ -1,88 +0,0 @@ -use super::{Window, WindowId}; -use bevy_ecs::prelude::Resource; -use bevy_utils::HashMap; - -/// A collection of [`Window`]s with unique [`WindowId`]s. -#[derive(Debug, Default, Resource)] -pub struct Windows { - windows: HashMap, -} - -impl Windows { - /// Add the provided [`Window`] to the [`Windows`] resource. - pub fn add(&mut self, window: Window) { - self.windows.insert(window.id(), window); - } - - /// Get a reference to the [`Window`] of `id`. - pub fn get(&self, id: WindowId) -> Option<&Window> { - self.windows.get(&id) - } - - /// Get a mutable reference to the provided [`WindowId`]. - pub fn get_mut(&mut self, id: WindowId) -> Option<&mut Window> { - self.windows.get_mut(&id) - } - - /// Get a reference to the primary [`Window`]. - pub fn get_primary(&self) -> Option<&Window> { - self.get(WindowId::primary()) - } - - /// Get a reference to the primary [`Window`]. - /// - /// # Panics - /// - /// Panics if the primary window does not exist in [`Windows`]. - pub fn primary(&self) -> &Window { - self.get_primary().expect("Primary window does not exist") - } - - /// Get a mutable reference to the primary [`Window`]. - pub fn get_primary_mut(&mut self) -> Option<&mut Window> { - self.get_mut(WindowId::primary()) - } - - /// Get a mutable reference to the primary [`Window`]. - /// - /// # Panics - /// - /// Panics if the primary window does not exist in [`Windows`]. - pub fn primary_mut(&mut self) -> &mut Window { - self.get_primary_mut() - .expect("Primary window does not exist") - } - - /// Get a reference to the focused [`Window`]. - pub fn get_focused(&self) -> Option<&Window> { - self.windows.values().find(|window| window.is_focused()) - } - - /// Get a mutable reference to the focused [`Window`]. - pub fn get_focused_mut(&mut self) -> Option<&mut Window> { - self.windows.values_mut().find(|window| window.is_focused()) - } - - /// Returns the scale factor for the [`Window`] of `id`, or `1.0` if the window does not exist. - pub fn scale_factor(&self, id: WindowId) -> f64 { - if let Some(window) = self.get(id) { - window.scale_factor() - } else { - 1.0 - } - } - - /// An iterator over all registered [`Window`]s. - pub fn iter(&self) -> impl Iterator { - self.windows.values() - } - - /// A mutable iterator over all registered [`Window`]s. - pub fn iter_mut(&mut self) -> impl Iterator { - self.windows.values_mut() - } - - pub fn remove(&mut self, id: WindowId) -> Option { - self.windows.remove(&id) - } -}