mirror of
https://github.com/FroggMaster/CreamInstaller.git
synced 2026-06-12 19:11:25 -07:00
Fix EpicGames detect, possible fix stuck on Steam detect
Fixed broken DLC detection for games from Epic Games. Probably fixed detection freezing on Steam games that are unavailable in certain regions.
This commit is contained in:
@@ -2,7 +2,6 @@ name: Autobuild
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
tags:
|
||||
- '*'
|
||||
workflow_dispatch:
|
||||
|
||||
@@ -22,7 +22,7 @@ internal sealed class StringComparer : IComparer<string>
|
||||
{
|
||||
public int Compare(string a, string b)
|
||||
=> !int.TryParse(a, out _) && !int.TryParse(b, out _)
|
||||
? string.Compare(a, b, StringComparison.CurrentCulture)
|
||||
? string.Compare(a, b, StringComparison.Ordinal)
|
||||
: !int.TryParse(a, out int A)
|
||||
? 1
|
||||
: !int.TryParse(b, out int B)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
|
||||
<UseWindowsForms>True</UseWindowsForms>
|
||||
<ApplicationIcon>Resources\program.ico</ApplicationIcon>
|
||||
<Version>5.0.1.2</Version>
|
||||
<Version>5.0.1.3</Version>
|
||||
<Copyright>2021, pointfeev (https://github.com/pointfeev)</Copyright>
|
||||
<Company>CreamInstaller</Company>
|
||||
<Product>Automatic DLC Unlocker Installer & Configuration Generator</Product>
|
||||
|
||||
@@ -109,7 +109,12 @@ internal sealed partial class SelectForm : CustomForm
|
||||
UpdateRemainingDLCs();
|
||||
});
|
||||
}
|
||||
|
||||
private static async Task<T> WithTimeout<T>(Task<T> task, int millisecondsTimeout)
|
||||
{
|
||||
if (await Task.WhenAny(task, Task.Delay(millisecondsTimeout)) == task)
|
||||
return await task;
|
||||
return default;
|
||||
}
|
||||
private async Task GetApplicablePrograms(IProgress<int> progress, bool uninstallAll = false)
|
||||
{
|
||||
if (!uninstallAll && (programsToScan is null || programsToScan.Count < 1))
|
||||
@@ -199,7 +204,7 @@ internal sealed partial class SelectForm : CustomForm
|
||||
return;
|
||||
StoreAppData storeAppData = await SteamStore.QueryStoreAPI(appId);
|
||||
_ = Interlocked.Decrement(ref steamGamesToCheck);
|
||||
CmdAppData cmdAppData = await SteamCMD.GetAppInfo(appId, branch, buildId);
|
||||
CmdAppData cmdAppData = await WithTimeout(SteamCMD.GetAppInfo(appId, branch, buildId), 20000);
|
||||
if (storeAppData is null && cmdAppData is null)
|
||||
{
|
||||
RemoveFromRemainingGames(name);
|
||||
@@ -1099,7 +1104,7 @@ internal sealed partial class SelectForm : CustomForm
|
||||
|
||||
private static bool CanLoadProxy() => ProgramData.ReadProxyChoices().Any();
|
||||
|
||||
private bool CanLoadSelections() => CanLoadDlc() || CanLoadProxy();
|
||||
private static bool CanLoadSelections() => CanLoadDlc() || CanLoadProxy();
|
||||
|
||||
private void OnLoadSelections(object sender, EventArgs e)
|
||||
{
|
||||
@@ -1175,7 +1180,7 @@ internal sealed partial class SelectForm : CustomForm
|
||||
saveButton.Enabled = CanSaveSelections();
|
||||
resetButton.Enabled = CanResetSelections();
|
||||
proxyAllCheckBox.CheckedChanged -= OnProxyAllCheckBoxChanged;
|
||||
proxyAllCheckBox.Checked = Selection.All.Keys.All(selection => selection.UseProxy);
|
||||
proxyAllCheckBox.Checked = Selection.All.Keys.Count != 0 && Selection.All.Keys.All(selection => selection.UseProxy);
|
||||
proxyAllCheckBox.CheckedChanged += OnProxyAllCheckBoxChanged;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ internal static class EpicLibrary
|
||||
epicManifestsPath ??=
|
||||
Registry.GetValue(@"HKEY_CURRENT_USER\Software\Epic Games\EOS", "ModSdkMetadataDir", null) as string;
|
||||
epicManifestsPath ??=
|
||||
Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Epic Games\EpicGamesLauncher", "AppDataPath",
|
||||
Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Epic Games\EpicGamesLauncher", "AppDataPath",
|
||||
null) as string;
|
||||
if (epicManifestsPath is not null && epicManifestsPath.EndsWith(@"\Data", StringComparison.Ordinal))
|
||||
epicManifestsPath += @"\Manifests";
|
||||
|
||||
@@ -8,6 +8,10 @@ using CreamInstaller.Platforms.Epic.GraphQL;
|
||||
using CreamInstaller.Utility;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
#if DEBUG
|
||||
using CreamInstaller.Forms;
|
||||
#endif
|
||||
|
||||
namespace CreamInstaller.Platforms.Epic;
|
||||
|
||||
internal static class EpicStore
|
||||
@@ -19,11 +23,22 @@ internal static class EpicStore
|
||||
{
|
||||
List<(string id, string name, string product, string icon, string developer)> dlcIds = [];
|
||||
string cacheFile = ProgramData.AppInfoPath + @$"\{categoryNamespace}.json";
|
||||
string fileContent = cacheFile.ReadFile();
|
||||
if (string.IsNullOrWhiteSpace(fileContent) || fileContent.Trim() == "null")
|
||||
{
|
||||
cacheFile.DeleteFile();
|
||||
}
|
||||
bool cachedExists = cacheFile.FileExists();
|
||||
Response response = null;
|
||||
if (!cachedExists || ProgramData.CheckCooldown(categoryNamespace, Cooldown))
|
||||
{
|
||||
response = await QueryGraphQL(categoryNamespace);
|
||||
#if DEBUG
|
||||
if (response is null)
|
||||
{
|
||||
DebugForm.Current.Log("ES: QueryGraphQL returned null");
|
||||
}
|
||||
#endif
|
||||
try
|
||||
{
|
||||
cacheFile.WriteFile(JsonConvert.SerializeObject(response, Formatting.Indented));
|
||||
@@ -114,6 +129,8 @@ internal static class EpicStore
|
||||
dlcIds.Add((id, title, product, icon, developer));
|
||||
}
|
||||
|
||||
public static bool EpicBool = true;
|
||||
|
||||
private static async Task<Response> QueryGraphQL(string categoryNamespace)
|
||||
{
|
||||
try
|
||||
@@ -125,9 +142,14 @@ internal static class EpicStore
|
||||
content.Headers.ContentType = new("application/json");
|
||||
HttpClient client = HttpClientManager.HttpClient;
|
||||
if (client is null)
|
||||
{
|
||||
#if DEBUG
|
||||
DebugForm.Current.Log("ES: Client returned null");
|
||||
#endif
|
||||
return null;
|
||||
}
|
||||
HttpResponseMessage httpResponse =
|
||||
await client.PostAsync(new Uri("https://graphql.epicgames.com/graphql"), content);
|
||||
await client.PostAsync(new Uri("https://launcher.store.epicgames.com/graphql"), content);
|
||||
_ = httpResponse.EnsureSuccessStatusCode();
|
||||
string response = await httpResponse.Content.ReadAsStringAsync();
|
||||
return JsonConvert.DeserializeObject<Response>(response);
|
||||
|
||||
@@ -20,7 +20,15 @@ internal static class HttpClientManager
|
||||
internal static void Setup()
|
||||
{
|
||||
HttpClient = new();
|
||||
HttpClient.DefaultRequestHeaders.UserAgent.Add(new(Program.Name, Program.Version));
|
||||
if (CreamInstaller.Platforms.Epic.EpicStore.EpicBool)
|
||||
{
|
||||
HttpClient.DefaultRequestHeaders.UserAgent.Add(new("EpicGamesLauncher", "18.9.0-45233261+++Portal+Release-Live"));
|
||||
CreamInstaller.Platforms.Epic.EpicStore.EpicBool = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
HttpClient.DefaultRequestHeaders.UserAgent.Add(new(Program.Name, Program.Version));
|
||||
}
|
||||
HttpClient.DefaultRequestHeaders.AcceptLanguage.Add(new(CultureInfo.CurrentCulture.ToString()));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user