Fix issue where ui scale in the login menu was not updated when changed in-game

This commit is contained in:
Imbris 2020-11-13 20:16:42 -05:00
parent 1ed90bd0bf
commit cff5439796
7 changed files with 23 additions and 4 deletions

View File

@ -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 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 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 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 ## [0.7.0] - 2020-08-15

View File

@ -67,6 +67,9 @@ impl PlayState for CharSelectionState {
); );
self.char_selection_ui self.char_selection_ui
.update_language(std::sync::Arc::clone(&localized_strings)); .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<WinEvent>) -> PlayStateResult { fn tick(&mut self, global_state: &mut GlobalState, events: Vec<WinEvent>) -> PlayStateResult {

View File

@ -1429,6 +1429,10 @@ impl CharSelectionUi {
.expect("Impossible to load fonts!"); .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? // TODO: do we need whole client here or just character list?
pub fn maintain(&mut self, global_state: &mut GlobalState, client: &mut Client) -> Vec<Event> { pub fn maintain(&mut self, global_state: &mut GlobalState, client: &mut Client) -> Vec<Event> {
let mut events = Vec::new(); let mut events = Vec::new();

View File

@ -55,6 +55,9 @@ impl PlayState for MainMenuState {
std::sync::Arc::clone(&localized_strings), std::sync::Arc::clone(&localized_strings),
&global_state.settings, &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 #[allow(clippy::single_match)] // TODO: remove when event match has multiple arms

View File

@ -572,6 +572,10 @@ impl<'a> MainMenuUi {
self.ui.handle_event(event); 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<Event> { pub fn maintain(&mut self, global_state: &mut GlobalState, dt: Duration) -> Vec<Event> {
let mut events = Vec::new(); let mut events = Vec::new();

View File

@ -77,9 +77,8 @@ impl IcedUi {
pub fn scale(&self) -> Scale { self.scale } pub fn scale(&self) -> Scale { self.scale }
pub fn set_scaling_mode(&mut self, mode: ScaleMode) { pub fn set_scaling_mode(&mut self, mode: ScaleMode) {
self.scale.set_scaling_mode(mode);
// Signal that change needs to be handled // Signal that change needs to be handled
self.scale_changed = true; self.scale_changed |= self.scale.set_scaling_mode(mode);
} }
/// Dpi factor changed /// Dpi factor changed

View File

@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize};
use vek::*; use vek::*;
/// Type of scaling to use. /// Type of scaling to use.
#[derive(Clone, Copy, Debug, Serialize, Deserialize)] #[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq)]
pub enum ScaleMode { pub enum ScaleMode {
// Scale against physical size. // Scale against physical size.
Absolute(f64), Absolute(f64),
@ -41,7 +41,12 @@ impl Scale {
} }
// Change the scaling mode. // 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 // Get scaling mode transformed into absolute scaling
pub fn scaling_mode_as_absolute(&self) -> ScaleMode { pub fn scaling_mode_as_absolute(&self) -> ScaleMode {