This commit is contained in:
pointfeev 2021-11-12 13:12:21 -05:00
parent 1be79b8cda
commit de573b4edb
No known key found for this signature in database
GPG key ID: AA14DC36C4D7D13C
5 changed files with 75 additions and 58 deletions

View file

@ -6,7 +6,7 @@
<UseWindowsForms>true</UseWindowsForms> <UseWindowsForms>true</UseWindowsForms>
<ApplicationIcon>ini.ico</ApplicationIcon> <ApplicationIcon>ini.ico</ApplicationIcon>
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract> <IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
<Version>2.0.1.0</Version> <Version>2.0.2.0</Version>
<PackageIcon>ini.ico</PackageIcon> <PackageIcon>ini.ico</PackageIcon>
<PackageIconUrl /> <PackageIconUrl />
<Description>Automatically installs and generates CreamAPI files for programs/games on the user's computer.</Description> <Description>Automatically installs and generates CreamAPI files for programs/games on the user's computer.</Description>

View file

@ -146,22 +146,8 @@ namespace CreamInstaller
if (Program.Canceled) return; if (Program.Canceled) return;
ConcurrentDictionary<int, string> dlc = new(); ConcurrentDictionary<int, string> dlc = new();
List<Task> dlcTasks = new(); List<Task> dlcTasks = new();
List<int> dlcIds = new(); List<int> dlcIds = SteamCMD.ParseDlcAppIds(appInfo);
if (!(appInfo is null)) if (dlcIds.Count > 0)
{
if (!(appInfo.Value["extended"] is null))
foreach (VProperty property in appInfo.Value["extended"])
if (property.Key.ToString() == "listofdlc")
foreach (string id in property.Value.ToString().Split(","))
if (!dlcIds.Contains(int.Parse(id)))
dlcIds.Add(int.Parse(id));
if (!(appInfo.Value["depots"] is null))
foreach (VProperty _property in appInfo.Value["depots"])
if (int.TryParse(_property.Key.ToString(), out int _))
if (int.TryParse(_property.Value?["dlcappid"]?.ToString(), out int appid) && !dlcIds.Contains(appid))
dlcIds.Add(appid);
}
if (!(dlcIds is null) && dlcIds.Count > 0)
{ {
foreach (int id in dlcIds) foreach (int id in dlcIds)
{ {
@ -173,7 +159,7 @@ namespace CreamInstaller
VProperty dlcAppInfo = null; VProperty dlcAppInfo = null;
if (SteamCMD.GetAppInfo(id, out dlcAppInfo)) dlcName = dlcAppInfo?.Value?["common"]?["name"]?.ToString(); if (SteamCMD.GetAppInfo(id, out dlcAppInfo)) dlcName = dlcAppInfo?.Value?["common"]?["name"]?.ToString();
if (Program.Canceled) return; if (Program.Canceled) return;
if (string.IsNullOrWhiteSpace(dlcName)) dlcName = $"Unknown DLC ({id})"; if (string.IsNullOrWhiteSpace(dlcName)) return;
dlc[id] = dlcName; dlc[id] = dlcName;
}); });
dlcTasks.Add(task); dlcTasks.Add(task);
@ -242,7 +228,7 @@ namespace CreamInstaller
progress.Report(RunningTasks.Count); progress.Report(RunningTasks.Count);
} }
private bool initialized = false; private bool validated = false;
private async void OnLoad() private async void OnLoad()
{ {
@ -320,9 +306,9 @@ namespace CreamInstaller
cancelButton.Enabled = false; cancelButton.Enabled = false;
scanButton.Enabled = true; scanButton.Enabled = true;
if (!initialized) if (!validated && !Program.Canceled)
{ {
initialized = true; validated = true;
OnLoad(); OnLoad();
} }
} }

View file

@ -7,6 +7,7 @@ using System.IO;
using System.IO.Compression; using System.IO.Compression;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Windows.Forms;
namespace CreamInstaller namespace CreamInstaller
{ {
@ -19,6 +20,7 @@ namespace CreamInstaller
public static string AppCachePath = DirectoryPath + @"\appcache"; public static string AppCachePath = DirectoryPath + @"\appcache";
public static string AppCacheAppInfoPath = AppCachePath + @"\appinfo.vdf"; public static string AppCacheAppInfoPath = AppCachePath + @"\appinfo.vdf";
public static string AppInfoPath = DirectoryPath + @"\appinfo"; public static string AppInfoPath = DirectoryPath + @"\appinfo";
public static string AppInfoVersionPath = AppInfoPath + @"\version.txt";
public static bool Run(string command, out string output) public static bool Run(string command, out string output)
{ {
@ -56,6 +58,12 @@ namespace CreamInstaller
File.Delete(ArchivePath); File.Delete(ArchivePath);
} }
if (File.Exists(AppCacheAppInfoPath)) File.Delete(AppCacheAppInfoPath); if (File.Exists(AppCacheAppInfoPath)) File.Delete(AppCacheAppInfoPath);
if (!File.Exists(AppInfoVersionPath) || !Version.TryParse(File.ReadAllText(AppInfoVersionPath), out Version version) || version < Version.Parse("2.0.2.0"))
{
if (Directory.Exists(AppInfoPath)) Directory.Delete(AppInfoPath, true);
Directory.CreateDirectory(AppInfoPath);
File.WriteAllText(AppInfoVersionPath, Application.ProductVersion);
}
if (!File.Exists(DllPath)) Run($@"+quit", out _); if (!File.Exists(DllPath)) Run($@"+quit", out _);
} }
@ -84,13 +92,13 @@ namespace CreamInstaller
try { appInfo = VdfConvert.Deserialize(output); } try { appInfo = VdfConvert.Deserialize(output); }
catch catch
{ {
if (File.Exists(appUpdateFile)) if (Directory.Exists(appUpdatePath))
{ {
File.Delete(appUpdateFile); Directory.Delete(appUpdatePath, true);
goto restart; goto restart;
} }
} }
if (!(appInfo is null) && appInfo.Value is VValue) goto restart; if (appInfo.Value is VValue) goto restart;
if (appInfo is null || (!(appInfo.Value is VValue) && appInfo.Value.Children().ToList().Count == 0)) return true; if (appInfo is null || (!(appInfo.Value is VValue) && appInfo.Value.Children().ToList().Count == 0)) return true;
VToken type = appInfo.Value is VValue ? null : appInfo.Value?["common"]?["type"]; VToken type = appInfo.Value is VValue ? null : appInfo.Value?["common"]?["type"];
if (type is null || type.ToString() == "Game") if (type is null || type.ToString() == "Game")
@ -99,13 +107,36 @@ namespace CreamInstaller
if (buildid is null && !(type is null)) return true; if (buildid is null && !(type is null)) return true;
if (type is null || int.Parse(buildid) < buildId) if (type is null || int.Parse(buildid) < buildId)
{ {
if (File.Exists(appUpdateFile)) File.Delete(appUpdateFile); foreach (int id in ParseDlcAppIds(appInfo))
{
string dlcAppUpdatePath = $@"{AppInfoPath}\{id}";
if (Directory.Exists(dlcAppUpdatePath)) Directory.Delete(dlcAppUpdatePath, true);
}
if (Directory.Exists(appUpdatePath)) Directory.Delete(appUpdatePath, true);
goto restart; goto restart;
} }
} }
return true; return true;
} }
public static List<int> ParseDlcAppIds(VProperty appInfo)
{
List<int> dlcIds = new();
if (!(appInfo is VProperty)) return dlcIds;
if (!(appInfo.Value["extended"] is null))
foreach (VProperty property in appInfo.Value["extended"])
if (property.Key.ToString() == "listofdlc")
foreach (string id in property.Value.ToString().Split(","))
if (!dlcIds.Contains(int.Parse(id)))
dlcIds.Add(int.Parse(id));
if (!(appInfo.Value["depots"] is null))
foreach (VProperty _property in appInfo.Value["depots"])
if (int.TryParse(_property.Key.ToString(), out int _))
if (int.TryParse(_property.Value?["dlcappid"]?.ToString(), out int appid) && !dlcIds.Contains(appid))
dlcIds.Add(appid);
return dlcIds;
}
public static void Kill() public static void Kill()
{ {
foreach (Process process in Process.GetProcessesByName("steamcmd")) process.Kill(); foreach (Process process in Process.GetProcessesByName("steamcmd")) process.Kill();