This commit is contained in:
pointfeev 2021-11-16 11:16:15 -05:00
parent fb100c10ae
commit 6024b0287f
No known key found for this signature in database
GPG key ID: AA14DC36C4D7D13C
5 changed files with 63 additions and 38 deletions

View file

@ -6,7 +6,7 @@
<UseWindowsForms>true</UseWindowsForms>
<ApplicationIcon>ini.ico</ApplicationIcon>
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
<Version>2.0.2.2</Version>
<Version>2.0.2.3</Version>
<PackageIcon>ini.ico</PackageIcon>
<PackageIconUrl />
<Description>Automatically generates and installs CreamAPI files for Steam games on the user's computer. It can also generate and install CreamAPI for the Paradox Launcher should the user select a Paradox Interactive game.</Description>

View file

@ -180,11 +180,20 @@ namespace CreamInstaller
reselectButton.Enabled = true;
}
private void OnLoad(object sender, EventArgs e)
private void OnLoad(object sender, EventArgs _)
{
userInfoLabel.Text = "Loading . . . ";
logTextBox.Text = string.Empty;
Start();
retry:
try
{
userInfoLabel.Text = "Loading . . . ";
logTextBox.Text = string.Empty;
Start();
}
catch (Exception e)
{
if (ExceptionHandler.OutputException(e)) goto retry;
Close();
}
}
private void OnAccept(object sender, EventArgs e)

View file

@ -130,20 +130,29 @@ namespace CreamInstaller
}
}
private void OnLoad(object sender, EventArgs e)
private void OnLoad(object sender, EventArgs _)
{
string FileName = Path.GetFileName(Program.CurrentProcessFilePath);
if (FileName != "CreamInstaller.exe")
retry:
try
{
if (new DialogForm(this).Show(Program.ApplicationName, SystemIcons.Warning,
"WARNING: CreamInstaller.exe was renamed!" +
"\n\nThis will cause unwanted behavior when updating the program!",
"Ignore", "Abort") == DialogResult.Cancel)
string FileName = Path.GetFileName(Program.CurrentProcessFilePath);
if (FileName != "CreamInstaller.exe")
{
Environment.Exit(0);
if (new DialogForm(this).Show(Program.ApplicationName, SystemIcons.Warning,
"WARNING: CreamInstaller.exe was renamed!" +
"\n\nThis will cause unwanted behavior when updating the program!",
"Ignore", "Abort") == DialogResult.Cancel)
{
Environment.Exit(0);
}
}
OnLoad();
}
catch (Exception e)
{
if (ExceptionHandler.OutputException(e)) goto retry;
Close();
}
OnLoad();
}
private void OnIgnore(object sender, EventArgs e)

View file

@ -31,25 +31,31 @@ namespace CreamInstaller
if (Program.Canceled) return gameDirectories;
string steamInstallPath = Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Valve\\Steam", "InstallPath", null) as string;
if (steamInstallPath == null) steamInstallPath = Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Valve\\Steam", "InstallPath", null) as string;
if (steamInstallPath != null)
if (steamInstallPath != null && Directory.Exists(steamInstallPath))
{
string libraryFolder = steamInstallPath + @"\steamapps";
gameDirectories.Add(libraryFolder);
try
if (Directory.Exists(libraryFolder))
{
string libraryFolders = libraryFolder + @"\libraryfolders.vdf";
dynamic property = VdfConvert.Deserialize(File.ReadAllText(libraryFolders));
foreach (dynamic _property in property.Value)
gameDirectories.Add(libraryFolder);
try
{
if (int.TryParse(_property.Key, out int _))
string libraryFolders = libraryFolder + @"\libraryfolders.vdf";
if (File.Exists(libraryFolders))
{
string path = _property.Value.path.ToString() + @"\steamapps";
if (string.IsNullOrWhiteSpace(path)) continue;
if (!gameDirectories.Contains(path)) gameDirectories.Add(path);
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) || !Directory.Exists(path)) continue;
if (!gameDirectories.Contains(path)) gameDirectories.Add(path);
}
}
}
}
catch { }
}
catch { }
}
return gameDirectories;
}
@ -58,7 +64,7 @@ namespace CreamInstaller
private static bool GetDllDirectoriesFromGameDirectory(string gameDirectory, out List<string> dllDirectories)
{
dllDirectories = new();
if (Program.Canceled) return false;
if (Program.Canceled || !Directory.Exists(gameDirectory)) return false;
string api = gameDirectory + @"\steam_api.dll";
string api64 = gameDirectory + @"\steam_api64.dll";
if (File.Exists(api) || File.Exists(api64)) dllDirectories.Add(gameDirectory);
@ -79,7 +85,7 @@ namespace CreamInstaller
private static bool GetGamesFromLibraryDirectory(string libraryDirectory, out List<Tuple<int, string, string, int, string>> games)
{
games = new();
if (Program.Canceled) return false;
if (Program.Canceled || !Directory.Exists(libraryDirectory)) return false;
foreach (string directory in Directory.GetFiles(libraryDirectory))
{
if (Program.Canceled) return false;
@ -335,7 +341,7 @@ namespace CreamInstaller
}
}
private void OnLoad(object sender, EventArgs e)
private void OnLoad(object sender, EventArgs _)
{
treeView1.AfterCheck += OnTreeViewNodeCheckedChanged;
treeView1.NodeMouseClick += (sender, e) =>
@ -352,7 +358,16 @@ namespace CreamInstaller
});
}
};
OnLoad();
retry:
try
{
OnLoad();
}
catch (Exception e)
{
if (ExceptionHandler.OutputException(e)) goto retry;
Close();
}
}
private static bool ParadoxLauncherDlcDialog(Form form)

View file

@ -28,15 +28,7 @@ namespace CreamInstaller
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.ApplicationExit += new(OnApplicationExit);
retry:
try
{
Application.Run(new MainForm());
}
catch (Exception e)
{
if (ExceptionHandler.OutputException(e)) goto retry;
}
Application.Run(new MainForm());
}
mutex.Close();
}