From 78ea2f0f54c3d6e04b0c968e10f94a073ec6d6ed Mon Sep 17 00:00:00 2001 From: objz Date: Fri, 4 Sep 2026 22:16:35 +0200 Subject: [PATCH] fix: use concrete launcher resolution default --- README.md | 2 +- assets/config.toml | 2 +- src/config/settings.rs | 13 +++++++++++-- src/config/tests/loading.rs | 9 +++++++++ src/tui/widgets/popups/global_settings.rs | 8 ++++++-- 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 7ad30ee..804c6ad 100644 --- a/README.md +++ b/README.md @@ -147,7 +147,7 @@ memory_max = "2G" jvm_args = [] environment = {} window_mode = "windowed" -# resolution = [1920, 1080] +resolution = [854, 480] [ui] image_protocol = "auto" diff --git a/assets/config.toml b/assets/config.toml index 935fafc..e923cc7 100644 --- a/assets/config.toml +++ b/assets/config.toml @@ -19,7 +19,7 @@ jvm_args = [] environment = {} # inherited by instances that use launcher window defaults window_mode = "windowed" -# resolution = [1920, 1080] # omitted = Minecraft default +resolution = [854, 480] [ui] # image protocol: auto, halfblocks, quadrants, kitty, or iterm2 diff --git a/src/config/settings.rs b/src/config/settings.rs index af53c31..3da5741 100644 --- a/src/config/settings.rs +++ b/src/config/settings.rs @@ -10,6 +10,8 @@ use serde::{Deserialize, Serialize}; use crate::instance::models::{WindowMode, memory_kib, normalize_memory_value}; +pub const DEFAULT_RESOLUTION: (u32, u32) = (854, 480); + #[derive(Debug, Serialize, Deserialize, Default, Clone, Copy, PartialEq, Eq)] #[serde(rename_all = "lowercase")] pub enum ImageProtocol { @@ -271,7 +273,7 @@ pub struct Defaults { pub environment: BTreeMap, #[serde(default)] pub window_mode: WindowMode, - #[serde(default)] + #[serde(default = "default_resolution")] #[serde(skip_serializing_if = "Option::is_none")] pub resolution: Option<(u32, u32)>, } @@ -283,6 +285,10 @@ fn default_memory_max() -> String { "2G".to_owned() } +fn default_resolution() -> Option<(u32, u32)> { + Some(DEFAULT_RESOLUTION) +} + impl Default for Defaults { fn default() -> Self { Self { @@ -291,7 +297,7 @@ impl Default for Defaults { jvm_args: Vec::new(), environment: BTreeMap::new(), window_mode: WindowMode::default(), - resolution: None, + resolution: default_resolution(), } } } @@ -373,6 +379,9 @@ impl Config { .memory_max .clone_from(&self.defaults.memory_min); } + if self.defaults.resolution.is_none() { + self.defaults.resolution = default_resolution(); + } self.ui.error_auto_dismiss_ms = self.ui.error_auto_dismiss_ms.max(1); self.ui.error_slide_start_ms = self .ui diff --git a/src/config/tests/loading.rs b/src/config/tests/loading.rs index aabd59d..47b7e28 100644 --- a/src/config/tests/loading.rs +++ b/src/config/tests/loading.rs @@ -68,6 +68,10 @@ fn bundled_config_uses_platform_paths_and_automatic_java() { assert_eq!(config.paths.meta_dir, settings::Paths::default().meta_dir); assert!(config.paths.java_path.is_none()); assert_eq!(config.ui.image_protocol, settings::ImageProtocol::Auto); + assert_eq!( + config.defaults.resolution, + Some(settings::DEFAULT_RESOLUTION) + ); } #[test] @@ -81,6 +85,7 @@ fn config_normalizes_memory_java_and_notification_bounds() { defaults: settings::Defaults { memory_min: "invalid".to_owned(), memory_max: "1G".to_owned(), + resolution: None, ..Default::default() }, ui: settings::Ui { @@ -101,6 +106,10 @@ fn config_normalizes_memory_java_and_notification_bounds() { assert!(config.paths.java_path.is_none()); assert_eq!(config.defaults.memory_min, "512M"); assert_eq!(config.defaults.memory_max, "1G"); + assert_eq!( + config.defaults.resolution, + Some(settings::DEFAULT_RESOLUTION) + ); assert_eq!(config.ui.error_slide_start_ms, 100); assert_eq!(config.ui.error_fly_out_ms, 100); assert_eq!(config.ui.max_error_events, 1); diff --git a/src/tui/widgets/popups/global_settings.rs b/src/tui/widgets/popups/global_settings.rs index 63fdf65..d3dbc39 100644 --- a/src/tui/widgets/popups/global_settings.rs +++ b/src/tui/widgets/popups/global_settings.rs @@ -16,7 +16,7 @@ use ratatui_textarea::TextArea; use crate::{ config::{ Config, - settings::{ContentProvider, ImageProtocol}, + settings::{ContentProvider, DEFAULT_RESOLUTION, ImageProtocol}, theme::{BORDER_STYLE, BorderStyle, THEME, ThemeConfig}, }, instance::models::{WindowMode, normalize_memory_value, parse_resolution}, @@ -166,7 +166,9 @@ impl State { .unwrap_or_else(|| self.java_picker.detected_path()), ), 6 => window_mode_title(self.config.defaults.window_mode).to_owned(), - 7 if self.config.defaults.resolution.is_none() => "game default".to_owned(), + 7 if self.config.defaults.resolution.is_none() => { + format!("{}x{}", DEFAULT_RESOLUTION.0, DEFAULT_RESOLUTION.1) + } 16 if self.config.content.max_fingerprint_size_mib == 0 => "unlimited".to_owned(), 23 => "provider and Java metadata".to_owned(), _ => self.value(field), @@ -1346,6 +1348,8 @@ mod tests { #[test] fn launcher_resolution_reuses_display_and_preset_choices() { let mut state = State::new(); + state.config.defaults.resolution = None; + assert_eq!(state.display_value(7), "854x480"); state.display_resolutions = vec![DisplayResolution { width: 2560, height: 1440,