diff --git a/CHANGELOG.md b/CHANGELOG.md index e1d10a4858..a49bded69d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -81,6 +81,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed a bug where camera zoom in and zoom out distance didn't match. - Fixed a bug where a nearby item would also be collected when collecting collectible blocks - Fixed a bug where firing fast projectile at a downwards angle caused them to veer off at a higher angle +- Fixed a bug where ui scale in the login menu was not updated when changed in-game ## [0.7.0] - 2020-08-15 diff --git a/voxygen/src/menu/char_selection/mod.rs b/voxygen/src/menu/char_selection/mod.rs index 3a62263eb7..d9fb3b14ea 100644 --- a/voxygen/src/menu/char_selection/mod.rs +++ b/voxygen/src/menu/char_selection/mod.rs @@ -67,6 +67,9 @@ impl PlayState for CharSelectionState { ); self.char_selection_ui .update_language(std::sync::Arc::clone(&localized_strings)); + // Set scale mode in case it was change + self.char_selection_ui + .set_scale_mode(global_state.settings.gameplay.ui_scale); } fn tick(&mut self, global_state: &mut GlobalState, events: Vec) -> PlayStateResult { diff --git a/voxygen/src/menu/char_selection/ui/mod.rs b/voxygen/src/menu/char_selection/ui/mod.rs index cc7325e3f2..d6358622cf 100644 --- a/voxygen/src/menu/char_selection/ui/mod.rs +++ b/voxygen/src/menu/char_selection/ui/mod.rs @@ -1439,6 +1439,10 @@ impl CharSelectionUi { .expect("Impossible to load fonts!"); } + pub fn set_scale_mode(&mut self, scale_mode: ui::ScaleMode) { + self.ui.set_scaling_mode(scale_mode); + } + // TODO: do we need whole client here or just character list? pub fn maintain(&mut self, global_state: &mut GlobalState, client: &mut Client) -> Vec { let mut events = Vec::new(); diff --git a/voxygen/src/menu/main/mod.rs b/voxygen/src/menu/main/mod.rs index 54888112a5..6fc23d96a9 100644 --- a/voxygen/src/menu/main/mod.rs +++ b/voxygen/src/menu/main/mod.rs @@ -55,6 +55,9 @@ impl PlayState for MainMenuState { std::sync::Arc::clone(&localized_strings), &global_state.settings, ); + // Set scale mode in case it was change + self.main_menu_ui + .set_scale_mode(global_state.settings.gameplay.ui_scale); } #[allow(clippy::single_match)] // TODO: remove when event match has multiple arms diff --git a/voxygen/src/menu/main/ui/mod.rs b/voxygen/src/menu/main/ui/mod.rs index 686eedbc75..93e623e714 100644 --- a/voxygen/src/menu/main/ui/mod.rs +++ b/voxygen/src/menu/main/ui/mod.rs @@ -572,6 +572,10 @@ impl<'a> MainMenuUi { self.ui.handle_event(event); } + pub fn set_scale_mode(&mut self, scale_mode: ui::ScaleMode) { + self.ui.set_scaling_mode(scale_mode); + } + pub fn maintain(&mut self, global_state: &mut GlobalState, dt: Duration) -> Vec { let mut events = Vec::new(); diff --git a/voxygen/src/ui/ice/mod.rs b/voxygen/src/ui/ice/mod.rs index cae5a18a24..23b7afd976 100644 --- a/voxygen/src/ui/ice/mod.rs +++ b/voxygen/src/ui/ice/mod.rs @@ -77,9 +77,8 @@ impl IcedUi { pub fn scale(&self) -> Scale { self.scale } pub fn set_scaling_mode(&mut self, mode: ScaleMode) { - self.scale.set_scaling_mode(mode); // Signal that change needs to be handled - self.scale_changed = true; + self.scale_changed |= self.scale.set_scaling_mode(mode); } /// Dpi factor changed diff --git a/voxygen/src/ui/scale.rs b/voxygen/src/ui/scale.rs index 669adcd240..1d6c1e890c 100644 --- a/voxygen/src/ui/scale.rs +++ b/voxygen/src/ui/scale.rs @@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize}; use vek::*; /// Type of scaling to use. -#[derive(Clone, Copy, Debug, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq)] pub enum ScaleMode { // Scale against physical size. Absolute(f64), @@ -41,7 +41,12 @@ impl Scale { } // Change the scaling mode. - pub fn set_scaling_mode(&mut self, mode: ScaleMode) { self.mode = mode; } + // Returns false if the mode matches the current mode + pub fn set_scaling_mode(&mut self, mode: ScaleMode) -> bool { + let old_mode = self.mode; + self.mode = mode; + old_mode != mode + } // Get scaling mode transformed into absolute scaling pub fn scaling_mode_as_absolute(&self) -> ScaleMode {