From 211863c921f2063056a2eb51be6d1d8b4994699e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20W=C5=82odarczyk?= Date: Tue, 30 Jun 2026 21:30:52 +0200 Subject: [PATCH] Add dynamic lights setting and fix macOS config paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add DynamicLights (0–7) setting mapped to the eu07.ini dynamiclights key, exposed as a slider in the Graphics section of Settings. - Fix config file paths on macOS for eu07.ini, eu07_input-keyboard.ini, and userpresets.json to use ~/Library/Application Support/MaSzyna/ instead of falling through to the Linux XDG path. --- StarterNG/Classes/KeyboardConfig.cs | 6 ++++++ StarterNG/Classes/PresetStore.cs | 28 ++++++++++++++++++++++------ StarterNG/Classes/Settings.cs | 9 +++++++++ StarterNG/Views/Settings.axaml | 5 +++++ StarterNG/Views/Settings.axaml.cs | 2 ++ StarterNG/startercfg/lang/en.xml | 1 + StarterNG/startercfg/lang/pl.xml | 1 + 7 files changed, 46 insertions(+), 6 deletions(-) diff --git a/StarterNG/Classes/KeyboardConfig.cs b/StarterNG/Classes/KeyboardConfig.cs index f6a8c5e..840f7b5 100644 --- a/StarterNG/Classes/KeyboardConfig.cs +++ b/StarterNG/Classes/KeyboardConfig.cs @@ -88,6 +88,12 @@ public sealed class KeyboardConfig if (!string.IsNullOrEmpty(appData)) return Path.Combine(appData, "MaSzyna", "eu07_input-keyboard.ini"); } + else if (OperatingSystem.IsMacOS()) + { + string? home = Environment.GetEnvironmentVariable("HOME"); + if (!string.IsNullOrEmpty(home)) + return Path.Combine(home, "Library", "Application Support", "MaSzyna", "eu07_input-keyboard.ini"); + } else { string? home = Environment.GetEnvironmentVariable("HOME"); diff --git a/StarterNG/Classes/PresetStore.cs b/StarterNG/Classes/PresetStore.cs index 629905c..9d9ce65 100644 --- a/StarterNG/Classes/PresetStore.cs +++ b/StarterNG/Classes/PresetStore.cs @@ -27,16 +27,32 @@ public sealed class PresetCollection /// /// The user's vehicle/consist "warehouse": named trainset presets persisted as JSON. /// Stored under the per-user config directory so it survives reinstalls: -/// Windows: %appdata%\MaSzyna\starter\userpresets.json -/// Unix: ~/.config/MaSzyna/starter/userpresets.json -/// (both resolved via ). +/// Windows: %APPDATA%\MaSzyna\starter\userpresets.json +/// macOS: ~/Library/Application Support/MaSzyna/starter/userpresets.json +/// Linux: ~/.config/MaSzyna/starter/userpresets.json /// All operations are best-effort and never throw. /// public static class PresetStore { - public static string FilePath { get; } = Path.Combine( - Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), - "MaSzyna", "starter", "userpresets.json"); + private static string ResolvePath() + { + if (OperatingSystem.IsWindows()) + { + string appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); + return Path.Combine(appData, "MaSzyna", "starter", "userpresets.json"); + } + if (OperatingSystem.IsMacOS()) + { + string home = Environment.GetEnvironmentVariable("HOME") ?? AppContext.BaseDirectory; + return Path.Combine(home, "Library", "Application Support", "MaSzyna", "starter", "userpresets.json"); + } + { + string home = Environment.GetEnvironmentVariable("HOME") ?? AppContext.BaseDirectory; + return Path.Combine(home, ".config", "MaSzyna", "starter", "userpresets.json"); + } + } + + public static string FilePath { get; } = ResolvePath(); // Source-generated metadata keeps (de)serialisation AOT/trim-safe, matching the // approach used for the vehicle database. diff --git a/StarterNG/Classes/Settings.cs b/StarterNG/Classes/Settings.cs index 4f57612..1624669 100644 --- a/StarterNG/Classes/Settings.cs +++ b/StarterNG/Classes/Settings.cs @@ -65,6 +65,7 @@ public sealed class Settings public int MaxCabTextureSize = 4096; // maxcabtexturesize public int TextureFiltering = 8; // anisotropicfiltering (1/2/4/8/16) public int Multisampling = 2; // multisampling (0-3) + public int DynamicLights = 7; // dynamiclights (0-7) public double DrawRangeFactor = 1.0; // gfx.drawrange.factor.max public bool VSync = true; // vsync public bool Smoke = true; // gfx.smoke @@ -144,6 +145,12 @@ public sealed class Settings if (!string.IsNullOrEmpty(appData)) return Path.Combine(appData, "MaSzyna", "eu07.ini"); } + else if (OperatingSystem.IsMacOS()) + { + string? home = Environment.GetEnvironmentVariable("HOME"); + if (!string.IsNullOrEmpty(home)) + return Path.Combine(home, "Library", "Application Support", "MaSzyna", "eu07.ini"); + } else { string? home = Environment.GetEnvironmentVariable("HOME"); @@ -312,6 +319,7 @@ public sealed class Settings MaxCabTextureSize = c.GetInt("maxcabtexturesize", 4096); TextureFiltering = c.GetInt("anisotropicfiltering", 8); Multisampling = Clamp(c.GetInt("multisampling", 2), 0, 3); + DynamicLights = Clamp(c.GetInt("dynamiclights", 7), 0, 7); DrawRangeFactor = c.GetDouble("gfx.drawrange.factor.max", 1.0); VSync = c.GetBool("vsync", true); Smoke = c.GetBool("gfx.smoke", true); @@ -403,6 +411,7 @@ public sealed class Settings c.SetInt("maxcabtexturesize", MaxCabTextureSize); c.SetInt("anisotropicfiltering", TextureFiltering); c.SetInt("multisampling", Multisampling); + c.SetInt("dynamiclights", DynamicLights); c.SetDouble("gfx.drawrange.factor.max", DrawRangeFactor); c.SetBool("vsync", VSync); c.SetBool("gfx.smoke", Smoke); diff --git a/StarterNG/Views/Settings.axaml b/StarterNG/Views/Settings.axaml index 46b8daf..ed46966 100644 --- a/StarterNG/Views/Settings.axaml +++ b/StarterNG/Views/Settings.axaml @@ -149,6 +149,11 @@ + + + + Maximum cabin texture resolution: Texture filtering quality: Multisampling: + Dynamic light sources: Rendering range: VSync Smoke display diff --git a/StarterNG/startercfg/lang/pl.xml b/StarterNG/startercfg/lang/pl.xml index de2087f..d5f036c 100644 --- a/StarterNG/startercfg/lang/pl.xml +++ b/StarterNG/startercfg/lang/pl.xml @@ -243,6 +243,7 @@ Maksymalna rozdzielczość tekstur kabiny: Jakość filtrowania tekstur: Multisampling: + Dynamiczne źródła światła: Zasięg renderowania: VSync Wyświetlanie dymu