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> <UseWindowsForms>true</UseWindowsForms>
<ApplicationIcon>ini.ico</ApplicationIcon> <ApplicationIcon>ini.ico</ApplicationIcon>
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract> <IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
<Version>2.0.2.2</Version> <Version>2.0.2.3</Version>
<PackageIcon>ini.ico</PackageIcon> <PackageIcon>ini.ico</PackageIcon>
<PackageIconUrl /> <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> <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; reselectButton.Enabled = true;
} }
private void OnLoad(object sender, EventArgs e) private void OnLoad(object sender, EventArgs _)
{ {
userInfoLabel.Text = "Loading . . . "; retry:
logTextBox.Text = string.Empty; try
Start(); {
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) 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); retry:
if (FileName != "CreamInstaller.exe") try
{ {
if (new DialogForm(this).Show(Program.ApplicationName, SystemIcons.Warning, string FileName = Path.GetFileName(Program.CurrentProcessFilePath);
"WARNING: CreamInstaller.exe was renamed!" + if (FileName != "CreamInstaller.exe")
"\n\nThis will cause unwanted behavior when updating the program!",
"Ignore", "Abort") == DialogResult.Cancel)
{ {
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) private void OnIgnore(object sender, EventArgs e)

View file

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

View file

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