diff --git a/CreamInstaller/CreamInstaller.csproj b/CreamInstaller/CreamInstaller.csproj
index e91447b..5c74ccd 100644
--- a/CreamInstaller/CreamInstaller.csproj
+++ b/CreamInstaller/CreamInstaller.csproj
@@ -6,7 +6,7 @@
true
ini.ico
true
- 2.0.1.0
+ 2.0.2.0
ini.ico
Automatically installs and generates CreamAPI files for programs/games on the user's computer.
diff --git a/CreamInstaller/ExceptionHandler.cs b/CreamInstaller/ExceptionHandler.cs
index b3fdfce..3dd3dfc 100644
--- a/CreamInstaller/ExceptionHandler.cs
+++ b/CreamInstaller/ExceptionHandler.cs
@@ -52,4 +52,4 @@ namespace CreamInstaller
this.message = message;
}
}
-}
+}
\ No newline at end of file
diff --git a/CreamInstaller/Forms/SelectForm.cs b/CreamInstaller/Forms/SelectForm.cs
index 979567b..e9da57f 100644
--- a/CreamInstaller/Forms/SelectForm.cs
+++ b/CreamInstaller/Forms/SelectForm.cs
@@ -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 dlc = new();
List dlcTasks = new();
- List 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 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();
}
}
diff --git a/CreamInstaller/Program.cs b/CreamInstaller/Program.cs
index 6ce1ad4..2b647c7 100644
--- a/CreamInstaller/Program.cs
+++ b/CreamInstaller/Program.cs
@@ -29,7 +29,7 @@ namespace CreamInstaller
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.ApplicationExit += new EventHandler(OnApplicationExit);
- retry:
+ retry:
try
{
Application.Run(new MainForm());
diff --git a/CreamInstaller/SteamCMD.cs b/CreamInstaller/SteamCMD.cs
index 969ad02..0abf965 100644
--- a/CreamInstaller/SteamCMD.cs
+++ b/CreamInstaller/SteamCMD.cs
@@ -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 ParseDlcAppIds(VProperty appInfo)
+ {
+ List 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();