diff --git a/crates/horizon-client/src/game.rs b/crates/horizon-client/src/game.rs index f5803ad08..7b69a2ee3 100644 --- a/crates/horizon-client/src/game.rs +++ b/crates/horizon-client/src/game.rs @@ -9194,10 +9194,6 @@ impl Game<'_> { ) } fn apply_settings(&mut self) { - if let Some(r) = &self.renderer { - self.settings - .clamp_gui_scale([r.config.width as i32, r.config.height as i32]); - } self.streaming.radius = self.settings.render_distance; // Options.biomeBlendRadius, ambientOcclusion and cutoutLeaves: // LevelExtractor.allChanged when they change. @@ -13094,10 +13090,6 @@ impl Loading { return; } } - if let Some(r) = &self.renderer { - self.settings - .clamp_gui_scale([r.config.width as i32, r.config.height as i32]); - } horizon_client::hud::GUI_SCALE.store(self.settings.gui_scale, Ordering::Relaxed); self.window = Some(window); } @@ -13136,8 +13128,6 @@ impl Loading { self.settings.horizon.api, ) { Ok(r) => { - self.settings - .clamp_gui_scale([r.config.width as i32, r.config.height as i32]); horizon_client::hud::GUI_SCALE.store(self.settings.gui_scale, Ordering::Relaxed); self.renderer = Some(r); } diff --git a/crates/horizon-client/src/game/startup_menu.rs b/crates/horizon-client/src/game/startup_menu.rs index a5d658a4d..f7be6241f 100644 --- a/crates/horizon-client/src/game/startup_menu.rs +++ b/crates/horizon-client/src/game/startup_menu.rs @@ -272,8 +272,6 @@ impl Loading { } pub(super) fn apply_menu_settings(&mut self) { if let Some(renderer) = &mut self.renderer { - self.settings - .clamp_gui_scale([renderer.config.width as i32, renderer.config.height as i32]); renderer.gamma = self.settings.gamma; renderer.set_present_mode(self.settings.vsync, self.settings.horizon.present_mode); } diff --git a/crates/horizon-client/src/options_ui.rs b/crates/horizon-client/src/options_ui.rs index 1d1f099eb..9f91254bd 100644 --- a/crates/horizon-client/src/options_ui.rs +++ b/crates/horizon-client/src/options_ui.rs @@ -3403,9 +3403,6 @@ mod tests { assert_eq!(s.gui_scale, expected); } s.gui_scale = u32::MAX; - s.clamp_gui_scale(framebuffer); - assert_eq!(s.gui_scale, max); - s.gui_scale = u32::MAX; Opt::GuiScale.cycle(&mut s, false, framebuffer); assert_eq!(s.gui_scale, 0); s.gui_scale = u32::MAX; diff --git a/crates/horizon-client/src/settings.rs b/crates/horizon-client/src/settings.rs index 5fc09e35b..2a53e1702 100644 --- a/crates/horizon-client/src/settings.rs +++ b/crates/horizon-client/src/settings.rs @@ -104,7 +104,7 @@ pub struct Settings { pub master_volume: f32, /// Volumes of every other sound source, indexed like SOUND_SOURCES. pub volumes: [f32; 11], - /// 0 = auto. + /// Requested scale (0 = auto); rendering caps it to the current framebuffer. pub gui_scale: u32, pub view_bobbing: bool, /// Brightness 0..1 (gamma). @@ -284,12 +284,6 @@ fn put_s(f: &mut OptionsFile, key: &str, v: &str) { } } impl Settings { - /// `ClampingLazyMaxIntRange.validateValue`: clamp once the framebuffer is known. - pub fn clamp_gui_scale(&mut self, framebuffer: [i32; 2]) { - let max = crate::window::calculate_scale(framebuffer, 0, self.force_unicode) as u32; - self.gui_scale = self.gui_scale.min(max); - } - pub fn load(path: &Path) -> Self { let horizon = path .parent() @@ -597,6 +591,31 @@ impl Settings { #[cfg(test)] mod tests { use super::*; + #[test] + fn gui_scale_survives_temporary_small_framebuffer() { + for requested in [0, 1, 2, 6] { + let settings = Settings::parse(&format!("guiScale:{requested}\n")); + // Hyprland's initial surface can be smaller than the fullscreen one. + for (framebuffer, maximum) in [([715, 860], 2), ([3400, 1913], 7)] { + let effective = crate::window::calculate_scale( + framebuffer, + settings.gui_scale as i32, + settings.force_unicode, + ); + assert_eq!( + effective, + if requested == 0 { + maximum + } else { + (requested as i32).min(maximum) + } + ); + let saved = Settings::parse(&settings.serialize()); + assert_eq!(saved.gui_scale, requested); + } + } + } + #[test] fn round_trips_vanilla_options_txt() { let text = "version:4000\nfov:0.5\nrenderDistance:16\nmaxFps:260\nrenderClouds:\"fast\"\nkey_key.jump:key.keyboard.j\nsoundCategory_music:0.25\nresourcePacks:[\"vanilla\",\"file/x.zip\"]\nlang:fr_fr\nsomeFutureOption:42\n";