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>
<ApplicationIcon>ini.ico</ApplicationIcon>
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
<Version>2.0.1.0</Version>
<Version>2.0.2.0</Version>
<PackageIcon>ini.ico</PackageIcon>
<PackageIconUrl />
<Description>Automatically installs and generates CreamAPI files for programs/games on the user's computer.</Description>

View file

@ -52,4 +52,4 @@ namespace CreamInstaller
this.message = message;
}
}
}
}

View file

@ -35,21 +35,21 @@ namespace CreamInstaller
{
string libraryFolder = steamInstallPath + @"\steamapps";
gameDirectories.Add(libraryFolder);
try
{
string libraryFolders = libraryFolder + @"\libraryfolders.vdf";
dynamic property = VdfConvert.Deserialize(File.ReadAllText(libraryFolders));
foreach (dynamic _property in property.Value)
{
if (int.TryParse(_property.Key, out int _))
{
string path = _property.Value.path.ToString() + @"\steamapps";
if (string.IsNullOrWhiteSpace(path)) continue;
if (!gameDirectories.Contains(path)) gameDirectories.Add(path);
}
}
}
catch {}
try
{
string libraryFolders = libraryFolder + @"\libraryfolders.vdf";
dynamic property = VdfConvert.Deserialize(File.ReadAllText(libraryFolders));
foreach (dynamic _property in property.Value)
{
if (int.TryParse(_property.Key, out int _))
{
string path = _property.Value.path.ToString() + @"\steamapps";
if (string.IsNullOrWhiteSpace(path)) continue;
if (!gameDirectories.Contains(path)) gameDirectories.Add(path);
}
}
}
catch { }
}
return gameDirectories;
}
@ -85,25 +85,25 @@ namespace CreamInstaller
if (Program.Canceled) return false;
if (Path.GetExtension(directory) == ".acf")
{
try
{
dynamic property = VdfConvert.Deserialize(File.ReadAllText(directory));
string _appid = property.Value.appid.ToString();
string installdir = property.Value.installdir.ToString();
string name = property.Value.name.ToString();
string _buildid = property.Value.buildid.ToString();
try
{
dynamic property = VdfConvert.Deserialize(File.ReadAllText(directory));
string _appid = property.Value.appid.ToString();
string installdir = property.Value.installdir.ToString();
string name = property.Value.name.ToString();
string _buildid = property.Value.buildid.ToString();
if (string.IsNullOrWhiteSpace(_appid)
|| string.IsNullOrWhiteSpace(installdir)
|| string.IsNullOrWhiteSpace(name)
|| string.IsNullOrWhiteSpace(_buildid)) continue;
|| string.IsNullOrWhiteSpace(installdir)
|| string.IsNullOrWhiteSpace(name)
|| string.IsNullOrWhiteSpace(_buildid)) continue;
string branch = property.Value.UserConfig?.betakey?.ToString();
if (string.IsNullOrWhiteSpace(branch)) branch = "public";
string gameDirectory = libraryDirectory + @"\common\" + installdir;
if (!int.TryParse(_appid, out int appid)) continue;
if (!int.TryParse(_buildid, out int buildid)) continue;
games.Add(new(appid, name, branch, buildid, gameDirectory));
}
catch {}
if (!int.TryParse(_appid, out int appid)) continue;
if (!int.TryParse(_buildid, out int buildid)) continue;
games.Add(new(appid, name, branch, buildid, gameDirectory));
}
catch { }
}
}
if (!games.Any()) return false;
@ -146,22 +146,8 @@ namespace CreamInstaller
if (Program.Canceled) return;
ConcurrentDictionary<int, string> dlc = new();
List<Task> dlcTasks = new();
List<int> dlcIds = new();
if (!(appInfo is null))
{
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)
List<int> dlcIds = SteamCMD.ParseDlcAppIds(appInfo);
if (dlcIds.Count > 0)
{
foreach (int id in dlcIds)
{
@ -173,7 +159,7 @@ namespace CreamInstaller
VProperty dlcAppInfo = null;
if (SteamCMD.GetAppInfo(id, out dlcAppInfo)) dlcName = dlcAppInfo?.Value?["common"]?["name"]?.ToString();
if (Program.Canceled) return;
if (string.IsNullOrWhiteSpace(dlcName)) dlcName = $"Unknown DLC ({id})";
if (string.IsNullOrWhiteSpace(dlcName)) return;
dlc[id] = dlcName;
});
dlcTasks.Add(task);
@ -242,7 +228,7 @@ namespace CreamInstaller
progress.Report(RunningTasks.Count);
}
private bool initialized = false;
private bool validated = false;
private async void OnLoad()
{
@ -320,9 +306,9 @@ namespace CreamInstaller
cancelButton.Enabled = false;
scanButton.Enabled = true;
if (!initialized)
if (!validated && !Program.Canceled)
{
initialized = true;
validated = true;
OnLoad();
}
}

View file

@ -29,7 +29,7 @@ namespace CreamInstaller
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.ApplicationExit += new EventHandler(OnApplicationExit);
retry:
retry:
try
{
Application.Run(new MainForm());

View file

@ -7,6 +7,7 @@ using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Windows.Forms;
namespace CreamInstaller
{
@ -19,6 +20,7 @@ namespace CreamInstaller
public static string AppCachePath = DirectoryPath + @"\appcache";
public static string AppCacheAppInfoPath = AppCachePath + @"\appinfo.vdf";
public static string AppInfoPath = DirectoryPath + @"\appinfo";
public static string AppInfoVersionPath = AppInfoPath + @"\version.txt";
public static bool Run(string command, out string output)
{
@ -56,6 +58,12 @@ namespace CreamInstaller
File.Delete(ArchivePath);
}
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 _);
}
@ -66,7 +74,7 @@ namespace CreamInstaller
string output;
string appUpdatePath = $@"{AppInfoPath}\{appId}";
string appUpdateFile = $@"{appUpdatePath}\appinfo.txt";
restart:
restart:
if (Directory.Exists(appUpdatePath) && File.Exists(appUpdateFile)) output = File.ReadAllText(appUpdateFile);
else
{
@ -84,13 +92,13 @@ namespace CreamInstaller
try { appInfo = VdfConvert.Deserialize(output); }
catch
{
if (File.Exists(appUpdateFile))
if (Directory.Exists(appUpdatePath))
{
File.Delete(appUpdateFile);
Directory.Delete(appUpdatePath, true);
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;
VToken type = appInfo.Value is VValue ? null : appInfo.Value?["common"]?["type"];
if (type is null || type.ToString() == "Game")
@ -99,13 +107,36 @@ namespace CreamInstaller
if (buildid is null && !(type is null)) return true;
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;
}
}
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()
{
foreach (Process process in Process.GetProcessesByName("steamcmd")) process.Kill();