From b402c5e30727d99ec64dd6664b21cc018dd76231 Mon Sep 17 00:00:00 2001 From: Vitalii Mikhailov Date: Thu, 20 Apr 2023 09:49:51 +0300 Subject: [PATCH] * Show a warning for Game and Engine options for one time launch * Engine was showing Game options * Importing a list was not saving automatically --- build/common.props | 4 ++-- changelog.txt | 6 ++++++ .../Bannerlord.BLSE.Shared.csproj | 2 +- .../Bannerlord.LauncherEx.csproj | 4 ++-- .../Helpers/ConfigReader.cs | 6 +++--- .../Mixins/LauncherModsVMMixin.cs | 3 ++- .../Resources/Prefabs/Launcher.Options.xml | 1 + .../ViewModels/BUTRLauncherOptionsVM.cs | 19 +++++++++++++++++-- 8 files changed, 34 insertions(+), 11 deletions(-) diff --git a/build/common.props b/build/common.props index c5965a0..80cffbe 100644 --- a/build/common.props +++ b/build/common.props @@ -10,13 +10,13 @@ - 1.3.5 + 1.3.6 2.2.2 3.0.0.136 5.0.198 3.2.0.77 1.0.1.44 - 1.0.66 + 1.0.69 full diff --git a/changelog.txt b/changelog.txt index 9f32e29..4d9b0d7 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,10 @@ --------------------------------------------------------------------------------------------------- +Version: 1.3.6 +Game Versions: v1.0.0,v1.0.1,v1.0.2,v1.0.3,v1.1.0,v1.1.1,v1.1.2,v1.1.3 +* Show a warning for Game and Engine options for one time launch +* Engine was showing Game options +* Importing a list was not saving automatically +--------------------------------------------------------------------------------------------------- Version: 1.3.5 Game Versions: v1.0.0,v1.0.1,v1.0.2,v1.0.3,v1.1.0,v1.1.1,v1.1.2 * Fixed Steam running as admin detection diff --git a/src/Bannerlord.BLSE.Shared/Bannerlord.BLSE.Shared.csproj b/src/Bannerlord.BLSE.Shared/Bannerlord.BLSE.Shared.csproj index 0a76fc1..39d34de 100644 --- a/src/Bannerlord.BLSE.Shared/Bannerlord.BLSE.Shared.csproj +++ b/src/Bannerlord.BLSE.Shared/Bannerlord.BLSE.Shared.csproj @@ -34,7 +34,7 @@ - + diff --git a/src/Bannerlord.LauncherEx/Bannerlord.LauncherEx.csproj b/src/Bannerlord.LauncherEx/Bannerlord.LauncherEx.csproj index fe0ad2a..36410b9 100644 --- a/src/Bannerlord.LauncherEx/Bannerlord.LauncherEx.csproj +++ b/src/Bannerlord.LauncherEx/Bannerlord.LauncherEx.csproj @@ -6,7 +6,7 @@ enable x64 full - 1.24.2 + 1.24.3 System.Diagnostics.CodeAnalysis.UnscopedRefAttribute true @@ -90,7 +90,7 @@ - + diff --git a/src/Bannerlord.LauncherEx/Helpers/ConfigReader.cs b/src/Bannerlord.LauncherEx/Helpers/ConfigReader.cs index 51a1cba..62f74c0 100644 --- a/src/Bannerlord.LauncherEx/Helpers/ConfigReader.cs +++ b/src/Bannerlord.LauncherEx/Helpers/ConfigReader.cs @@ -25,7 +25,7 @@ public static Dictionary GetGameOptions(Func re if (split.Length != 2) continue; var key = split[0].Trim(); var value = split[1].Trim(); - dict.Add(key, value); + dict[key] = value; } } catch (Exception) { /* ignore */ } @@ -34,7 +34,7 @@ public static Dictionary GetGameOptions(Func re public static Dictionary GetEngineOptions(Func readFileContent) { var dict = new Dictionary(); - if (readFileContent(GameConfigPath) is not { } data) return dict; + if (readFileContent(EngineConfigPath) is not { } data) return dict; try { var content = Encoding.UTF8.GetString(data); @@ -44,7 +44,7 @@ public static Dictionary GetEngineOptions(Func if (split.Length != 2) continue; var key = split[0].Trim(); var value = split[1].Trim(); - dict.Add(key, value); + dict[key] = value; } } catch (Exception) { /* ignore */ } diff --git a/src/Bannerlord.LauncherEx/Mixins/LauncherModsVMMixin.cs b/src/Bannerlord.LauncherEx/Mixins/LauncherModsVMMixin.cs index 8dee529..21cf508 100644 --- a/src/Bannerlord.LauncherEx/Mixins/LauncherModsVMMixin.cs +++ b/src/Bannerlord.LauncherEx/Mixins/LauncherModsVMMixin.cs @@ -101,7 +101,6 @@ public void Initialize() //TryOrderByLoadOrder(Enumerable.Empty(), x => loadOrder.TryGetValue(x, out var isSelected) && isSelected); } - _launcherManagerHandler.SetGameParametersLoadOrder(Modules2); } private void SetViewModels(IEnumerable orderedModuleViewModels) @@ -113,6 +112,8 @@ private void SetViewModels(IEnumerable orderedModuleViewModels // Validate all VM's after they were selected and ordered foreach (var modules in Modules2) modules.Validate(); + + _launcherManagerHandler.SetGameParametersLoadOrder(Modules2); } private IEnumerable ValidateModule(BUTRLauncherModuleVM moduleVM) => SortHelper.ValidateModule(Modules2, _modulesLookup, moduleVM); diff --git a/src/Bannerlord.LauncherEx/Resources/Prefabs/Launcher.Options.xml b/src/Bannerlord.LauncherEx/Resources/Prefabs/Launcher.Options.xml index 44cd286..f365705 100644 --- a/src/Bannerlord.LauncherEx/Resources/Prefabs/Launcher.Options.xml +++ b/src/Bannerlord.LauncherEx/Resources/Prefabs/Launcher.Options.xml @@ -8,6 +8,7 @@ + diff --git a/src/Bannerlord.LauncherEx/ViewModels/BUTRLauncherOptionsVM.cs b/src/Bannerlord.LauncherEx/ViewModels/BUTRLauncherOptionsVM.cs index 353eda9..830a730 100644 --- a/src/Bannerlord.LauncherEx/ViewModels/BUTRLauncherOptionsVM.cs +++ b/src/Bannerlord.LauncherEx/ViewModels/BUTRLauncherOptionsVM.cs @@ -35,6 +35,13 @@ internal sealed class BUTRLauncherOptionsVM : BUTRViewModel public MBBindingList SettingProperties { get => _settingProperties; set => SetField(ref _settingProperties, value); } private MBBindingList _settingProperties = new(); + [BUTRDataSourceProperty] + public string NeedsGameLaunchMessage { get => _needsGameLaunchMessage; set => SetField(ref _needsGameLaunchMessage, value); } + private string _needsGameLaunchMessage = new BUTRTextObject("{=jfNh7Sg3}One-time game launch is required!").ToString(); + + [BUTRDataSourceProperty] + public bool NeedsGameLaunch { get => _needsGameLaunch; set => SetField(ref _needsGameLaunch, value); } + private bool _needsGameLaunch; public BUTRLauncherOptionsVM(OptionsType optionsType, Action saveUserData, Action refreshOptions) { @@ -165,7 +172,11 @@ private void RefreshGameOptions() { try { - foreach (var (key, value) in ConfigReader.GetGameOptions(path => File.Exists(path) ? File.ReadAllBytes(path) : null)) + var options = ConfigReader.GetGameOptions(path => File.Exists(path) ? File.ReadAllBytes(path) : null); + if (options.Count == 0) + NeedsGameLaunch = true; + + foreach (var (key, value) in options) { SettingProperties.Add(CreateSettingsPropertyVM(key, value, ToSeparateWords)); } @@ -176,7 +187,11 @@ private void RefreshEngineOptions() { try { - foreach (var (key, value) in ConfigReader.GetEngineOptions(path => File.Exists(path) ? File.ReadAllBytes(path) : null)) + var options = ConfigReader.GetEngineOptions(path => File.Exists(path) ? File.ReadAllBytes(path) : null); + if (options.Count == 0) + NeedsGameLaunch = true; + + foreach (var (key, value) in options) { SettingProperties.Add(CreateSettingsPropertyVM(key, value, x => ToTitleCase(x.Replace("_", " ")))); }