From 22e7e9ec4694ce8620cf4aafdfbe6b179c5f80fb Mon Sep 17 00:00:00 2001 From: pointfeev Date: Sat, 25 Jun 2022 00:31:01 -0500 Subject: [PATCH] v3.5.4.0 - SmokeAPI's dlc_ids parameter is now properly utilized (should fix Arma 3 launcher issues) - Overhauled the ScreamAPI config creation to utilize unlock_all and auto_inject with proper overrides --- CreamInstaller/CreamInstaller.csproj | 2 +- CreamInstaller/Forms/InstallForm.cs | 73 ++++++++++++++-------------- CreamInstaller/Forms/SelectForm.cs | 4 +- CreamInstaller/ProgramSelection.cs | 5 +- 4 files changed, 44 insertions(+), 40 deletions(-) diff --git a/CreamInstaller/CreamInstaller.csproj b/CreamInstaller/CreamInstaller.csproj index c777c84..5a03ffa 100644 --- a/CreamInstaller/CreamInstaller.csproj +++ b/CreamInstaller/CreamInstaller.csproj @@ -5,7 +5,7 @@ True Resources\ini.ico true - 3.5.3.1 + 3.5.4.0 Resources\ini.ico LICENSE 2021, pointfeev (https://github.com/pointfeev) diff --git a/CreamInstaller/Forms/InstallForm.cs b/CreamInstaller/Forms/InstallForm.cs index b24c5d2..c1d2925 100644 --- a/CreamInstaller/Forms/InstallForm.cs +++ b/CreamInstaller/Forms/InstallForm.cs @@ -56,7 +56,7 @@ internal partial class InstallForm : CustomForm } } - internal static void WriteSmokeConfiguration(StreamWriter writer, SortedList overrideDlc, SortedList allDlc, InstallForm installForm = null) + internal static void WriteSmokeConfiguration(StreamWriter writer, SortedList overrideDlc, SortedList injectDlc, InstallForm installForm = null) { Thread.Sleep(0); writer.WriteLine("{"); @@ -81,18 +81,18 @@ internal partial class InstallForm : CustomForm } else writer.WriteLine(" \"override\": [],"); - if (allDlc.Count > 0) + if (injectDlc.Count > 0) { writer.WriteLine(" \"dlc_ids\": ["); - KeyValuePair lastAllDlc = allDlc.Last(); - foreach (KeyValuePair pair in allDlc) + KeyValuePair lastInjectDlc = injectDlc.Last(); + foreach (KeyValuePair pair in injectDlc) { Thread.Sleep(0); string dlcId = pair.Key; (_, string dlcName, _) = pair.Value; - writer.WriteLine($" {dlcId}{(pair.Equals(lastAllDlc) ? "" : ",")}"); + writer.WriteLine($" {dlcId}{(pair.Equals(lastInjectDlc) ? "" : ",")}"); if (installForm is not null) - installForm.UpdateUser($"Added DLC to SmokeAPI.json with appid {dlcId} ({dlcName})", InstallationLog.Action, info: false); + installForm.UpdateUser($"Added injected DLC to SmokeAPI.json with appid {dlcId} ({dlcName})", InstallationLog.Action, info: false); } writer.WriteLine(" ],"); } @@ -176,21 +176,26 @@ internal partial class InstallForm : CustomForm installForm.UpdateUser("Generating SmokeAPI configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", InstallationLog.Operation); File.Create(config).Close(); StreamWriter writer = new(config, true, Encoding.UTF8); - IEnumerable> allDlc = selection.AllDlc.AsEnumerable(); - foreach ((string id, string name, SortedList extraDlc) in selection.ExtraDlc) - allDlc = allDlc.Concat(extraDlc); - IEnumerable> overrideDlc = allDlc.Except(selection.SelectedDlc); + IEnumerable> overrideDlc = selection.AllDlc.Except(selection.SelectedDlc); foreach ((string id, string name, SortedList extraDlc) in selection.ExtraSelectedDlc) overrideDlc = overrideDlc.Except(extraDlc); + IEnumerable> injectDlc = new List>(); + if (selection.AllDlc.Count > 64 || selection.ExtraDlc.Any(e => e.dlc.Count > 64)) + { + injectDlc = injectDlc.Concat(selection.SelectedDlc.Where(pair => pair.Value.type is DlcType.SteamHidden)); + foreach ((string id, string name, SortedList extraDlc) in selection.ExtraSelectedDlc) + if (selection.ExtraDlc.Where(e => e.id == id).Single().dlc.Count > 64) + injectDlc = injectDlc.Concat(extraDlc.Where(pair => pair.Value.type is DlcType.SteamHidden)); + } WriteSmokeConfiguration(writer, new(overrideDlc.ToDictionary(pair => pair.Key, pair => pair.Value), AppIdComparer.Comparer), - new(allDlc.ToDictionary(pair => pair.Key, pair => pair.Value), AppIdComparer.Comparer), + new(injectDlc.ToDictionary(pair => pair.Key, pair => pair.Value), AppIdComparer.Comparer), installForm); writer.Flush(); writer.Close(); }); - internal static void WriteScreamConfiguration(StreamWriter writer, SortedList dlc, List<(string id, string name, SortedList dlc)> extraDlc, InstallForm installForm = null) + internal static void WriteScreamConfiguration(StreamWriter writer, SortedList overrideCatalogItems, SortedList entitlements, InstallForm installForm = null) { Thread.Sleep(0); writer.WriteLine("{"); @@ -199,39 +204,30 @@ internal partial class InstallForm : CustomForm writer.WriteLine(" \"eos_logging\": false,"); writer.WriteLine(" \"block_metrics\": false,"); writer.WriteLine(" \"catalog_items\": {"); - IEnumerable> catalogItems = dlc.Where(pair => pair.Value.type == DlcType.EpicCatalogItem); - foreach ((string id, string name, SortedList _dlc) in extraDlc) - catalogItems = catalogItems.Concat(_dlc.Where(pair => pair.Value.type == DlcType.EpicCatalogItem)); - if (catalogItems.Any()) + writer.WriteLine(" \"unlock_all\": true,"); + if (overrideCatalogItems.Any()) { - writer.WriteLine(" \"unlock_all\": false,"); writer.WriteLine(" \"override\": ["); - KeyValuePair lastCatalogItem = catalogItems.Last(); - foreach (KeyValuePair pair in catalogItems) + KeyValuePair lastOverrideCatalogItem = overrideCatalogItems.Last(); + foreach (KeyValuePair pair in overrideCatalogItems) { Thread.Sleep(0); string id = pair.Key; (_, string name, _) = pair.Value; - writer.WriteLine($" \"{id}\"{(pair.Equals(lastCatalogItem) ? "" : ",")}"); + writer.WriteLine($" \"{id}\"{(pair.Equals(lastOverrideCatalogItem) ? "" : ",")}"); if (installForm is not null) - installForm.UpdateUser($"Added catalog item to ScreamAPI.json with id {id} ({name})", InstallationLog.Action, info: false); + installForm.UpdateUser($"Added override catalog item to ScreamAPI.json with id {id} ({name})", InstallationLog.Action, info: false); } writer.WriteLine(" ]"); } else - { - writer.WriteLine(" \"unlock_all\": true,"); writer.WriteLine(" \"override\": []"); - } writer.WriteLine(" },"); writer.WriteLine(" \"entitlements\": {"); - IEnumerable> entitlements = dlc.Where(pair => pair.Value.type == DlcType.EpicEntitlement); - foreach ((string id, string name, SortedList _dlc) in extraDlc) - entitlements = entitlements.Concat(_dlc.Where(pair => pair.Value.type == DlcType.EpicEntitlement)); + writer.WriteLine(" \"unlock_all\": true,"); + writer.WriteLine(" \"auto_inject\": true,"); if (entitlements.Any()) { - writer.WriteLine(" \"unlock_all\": false,"); - writer.WriteLine(" \"auto_inject\": false,"); writer.WriteLine(" \"inject\": ["); KeyValuePair lastEntitlement = entitlements.Last(); foreach (KeyValuePair pair in entitlements) @@ -246,11 +242,7 @@ internal partial class InstallForm : CustomForm writer.WriteLine(" ]"); } else - { - writer.WriteLine(" \"unlock_all\": true,"); - writer.WriteLine(" \"auto_inject\": true,"); writer.WriteLine(" \"inject\": []"); - } writer.WriteLine(" }"); writer.WriteLine("}"); } @@ -321,7 +313,16 @@ internal partial class InstallForm : CustomForm installForm.UpdateUser("Generating ScreamAPI configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", InstallationLog.Operation); File.Create(config).Close(); StreamWriter writer = new(config, true, Encoding.UTF8); - WriteScreamConfiguration(writer, selection.SelectedDlc, selection.ExtraSelectedDlc, installForm); + IEnumerable> overrideCatalogItems = selection.AllDlc.Where(pair => pair.Value.type is DlcType.EpicCatalogItem).Except(selection.SelectedDlc); + foreach ((string id, string name, SortedList extraDlc) in selection.ExtraSelectedDlc) + overrideCatalogItems = overrideCatalogItems.Except(extraDlc); + IEnumerable> entitlements = selection.SelectedDlc.Where(pair => pair.Value.type == DlcType.EpicEntitlement); + foreach ((string id, string name, SortedList _dlc) in selection.ExtraSelectedDlc) + entitlements = entitlements.Concat(_dlc.Where(pair => pair.Value.type == DlcType.EpicEntitlement)); + WriteScreamConfiguration(writer, + new(overrideCatalogItems.ToDictionary(pair => pair.Key, pair => pair.Value), AppIdComparer.Comparer), + new(entitlements.ToDictionary(pair => pair.Key, pair => pair.Value), AppIdComparer.Comparer), + installForm); writer.Flush(); writer.Close(); }); @@ -356,8 +357,8 @@ internal partial class InstallForm : CustomForm foreach (string directory in selection.DllDirectories) { Thread.Sleep(0); - if (selection.IsSteam && selection.SelectedDlc.Any(d => d.Value.type is DlcType.Steam) - || selection.ExtraSelectedDlc.Any(item => item.dlc.Any(dlc => dlc.Value.type is DlcType.Steam))) + if (selection.IsSteam && selection.SelectedDlc.Any(d => d.Value.type is DlcType.Steam or DlcType.SteamHidden) + || selection.ExtraSelectedDlc.Any(item => item.dlc.Any(dlc => dlc.Value.type is DlcType.Steam or DlcType.SteamHidden))) { directory.GetSmokeApiComponents(out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config); if (File.Exists(sdk32) || File.Exists(sdk32_o) || File.Exists(sdk64) || File.Exists(sdk64_o) || File.Exists(config)) diff --git a/CreamInstaller/Forms/SelectForm.cs b/CreamInstaller/Forms/SelectForm.cs index 5d22873..62c4b46 100644 --- a/CreamInstaller/Forms/SelectForm.cs +++ b/CreamInstaller/Forms/SelectForm.cs @@ -180,11 +180,13 @@ internal partial class SelectForm : CustomForm if (Program.Canceled) return; string dlcName = null; string dlcIcon = null; + bool onSteamStore = false; AppData dlcAppData = await SteamStore.QueryStoreAPI(dlcAppId, true); if (dlcAppData is not null) { dlcName = dlcAppData.name; dlcIcon = dlcAppData.header_image; + onSteamStore = true; } else { @@ -201,7 +203,7 @@ internal partial class SelectForm : CustomForm } if (Program.Canceled) return; if (!string.IsNullOrWhiteSpace(dlcName)) - dlc[dlcAppId] = (DlcType.Steam, dlcName, dlcIcon); + dlc[dlcAppId] = (onSteamStore ? DlcType.Steam : DlcType.SteamHidden, dlcName, dlcIcon); RemoveFromRemainingDLCs(dlcAppId); }); dlcTasks.Add(task); diff --git a/CreamInstaller/ProgramSelection.cs b/CreamInstaller/ProgramSelection.cs index 4937eb8..28c69cc 100644 --- a/CreamInstaller/ProgramSelection.cs +++ b/CreamInstaller/ProgramSelection.cs @@ -10,8 +10,9 @@ namespace CreamInstaller; public enum DlcType { Steam = 0, - EpicCatalogItem = 1, - EpicEntitlement = 2 + SteamHidden = 1, + EpicCatalogItem = 2, + EpicEntitlement = 3 } internal class ProgramSelection