epic games paradox launcher support

This commit is contained in:
pointfeev 2022-03-03 07:47:48 -05:00
parent 5716d05b91
commit a53a9c1efb
6 changed files with 20 additions and 18 deletions

View file

@ -13,9 +13,9 @@ namespace CreamInstaller.Epic;
internal static class EpicStore internal static class EpicStore
{ {
internal static async Task<List<(string id, string name, string product, string icon)>> ParseDlcAppIds(string categoryNamespace) internal static async Task<List<(string id, string name, string product, string icon, string developer)>> ParseDlcAppIds(string categoryNamespace)
{ {
List<(string id, string name, string product, string icon)> dlcIds = new(); List<(string id, string name, string product, string icon, string developer)> dlcIds = new();
Response response = await QueryGraphQL(categoryNamespace); Response response = await QueryGraphQL(categoryNamespace);
if (response is null) if (response is null)
return dlcIds; return dlcIds;
@ -35,7 +35,7 @@ internal static class EpicStore
break; break;
} }
} }
(string id, string name, string product, string icon) app = (element.Items[0].Id, element.Title, product, icon); (string id, string name, string product, string icon, string developer) app = (element.Items[0].Id, element.Title, product, icon, element.Developer);
if (!dlcIds.Contains(app)) if (!dlcIds.Contains(app))
dlcIds.Add(app); dlcIds.Add(app);
} }

View file

@ -34,6 +34,7 @@ internal class Request
pageSlug pageSlug
} }
} }
developer
} }
} }
searchStore(category: ""games/edition/base"", namespace: $namespace) { searchStore(category: ""games/edition/base"", namespace: $namespace) {
@ -52,6 +53,7 @@ internal class Request
pageSlug pageSlug
} }
} }
developer
} }
} }
} }

View file

@ -53,9 +53,6 @@ public class Element
[JsonProperty(PropertyName = "title")] [JsonProperty(PropertyName = "title")]
public string Title { get; protected set; } public string Title { get; protected set; }
[JsonProperty(PropertyName = "offerType")]
public string OfferType { get; protected set; }
[JsonProperty(PropertyName = "items")] [JsonProperty(PropertyName = "items")]
public Item[] Items { get; protected set; } public Item[] Items { get; protected set; }
@ -64,6 +61,9 @@ public class Element
[JsonProperty(PropertyName = "catalogNs")] [JsonProperty(PropertyName = "catalogNs")]
public CatalogNs CatalogNs { get; protected set; } public CatalogNs CatalogNs { get; protected set; }
[JsonProperty(PropertyName = "developer")]
public string Developer { get; protected set; }
} }
public class Item public class Item

View file

@ -201,6 +201,7 @@ internal partial class SelectForm : CustomForm
selection.ProductUrl = "https://store.steampowered.com/app/" + appId; selection.ProductUrl = "https://store.steampowered.com/app/" + appId;
selection.IconUrl = IconGrabber.SteamAppImagesPath + @$"\{appId}\{appInfo?.Value?.GetChild("common")?.GetChild("icon")?.ToString()}.jpg"; selection.IconUrl = IconGrabber.SteamAppImagesPath + @$"\{appId}\{appInfo?.Value?.GetChild("common")?.GetChild("icon")?.ToString()}.jpg";
selection.ClientIconUrl = IconGrabber.SteamAppImagesPath + @$"\{appId}\{appInfo?.Value?.GetChild("common")?.GetChild("clienticon")?.ToString()}.ico"; selection.ClientIconUrl = IconGrabber.SteamAppImagesPath + @$"\{appId}\{appInfo?.Value?.GetChild("common")?.GetChild("clienticon")?.ToString()}.ico";
selection.Publisher = appInfo?.Value?.GetChild("extended")?.GetChild("publisher")?.ToString();
if (Program.Canceled) return; if (Program.Canceled) return;
Program.Invoke(selectionTreeView, delegate Program.Invoke(selectionTreeView, delegate
@ -260,19 +261,19 @@ internal partial class SelectForm : CustomForm
return; return;
} }
if (Program.Canceled) return; if (Program.Canceled) return;
ConcurrentDictionary<string, (string name, string product, string icon)> dlc = new(); ConcurrentDictionary<string, (string name, string product, string icon, string developer)> dlc = new();
List<Task> dlcTasks = new(); List<Task> dlcTasks = new();
List<(string id, string name, string product, string icon)> dlcIds = await EpicStore.ParseDlcAppIds(@namespace); List<(string id, string name, string product, string icon, string developer)> dlcIds = await EpicStore.ParseDlcAppIds(@namespace);
if (dlcIds.Count > 0) if (dlcIds.Count > 0)
{ {
foreach ((string id, string name, string product, string icon) in dlcIds) foreach ((string id, string name, string product, string icon, string developer) in dlcIds)
{ {
if (Program.Canceled) return; if (Program.Canceled) return;
AddToRemainingDLCs(id); AddToRemainingDLCs(id);
Task task = Task.Run(() => Task task = Task.Run(() =>
{ {
if (Program.Canceled) return; if (Program.Canceled) return;
dlc[id] = (name, product, icon); dlc[id] = (name, product, icon, developer);
RemoveFromRemainingDLCs(id); RemoveFromRemainingDLCs(id);
progress.Report(++CompleteTasks); progress.Report(++CompleteTasks);
}); });
@ -301,11 +302,12 @@ internal partial class SelectForm : CustomForm
selection.Name = name; selection.Name = name;
selection.RootDirectory = directory; selection.RootDirectory = directory;
selection.DllDirectories = dllDirectories; selection.DllDirectories = dllDirectories;
foreach (KeyValuePair<string, (string name, string product, string icon)> pair in dlc) foreach (KeyValuePair<string, (string name, string product, string icon, string developer)> pair in dlc)
if (pair.Value.name == selection.Name) if (pair.Value.name == selection.Name)
{ {
selection.ProductUrl = "https://www.epicgames.com/store/product/" + pair.Value.product; selection.ProductUrl = "https://www.epicgames.com/store/product/" + pair.Value.product;
selection.IconUrl = pair.Value.icon; selection.IconUrl = pair.Value.icon;
selection.Publisher = pair.Value.developer;
} }
if (Program.Canceled) return; if (Program.Canceled) return;
@ -318,7 +320,7 @@ internal partial class SelectForm : CustomForm
programNode.Checked = selection.Enabled; programNode.Checked = selection.Enabled;
programNode.Remove(); programNode.Remove();
selectionTreeView.Nodes.Add(programNode); selectionTreeView.Nodes.Add(programNode);
foreach (KeyValuePair<string, (string name, string product, string icon)> pair in dlc) foreach (KeyValuePair<string, (string name, string product, string icon, string developer)> pair in dlc)
{ {
if (Program.Canceled || programNode is null) return; if (Program.Canceled || programNode is null) return;
string dlcId = pair.Key; string dlcId = pair.Key;

View file

@ -2,8 +2,6 @@
using System.Linq; using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using CreamInstaller.Steam;
using Microsoft.Win32; using Microsoft.Win32;
namespace CreamInstaller.Paradox; namespace CreamInstaller.Paradox;
@ -29,15 +27,13 @@ internal static class ParadoxLauncher
paradoxLauncher.ExtraDlc.Clear(); paradoxLauncher.ExtraDlc.Clear();
foreach (ProgramSelection selection in ProgramSelection.AllUsableEnabled) foreach (ProgramSelection selection in ProgramSelection.AllUsableEnabled)
{ {
if (selection == paradoxLauncher) continue; if (selection == paradoxLauncher || selection.Publisher != "Paradox Interactive") continue;
if (selection.AppInfo?.Value?.GetChild("extended")?.GetChild("publisher")?.ToString() != "Paradox Interactive") continue;
paradoxLauncher.ExtraDlc.Add(new(selection.Id, selection.Name, selection.SelectedDlc)); paradoxLauncher.ExtraDlc.Add(new(selection.Id, selection.Name, selection.SelectedDlc));
} }
if (!paradoxLauncher.ExtraDlc.Any()) if (!paradoxLauncher.ExtraDlc.Any())
foreach (ProgramSelection selection in ProgramSelection.AllUsable) foreach (ProgramSelection selection in ProgramSelection.AllUsable)
{ {
if (selection == paradoxLauncher) continue; if (selection == paradoxLauncher || selection.Publisher != "Paradox Interactive") continue;
if (selection.AppInfo?.Value?.GetChild("extended")?.GetChild("publisher")?.ToString() != "Paradox Interactive") continue;
paradoxLauncher.ExtraDlc.Add(new(selection.Id, selection.Name, selection.AllDlc)); paradoxLauncher.ExtraDlc.Add(new(selection.Id, selection.Name, selection.AllDlc));
} }
} }

View file

@ -20,6 +20,8 @@ internal class ProgramSelection
internal string IconUrl = null; internal string IconUrl = null;
internal string ClientIconUrl = null; internal string ClientIconUrl = null;
internal string Publisher = null;
internal string RootDirectory = null; internal string RootDirectory = null;
internal List<string> DllDirectories = null; internal List<string> DllDirectories = null;