Skip to content

Commit

Permalink
* Show a warning for Game and Engine options for one time launch
Browse files Browse the repository at this point in the history
* Engine was showing Game options
* Importing a list was not saving automatically
  • Loading branch information
Aragas committed Apr 20, 2023
1 parent 88781b1 commit b402c5e
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 11 deletions.
4 changes: 2 additions & 2 deletions build/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@

<!--Development Variables-->
<PropertyGroup>
<Version>1.3.5</Version>
<Version>1.3.6</Version>
<HarmonyVersion>2.2.2</HarmonyVersion>
<BUTRSharedVersion>3.0.0.136</BUTRSharedVersion>
<BUTRModuleManagerVersion>5.0.198</BUTRModuleManagerVersion>
<HarmonyExtensionsVersion>3.2.0.77</HarmonyExtensionsVersion>
<HarmonyAnalyzerVersion>1.0.1.44</HarmonyAnalyzerVersion>
<LauncherManagerVersion>1.0.66</LauncherManagerVersion>
<LauncherManagerVersion>1.0.69</LauncherManagerVersion>
<DebugType>full</DebugType>
</PropertyGroup>

Expand Down
6 changes: 6 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Bannerlord.BLSE.Shared/Bannerlord.BLSE.Shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<PackageReference Include="IsExternalInit" Version="1.0.3" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />

<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.2.188-beta" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />
<PackageReference Include="Mono.Cecil" Version="0.11.4" IncludeAssets="compile" PrivateAssets="all" />
<PackageReference Include="Mono.Cecil" Version="0.11.5" IncludeAssets="compile" PrivateAssets="all" />
<PackageReference Include="System.Memory" Version="4.5.5" PrivateAssets="all" />
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions src/Bannerlord.LauncherEx/Bannerlord.LauncherEx.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Nullable>enable</Nullable>
<PlatformTarget>x64</PlatformTarget>
<DebugType>full</DebugType>
<Version>1.24.2</Version>
<Version>1.24.3</Version>
<PolySharpExcludeGeneratedTypes>System.Diagnostics.CodeAnalysis.UnscopedRefAttribute</PolySharpExcludeGeneratedTypes>
<EnableWindowsTargeting>true</EnableWindowsTargeting>

Expand Down Expand Up @@ -90,7 +90,7 @@
<PackageReference Include="Bannerlord.Lib.Harmony" Version="$(HarmonyVersion)" IncludeAssets="compile" />
<PackageReference Include="lz4net" Version="1.0.15.93" />
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.2.188-beta" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />
<PackageReference Include="Mono.Cecil" Version="0.11.4" IncludeAssets="compile" />
<PackageReference Include="Mono.Cecil" Version="0.11.5" IncludeAssets="compile" />
<PackageReference Include="PolySharp" Version="1.13.1" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />
<PackageReference Include="StbSharp" Version="0.7.2.38" PrivateAssets="all" />
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />
Expand Down
6 changes: 3 additions & 3 deletions src/Bannerlord.LauncherEx/Helpers/ConfigReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static Dictionary<string, string> GetGameOptions(Func<string, byte[]?> 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 */ }
Expand All @@ -34,7 +34,7 @@ public static Dictionary<string, string> GetGameOptions(Func<string, byte[]?> re
public static Dictionary<string, string> GetEngineOptions(Func<string, byte[]?> readFileContent)
{
var dict = new Dictionary<string, string>();
if (readFileContent(GameConfigPath) is not { } data) return dict;
if (readFileContent(EngineConfigPath) is not { } data) return dict;
try
{
var content = Encoding.UTF8.GetString(data);
Expand All @@ -44,7 +44,7 @@ public static Dictionary<string, string> GetEngineOptions(Func<string, byte[]?>
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 */ }
Expand Down
3 changes: 2 additions & 1 deletion src/Bannerlord.LauncherEx/Mixins/LauncherModsVMMixin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ public void Initialize()

//TryOrderByLoadOrder(Enumerable.Empty<string>(), x => loadOrder.TryGetValue(x, out var isSelected) && isSelected);
}
_launcherManagerHandler.SetGameParametersLoadOrder(Modules2);
}

private void SetViewModels(IEnumerable<IModuleViewModel> orderedModuleViewModels)
Expand All @@ -113,6 +112,8 @@ private void SetViewModels(IEnumerable<IModuleViewModel> orderedModuleViewModels
// Validate all VM's after they were selected and ordered
foreach (var modules in Modules2)
modules.Validate();

_launcherManagerHandler.SetGameParametersLoadOrder(Modules2);
}

private IEnumerable<string> ValidateModule(BUTRLauncherModuleVM moduleVM) => SortHelper.ValidateModule(Modules2, _modulesLookup, moduleVM);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<Children>
<Widget Id="MyClipRect" WidthSizePolicy="StretchToParent" HeightSizePolicy="StretchToParent" HorizontalAlignment="Center" ClipContents="true">
<Children>
<TextWidget Text="@NeedsGameLaunchMessage" WidthSizePolicy="StretchToParent" HeightSizePolicy="CoverChildren" Brush="Launcher.Mods.ModNameText" Brush.TextHorizontalAlignment="Left" IsVisible="@NeedsGameLaunch" />
<ListPanel Id="InnerPanel" DataSource="{SettingProperties}" HeightSizePolicy="CoverChildren" WidthSizePolicy="StretchToParent" LayoutImp.LayoutMethod="VerticalBottomToTop" VerticalAlignment="Top">
<ItemTemplate>
<Launcher.Options.OptionTuple />
Expand Down
19 changes: 17 additions & 2 deletions src/Bannerlord.LauncherEx/ViewModels/BUTRLauncherOptionsVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ internal sealed class BUTRLauncherOptionsVM : BUTRViewModel
public MBBindingList<SettingsPropertyVM> SettingProperties { get => _settingProperties; set => SetField(ref _settingProperties, value); }
private MBBindingList<SettingsPropertyVM> _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)
{
Expand Down Expand Up @@ -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));
}
Expand All @@ -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("_", " "))));
}
Expand Down

0 comments on commit b402c5e

Please sign in to comment.