v2.2.4.2
- Minor refactoring - Moved from VDF dynamic parsing to the more reliable method introduced in v2.2.4.1 - Fixed a bug where selections were validating prematurely
This commit is contained in:
parent
f1b7e04842
commit
947809b4ad
15 changed files with 1363 additions and 1386 deletions
|
@ -118,8 +118,8 @@ csharp_style_prefer_index_operator = true
|
|||
csharp_style_prefer_null_check_over_type_check = true
|
||||
csharp_style_prefer_range_operator = true
|
||||
csharp_style_throw_expression = true
|
||||
csharp_style_unused_value_assignment_preference = discard_variable
|
||||
csharp_style_unused_value_expression_statement_preference = unused_local_variable:suggestion
|
||||
csharp_style_unused_value_assignment_preference = discard_variable:silent
|
||||
csharp_style_unused_value_expression_statement_preference = discard_variable
|
||||
|
||||
# 'using' directive preferences
|
||||
csharp_using_directive_placement = outside_namespace:suggestion
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CreamInstaller
|
||||
namespace CreamInstaller;
|
||||
|
||||
internal static class ExceptionHandler
|
||||
{
|
||||
internal static class ExceptionHandler
|
||||
{
|
||||
internal static bool OutputException(Exception e)
|
||||
{
|
||||
while (e.InnerException is not null)
|
||||
|
@ -46,15 +46,14 @@ namespace CreamInstaller
|
|||
}
|
||||
return MessageBox.Show(output, caption: "CreamInstaller encountered an exception", buttons: MessageBoxButtons.RetryCancel, icon: MessageBoxIcon.Error) == DialogResult.Retry;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal class CustomMessageException : Exception
|
||||
{
|
||||
internal class CustomMessageException : Exception
|
||||
{
|
||||
private readonly string message;
|
||||
public override string Message => message ?? "CustomMessageException";
|
||||
|
||||
public override string ToString() => Message;
|
||||
|
||||
internal CustomMessageException(string message) => this.message = message;
|
||||
}
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CreamInstaller
|
||||
namespace CreamInstaller;
|
||||
|
||||
internal static class InstallationLog
|
||||
{
|
||||
internal static class InstallationLog
|
||||
{
|
||||
internal static readonly Color Background = Color.DarkSlateGray;
|
||||
internal static readonly Color Operation = Color.LightGray;
|
||||
internal static readonly Color Resource = Color.LightBlue;
|
||||
|
@ -21,5 +21,4 @@ namespace CreamInstaller
|
|||
logTextBox.AppendText(text);
|
||||
logTextBox.SelectionColor = logTextBox.ForeColor;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,10 +7,10 @@ using System.Threading.Tasks;
|
|||
|
||||
using Gameloop.Vdf.Linq;
|
||||
|
||||
namespace CreamInstaller
|
||||
namespace CreamInstaller;
|
||||
|
||||
internal class ProgramSelection
|
||||
{
|
||||
internal class ProgramSelection
|
||||
{
|
||||
internal bool Enabled = false;
|
||||
internal bool Usable = true;
|
||||
|
||||
|
@ -133,5 +133,4 @@ namespace CreamInstaller
|
|||
if (app.Key == appId) return app;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,10 +11,10 @@ using System.Windows.Forms;
|
|||
|
||||
using Gameloop.Vdf.Linq;
|
||||
|
||||
namespace CreamInstaller
|
||||
namespace CreamInstaller;
|
||||
|
||||
internal static class SteamCMD
|
||||
{
|
||||
internal static class SteamCMD
|
||||
{
|
||||
internal static readonly string DirectoryPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\CreamInstaller";
|
||||
internal static readonly string FilePath = DirectoryPath + @"\steamcmd.exe";
|
||||
internal static readonly string ArchivePath = DirectoryPath + @"\steamcmd.zip";
|
||||
|
@ -107,10 +107,10 @@ namespace CreamInstaller
|
|||
}
|
||||
if (appInfo.Value is VValue) goto restart;
|
||||
if (appInfo is null || appInfo.Value?.Children()?.ToList()?.Count == 0) return appInfo;
|
||||
VToken type = appInfo.Value?.TryGet("common")?.TryGet("type");
|
||||
VToken type = appInfo.Value?.GetChild("common")?.GetChild("type");
|
||||
if (type is null || type.ToString() == "Game")
|
||||
{
|
||||
string buildid = appInfo.Value?.TryGet("depots")?.TryGet("branches")?.TryGet(branch)?.TryGet("buildid")?.ToString();
|
||||
string buildid = appInfo.Value?.GetChild("depots")?.GetChild("branches")?.GetChild(branch)?.GetChild("buildid")?.ToString();
|
||||
if (buildid is null && type is not null) return appInfo;
|
||||
if (type is null || int.Parse(buildid) < buildId)
|
||||
{
|
||||
|
@ -131,14 +131,16 @@ namespace CreamInstaller
|
|||
{
|
||||
List<int> dlcIds = new();
|
||||
if (Program.Canceled || appInfo is not VProperty) return dlcIds;
|
||||
VToken extended = appInfo.Value.TryGet("extended");
|
||||
if (extended is not null) foreach (VProperty property in extended)
|
||||
if (property.Key.ToString() == "listofdlc") foreach (string id in property.Value.ToString().Split(","))
|
||||
VToken extended = appInfo.Value.GetChild("extended");
|
||||
if (extended is not null)
|
||||
foreach (VProperty property in 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));
|
||||
VToken depots = appInfo.Value.TryGet("depots");
|
||||
VToken depots = appInfo.Value.GetChild("depots");
|
||||
if (depots is not null) foreach (VProperty property in depots)
|
||||
if (int.TryParse(property.Key.ToString(), out int _)
|
||||
&& int.TryParse(property.Value.TryGet("dlcappid")?.ToString(), out int appid)
|
||||
&& int.TryParse(property.Value.GetChild("dlcappid")?.ToString(), out int appid)
|
||||
&& !dlcIds.Contains(appid))
|
||||
dlcIds.Add(appid);
|
||||
return dlcIds;
|
||||
|
@ -163,5 +165,4 @@ namespace CreamInstaller
|
|||
Directory.Delete(DirectoryPath, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -17,7 +17,7 @@ internal static class ValveDataFile
|
|||
return false;
|
||||
}
|
||||
|
||||
internal static VToken TryGet(this VToken token, string index)
|
||||
internal static VToken GetChild(this VToken token, string index)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ApplicationIcon>Resources\ini.ico</ApplicationIcon>
|
||||
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
|
||||
<Version>2.2.4.1</Version>
|
||||
<Version>2.2.4.2</Version>
|
||||
<PackageIcon>Resources\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>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
using System.Windows.Forms;
|
||||
|
||||
namespace CreamInstaller
|
||||
namespace CreamInstaller;
|
||||
|
||||
internal class CustomForm : Form
|
||||
{
|
||||
internal class CustomForm : Form
|
||||
{
|
||||
internal CustomForm() : base() => Icon = Properties.Resources.Icon;
|
||||
|
||||
internal CustomForm(IWin32Window owner) : this() => Owner = owner as Form;
|
||||
|
@ -17,5 +17,4 @@ namespace CreamInstaller
|
|||
return handleParam;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CreamInstaller
|
||||
namespace CreamInstaller;
|
||||
|
||||
internal class CustomTreeView : TreeView
|
||||
{
|
||||
internal class CustomTreeView : TreeView
|
||||
{
|
||||
protected override void WndProc(ref Message m)
|
||||
{
|
||||
if (m.Msg == 0x203)
|
||||
|
@ -53,5 +53,4 @@ namespace CreamInstaller
|
|||
Point subLocation = new(location.X - 1, location.Y + 1);
|
||||
TextRenderer.DrawText(graphics, subText, subFont, subLocation, Color.Gray);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CreamInstaller
|
||||
namespace CreamInstaller;
|
||||
|
||||
internal partial class DialogForm : CustomForm
|
||||
{
|
||||
internal partial class DialogForm : CustomForm
|
||||
{
|
||||
internal DialogForm(IWin32Window owner) : base(owner) => InitializeComponent();
|
||||
|
||||
internal DialogResult Show(string formName, Icon descriptionIcon, string descriptionText, string acceptButtonText, string cancelButtonText = null)
|
||||
|
@ -21,5 +21,4 @@ namespace CreamInstaller
|
|||
else cancelButton.Text = cancelButtonText;
|
||||
return ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,10 +8,10 @@ using System.Threading;
|
|||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CreamInstaller
|
||||
namespace CreamInstaller;
|
||||
|
||||
internal partial class InstallForm : CustomForm
|
||||
{
|
||||
internal partial class InstallForm : CustomForm
|
||||
{
|
||||
internal bool Reselecting = false;
|
||||
internal bool Uninstalling = false;
|
||||
|
||||
|
@ -69,10 +69,7 @@ namespace CreamInstaller
|
|||
foreach (string directory in selection.SteamApiDllDirectories)
|
||||
{
|
||||
await UpdateUser($"{(Uninstalling ? "Uninstalling" : "Installing")} CreamAPI for " + selection.Name + $" in directory \"{directory}\" . . . ", InstallationLog.Operation);
|
||||
if (!Program.IsProgramRunningDialog(this, selection))
|
||||
{
|
||||
throw new OperationCanceledException();
|
||||
}
|
||||
if (!Program.IsProgramRunningDialog(this, selection)) throw new OperationCanceledException();
|
||||
string api = directory + @"\steam_api.dll";
|
||||
string api_o = directory + @"\steam_api_o.dll";
|
||||
string api64 = directory + @"\steam_api64.dll";
|
||||
|
@ -132,14 +129,9 @@ namespace CreamInstaller
|
|||
File.Create(cApi).Close();
|
||||
StreamWriter writer = new(cApi, true, Encoding.UTF8);
|
||||
writer.WriteLine("; " + Application.CompanyName + " v" + Application.ProductVersion);
|
||||
if (selection.SteamAppId > 0)
|
||||
{
|
||||
await WriteConfiguration(writer, selection.SteamAppId, selection.Name, selection.SelectedSteamDlc);
|
||||
}
|
||||
if (selection.SteamAppId > 0) await WriteConfiguration(writer, selection.SteamAppId, selection.Name, selection.SelectedSteamDlc);
|
||||
foreach (Tuple<int, string, SortedList<int, string>> extraAppDlc in selection.ExtraSteamAppIdDlc)
|
||||
{
|
||||
await WriteConfiguration(writer, extraAppDlc.Item1, extraAppDlc.Item2, extraAppDlc.Item3);
|
||||
}
|
||||
writer.Flush();
|
||||
writer.Close();
|
||||
}
|
||||
|
@ -239,5 +231,4 @@ namespace CreamInstaller
|
|||
Reselecting = true;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -15,10 +15,10 @@ using Onova;
|
|||
using Onova.Models;
|
||||
using Onova.Services;
|
||||
|
||||
namespace CreamInstaller
|
||||
namespace CreamInstaller;
|
||||
|
||||
internal partial class MainForm : CustomForm
|
||||
{
|
||||
internal partial class MainForm : CustomForm
|
||||
{
|
||||
internal MainForm() : base()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
@ -199,5 +199,4 @@ namespace CreamInstaller
|
|||
updateManager.Dispose();
|
||||
updateManager = null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -14,10 +14,10 @@ using Gameloop.Vdf.Linq;
|
|||
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace CreamInstaller
|
||||
namespace CreamInstaller;
|
||||
|
||||
internal partial class SelectForm : CustomForm
|
||||
{
|
||||
internal partial class SelectForm : CustomForm
|
||||
{
|
||||
internal SelectForm(IWin32Window owner) : base(owner)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
@ -38,12 +38,12 @@ namespace CreamInstaller
|
|||
{
|
||||
gameDirectories.Add(libraryFolder);
|
||||
string libraryFolders = libraryFolder + @"\libraryfolders.vdf";
|
||||
if (File.Exists(libraryFolders) && ValveDataFile.TryDeserialize(File.ReadAllText(libraryFolders, Encoding.UTF8), out VProperty _result))
|
||||
if (File.Exists(libraryFolders) && ValveDataFile.TryDeserialize(File.ReadAllText(libraryFolders, Encoding.UTF8), out VProperty result))
|
||||
{
|
||||
dynamic result = _result;
|
||||
foreach (dynamic property in result?.Value) if (int.TryParse(property.Key, out int _))
|
||||
foreach (VProperty property in result.Value)
|
||||
if (int.TryParse(property.Key, out int _))
|
||||
{
|
||||
string path = property.Value?.path?.ToString();
|
||||
string path = property.Value.GetChild("path")?.ToString();
|
||||
if (string.IsNullOrWhiteSpace(path)) continue;
|
||||
path += @"\steamapps";
|
||||
if (Directory.Exists(path) && !gameDirectories.Contains(path)) gameDirectories.Add(path);
|
||||
|
@ -72,8 +72,7 @@ namespace CreamInstaller
|
|||
}
|
||||
catch { }
|
||||
}
|
||||
if (!dllDirectories.Any()) return null;
|
||||
return dllDirectories;
|
||||
return !dllDirectories.Any() ? null : dllDirectories;
|
||||
});
|
||||
|
||||
private static async Task<List<Tuple<int, string, string, int, string>>> GetGamesFromLibraryDirectory(string libraryDirectory) => await Task.Run(() =>
|
||||
|
@ -84,28 +83,26 @@ namespace CreamInstaller
|
|||
foreach (string file in files)
|
||||
{
|
||||
if (Program.Canceled) return null;
|
||||
if (Path.GetExtension(file) == ".acf" && ValveDataFile.TryDeserialize(File.ReadAllText(file, Encoding.UTF8), out VProperty _result))
|
||||
if (Path.GetExtension(file) == ".acf" && ValveDataFile.TryDeserialize(File.ReadAllText(file, Encoding.UTF8), out VProperty result))
|
||||
{
|
||||
dynamic result = _result;
|
||||
string _appid = result.Value?.appid?.ToString();
|
||||
string installdir = result.Value?.installdir?.ToString();
|
||||
string name = result.Value?.name?.ToString();
|
||||
string _buildid = result.Value?.buildid?.ToString();
|
||||
if (string.IsNullOrWhiteSpace(_appid)
|
||||
string appId = result.Value.GetChild("appid")?.ToString();
|
||||
string installdir = result.Value.GetChild("installdir")?.ToString();
|
||||
string name = result.Value.GetChild("name")?.ToString();
|
||||
string buildId = result.Value.GetChild("buildid")?.ToString();
|
||||
if (string.IsNullOrWhiteSpace(appId)
|
||||
|| string.IsNullOrWhiteSpace(installdir)
|
||||
|| string.IsNullOrWhiteSpace(name)
|
||||
|| string.IsNullOrWhiteSpace(_buildid))
|
||||
|| string.IsNullOrWhiteSpace(buildId))
|
||||
continue;
|
||||
string branch = result.Value?.UserConfig?.betakey?.ToString();
|
||||
string branch = result.Value.GetChild("UserConfig")?.GetChild("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));
|
||||
if (!int.TryParse(appId, out int appIdInt)) continue;
|
||||
if (!int.TryParse(buildId, out int buildIdInt)) continue;
|
||||
games.Add(new(appIdInt, name, branch, buildIdInt, gameDirectory));
|
||||
}
|
||||
}
|
||||
if (!games.Any()) return null;
|
||||
return games;
|
||||
return !games.Any() ? null : games;
|
||||
});
|
||||
|
||||
internal List<TreeNode> TreeNodes => GatherTreeNodes(selectionTreeView.Nodes);
|
||||
|
@ -138,7 +135,7 @@ namespace CreamInstaller
|
|||
applicablePrograms.Add(game);
|
||||
}
|
||||
|
||||
int cur = 0;
|
||||
int CompleteTasks = 0;
|
||||
RunningTasks.Clear();
|
||||
foreach (Tuple<int, string, string, int, string> program in applicablePrograms)
|
||||
{
|
||||
|
@ -148,7 +145,6 @@ namespace CreamInstaller
|
|||
int buildId = program.Item4;
|
||||
string directory = program.Item5;
|
||||
ProgramSelection selection = ProgramSelection.FromAppId(appId);
|
||||
if (selection is not null) selection.Validate();
|
||||
if (Program.Canceled) return;
|
||||
if (Program.BlockProtectedGames && Program.IsGameBlocked(name, directory)) continue;
|
||||
RunningTasks.Add(Task.Run(async () =>
|
||||
|
@ -173,11 +169,11 @@ namespace CreamInstaller
|
|||
if (Program.Canceled) return;
|
||||
string dlcName = null;
|
||||
VProperty dlcAppInfo = await SteamCMD.GetAppInfo(id);
|
||||
if (dlcAppInfo is not null) dlcName = dlcAppInfo.Value?.TryGet("common")?.TryGet("name")?.ToString();
|
||||
if (dlcAppInfo is not null) dlcName = dlcAppInfo.Value?.GetChild("common")?.GetChild("name")?.ToString();
|
||||
if (Program.Canceled) return;
|
||||
if (string.IsNullOrWhiteSpace(dlcName)) return; //dlcName = "Unknown DLC";
|
||||
dlc[id] = /*$"[{id}] " +*/ dlcName;
|
||||
progress.Report(++cur);
|
||||
progress.Report(++CompleteTasks);
|
||||
});
|
||||
dlcTasks.Add(task);
|
||||
RunningTasks.Add(task);
|
||||
|
@ -201,8 +197,8 @@ namespace CreamInstaller
|
|||
if (appId == 0) selection.Icon = Program.GetFileIconImage(directory + @"\launcher\bootstrapper-v2.exe");
|
||||
else
|
||||
{
|
||||
selection.IconStaticID = appInfo?.Value?.TryGet("common")?.TryGet("icon")?.ToString();
|
||||
selection.ClientIconStaticID = appInfo?.Value?.TryGet("common")?.TryGet("clienticon")?.ToString();
|
||||
selection.IconStaticID = appInfo?.Value?.GetChild("common")?.GetChild("icon")?.ToString();
|
||||
selection.ClientIconStaticID = appInfo?.Value?.GetChild("common")?.GetChild("clienticon")?.ToString();
|
||||
}
|
||||
}
|
||||
if (allCheckBox.Checked) selection.Enabled = true;
|
||||
|
@ -242,8 +238,7 @@ namespace CreamInstaller
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
progress.Report(++cur);
|
||||
progress.Report(++CompleteTasks);
|
||||
}));
|
||||
progress.Report(-RunningTasks.Count);
|
||||
}
|
||||
|
@ -443,14 +438,14 @@ namespace CreamInstaller
|
|||
foreach (ProgramSelection selection in ProgramSelection.AllUsableEnabled)
|
||||
{
|
||||
if (selection.Name == paradoxLauncher.Name) continue;
|
||||
if (selection.AppInfo.Value?.TryGet("extended")?.TryGet("publisher")?.ToString() != "Paradox Interactive") continue;
|
||||
if (selection.AppInfo.Value?.GetChild("extended")?.GetChild("publisher")?.ToString() != "Paradox Interactive") continue;
|
||||
paradoxLauncher.ExtraSteamAppIdDlc.Add(new(selection.SteamAppId, selection.Name, selection.SelectedSteamDlc));
|
||||
}
|
||||
if (!paradoxLauncher.ExtraSteamAppIdDlc.Any())
|
||||
foreach (ProgramSelection selection in ProgramSelection.AllUsable)
|
||||
{
|
||||
if (selection.Name == paradoxLauncher.Name) continue;
|
||||
if (selection.AppInfo.Value?.TryGet("extended")?.TryGet("publisher")?.ToString() != "Paradox Interactive") continue;
|
||||
if (selection.AppInfo.Value?.GetChild("extended")?.GetChild("publisher")?.ToString() != "Paradox Interactive") continue;
|
||||
paradoxLauncher.ExtraSteamAppIdDlc.Add(new(selection.SteamAppId, selection.Name, selection.AllSteamDlc));
|
||||
}
|
||||
}
|
||||
|
@ -547,5 +542,4 @@ namespace CreamInstaller
|
|||
"\n\nBlocked game sub-directory exceptions (not blocked):" + blockedDirectoryExceptions,
|
||||
"OK");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,10 +10,10 @@ using System.Threading;
|
|||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CreamInstaller
|
||||
namespace CreamInstaller;
|
||||
|
||||
internal static class Program
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
internal static readonly string ApplicationName = Application.CompanyName + " v" + Application.ProductVersion + ": " + Application.ProductName;
|
||||
internal static readonly Assembly EntryAssembly = Assembly.GetEntryAssembly();
|
||||
internal static readonly Process CurrentProcess = Process.GetCurrentProcess();
|
||||
|
@ -130,5 +130,4 @@ namespace CreamInstaller
|
|||
int Y = fromForm.Location.Y + fromForm.Size.Height / 2 - form.Size.Height / 2;
|
||||
form.Location = new(X, Y);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,13 +1,12 @@
|
|||
using System.IO;
|
||||
|
||||
namespace CreamInstaller
|
||||
namespace CreamInstaller;
|
||||
|
||||
internal static class FileResourceExtensions
|
||||
{
|
||||
internal static class FileResourceExtensions
|
||||
{
|
||||
internal static void Write(this byte[] resource, string filePath)
|
||||
{
|
||||
using FileStream file = new(filePath, FileMode.Create, FileAccess.Write);
|
||||
file.Write(resource);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue