From f0af5f4cfdfa5b126e616d905249f85fb31d37ac Mon Sep 17 00:00:00 2001 From: raphael Date: Fri, 8 Mar 2024 08:20:34 +0100 Subject: [PATCH] pull request --- crates/border-wars/src/lib.rs | 11 ----------- crates/border-wars/src/responsive_scale.rs | 13 +++++++++++++ 2 files changed, 13 insertions(+), 11 deletions(-) create mode 100644 crates/border-wars/src/responsive_scale.rs diff --git a/crates/border-wars/src/lib.rs b/crates/border-wars/src/lib.rs index f6e9173..a4acdb8 100644 --- a/crates/border-wars/src/lib.rs +++ b/crates/border-wars/src/lib.rs @@ -19,14 +19,3 @@ pub enum CurrentScene { /// When we play this wonderful game. Game, } - -/// Calculates the ui_scale.0 depending on the size of the main node -/// in order to make the screen responsive -pub fn change_scaling(mut ui_scale: ResMut, window: Query<&Window>) { - let window = window.single(); - let (a, b) = ( - window.resolution.width() / 1280., - window.resolution.height() / 720., - ); - ui_scale.0 = if a < b { a } else { b } as f64 -} diff --git a/crates/border-wars/src/responsive_scale.rs b/crates/border-wars/src/responsive_scale.rs new file mode 100644 index 0000000..89681e5 --- /dev/null +++ b/crates/border-wars/src/responsive_scale.rs @@ -0,0 +1,13 @@ +const DEFAULT_WIDTH = 1280. +const DEFAULT_HEIGHT = 720. + +/// Calculates the ui_scale.0 depending on the size of the main node +/// in order to make the screen responsive +pub fn change_scaling(mut ui_scale: ResMut, window: Query<&Window>) { + let window = window.single(); + let (a, b) = ( + window.resolution.width() / DEFAULT_WIDTH, + window.resolution.height() / DEFAULT_HEIGHT, + ); + ui_scale.0 = if a < b { a } else { b } as f64 +} \ No newline at end of file