beginning of migration back to CreamAPI

This commit is contained in:
pointfeev 2024-07-21 05:57:26 -04:00
parent a25bd8b9dc
commit a198b7f9e5
15 changed files with 548 additions and 328 deletions

View file

@ -13,7 +13,7 @@ namespace CreamInstaller.Components;
internal sealed class CustomTreeView : TreeView internal sealed class CustomTreeView : TreeView
{ {
private const string KoaloaderToggleString = "Koaloader"; private const string ProxyToggleString = "Proxy";
private static readonly Color C1 = ColorTranslator.FromHtml("#FFFF99"); private static readonly Color C1 = ColorTranslator.FromHtml("#FFFF99");
private static readonly Color C2 = ColorTranslator.FromHtml("#696900"); private static readonly Color C2 = ColorTranslator.FromHtml("#696900");
@ -121,7 +121,7 @@ internal sealed class CustomTreeView : TreeView
if (form is SelectForm) if (form is SelectForm)
{ {
Selection selection = Selection.FromId(platform, id); Selection selection = Selection.FromId(platform, id);
if (selection is not null) if (selection is not null && selection.CanUseProxy)
{ {
if (bounds == node.Bounds) if (bounds == node.Bounds)
{ {
@ -130,7 +130,7 @@ internal sealed class CustomTreeView : TreeView
graphics.FillRectangle(brush, bounds); graphics.FillRectangle(brush, bounds);
} }
CheckBoxState checkBoxState = selection.Koaloader CheckBoxState checkBoxState = selection.UseProxy
? Enabled ? CheckBoxState.CheckedPressed : CheckBoxState.CheckedDisabled ? Enabled ? CheckBoxState.CheckedPressed : CheckBoxState.CheckedDisabled
: Enabled : Enabled
? CheckBoxState.UncheckedPressed ? CheckBoxState.UncheckedPressed
@ -142,7 +142,7 @@ internal sealed class CustomTreeView : TreeView
graphics.FillRectangle(backBrush, bounds); graphics.FillRectangle(backBrush, bounds);
point = new(bounds.Left, bounds.Top + bounds.Height / 2 - size.Height / 2 - 1); point = new(bounds.Left, bounds.Top + bounds.Height / 2 - size.Height / 2 - 1);
CheckBoxRenderer.DrawCheckBox(graphics, point, checkBoxState); CheckBoxRenderer.DrawCheckBox(graphics, point, checkBoxState);
text = KoaloaderToggleString; text = ProxyToggleString;
size = TextRenderer.MeasureText(graphics, text, font); size = TextRenderer.MeasureText(graphics, text, font);
int left = 1; int left = 1;
bounds = bounds with { X = bounds.X + bounds.Width, Width = size.Width + left }; bounds = bounds with { X = bounds.X + bounds.Width, Width = size.Width + left };
@ -152,12 +152,12 @@ internal sealed class CustomTreeView : TreeView
point = new(bounds.Location.X - 1 + left, bounds.Location.Y + 1); point = new(bounds.Location.X - 1 + left, bounds.Location.Y + 1);
TextRenderer.DrawText(graphics, text, font, point, Enabled ? C7 : C8, TextFormatFlags.Default); TextRenderer.DrawText(graphics, text, font, point, Enabled ? C7 : C8, TextFormatFlags.Default);
this.checkBoxBounds[selection] = RectangleToClient(checkBoxBounds); this.checkBoxBounds[selection] = RectangleToClient(checkBoxBounds);
if (selection.Koaloader) if (selection.UseProxy)
{ {
comboBoxFont ??= new(font.FontFamily, 6, font.Style, font.Unit, font.GdiCharSet, comboBoxFont ??= new(font.FontFamily, 6, font.Style, font.Unit, font.GdiCharSet,
font.GdiVerticalFont); font.GdiVerticalFont);
ComboBoxState comboBoxState = Enabled ? ComboBoxState.Normal : ComboBoxState.Disabled; ComboBoxState comboBoxState = Enabled ? ComboBoxState.Normal : ComboBoxState.Disabled;
text = (selection.KoaloaderProxy ?? Selection.DefaultKoaloaderProxy) + ".dll"; text = (selection.Proxy ?? Selection.DefaultProxy) + ".dll";
size = TextRenderer.MeasureText(graphics, text, comboBoxFont) + new Size(6, 0); size = TextRenderer.MeasureText(graphics, text, comboBoxFont) + new Size(6, 0);
const int padding = 2; const int padding = 2;
bounds = new(bounds.X + bounds.Width, bounds.Y + padding / 2, size.Width, bounds.Height - padding); bounds = new(bounds.X + bounds.Width, bounds.Y + padding / 2, size.Width, bounds.Height - padding);
@ -233,8 +233,8 @@ internal sealed class CustomTreeView : TreeView
if (canUse) if (canUse)
_ = comboBoxDropDown.Items.Add(new ToolStripButton(proxy + ".dll", null, (_, _) => _ = comboBoxDropDown.Items.Add(new ToolStripButton(proxy + ".dll", null, (_, _) =>
{ {
pair.Key.KoaloaderProxy = proxy == Selection.DefaultKoaloaderProxy ? null : proxy; pair.Key.Proxy = proxy == Selection.DefaultProxy ? null : proxy;
selectForm.OnKoaloaderChanged(); selectForm.OnProxyChanged();
}) { Font = comboBoxFont }); }) { Font = comboBoxFont });
} }
@ -247,8 +247,8 @@ internal sealed class CustomTreeView : TreeView
_ = checkBoxBounds.Remove(pair.Key); _ = checkBoxBounds.Remove(pair.Key);
else if (pair.Value.Contains(clickPoint)) else if (pair.Value.Contains(clickPoint))
{ {
pair.Key.Koaloader = !pair.Key.Koaloader; pair.Key.UseProxy = !pair.Key.UseProxy;
selectForm?.OnKoaloaderChanged(); selectForm?.OnProxyChanged();
break; break;
} }
} }

View file

@ -4,7 +4,7 @@
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework> <TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
<UseWindowsForms>True</UseWindowsForms> <UseWindowsForms>True</UseWindowsForms>
<ApplicationIcon>Resources\program.ico</ApplicationIcon> <ApplicationIcon>Resources\program.ico</ApplicationIcon>
<Version>4.10.2</Version> <Version>5.0.0.0</Version>
<Copyright>2021, pointfeev (https://github.com/pointfeev)</Copyright> <Copyright>2021, pointfeev (https://github.com/pointfeev)</Copyright>
<Company>CreamInstaller</Company> <Company>CreamInstaller</Company>
<Product>Automatic DLC Unlocker Installer &amp; Configuration Generator</Product> <Product>Automatic DLC Unlocker Installer &amp; Configuration Generator</Product>
@ -22,7 +22,7 @@
<ProduceReferenceAssembly>False</ProduceReferenceAssembly> <ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks> <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<SupportedOSPlatformVersion>8.0</SupportedOSPlatformVersion> <SupportedOSPlatformVersion>10.0.17763.0</SupportedOSPlatformVersion>
<Platforms>x64</Platforms> <Platforms>x64</Platforms>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'"> <PropertyGroup Condition="'$(Configuration)'=='Release'">
@ -147,11 +147,15 @@
<EmbeddedResource Include="Resources\UplayR1\uplay_r1_loader64.dll" /> <EmbeddedResource Include="Resources\UplayR1\uplay_r1_loader64.dll" />
<EmbeddedResource Include="Resources\UplayR2\upc_r2_loader.dll" /> <EmbeddedResource Include="Resources\UplayR2\upc_r2_loader.dll" />
<EmbeddedResource Include="Resources\UplayR2\upc_r2_loader64.dll" /> <EmbeddedResource Include="Resources\UplayR2\upc_r2_loader64.dll" />
<None Remove="Resources\CreamAPI\steam_api.dll" />
<EmbeddedResource Include="Resources\CreamAPI\steam_api.dll" />
<None Remove="Resources\CreamAPI\steam_api64.dll" />
<EmbeddedResource Include="Resources\CreamAPI\steam_api64.dll" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Gameloop.Vdf" Version="0.6.2" /> <PackageReference Include="Gameloop.Vdf" Version="0.6.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.ServiceModel.Primitives" Version="6.0.0"/> <PackageReference Include="System.ServiceModel.Primitives" Version="8.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Update="Forms\DebugForm.cs"> <Compile Update="Forms\DebugForm.cs">

View file

@ -64,6 +64,8 @@ internal sealed partial class InstallForm : CustomForm
_ = await Repair(this, selection); _ = await Repair(this, selection);
} }
bool useKoaloader = selection.UseProxy && (Program.UseSmokeAPI || selection.Platform is not Platform.Steam);
UpdateUser( UpdateUser(
$"{(uninstalling ? "Uninstalling" : "Installing")}" + $" {(uninstalling ? "from" : "for")} " + $"{(uninstalling ? "Uninstalling" : "Installing")}" + $" {(uninstalling ? "from" : "for")} " +
selection.Name selection.Name
@ -93,7 +95,7 @@ internal sealed partial class InstallForm : CustomForm
} }
} }
if (uninstalling || !selection.Koaloader) if (uninstalling || !useKoaloader)
foreach ((string directory, BinaryType _) in selection.ExecutableDirectories) foreach ((string directory, BinaryType _) in selection.ExecutableDirectories)
{ {
if (Program.Canceled) if (Program.Canceled)
@ -111,47 +113,68 @@ internal sealed partial class InstallForm : CustomForm
} }
} }
bool uninstallProxy = uninstalling || selection.Koaloader; bool uninstallingForKoaloader = uninstalling || useKoaloader;
int count = selection.DllDirectories.Count, cur = 0; int count = selection.DllDirectories.Count, cur = 0;
foreach (string directory in selection.DllDirectories) foreach (string directory in selection.DllDirectories)
{ {
if (Program.Canceled) if (Program.Canceled)
return; return;
if (selection.Platform is Platform.Steam or Platform.Paradox) if (selection.Platform is Platform.Steam or Platform.Paradox)
{
if (Program.UseSmokeAPI)
{ {
directory.GetSmokeApiComponents(out string api32, out string api32_o, out string api64, directory.GetSmokeApiComponents(out string api32, out string api32_o, out string api64,
out string api64_o, out string old_config, out string api64_o, out string old_config,
out string config, out string old_log, out string log, out string cache); out string config, out string old_log, out string log, out string cache);
if (uninstallProxy if (uninstallingForKoaloader
? api32_o.FileExists() || api64_o.FileExists() || old_config.FileExists() || ? api32_o.FileExists() || api64_o.FileExists() || old_config.FileExists() ||
config.FileExists() || old_log.FileExists() || log.FileExists() config.FileExists() || old_log.FileExists() || log.FileExists()
|| cache.FileExists() || cache.FileExists()
: api32.FileExists() || api64.FileExists()) : api32.FileExists() || api64.FileExists())
{ {
UpdateUser( UpdateUser(
$"{(uninstallProxy ? "Uninstalling" : "Installing")} SmokeAPI" + $"{(uninstallingForKoaloader ? "Uninstalling" : "Installing")} SmokeAPI" +
$" {(uninstallProxy ? "from" : "for")} " + selection.Name $" {(uninstallingForKoaloader ? "from" : "for")} " + selection.Name
+ $" in directory \"{directory}\" . . . ", LogTextBox.Operation); + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);
if (uninstallProxy) if (uninstallingForKoaloader)
await SmokeAPI.Uninstall(directory, this); await SmokeAPI.Uninstall(directory, this);
else else
await SmokeAPI.Install(directory, selection, this); await SmokeAPI.Install(directory, selection, this);
} }
} }
else
{
directory.GetCreamApiComponents(out string api32, out string api32_o, out string api64,
out string api64_o, out string config);
if (uninstalling
? api32_o.FileExists() || api64_o.FileExists() || config.FileExists()
: api32.FileExists() || api64.FileExists())
{
UpdateUser(
$"{(uninstalling ? "Uninstalling" : "Installing")} CreamAPI" +
$" {(uninstalling ? "from" : "for")} " + selection.Name
+ $" in directory \"{directory}\" . . . ", LogTextBox.Operation);
if (uninstalling)
await CreamAPI.Uninstall(directory, this);
else
await CreamAPI.Install(directory, selection, this);
}
}
}
if (selection.Platform is Platform.Epic or Platform.Paradox) if (selection.Platform is Platform.Epic or Platform.Paradox)
{ {
directory.GetScreamApiComponents(out string api32, out string api32_o, out string api64, directory.GetScreamApiComponents(out string api32, out string api32_o, out string api64,
out string api64_o, out string config, out string log); out string api64_o, out string config, out string log);
if (uninstallProxy if (uninstallingForKoaloader
? api32_o.FileExists() || api64_o.FileExists() || config.FileExists() || log.FileExists() ? api32_o.FileExists() || api64_o.FileExists() || config.FileExists() || log.FileExists()
: api32.FileExists() || api64.FileExists()) : api32.FileExists() || api64.FileExists())
{ {
UpdateUser( UpdateUser(
$"{(uninstallProxy ? "Uninstalling" : "Installing")} ScreamAPI" + $"{(uninstallingForKoaloader ? "Uninstalling" : "Installing")} ScreamAPI" +
$" {(uninstallProxy ? "from" : "for")} " + selection.Name $" {(uninstallingForKoaloader ? "from" : "for")} " + selection.Name
+ $" in directory \"{directory}\" . . . ", LogTextBox.Operation); + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);
if (uninstallProxy) if (uninstallingForKoaloader)
await ScreamAPI.Uninstall(directory, this); await ScreamAPI.Uninstall(directory, this);
else else
await ScreamAPI.Install(directory, selection, this); await ScreamAPI.Install(directory, selection, this);
@ -162,15 +185,15 @@ internal sealed partial class InstallForm : CustomForm
{ {
directory.GetUplayR1Components(out string api32, out string api32_o, out string api64, directory.GetUplayR1Components(out string api32, out string api32_o, out string api64,
out string api64_o, out string config, out string log); out string api64_o, out string config, out string log);
if (uninstallProxy if (uninstallingForKoaloader
? api32_o.FileExists() || api64_o.FileExists() || config.FileExists() || log.FileExists() ? api32_o.FileExists() || api64_o.FileExists() || config.FileExists() || log.FileExists()
: api32.FileExists() || api64.FileExists()) : api32.FileExists() || api64.FileExists())
{ {
UpdateUser( UpdateUser(
$"{(uninstallProxy ? "Uninstalling" : "Installing")} Uplay R1 Unlocker" + $"{(uninstallingForKoaloader ? "Uninstalling" : "Installing")} Uplay R1 Unlocker" +
$" {(uninstallProxy ? "from" : "for")} " + selection.Name $" {(uninstallingForKoaloader ? "from" : "for")} " + selection.Name
+ $" in directory \"{directory}\" . . . ", LogTextBox.Operation); + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);
if (uninstallProxy) if (uninstallingForKoaloader)
await UplayR1.Uninstall(directory, this); await UplayR1.Uninstall(directory, this);
else else
await UplayR1.Install(directory, selection, this); await UplayR1.Install(directory, selection, this);
@ -178,15 +201,15 @@ internal sealed partial class InstallForm : CustomForm
directory.GetUplayR2Components(out string old_api32, out string old_api64, out api32, out api32_o, directory.GetUplayR2Components(out string old_api32, out string old_api64, out api32, out api32_o,
out api64, out api64_o, out config, out log); out api64, out api64_o, out config, out log);
if (uninstallProxy if (uninstallingForKoaloader
? api32_o.FileExists() || api64_o.FileExists() || config.FileExists() || log.FileExists() ? api32_o.FileExists() || api64_o.FileExists() || config.FileExists() || log.FileExists()
: old_api32.FileExists() || old_api64.FileExists() || api32.FileExists() || api64.FileExists()) : old_api32.FileExists() || old_api64.FileExists() || api32.FileExists() || api64.FileExists())
{ {
UpdateUser( UpdateUser(
$"{(uninstallProxy ? "Uninstalling" : "Installing")} Uplay R2 Unlocker" + $"{(uninstallingForKoaloader ? "Uninstalling" : "Installing")} Uplay R2 Unlocker" +
$" {(uninstallProxy ? "from" : "for")} " + selection.Name $" {(uninstallingForKoaloader ? "from" : "for")} " + selection.Name
+ $" in directory \"{directory}\" . . . ", LogTextBox.Operation); + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);
if (uninstallProxy) if (uninstallingForKoaloader)
await UplayR2.Uninstall(directory, this); await UplayR2.Uninstall(directory, this);
else else
await UplayR2.Install(directory, selection, this); await UplayR2.Install(directory, selection, this);
@ -196,7 +219,7 @@ internal sealed partial class InstallForm : CustomForm
UpdateProgress(++cur / count * 100); UpdateProgress(++cur / count * 100);
} }
if (selection.Koaloader && !uninstalling) if (useKoaloader && !uninstalling)
foreach ((string directory, BinaryType binaryType) in selection.ExecutableDirectories) foreach ((string directory, BinaryType binaryType) in selection.ExecutableDirectories)
{ {
if (Program.Canceled) if (Program.Canceled)

View file

@ -22,8 +22,8 @@ namespace CreamInstaller.Forms
installButton = new Button(); installButton = new Button();
cancelButton = new Button(); cancelButton = new Button();
programsGroupBox = new GroupBox(); programsGroupBox = new GroupBox();
koaloaderFlowPanel = new FlowLayoutPanel(); proxyFlowPanel = new FlowLayoutPanel();
koaloaderAllCheckBox = new CheckBox(); proxyAllCheckBox = new CheckBox();
noneFoundLabel = new Label(); noneFoundLabel = new Label();
blockedGamesFlowPanel = new FlowLayoutPanel(); blockedGamesFlowPanel = new FlowLayoutPanel();
blockedGamesCheckBox = new CheckBox(); blockedGamesCheckBox = new CheckBox();
@ -39,13 +39,13 @@ namespace CreamInstaller.Forms
sortCheckBox = new CheckBox(); sortCheckBox = new CheckBox();
saveButton = new Button(); saveButton = new Button();
loadButton = new Button(); loadButton = new Button();
resetKoaloaderButton = new Button(); resetProxyButton = new Button();
resetButton = new Button(); resetButton = new Button();
saveKoaloaderButton = new Button(); saveProxyButton = new Button();
loadKoaloaderButton = new Button(); loadProxyButton = new Button();
selectionTreeView = new CustomTreeView(); selectionTreeView = new CustomTreeView();
programsGroupBox.SuspendLayout(); programsGroupBox.SuspendLayout();
koaloaderFlowPanel.SuspendLayout(); proxyFlowPanel.SuspendLayout();
blockedGamesFlowPanel.SuspendLayout(); blockedGamesFlowPanel.SuspendLayout();
allCheckBoxLayoutPanel.SuspendLayout(); allCheckBoxLayoutPanel.SuspendLayout();
SuspendLayout(); SuspendLayout();
@ -82,7 +82,7 @@ namespace CreamInstaller.Forms
// programsGroupBox // programsGroupBox
// //
programsGroupBox.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; programsGroupBox.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
programsGroupBox.Controls.Add(koaloaderFlowPanel); programsGroupBox.Controls.Add(proxyFlowPanel);
programsGroupBox.Controls.Add(noneFoundLabel); programsGroupBox.Controls.Add(noneFoundLabel);
programsGroupBox.Controls.Add(blockedGamesFlowPanel); programsGroupBox.Controls.Add(blockedGamesFlowPanel);
programsGroupBox.Controls.Add(allCheckBoxLayoutPanel); programsGroupBox.Controls.Add(allCheckBoxLayoutPanel);
@ -94,33 +94,33 @@ namespace CreamInstaller.Forms
programsGroupBox.TabStop = false; programsGroupBox.TabStop = false;
programsGroupBox.Text = "Programs / Games"; programsGroupBox.Text = "Programs / Games";
// //
// koaloaderFlowPanel // proxyFlowPanel
// //
koaloaderFlowPanel.Anchor = AnchorStyles.Top | AnchorStyles.Right; proxyFlowPanel.Anchor = AnchorStyles.Top | AnchorStyles.Right;
koaloaderFlowPanel.AutoSize = true; proxyFlowPanel.AutoSize = true;
koaloaderFlowPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink; proxyFlowPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink;
koaloaderFlowPanel.Controls.Add(koaloaderAllCheckBox); proxyFlowPanel.Controls.Add(proxyAllCheckBox);
koaloaderFlowPanel.Location = new System.Drawing.Point(422, -1); proxyFlowPanel.Location = new System.Drawing.Point(422, -1);
koaloaderFlowPanel.Margin = new Padding(0); proxyFlowPanel.Margin = new Padding(0);
koaloaderFlowPanel.Name = "koaloaderFlowPanel"; proxyFlowPanel.Name = "proxyFlowPanel";
koaloaderFlowPanel.Size = new System.Drawing.Size(81, 19); proxyFlowPanel.Size = new System.Drawing.Size(81, 19);
koaloaderFlowPanel.TabIndex = 10005; proxyFlowPanel.TabIndex = 10005;
koaloaderFlowPanel.WrapContents = false; proxyFlowPanel.WrapContents = false;
// //
// koaloaderAllCheckBox // proxyAllCheckBox
// //
koaloaderAllCheckBox.Anchor = AnchorStyles.Top | AnchorStyles.Right; proxyAllCheckBox.Anchor = AnchorStyles.Top | AnchorStyles.Right;
koaloaderAllCheckBox.AutoSize = true; proxyAllCheckBox.AutoSize = true;
koaloaderAllCheckBox.Checked = true; proxyAllCheckBox.Checked = false;
koaloaderAllCheckBox.CheckState = CheckState.Checked; proxyAllCheckBox.CheckState = CheckState.Checked;
koaloaderAllCheckBox.Enabled = false; proxyAllCheckBox.Enabled = false;
koaloaderAllCheckBox.Location = new System.Drawing.Point(2, 0); proxyAllCheckBox.Location = new System.Drawing.Point(2, 0);
koaloaderAllCheckBox.Margin = new Padding(2, 0, 0, 0); proxyAllCheckBox.Margin = new Padding(2, 0, 0, 0);
koaloaderAllCheckBox.Name = "koaloaderAllCheckBox"; proxyAllCheckBox.Name = "proxyAllCheckBox";
koaloaderAllCheckBox.Size = new System.Drawing.Size(79, 19); proxyAllCheckBox.Size = new System.Drawing.Size(79, 19);
koaloaderAllCheckBox.TabIndex = 4; proxyAllCheckBox.TabIndex = 4;
koaloaderAllCheckBox.Text = "Koaloader"; proxyAllCheckBox.Text = "Proxy All";
koaloaderAllCheckBox.CheckedChanged += OnKoaloaderAllCheckBoxChanged; proxyAllCheckBox.CheckedChanged += OnProxyAllCheckBoxChanged;
// //
// noneFoundLabel // noneFoundLabel
// //
@ -323,19 +323,19 @@ namespace CreamInstaller.Forms
loadButton.UseVisualStyleBackColor = true; loadButton.UseVisualStyleBackColor = true;
loadButton.Click += OnLoadDlc; loadButton.Click += OnLoadDlc;
// //
// resetKoaloaderButton // resetProxyButton
// //
resetKoaloaderButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; resetProxyButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
resetKoaloaderButton.AutoSize = true; resetProxyButton.AutoSize = true;
resetKoaloaderButton.AutoSizeMode = AutoSizeMode.GrowAndShrink; resetProxyButton.AutoSizeMode = AutoSizeMode.GrowAndShrink;
resetKoaloaderButton.Enabled = false; resetProxyButton.Enabled = false;
resetKoaloaderButton.Location = new System.Drawing.Point(12, 295); resetProxyButton.Location = new System.Drawing.Point(12, 295);
resetKoaloaderButton.Name = "resetKoaloaderButton"; resetProxyButton.Name = "resetProxyButton";
resetKoaloaderButton.Size = new System.Drawing.Size(101, 25); resetProxyButton.Size = new System.Drawing.Size(101, 25);
resetKoaloaderButton.TabIndex = 10010; resetProxyButton.TabIndex = 10010;
resetKoaloaderButton.Text = "Reset Koaloader"; resetProxyButton.Text = "Reset Proxy";
resetKoaloaderButton.UseVisualStyleBackColor = true; resetProxyButton.UseVisualStyleBackColor = true;
resetKoaloaderButton.Click += OnResetKoaloader; resetProxyButton.Click += OnResetProxy;
// //
// resetButton // resetButton
// //
@ -351,33 +351,33 @@ namespace CreamInstaller.Forms
resetButton.UseVisualStyleBackColor = true; resetButton.UseVisualStyleBackColor = true;
resetButton.Click += OnResetDlc; resetButton.Click += OnResetDlc;
// //
// saveKoaloaderButton // saveProxyButton
// //
saveKoaloaderButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; saveProxyButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
saveKoaloaderButton.AutoSize = true; saveProxyButton.AutoSize = true;
saveKoaloaderButton.AutoSizeMode = AutoSizeMode.GrowAndShrink; saveProxyButton.AutoSizeMode = AutoSizeMode.GrowAndShrink;
saveKoaloaderButton.Enabled = false; saveProxyButton.Enabled = false;
saveKoaloaderButton.Location = new System.Drawing.Point(119, 295); saveProxyButton.Location = new System.Drawing.Point(119, 295);
saveKoaloaderButton.Name = "saveKoaloaderButton"; saveProxyButton.Name = "saveProxyButton";
saveKoaloaderButton.Size = new System.Drawing.Size(97, 25); saveProxyButton.Size = new System.Drawing.Size(97, 25);
saveKoaloaderButton.TabIndex = 10009; saveProxyButton.TabIndex = 10009;
saveKoaloaderButton.Text = "Save Koaloader"; saveProxyButton.Text = "Save Proxy";
saveKoaloaderButton.UseVisualStyleBackColor = true; saveProxyButton.UseVisualStyleBackColor = true;
saveKoaloaderButton.Click += OnSaveKoaloader; saveProxyButton.Click += OnSaveProxy;
// //
// loadKoaloaderButton // loadProxyButton
// //
loadKoaloaderButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; loadProxyButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
loadKoaloaderButton.AutoSize = true; loadProxyButton.AutoSize = true;
loadKoaloaderButton.AutoSizeMode = AutoSizeMode.GrowAndShrink; loadProxyButton.AutoSizeMode = AutoSizeMode.GrowAndShrink;
loadKoaloaderButton.Enabled = false; loadProxyButton.Enabled = false;
loadKoaloaderButton.Location = new System.Drawing.Point(222, 295); loadProxyButton.Location = new System.Drawing.Point(222, 295);
loadKoaloaderButton.Name = "loadKoaloaderButton"; loadProxyButton.Name = "loadProxyButton";
loadKoaloaderButton.Size = new System.Drawing.Size(99, 25); loadProxyButton.Size = new System.Drawing.Size(99, 25);
loadKoaloaderButton.TabIndex = 10008; loadProxyButton.TabIndex = 10008;
loadKoaloaderButton.Text = "Load Koaloader"; loadProxyButton.Text = "Load Proxy";
loadKoaloaderButton.UseVisualStyleBackColor = true; loadProxyButton.UseVisualStyleBackColor = true;
loadKoaloaderButton.Click += OnLoadKoaloader; loadProxyButton.Click += OnLoadProxy;
// //
// SelectForm // SelectForm
// //
@ -386,10 +386,10 @@ namespace CreamInstaller.Forms
AutoSize = true; AutoSize = true;
AutoSizeMode = AutoSizeMode.GrowAndShrink; AutoSizeMode = AutoSizeMode.GrowAndShrink;
ClientSize = new System.Drawing.Size(584, 361); ClientSize = new System.Drawing.Size(584, 361);
Controls.Add(loadKoaloaderButton); Controls.Add(loadProxyButton);
Controls.Add(saveKoaloaderButton); Controls.Add(saveProxyButton);
Controls.Add(resetButton); Controls.Add(resetButton);
Controls.Add(resetKoaloaderButton); Controls.Add(resetProxyButton);
Controls.Add(loadButton); Controls.Add(loadButton);
Controls.Add(saveButton); Controls.Add(saveButton);
Controls.Add(sortCheckBox); Controls.Add(sortCheckBox);
@ -412,8 +412,8 @@ namespace CreamInstaller.Forms
Load += OnLoad; Load += OnLoad;
programsGroupBox.ResumeLayout(false); programsGroupBox.ResumeLayout(false);
programsGroupBox.PerformLayout(); programsGroupBox.PerformLayout();
koaloaderFlowPanel.ResumeLayout(false); proxyFlowPanel.ResumeLayout(false);
koaloaderFlowPanel.PerformLayout(); proxyFlowPanel.PerformLayout();
blockedGamesFlowPanel.ResumeLayout(false); blockedGamesFlowPanel.ResumeLayout(false);
blockedGamesFlowPanel.PerformLayout(); blockedGamesFlowPanel.PerformLayout();
allCheckBoxLayoutPanel.ResumeLayout(false); allCheckBoxLayoutPanel.ResumeLayout(false);
@ -441,14 +441,14 @@ namespace CreamInstaller.Forms
private Label progressLabelGames; private Label progressLabelGames;
private Label progressLabelDLCs; private Label progressLabelDLCs;
private CheckBox sortCheckBox; private CheckBox sortCheckBox;
private FlowLayoutPanel koaloaderFlowPanel; private FlowLayoutPanel proxyFlowPanel;
internal CheckBox koaloaderAllCheckBox; internal CheckBox proxyAllCheckBox;
private Button saveButton; private Button saveButton;
private Button loadButton; private Button loadButton;
private Button resetKoaloaderButton; private Button resetProxyButton;
private Button resetButton; private Button resetButton;
private Button saveKoaloaderButton; private Button saveProxyButton;
private Button loadKoaloaderButton; private Button loadProxyButton;
} }
} }

View file

@ -23,6 +23,9 @@ namespace CreamInstaller.Forms;
internal sealed partial class SelectForm : CustomForm internal sealed partial class SelectForm : CustomForm
{ {
// TODO: fix the form display reset save load buttons for proxy
// consolidate all reset save load functionality into only 3 buttons instead of 6?
private const string HelpButtonListPrefix = "\n • "; private const string HelpButtonListPrefix = "\n • ";
private static SelectForm current; private static SelectForm current;
@ -562,16 +565,16 @@ internal sealed partial class SelectForm : CustomForm
scanButton.Enabled = false; scanButton.Enabled = false;
noneFoundLabel.Visible = false; noneFoundLabel.Visible = false;
allCheckBox.Enabled = false; allCheckBox.Enabled = false;
koaloaderAllCheckBox.Enabled = false; proxyAllCheckBox.Enabled = false;
installButton.Enabled = false; installButton.Enabled = false;
uninstallButton.Enabled = installButton.Enabled; uninstallButton.Enabled = installButton.Enabled;
selectionTreeView.Enabled = false; selectionTreeView.Enabled = false;
saveButton.Enabled = false; saveButton.Enabled = false;
loadButton.Enabled = false; loadButton.Enabled = false;
resetButton.Enabled = false; resetButton.Enabled = false;
saveKoaloaderButton.Enabled = false; saveProxyButton.Enabled = false;
loadKoaloaderButton.Enabled = false; loadProxyButton.Enabled = false;
resetKoaloaderButton.Enabled = false; resetProxyButton.Enabled = false;
progressLabel.Text = "Waiting for user to select which programs/games to scan . . ."; progressLabel.Text = "Waiting for user to select which programs/games to scan . . .";
ShowProgressBar(); ShowProgressBar();
await ProgramData.Setup(this); await ProgramData.Setup(this);
@ -693,20 +696,20 @@ internal sealed partial class SelectForm : CustomForm
} }
OnLoadDlc(null, null); OnLoadDlc(null, null);
OnLoadKoaloader(null, null); OnLoadProxy(null, null);
HideProgressBar(); HideProgressBar();
selectionTreeView.Enabled = !Selection.All.IsEmpty; selectionTreeView.Enabled = !Selection.All.IsEmpty;
allCheckBox.Enabled = selectionTreeView.Enabled; allCheckBox.Enabled = selectionTreeView.Enabled;
koaloaderAllCheckBox.Enabled = selectionTreeView.Enabled; proxyAllCheckBox.Enabled = selectionTreeView.Enabled;
noneFoundLabel.Visible = !selectionTreeView.Enabled; noneFoundLabel.Visible = !selectionTreeView.Enabled;
installButton.Enabled = Selection.AllEnabled.Any(); installButton.Enabled = Selection.AllEnabled.Any();
uninstallButton.Enabled = installButton.Enabled; uninstallButton.Enabled = installButton.Enabled;
saveButton.Enabled = CanSaveDlc(); saveButton.Enabled = CanSaveDlc();
loadButton.Enabled = CanLoadDlc(); loadButton.Enabled = CanLoadDlc();
resetButton.Enabled = CanResetDlc(); resetButton.Enabled = CanResetDlc();
saveKoaloaderButton.Enabled = CanSaveKoaloader(); saveProxyButton.Enabled = CanSaveProxy();
loadKoaloaderButton.Enabled = CanLoadKoaloader(); loadProxyButton.Enabled = CanLoadProxy();
resetKoaloaderButton.Enabled = CanResetKoaloader(); resetProxyButton.Enabled = CanResetProxy();
cancelButton.Enabled = false; cancelButton.Enabled = false;
scanButton.Enabled = true; scanButton.Enabled = true;
blockedGamesCheckBox.Enabled = true; blockedGamesCheckBox.Enabled = true;
@ -1043,16 +1046,16 @@ internal sealed partial class SelectForm : CustomForm
allCheckBox.CheckedChanged += OnAllCheckBoxChanged; allCheckBox.CheckedChanged += OnAllCheckBoxChanged;
} }
private void OnKoaloaderAllCheckBoxChanged(object sender, EventArgs e) private void OnProxyAllCheckBoxChanged(object sender, EventArgs e)
{ {
bool shouldEnable = Selection.All.Keys.Any(selection => !selection.Koaloader); bool shouldEnable = Selection.All.Keys.Any(selection => !selection.UseProxy);
foreach (Selection selection in Selection.All.Keys) foreach (Selection selection in Selection.All.Keys)
selection.Koaloader = shouldEnable; selection.UseProxy = shouldEnable;
selectionTreeView.Invalidate(); selectionTreeView.Invalidate();
koaloaderAllCheckBox.CheckedChanged -= OnKoaloaderAllCheckBoxChanged; proxyAllCheckBox.CheckedChanged -= OnProxyAllCheckBoxChanged;
koaloaderAllCheckBox.Checked = shouldEnable; proxyAllCheckBox.Checked = shouldEnable;
koaloaderAllCheckBox.CheckedChanged += OnKoaloaderAllCheckBoxChanged; proxyAllCheckBox.CheckedChanged += OnProxyAllCheckBoxChanged;
resetKoaloaderButton.Enabled = CanResetKoaloader(); resetProxyButton.Enabled = CanResetProxy();
} }
private bool AreSelectionsDefault() private bool AreSelectionsDefault()
@ -1107,36 +1110,36 @@ internal sealed partial class SelectForm : CustomForm
resetButton.Enabled = CanResetDlc(); resetButton.Enabled = CanResetDlc();
} }
private static bool AreKoaloaderSelectionsDefault() => private static bool AreProxySelectionsDefault() =>
Selection.All.Keys.All(selection => selection.Koaloader && selection.KoaloaderProxy is null); Selection.All.Keys.All(selection => !selection.UseProxy && selection.Proxy is null);
private static bool CanSaveKoaloader() => private static bool CanSaveProxy() =>
ProgramData.ReadKoaloaderChoices().Any() || !AreKoaloaderSelectionsDefault(); ProgramData.ReadProxyChoices().Any() || !AreProxySelectionsDefault();
private void OnSaveKoaloader(object sender, EventArgs e) private void OnSaveProxy(object sender, EventArgs e)
{ {
List<(Platform platform, string id, string proxy, bool enabled)> choices = List<(Platform platform, string id, string proxy, bool enabled)> choices =
ProgramData.ReadKoaloaderChoices().ToList(); ProgramData.ReadProxyChoices().ToList();
foreach (Selection selection in Selection.All.Keys) foreach (Selection selection in Selection.All.Keys)
{ {
_ = choices.RemoveAll(c => c.platform == selection.Platform && c.id == selection.Id); _ = choices.RemoveAll(c => c.platform == selection.Platform && c.id == selection.Id);
if (selection.KoaloaderProxy is not null and not Selection.DefaultKoaloaderProxy || !selection.Koaloader) if (selection.Proxy is not null and not Selection.DefaultProxy || selection.UseProxy)
choices.Add((selection.Platform, selection.Id, choices.Add((selection.Platform, selection.Id,
selection.KoaloaderProxy == Selection.DefaultKoaloaderProxy ? null : selection.KoaloaderProxy, selection.Proxy == Selection.DefaultProxy ? null : selection.Proxy,
selection.Koaloader)); selection.UseProxy));
} }
ProgramData.WriteKoaloaderProxyChoices(choices); ProgramData.WriteProxyChoices(choices);
saveKoaloaderButton.Enabled = CanSaveKoaloader(); saveProxyButton.Enabled = CanSaveProxy();
loadKoaloaderButton.Enabled = CanLoadKoaloader(); loadProxyButton.Enabled = CanLoadProxy();
} }
private static bool CanLoadKoaloader() => ProgramData.ReadKoaloaderChoices().Any(); private static bool CanLoadProxy() => ProgramData.ReadProxyChoices().Any();
private void OnLoadKoaloader(object sender, EventArgs e) private void OnLoadProxy(object sender, EventArgs e)
{ {
List<(Platform platform, string id, string proxy, bool enabled)> choices = List<(Platform platform, string id, string proxy, bool enabled)> choices =
ProgramData.ReadKoaloaderChoices().ToList(); ProgramData.ReadProxyChoices().ToList();
foreach (Selection selection in Selection.All.Keys) foreach (Selection selection in Selection.All.Keys)
if (choices.Any(c => c.platform == selection.Platform && c.id == selection.Id)) if (choices.Any(c => c.platform == selection.Platform && c.id == selection.Id))
{ {
@ -1148,46 +1151,46 @@ internal sealed partial class SelectForm : CustomForm
proxy.GetProxyInfoFromIdentifier(out currentProxy, out _); proxy.GetProxyInfoFromIdentifier(out currentProxy, out _);
if (proxy != currentProxy && choices.Remove(choice)) // convert pre-v4.1.0.0 choices if (proxy != currentProxy && choices.Remove(choice)) // convert pre-v4.1.0.0 choices
choices.Add((platform, id, currentProxy, enabled)); choices.Add((platform, id, currentProxy, enabled));
if (currentProxy is null or Selection.DefaultKoaloaderProxy && enabled) if (currentProxy is null or Selection.DefaultProxy && !enabled)
_ = choices.RemoveAll(c => c.platform == platform && c.id == id); _ = choices.RemoveAll(c => c.platform == platform && c.id == id);
else else
{ {
selection.Koaloader = enabled; selection.UseProxy = enabled;
selection.KoaloaderProxy = currentProxy == Selection.DefaultKoaloaderProxy ? currentProxy : proxy; selection.Proxy = currentProxy == Selection.DefaultProxy ? currentProxy : proxy;
} }
} }
else else
{ {
selection.Koaloader = true; selection.UseProxy = false;
selection.KoaloaderProxy = null; selection.Proxy = null;
} }
ProgramData.WriteKoaloaderProxyChoices(choices); ProgramData.WriteProxyChoices(choices);
loadKoaloaderButton.Enabled = CanLoadKoaloader(); loadProxyButton.Enabled = CanLoadProxy();
OnKoaloaderChanged(); OnProxyChanged();
} }
private static bool CanResetKoaloader() => !AreKoaloaderSelectionsDefault(); private static bool CanResetProxy() => !AreProxySelectionsDefault();
private void OnResetKoaloader(object sender, EventArgs e) private void OnResetProxy(object sender, EventArgs e)
{ {
foreach (Selection selection in Selection.All.Keys) foreach (Selection selection in Selection.All.Keys)
{ {
selection.Koaloader = true; selection.UseProxy = false;
selection.KoaloaderProxy = null; selection.Proxy = null;
} }
OnKoaloaderChanged(); OnProxyChanged();
} }
internal void OnKoaloaderChanged() internal void OnProxyChanged()
{ {
selectionTreeView.Invalidate(); selectionTreeView.Invalidate();
saveKoaloaderButton.Enabled = CanSaveKoaloader(); saveProxyButton.Enabled = CanSaveProxy();
resetKoaloaderButton.Enabled = CanResetKoaloader(); resetProxyButton.Enabled = CanResetProxy();
koaloaderAllCheckBox.CheckedChanged -= OnKoaloaderAllCheckBoxChanged; proxyAllCheckBox.CheckedChanged -= OnProxyAllCheckBoxChanged;
koaloaderAllCheckBox.Checked = Selection.All.Keys.All(selection => selection.Koaloader); proxyAllCheckBox.Checked = Selection.All.Keys.All(selection => !selection.CanUseProxy || selection.UseProxy);
koaloaderAllCheckBox.CheckedChanged += OnKoaloaderAllCheckBoxChanged; proxyAllCheckBox.CheckedChanged += OnProxyAllCheckBoxChanged;
} }
private void OnBlockProtectedGamesCheckBoxChanged(object sender, EventArgs e) private void OnBlockProtectedGamesCheckBoxChanged(object sender, EventArgs e)

View file

@ -75,7 +75,7 @@ internal static class ParadoxLauncher
} }
using DialogForm dialogForm = new(form); using DialogForm dialogForm = new(form);
bool smokeInstalled = false; bool creamInstalled = false;
byte[] steamOriginalSdk32 = null; byte[] steamOriginalSdk32 = null;
byte[] steamOriginalSdk64 = null; byte[] steamOriginalSdk64 = null;
bool screamInstalled = false; bool screamInstalled = false;
@ -86,24 +86,39 @@ internal static class ParadoxLauncher
bool koaloaderInstalled = Koaloader.AutoLoadDLLs bool koaloaderInstalled = Koaloader.AutoLoadDLLs
.Select(pair => (pair.unlocker, path: directory + @"\" + pair.dll)) .Select(pair => (pair.unlocker, path: directory + @"\" + pair.dll))
.Any(pair => pair.path.FileExists() && pair.path.IsResourceFile()); .Any(pair => pair.path.FileExists() && pair.path.IsResourceFile());
directory.GetSmokeApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, string api32;
out string old_config, string api32_o;
out string config, out _, out _, out _); string api64;
smokeInstalled = smokeInstalled || api32_o.FileExists() || api64_o.FileExists() string api64_o;
if (Program.UseSmokeAPI)
{
directory.GetSmokeApiComponents(out api32, out api32_o, out api64, out api64_o,
out string old_config, out string config, out _, out _, out _);
creamInstalled = creamInstalled || api32_o.FileExists() || api64_o.FileExists()
|| (old_config.FileExists() || config.FileExists()) && !koaloaderInstalled || (old_config.FileExists() || config.FileExists()) && !koaloaderInstalled
|| api32.FileExists() && api32.IsResourceFile(ResourceIdentifier.Steamworks32) || api32.FileExists() && api32.IsResourceFile(ResourceIdentifier.Steamworks32)
|| api64.FileExists() && api64.IsResourceFile(ResourceIdentifier.Steamworks64); || api64.FileExists() && api64.IsResourceFile(ResourceIdentifier.Steamworks64);
await SmokeAPI.Uninstall(directory, deleteOthers: false); await SmokeAPI.Uninstall(directory, deleteOthers: false);
}
else
{
directory.GetCreamApiComponents(out api32, out api32_o, out api64, out api64_o, out string config);
creamInstalled = creamInstalled || api32_o.FileExists() || api64_o.FileExists() || config.FileExists()
|| api32.FileExists() && api32.IsResourceFile(ResourceIdentifier.Steamworks32)
|| api64.FileExists() && api64.IsResourceFile(ResourceIdentifier.Steamworks64);
await CreamAPI.Uninstall(directory, deleteOthers: false);
}
if (steamOriginalSdk32 is null && api32.FileExists() && if (steamOriginalSdk32 is null && api32.FileExists() &&
!api32.IsResourceFile(ResourceIdentifier.Steamworks32)) !api32.IsResourceFile(ResourceIdentifier.Steamworks32))
steamOriginalSdk32 = api32.ReadFileBytes(true); steamOriginalSdk32 = api32.ReadFileBytes(true);
if (steamOriginalSdk64 is null && api64.FileExists() && if (steamOriginalSdk64 is null && api64.FileExists() &&
!api64.IsResourceFile(ResourceIdentifier.Steamworks64)) !api64.IsResourceFile(ResourceIdentifier.Steamworks64))
steamOriginalSdk64 = api64.ReadFileBytes(true); steamOriginalSdk64 = api64.ReadFileBytes(true);
directory.GetScreamApiComponents(out api32, out api32_o, out api64, out api64_o, out config, directory.GetScreamApiComponents(out api32, out api32_o, out api64, out api64_o, out string screamConfig,
out string log); out string log);
screamInstalled = screamInstalled || api32_o.FileExists() || api64_o.FileExists() screamInstalled = screamInstalled || api32_o.FileExists() || api64_o.FileExists()
|| (config.FileExists() || log.FileExists()) && !koaloaderInstalled || (screamConfig.FileExists() || log.FileExists()) && !koaloaderInstalled
|| api32.FileExists() && api32.IsResourceFile(ResourceIdentifier.EpicOnlineServices32) || api32.FileExists() && api32.IsResourceFile(ResourceIdentifier.EpicOnlineServices32)
|| api64.FileExists() && api64.IsResourceFile(ResourceIdentifier.EpicOnlineServices64); || api64.FileExists() && api64.IsResourceFile(ResourceIdentifier.EpicOnlineServices64);
await ScreamAPI.Uninstall(directory, deleteOthers: false); await ScreamAPI.Uninstall(directory, deleteOthers: false);
@ -143,8 +158,16 @@ internal static class ParadoxLauncher
neededRepair = true; neededRepair = true;
} }
if (smokeInstalled) if (creamInstalled)
if (Program.UseSmokeAPI)
{
await SmokeAPI.Install(directory, selection, generateConfig: false); await SmokeAPI.Install(directory, selection, generateConfig: false);
}
else
{
await CreamAPI.Install(directory, selection, generateConfig: false);
}
directory.GetScreamApiComponents(out api32, out _, out api64, out _, out _, out _); directory.GetScreamApiComponents(out api32, out _, out api64, out _, out _, out _);
if (epicOriginalSdk32 is not null && api32.IsResourceFile(ResourceIdentifier.EpicOnlineServices32)) if (epicOriginalSdk32 is not null && api32.IsResourceFile(ResourceIdentifier.EpicOnlineServices32))
{ {

View file

@ -35,6 +35,9 @@ internal static class Program
internal static readonly string CurrentProcessFilePath = CurrentProcess.MainModule?.FileName; internal static readonly string CurrentProcessFilePath = CurrentProcess.MainModule?.FileName;
internal static readonly int CurrentProcessId = CurrentProcess.Id; internal static readonly int CurrentProcessId = CurrentProcess.Id;
// this may forever be false, but who knows, maybe acidicoala makes it once again better than CreamAPI some day
internal static bool UseSmokeAPI = false;
internal static bool BlockProtectedGames = true; internal static bool BlockProtectedGames = true;
internal static readonly string[] ProtectedGames = ["PAYDAY 2"]; internal static readonly string[] ProtectedGames = ["PAYDAY 2"];
internal static readonly string[] ProtectedGameDirectories = [@"\EasyAntiCheat", @"\BattlEye"]; internal static readonly string[] ProtectedGameDirectories = [@"\EasyAntiCheat", @"\BattlEye"];

View file

@ -1,16 +1,21 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using CreamInstaller.Components;
using CreamInstaller.Forms; using CreamInstaller.Forms;
using CreamInstaller.Utility;
using static CreamInstaller.Resources.Resources; using static CreamInstaller.Resources.Resources;
namespace CreamInstaller.Resources; namespace CreamInstaller.Resources;
internal static class CreamAPI internal static class CreamAPI
{ {
// TODO: add proxy mode support
internal static void GetCreamApiComponents(this string directory, out string api32, out string api32_o, internal static void GetCreamApiComponents(this string directory, out string api32, out string api32_o,
out string api64, out string api64_o, out string api64, out string api64_o, out string config)
out string config)
{ {
api32 = directory + @"\steam_api.dll"; api32 = directory + @"\steam_api.dll";
api32_o = directory + @"\steam_api_o.dll"; api32_o = directory + @"\steam_api_o.dll";
@ -22,28 +27,171 @@ internal static class CreamAPI
internal static void CheckConfig(string directory, Selection selection, InstallForm installForm = null) internal static void CheckConfig(string directory, Selection selection, InstallForm installForm = null)
{ {
// TODO directory.GetCreamApiComponents(out _, out _, out _, out _, out string config);
HashSet<SelectionDLC> dlc = selection.DLC.Where(dlc => dlc.Enabled).ToHashSet();
foreach (SelectionDLC extraDlc in selection.ExtraSelections.SelectMany(extraSelection =>
extraSelection.DLC.Where(_dlc => _dlc.Enabled)))
_ = dlc.Add(extraDlc);
if (dlc.Count > 0)
{
/*if (installForm is not null)
installForm.UpdateUser("Generating CreamAPI configuration for " + selection.Name + $" in directory \"{directory}\" . . . ", LogTextBox.Operation);*/
config.CreateFile(true, installForm)?.Close();
StreamWriter writer = new(config, true, Encoding.UTF8);
WriteConfig(writer, selection.Name, selection.Id,
new(dlc.ToDictionary(_dlc => _dlc.Id, _dlc => _dlc.Name), PlatformIdComparer.String), installForm);
writer.Flush();
writer.Close();
}
else if (config.FileExists())
{
config.DeleteFile();
installForm?.UpdateUser($"Deleted unnecessary configuration: {Path.GetFileName(config)}", LogTextBox.Action,
false);
}
} }
private static void WriteConfig(StreamWriter writer, string appId, private static void WriteConfig(StreamWriter writer, string name, string appId,
SortedList<string, (string name, SortedList<string, SelectionDLC> injectDlc)> extraApps, SortedList<string, string> dlc, InstallForm installForm = null)
SortedList<string, SelectionDLC> overrideDlc, SortedList<string, SelectionDLC> injectDlc,
InstallForm installForm = null)
{ {
// TODO writer.WriteLine($"; {name}");
writer.WriteLine("[steam]");
writer.WriteLine($"appid = {appId}");
// TODO: check if we should add these
// writer.WriteLine("unlockall = true");
// writer.WriteLine("extraprotection = true");
writer.WriteLine();
writer.WriteLine("[dlc]");
// installForm?.UpdateUser($"Added game to cream_api.ini with appid {appId} ({name})",
// LogTextBox.Action, false);
foreach ((string dlcId, string dlcName) in dlc)
{
writer.WriteLine($"{dlcId} = {dlcName}");
installForm?.UpdateUser($"Added DLC to cream_api.ini with appid {dlcId} ({dlcName})",
LogTextBox.Action, false);
}
}
private static void DeleteSmokeApiComponents(string directory, InstallForm installForm = null)
{
directory.GetSmokeApiComponents(out _, out _, out _, out _,
out string old_config, out string config, out string old_log, out string log, out string cache);
if (old_config.FileExists())
{
old_config.DeleteFile();
installForm?.UpdateUser($"Deleted old SmokeAPI configuration: {Path.GetFileName(old_config)}",
LogTextBox.Action, false);
}
if (config.FileExists())
{
config.DeleteFile();
installForm?.UpdateUser($"Deleted old SmokeAPI configuration: {Path.GetFileName(config)}",
LogTextBox.Action, false);
}
if (old_log.FileExists())
{
old_log.DeleteFile();
installForm?.UpdateUser($"Deleted old SmokeAPI log: {Path.GetFileName(old_log)}",
LogTextBox.Action, false);
}
if (log.FileExists())
{
log.DeleteFile();
installForm?.UpdateUser($"Deleted old SmokeAPI log: {Path.GetFileName(log)}",
LogTextBox.Action, false);
}
if (cache.FileExists())
{
cache.DeleteFile();
installForm?.UpdateUser($"Deleted old SmokeAPI cache: {Path.GetFileName(cache)}",
LogTextBox.Action, false);
}
} }
internal static async Task Uninstall(string directory, InstallForm installForm = null, bool deleteOthers = true) internal static async Task Uninstall(string directory, InstallForm installForm = null, bool deleteOthers = true)
=> await Task.Run(() => => await Task.Run(() =>
{ {
// TODO DeleteSmokeApiComponents(directory, installForm);
directory.GetCreamApiComponents(out string api32, out string api32_o, out string api64, out string api64_o,
out string config);
if (api32_o.FileExists())
{
if (api32.FileExists())
{
api32.DeleteFile(true);
installForm?.UpdateUser($"Deleted CreamAPI: {Path.GetFileName(api32)}", LogTextBox.Action, false);
}
api32_o.MoveFile(api32!);
installForm?.UpdateUser(
$"Restored Steamworks: {Path.GetFileName(api32_o)} -> {Path.GetFileName(api32)}", LogTextBox.Action,
false);
}
if (api64_o.FileExists())
{
if (api64.FileExists())
{
api64.DeleteFile(true);
installForm?.UpdateUser($"Deleted CreamAPI: {Path.GetFileName(api64)}", LogTextBox.Action, false);
}
api64_o.MoveFile(api64!);
installForm?.UpdateUser(
$"Restored Steamworks: {Path.GetFileName(api64_o)} -> {Path.GetFileName(api64)}", LogTextBox.Action,
false);
}
if (!deleteOthers)
return;
if (config.FileExists())
{
config.DeleteFile();
installForm?.UpdateUser($"Deleted configuration: {Path.GetFileName(config)}", LogTextBox.Action, false);
}
}); });
internal static async Task Install(string directory, Selection selection, InstallForm installForm = null, internal static async Task Install(string directory, Selection selection, InstallForm installForm = null,
bool generateConfig = true) bool generateConfig = true)
=> await Task.Run(() => => await Task.Run(() =>
{ {
// TODO DeleteSmokeApiComponents(directory, installForm);
directory.GetCreamApiComponents(out string api32, out string api32_o, out string api64, out string api64_o,
out _);
if (api32.FileExists() && !api32_o.FileExists())
{
api32.MoveFile(api32_o!, true);
installForm?.UpdateUser($"Renamed Steamworks: {Path.GetFileName(api32)} -> {Path.GetFileName(api32_o)}",
LogTextBox.Action, false);
}
if (api32_o.FileExists())
{
"CreamAPI.steam_api.dll".WriteManifestResource(api32);
installForm?.UpdateUser($"Wrote CreamAPI: {Path.GetFileName(api32)}", LogTextBox.Action, false);
}
if (api64.FileExists() && !api64_o.FileExists())
{
api64.MoveFile(api64_o!, true);
installForm?.UpdateUser($"Renamed Steamworks: {Path.GetFileName(api64)} -> {Path.GetFileName(api64_o)}",
LogTextBox.Action, false);
}
if (api64_o.FileExists())
{
"CreamAPI.steam_api64.dll".WriteManifestResource(api64);
installForm?.UpdateUser($"Wrote CreamAPI: {Path.GetFileName(api64)}", LogTextBox.Action, false);
}
if (generateConfig)
CheckConfig(directory, selection, installForm);
}); });
internal static readonly Dictionary<ResourceIdentifier, HashSet<string>> ResourceMD5s = new() internal static readonly Dictionary<ResourceIdentifier, HashSet<string>> ResourceMD5s = new()
@ -111,7 +259,11 @@ internal static class CreamAPI
"23909B4B1C7A182A6596BD0FDF2BFC7C", // CreamAPI v5.0.0.0 Log build "23909B4B1C7A182A6596BD0FDF2BFC7C", // CreamAPI v5.0.0.0 Log build
"E6DDF91F4419BE471FBE126A0966648B", // CreamAPI v5.0.0.0 Non-log build "E6DDF91F4419BE471FBE126A0966648B", // CreamAPI v5.0.0.0 Non-log build
"B14007170E59B03D5DF844BD3457295B", // CreamAPI v5.1.0.0 Log build "B14007170E59B03D5DF844BD3457295B", // CreamAPI v5.1.0.0 Log build
"24C712826D939F5CEC9049D4B94FCBDB" // CreamAPI v5.1.0.0 Non-log build "24C712826D939F5CEC9049D4B94FCBDB", // CreamAPI v5.1.0.0 Non-log build
"BAB060E3FB98BFAB60003089EFF3714B", // CreamAPI v5.2.0.0 Log build
"3DD6F774B64BA9F1C12A0CAAD801E4CB", // CreamAPI v5.2.0.0 Non-log build
"7B052096931080FDC7E10FB9BCE25177", // CreamAPI v5.3.0.0 Log build
"10638F7AC4E18DDBFA533EB6F307AE9E" // CreamAPI v5.3.0.0 Non-log build
], ],
[ResourceIdentifier.Steamworks64] = [ResourceIdentifier.Steamworks64] =
[ [
@ -176,7 +328,11 @@ internal static class CreamAPI
"15D76C0CBB175AA94936200C5208611E", // CreamAPI v5.0.0.0 Log build "15D76C0CBB175AA94936200C5208611E", // CreamAPI v5.0.0.0 Log build
"B7CF4BC4020C6419249E32EE126FF647", // CreamAPI v5.0.0.0 Non-log build "B7CF4BC4020C6419249E32EE126FF647", // CreamAPI v5.0.0.0 Non-log build
"BE635705410B93A1075ED32AA97E3B5C", // CreamAPI v5.1.0.0 Log build "BE635705410B93A1075ED32AA97E3B5C", // CreamAPI v5.1.0.0 Log build
"1B14C913C0DF41CC0667993D9B37404D" // CreamAPI v5.1.0.0 Non-log build "1B14C913C0DF41CC0667993D9B37404D", // CreamAPI v5.1.0.0 Non-log build
"218DC783A7E274494517F3A55FFCA225", // CreamAPI v5.2.0.0 Log build
"562F62C0AA6244397B92246C6C5A778F", // CreamAPI v5.2.0.0 Non-log build
"D719E3852BBA105B97F061630A08CA74", // CreamAPI v5.3.0.0 Log build
"87EA1775F0CEE3649DBB31043EB51FC0" // CreamAPI v5.3.0.0 Non-log build
] ]
}; };
} }

Binary file not shown.

Binary file not shown.

View file

@ -182,7 +182,7 @@ internal static class Koaloader
installForm?.UpdateUser($"Deleted configuration: {Path.GetFileName(config)}", LogTextBox.Action, false); installForm?.UpdateUser($"Deleted configuration: {Path.GetFileName(config)}", LogTextBox.Action, false);
} }
await SmokeAPI.Uninstall(directory, installForm, deleteConfig); if (Program.UseSmokeAPI) await SmokeAPI.Uninstall(directory, installForm, deleteConfig);
await ScreamAPI.Uninstall(directory, installForm, deleteConfig); await ScreamAPI.Uninstall(directory, installForm, deleteConfig);
await UplayR1.Uninstall(directory, installForm, deleteConfig); await UplayR1.Uninstall(directory, installForm, deleteConfig);
await UplayR2.Uninstall(directory, installForm, deleteConfig); await UplayR2.Uninstall(directory, installForm, deleteConfig);
@ -195,7 +195,7 @@ internal static class Koaloader
InstallForm installForm = null, bool generateConfig = true) InstallForm installForm = null, bool generateConfig = true)
=> await Task.Run(() => => await Task.Run(() =>
{ {
string proxy = selection.KoaloaderProxy ?? Selection.DefaultKoaloaderProxy; string proxy = selection.Proxy ?? Selection.DefaultProxy;
string path = directory + @"\" + proxy + ".dll"; string path = directory + @"\" + proxy + ".dll";
foreach (string _path in directory.GetKoaloaderProxies().Where(p => foreach (string _path in directory.GetKoaloaderProxies().Where(p =>
p != path && p.FileExists() && p.IsResourceFile(ResourceIdentifier.Koaloader))) p != path && p.FileExists() && p.IsResourceFile(ResourceIdentifier.Koaloader)))
@ -230,7 +230,7 @@ internal static class Koaloader
break; break;
} }
if (selection.Platform is Platform.Steam or Platform.Paradox) if (Program.UseSmokeAPI && selection.Platform is Platform.Steam or Platform.Paradox)
{ {
if (bit32) if (bit32)
{ {

View file

@ -174,8 +174,7 @@ internal static class SmokeAPI
writer.WriteLine("}"); writer.WriteLine("}");
} }
internal static async Task Uninstall(string directory, InstallForm installForm = null, bool deleteOthers = true) private static void DeleteCreamApiComponents(string directory, InstallForm installForm = null)
=> await Task.Run(() =>
{ {
directory.GetCreamApiComponents(out _, out _, out _, out _, out string oldConfig); directory.GetCreamApiComponents(out _, out _, out _, out _, out string oldConfig);
if (oldConfig.FileExists()) if (oldConfig.FileExists())
@ -184,10 +183,15 @@ internal static class SmokeAPI
installForm?.UpdateUser($"Deleted old CreamAPI configuration: {Path.GetFileName(oldConfig)}", installForm?.UpdateUser($"Deleted old CreamAPI configuration: {Path.GetFileName(oldConfig)}",
LogTextBox.Action, false); LogTextBox.Action, false);
} }
}
internal static async Task Uninstall(string directory, InstallForm installForm = null, bool deleteOthers = true)
=> await Task.Run(() =>
{
DeleteCreamApiComponents(directory, installForm);
directory.GetSmokeApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, directory.GetSmokeApiComponents(out string api32, out string api32_o, out string api64, out string api64_o,
out string old_config, out string old_config, out string config, out string old_log, out string log, out string cache);
out string config, out string old_log, out string log, out string cache);
if (api32_o.FileExists()) if (api32_o.FileExists())
{ {
if (api32.FileExists()) if (api32.FileExists())
@ -254,13 +258,7 @@ internal static class SmokeAPI
bool generateConfig = true) bool generateConfig = true)
=> await Task.Run(() => => await Task.Run(() =>
{ {
directory.GetCreamApiComponents(out _, out _, out _, out _, out string oldConfig); DeleteCreamApiComponents(directory, installForm);
if (oldConfig.FileExists())
{
oldConfig.DeleteFile();
installForm?.UpdateUser($"Deleted old CreamAPI configuration: {Path.GetFileName(oldConfig)}",
LogTextBox.Action, false);
}
directory.GetSmokeApiComponents(out string api32, out string api32_o, out string api64, out string api64_o, directory.GetSmokeApiComponents(out string api32, out string api32_o, out string api64, out string api64_o,
out _, out _, out _, out _, out _); out _, out _, out _, out _, out _);

View file

@ -20,7 +20,10 @@ public enum Platform
internal sealed class Selection : IEquatable<Selection> internal sealed class Selection : IEquatable<Selection>
{ {
internal const string DefaultKoaloaderProxy = "version"; internal const string DefaultProxy = "version";
// TODO: add proxy mode support for CreamAPI and set this to true
internal bool CanUseProxy => Program.UseSmokeAPI || Platform is not Platform.Steam;
internal static readonly ConcurrentDictionary<Selection, byte> All = new(); internal static readonly ConcurrentDictionary<Selection, byte> All = new();
@ -33,8 +36,8 @@ internal sealed class Selection : IEquatable<Selection>
internal readonly string RootDirectory; internal readonly string RootDirectory;
internal readonly TreeNode TreeNode; internal readonly TreeNode TreeNode;
internal string Icon; internal string Icon;
internal bool Koaloader; internal bool UseProxy;
internal string KoaloaderProxy; internal string Proxy;
internal string Product; internal string Product;
internal string Publisher; internal string Publisher;
internal string SubIcon; internal string SubIcon;
@ -55,7 +58,7 @@ internal sealed class Selection : IEquatable<Selection>
if (selectForm is null) if (selectForm is null)
return; return;
Enabled = selectForm.allCheckBox.Checked; Enabled = selectForm.allCheckBox.Checked;
Koaloader = selectForm.koaloaderAllCheckBox.Checked; UseProxy = selectForm.proxyAllCheckBox.Checked;
} }
internal static IEnumerable<Selection> AllEnabled => All.Keys.Where(s => s.Enabled); internal static IEnumerable<Selection> AllEnabled => All.Keys.Where(s => s.Enabled);

View file

@ -162,7 +162,7 @@ internal static class ProgramData
} }
} }
internal static IEnumerable<(Platform platform, string id, string proxy, bool enabled)> ReadKoaloaderChoices() internal static IEnumerable<(Platform platform, string id, string proxy, bool enabled)> ReadProxyChoices()
{ {
if (KoaloaderProxyChoicesPath.FileExists()) if (KoaloaderProxyChoicesPath.FileExists())
try try
@ -180,7 +180,7 @@ internal static class ProgramData
return Enumerable.Empty<(Platform platform, string id, string proxy, bool enabled)>(); return Enumerable.Empty<(Platform platform, string id, string proxy, bool enabled)>();
} }
internal static void WriteKoaloaderProxyChoices( internal static void WriteProxyChoices(
IEnumerable<(Platform platform, string id, string proxy, bool enabled)> choices) IEnumerable<(Platform platform, string id, string proxy, bool enabled)> choices)
{ {
try try

7
global.json Normal file
View file

@ -0,0 +1,7 @@
{
"sdk": {
"version": "8.0.0",
"rollForward": "latestMinor",
"allowPrerelease": false
}
}