intermediary updates

- Uplay R1 & R2 preparation
- Minor refactoring
- Install form whiteout fix
This commit is contained in:
pointfeev 2022-08-16 17:15:29 -04:00
parent d95598fa38
commit e4a90d9c8d
21 changed files with 241 additions and 183 deletions

View file

@ -19,12 +19,12 @@ insert_final_newline = false
# Organize usings
dotnet_separate_import_directive_groups = true
dotnet_sort_system_directives_first = true
dotnet_sort_system_directives_first = false
file_header_template = unset
# this. and Me. preferences
dotnet_style_qualification_for_event = false:suggestion
dotnet_style_qualification_for_field = false
dotnet_style_qualification_for_field = false:suggestion
dotnet_style_qualification_for_method = false:suggestion
dotnet_style_qualification_for_property = false:suggestion
@ -53,6 +53,7 @@ dotnet_style_prefer_auto_properties = true:suggestion
dotnet_style_prefer_compound_assignment = true
dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion
dotnet_style_prefer_conditional_expression_over_return = true:suggestion
dotnet_style_prefer_foreach_explicit_cast_in_source = when_strongly_typed
dotnet_style_prefer_inferred_anonymous_type_member_names = true
dotnet_style_prefer_inferred_tuple_names = true
dotnet_style_prefer_is_null_check_over_reference_equality_method = true
@ -92,6 +93,7 @@ csharp_style_expression_bodied_properties = true:suggestion
# Pattern matching preferences
csharp_style_pattern_matching_over_as_with_null_check = true
csharp_style_pattern_matching_over_is_with_cast_check = true
csharp_style_prefer_extended_property_pattern = true
csharp_style_prefer_not_pattern = true
csharp_style_prefer_pattern_matching = true:suggestion
csharp_style_prefer_switch_expression = true
@ -101,31 +103,35 @@ csharp_style_conditional_delegate_call = true
# Modifier preferences
csharp_prefer_static_local_function = true
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async
# Code-block preferences
csharp_prefer_braces = false:suggestion
csharp_prefer_simple_using_statement = true
csharp_style_namespace_declarations = file_scoped:suggestion
csharp_style_prefer_method_group_conversion = true:suggestion
csharp_style_prefer_top_level_statements = true:suggestion
# Expression-level preferences
csharp_prefer_simple_default_expression = true
csharp_style_deconstructed_variable_declaration = true
csharp_style_implicit_object_creation_when_type_is_apparent = true
csharp_style_inlined_variable_declaration = true
csharp_style_pattern_local_over_anonymous_function = true
csharp_style_prefer_index_operator = true
csharp_style_prefer_local_over_anonymous_function = true
csharp_style_prefer_null_check_over_type_check = true
csharp_style_prefer_range_operator = true
csharp_style_prefer_tuple_swap = true
csharp_style_prefer_utf8_string_literals = true
csharp_style_throw_expression = true
csharp_style_unused_value_assignment_preference = discard_variable:silent
csharp_style_unused_value_expression_statement_preference = discard_variable
csharp_style_unused_value_assignment_preference = discard_variable
csharp_style_unused_value_expression_statement_preference = discard_variable:suggestion
# 'using' directive preferences
csharp_using_directive_placement = outside_namespace:suggestion
# New line preferences
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true:suggestion
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = false:suggestion
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false:suggestion
csharp_style_allow_embedded_statements_on_same_line_experimental = true:suggestion
@ -144,8 +150,8 @@ csharp_new_line_between_query_expression_clauses = true
csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_case_contents = true
csharp_indent_case_contents_when_block = true
csharp_indent_labels = one_less_than_current
csharp_indent_case_contents_when_block = false
csharp_indent_labels = no_change
csharp_indent_switch_labels = true
# Space preferences

View file

@ -1,13 +1,13 @@
using System;
using CreamInstaller.Paradox;
using CreamInstaller.Utility;
using System;
using System.Collections.Concurrent;
using System.Drawing;
using System.IO;
using System.Threading.Tasks;
using System.Windows.Forms;
using CreamInstaller.Paradox;
using CreamInstaller.Utility;
namespace CreamInstaller.Components;
internal class ContextMenuItem : ToolStripMenuItem

View file

@ -1,14 +1,14 @@
using System.Collections.Generic;
using CreamInstaller.Resources;
using Microsoft.Win32;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using CreamInstaller.Resources;
using Microsoft.Win32;
namespace CreamInstaller.Epic;
internal static class EpicLibrary
@ -53,13 +53,12 @@ internal static class EpicLibrary
{
List<string> dllDirectories = new();
if (Program.Canceled || !Directory.Exists(gameDirectory)) return null;
gameDirectory.GetScreamApiComponents(out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config, out string cache);
gameDirectory.GetScreamApiComponents(out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config);
if (File.Exists(sdk32)
|| File.Exists(sdk32_o)
|| File.Exists(sdk64)
|| File.Exists(sdk64_o)
|| File.Exists(config)
|| File.Exists(cache))
|| File.Exists(config))
dllDirectories.Add(gameDirectory);
string[] directories = Directory.GetDirectories(gameDirectory);
foreach (string _directory in directories)

View file

@ -1,4 +1,9 @@
using System;
using CreamInstaller.Epic.GraphQL;
using CreamInstaller.Utility;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@ -7,11 +12,6 @@ using System.Net.Http.Headers;
using System.Threading.Tasks;
using System.Web;
using CreamInstaller.Epic.GraphQL;
using CreamInstaller.Utility;
using Newtonsoft.Json;
namespace CreamInstaller.Epic;
internal static class EpicStore
@ -124,7 +124,7 @@ internal static class EpicStore
HttpClient client = HttpClientManager.HttpClient;
if (client is null) return null;
HttpResponseMessage httpResponse = await client.PostAsync(new Uri("https://graphql.epicgames.com/graphql"), content);
httpResponse.EnsureSuccessStatusCode();
_ = httpResponse.EnsureSuccessStatusCode();
string response = await httpResponse.Content.ReadAsStringAsync();
return JsonConvert.DeserializeObject<Response>(response);
}

View file

@ -1,9 +1,9 @@
#pragma warning disable CA1819 // Properties should not return arrays
using System;
using Newtonsoft.Json;
using System;
namespace CreamInstaller.Epic.GraphQL;
public class Response

View file

@ -1,19 +1,18 @@
using System;
using CreamInstaller.Components;
using System;
using System.Drawing;
using System.Windows.Forms;
using CreamInstaller.Components;
namespace CreamInstaller;
internal partial class DialogForm : CustomForm
{
internal DialogForm(IWin32Window owner) : base(owner) => InitializeComponent();
internal DialogResult Show(Icon descriptionIcon, string descriptionText, string acceptButtonText, string cancelButtonText = null, string customFormText = null, Icon customFormIcon = null)
internal DialogResult Show(Icon descriptionIcon, string descriptionText, string acceptButtonText = "OK", string cancelButtonText = null, string customFormText = null, Icon customFormIcon = null)
{
if (descriptionIcon is null)
descriptionIcon = Icon;
descriptionIcon ??= Icon;
icon.Image = descriptionIcon.ToBitmap();
descriptionLabel.Text = descriptionText;
acceptButton.Text = acceptButtonText;

View file

@ -1,4 +1,8 @@
using System;
using CreamInstaller.Components;
using CreamInstaller.Resources;
using CreamInstaller.Utility;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
@ -8,10 +12,6 @@ using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using CreamInstaller.Components;
using CreamInstaller.Resources;
using CreamInstaller.Utility;
using static CreamInstaller.Paradox.ParadoxLauncher;
namespace CreamInstaller;
@ -45,13 +45,14 @@ internal partial class InstallForm : CustomForm
internal void UpdateUser(string text, Color color, bool info = true, bool log = true)
{
if (info) userInfoLabel.Invoke(() => userInfoLabel.Text = text);
if (info) _ = userInfoLabel.Invoke(() => userInfoLabel.Text = text);
if (log && !logTextBox.Disposing && !logTextBox.IsDisposed)
{
logTextBox.Invoke(() =>
{
if (logTextBox.Text.Length > 0) logTextBox.AppendText(Environment.NewLine, color);
logTextBox.AppendText(text, color);
logTextBox.Refresh();
});
Thread.Sleep(0);
}
@ -268,7 +269,7 @@ internal partial class InstallForm : CustomForm
internal static async Task UninstallScreamAPI(string directory, InstallForm installForm = null, bool deleteConfig = true) => await Task.Run(() =>
{
directory.GetScreamApiComponents(out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config, out string cache);
directory.GetScreamApiComponents(out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config);
if (File.Exists(sdk32_o))
{
if (File.Exists(sdk32))
@ -299,17 +300,11 @@ internal partial class InstallForm : CustomForm
if (installForm is not null)
installForm.UpdateUser($"Deleted configuration: {Path.GetFileName(config)}", InstallationLog.Action, info: false);
}
if (deleteConfig && File.Exists(cache))
{
File.Delete(cache);
if (installForm is not null)
installForm.UpdateUser($"Deleted cache: {Path.GetFileName(cache)}", InstallationLog.Action, info: false);
}
});
internal static async Task InstallScreamAPI(string directory, ProgramSelection selection, InstallForm installForm = null, bool generateConfig = true) => await Task.Run(() =>
{
directory.GetScreamApiComponents(out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config, out _);
directory.GetScreamApiComponents(out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config);
if (File.Exists(sdk32) && !File.Exists(sdk32_o))
{
File.Move(sdk32, sdk32_o);
@ -372,7 +367,7 @@ internal partial class InstallForm : CustomForm
if (selection.Id == "ParadoxLauncher")
{
UpdateUser($"Repairing Paradox Launcher . . . ", InstallationLog.Operation);
await Repair(this, selection);
_ = await Repair(this, selection);
}
foreach (string directory in selection.DllDirectories)
{
@ -394,8 +389,8 @@ internal partial class InstallForm : CustomForm
if (selection.IsEpic && selection.SelectedDlc.Any(d => d.Value.type is DlcType.EpicCatalogItem or DlcType.EpicEntitlement)
|| selection.ExtraSelectedDlc.Any(item => item.dlc.Any(dlc => dlc.Value.type is DlcType.EpicCatalogItem or DlcType.EpicEntitlement)))
{
directory.GetScreamApiComponents(out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config, out string cache);
if (File.Exists(sdk32) || File.Exists(sdk32_o) || File.Exists(sdk64) || File.Exists(sdk64_o) || File.Exists(config) || File.Exists(cache))
directory.GetScreamApiComponents(out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config);
if (File.Exists(sdk32) || File.Exists(sdk32_o) || File.Exists(sdk64) || File.Exists(sdk64_o) || File.Exists(config))
{
UpdateUser($"{(Uninstalling ? "Uninstalling" : "Installing")} ScreamAPI" +
$" {(Uninstalling ? "from" : "for")} " + selection.Name + $" in directory \"{directory}\" . . . ", InstallationLog.Operation);

View file

@ -1,4 +1,13 @@
using System;
using CreamInstaller.Components;
using CreamInstaller.Utility;
using HtmlAgilityPack;
using Onova;
using Onova.Models;
using Onova.Services;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
@ -8,15 +17,6 @@ using System.Threading.Tasks;
using System.Web;
using System.Windows.Forms;
using CreamInstaller.Components;
using CreamInstaller.Utility;
using HtmlAgilityPack;
using Onova;
using Onova.Models;
using Onova.Services;
namespace CreamInstaller;
internal partial class MainForm : CustomForm
@ -39,7 +39,7 @@ internal partial class MainForm : CustomForm
}
Hide();
using SelectForm form = new(this);
form.ShowDialog();
_ = form.ShowDialog();
Close();
}

View file

@ -1,13 +1,13 @@
using System;
using CreamInstaller.Components;
using CreamInstaller.Utility;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using CreamInstaller.Components;
using CreamInstaller.Utility;
using static CreamInstaller.Components.CustomTreeView;
namespace CreamInstaller;
@ -34,7 +34,7 @@ internal partial class SelectDialogForm : CustomForm
Checked = alreadySelected
};
OnTreeNodeChecked(node);
selectionTreeView.Nodes.Add(node);
_ = selectionTreeView.Nodes.Add(node);
}
if (!selected.Any()) OnLoad(null, null);
allCheckBox.CheckedChanged -= OnAllCheckBoxChanged;
@ -62,7 +62,7 @@ internal partial class SelectDialogForm : CustomForm
if (node.Checked)
selected.Add((node.Tag as string, id, node.Text));
else
selected.RemoveAll(s => s.id == id);
_ = selected.RemoveAll(s => s.id == id);
allCheckBox.CheckedChanged -= OnAllCheckBoxChanged;
allCheckBox.Checked = selectionTreeView.Nodes.Cast<TreeNode>().All(n => n.Checked);
allCheckBox.CheckedChanged += OnAllCheckBoxChanged;

View file

@ -1,13 +1,4 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
#pragma warning disable IDE0058
using CreamInstaller.Components;
using CreamInstaller.Epic;
@ -18,6 +9,17 @@ using CreamInstaller.Utility;
using Gameloop.Vdf.Linq;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CreamInstaller;
internal partial class SelectForm : CustomForm
@ -51,7 +53,7 @@ internal partial class SelectForm : CustomForm
{
if (Program.Canceled) return;
if (RemainingGames.Contains(gameName))
RemainingGames.Remove(gameName);
_ = RemainingGames.Remove(gameName);
UpdateRemainingGames();
});
}
@ -76,7 +78,7 @@ internal partial class SelectForm : CustomForm
{
if (Program.Canceled) return;
if (RemainingDLCs.Contains(dlcId))
RemainingDLCs.Remove(dlcId);
_ = RemainingDLCs.Remove(dlcId);
UpdateRemainingDLCs();
});
}
@ -123,7 +125,7 @@ internal partial class SelectForm : CustomForm
programNode.Text = selection.Name;
programNode.Checked = selection.Enabled;
programNode.Remove();
selectionTreeView.Nodes.Add(programNode);
_ = selectionTreeView.Nodes.Add(programNode);
}
}
if (Directory.Exists(SteamLibrary.InstallPath) && ProgramsToScan.Any(c => c.platform == "Steam"))
@ -245,7 +247,7 @@ internal partial class SelectForm : CustomForm
programNode.Text = appData?.name ?? name;
programNode.Checked = selection.Enabled;
programNode.Remove();
selectionTreeView.Nodes.Add(programNode);
_ = selectionTreeView.Nodes.Add(programNode);
foreach (KeyValuePair<string, (DlcType type, string name, string icon)> pair in dlc)
{
if (Program.Canceled || programNode is null) return;
@ -259,7 +261,7 @@ internal partial class SelectForm : CustomForm
dlcNode.Text = dlcApp.name;
dlcNode.Checked = selection.SelectedDlc.ContainsKey(appId);
dlcNode.Remove();
programNode.Nodes.Add(dlcNode);
_ = programNode.Nodes.Add(dlcNode);
}
});
if (Program.Canceled) return;
@ -352,7 +354,7 @@ internal partial class SelectForm : CustomForm
programNode.Text = name;
programNode.Checked = selection.Enabled;
programNode.Remove();
selectionTreeView.Nodes.Add(programNode);
_ = selectionTreeView.Nodes.Add(programNode);
/*TreeNode catalogItemsNode = treeNodes.Find(s => s.Name == @namespace + "_catalogItems") ?? new();
catalogItemsNode.Name = @namespace + "_catalogItems";
catalogItemsNode.Text = "Catalog Items";
@ -380,7 +382,7 @@ internal partial class SelectForm : CustomForm
dlcNode.Text = dlcApp.name;
dlcNode.Checked = selection.SelectedDlc.ContainsKey(dlcId);
dlcNode.Remove();
programNode.Nodes.Add(dlcNode); //entitlementsNode.Nodes.Add(dlcNode);
_ = programNode.Nodes.Add(dlcNode); //entitlementsNode.Nodes.Add(dlcNode);
}
}
});
@ -683,8 +685,8 @@ internal partial class SelectForm : CustomForm
for (int i = 0; i < directories.Count; i++)
{
string directory = directories[i];
directory.GetScreamApiComponents(out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config, out string cache);
if (File.Exists(sdk32) || File.Exists(sdk32_o) || File.Exists(sdk64) || File.Exists(sdk64_o) || File.Exists(config) || File.Exists(cache))
directory.GetScreamApiComponents(out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config);
if (File.Exists(sdk32) || File.Exists(sdk32_o) || File.Exists(sdk64) || File.Exists(sdk64_o) || File.Exists(config))
{
contextMenuStrip.Items.Add(new ContextMenuItem($"Open Epic Online Services SDK Directory #{i + 1}", "File Explorer",
new EventHandler((sender, e) => Diagnostics.OpenDirectoryInFileExplorer(directory))));
@ -743,7 +745,7 @@ internal partial class SelectForm : CustomForm
if (ParadoxLauncher.DlcDialog(this)) return;
Hide();
using InstallForm installForm = new(this, uninstall);
installForm.ShowDialog();
_ = installForm.ShowDialog();
if (installForm.Reselecting)
{
InheritLocation(installForm);
@ -795,15 +797,15 @@ internal partial class SelectForm : CustomForm
{
StringBuilder blockedGames = new();
foreach (string name in Program.ProtectedGames)
blockedGames.Append(helpButtonListPrefix + name);
_ = blockedGames.Append(helpButtonListPrefix + name);
StringBuilder blockedDirectories = new();
foreach (string path in Program.ProtectedGameDirectories)
blockedDirectories.Append(helpButtonListPrefix + path);
_ = blockedDirectories.Append(helpButtonListPrefix + path);
StringBuilder blockedDirectoryExceptions = new();
foreach (string name in Program.ProtectedGameDirectoryExceptions)
blockedDirectoryExceptions.Append(helpButtonListPrefix + name);
_ = blockedDirectoryExceptions.Append(helpButtonListPrefix + name);
using DialogForm form = new(this);
form.Show(SystemIcons.Information,
_ = form.Show(SystemIcons.Information,
"Blocks the program from caching and displaying games protected by DLL checks," +
"\nanti-cheats, or that are confirmed not to be working with SmokeAPI or ScreamAPI." +
"\n\nBlocked games:" + blockedGames +
@ -812,3 +814,5 @@ internal partial class SelectForm : CustomForm
"OK", customFormText: "Block Protected Games");
}
}
#pragma warning restore IDE0058

View file

@ -1,14 +1,14 @@
using System.Drawing;
using CreamInstaller.Resources;
using CreamInstaller.Utility;
using Microsoft.Win32;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using CreamInstaller.Resources;
using CreamInstaller.Utility;
using Microsoft.Win32;
using static CreamInstaller.Resources.Resources;
namespace CreamInstaller.Paradox;
@ -97,7 +97,7 @@ internal static class ParadoxLauncher
if (steamOriginalSdk64 is null && File.Exists(sdk64) && !sdk64.IsResourceFile(ResourceIdentifier.Steamworks64))
steamOriginalSdk64 = File.ReadAllBytes(sdk64);
directory.GetScreamApiComponents(out sdk32, out _, out sdk64, out _, out config, out _);
directory.GetScreamApiComponents(out sdk32, out _, out sdk64, out _, out config);
screamConfig = screamConfig || File.Exists(config);
await InstallForm.UninstallScreamAPI(directory, deleteConfig: false);
if (epicOriginalSdk32 is null && File.Exists(sdk32) && !sdk32.IsResourceFile(ResourceIdentifier.EpicOnlineServices32))
@ -129,7 +129,7 @@ internal static class ParadoxLauncher
if (smokeConfig)
await InstallForm.InstallSmokeAPI(directory, selection, generateConfig: false);
directory.GetScreamApiComponents(out sdk32, out _, out sdk64, out _, out _, out _);
directory.GetScreamApiComponents(out sdk32, out _, out sdk64, out _, out _);
if (epicOriginalSdk32 is not null && sdk32.IsResourceFile(ResourceIdentifier.EpicOnlineServices32))
{
epicOriginalSdk32.Write(sdk32);
@ -152,7 +152,7 @@ internal static class ParadoxLauncher
if (installForm is not null)
installForm.UpdateUser("Paradox Launcher successfully repaired!", InstallationLog.Success);
else
dialogForm.Show(form.Icon, "Paradox Launcher successfully repaired!", "OK", customFormText: "Paradox Launcher");
_ = dialogForm.Show(form.Icon, "Paradox Launcher successfully repaired!", "OK", customFormText: "Paradox Launcher");
return RepairResult.Success;
}
else
@ -160,18 +160,17 @@ internal static class ParadoxLauncher
if (installForm is not null)
installForm.UpdateUser("Paradox Launcher did not need to be repaired.", InstallationLog.Success);
else
dialogForm.Show(SystemIcons.Information, "Paradox Launcher does not need to be repaired.", "OK", customFormText: "Paradox Launcher");
_ = dialogForm.Show(SystemIcons.Information, "Paradox Launcher does not need to be repaired.", "OK", customFormText: "Paradox Launcher");
return RepairResult.Unnecessary;
}
}
else
{
if (form is InstallForm)
throw new CustomMessageException("Repair failed! " +
_ = form is InstallForm
? throw new CustomMessageException("Repair failed! " +
"An original Steamworks/Epic Online Services SDK file could not be found. " +
"You will likely have to reinstall Paradox Launcher to fix this issue.");
else
dialogForm.Show(SystemIcons.Error, "Paradox Launcher repair failed!"
"You will likely have to reinstall Paradox Launcher to fix this issue.")
: dialogForm.Show(SystemIcons.Error, "Paradox Launcher repair failed!"
+ "\n\nAn original Steamworks/Epic Online Services SDK file could not be found."
+ "\nYou will likely have to reinstall Paradox Launcher to fix this issue.", "OK", customFormText: "Paradox Launcher");
return RepairResult.Failure;

View file

@ -1,3 +1,6 @@
using CreamInstaller.Steam;
using CreamInstaller.Utility;
using System;
using System.Diagnostics;
using System.Drawing;
@ -7,9 +10,6 @@ using System.Reflection;
using System.Threading;
using System.Windows.Forms;
using CreamInstaller.Steam;
using CreamInstaller.Utility;
namespace CreamInstaller;
internal static class Program
@ -62,7 +62,7 @@ internal static class Program
using Mutex mutex = new(true, "CreamInstaller", out bool createdNew);
if (createdNew)
{
Application.SetHighDpiMode(HighDpiMode.SystemAware);
_ = Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.ApplicationExit += new(OnApplicationExit);

View file

@ -1,10 +1,10 @@
using System.Collections.Generic;
using CreamInstaller.Components;
using CreamInstaller.Resources;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using CreamInstaller.Components;
using CreamInstaller.Resources;
namespace CreamInstaller;
public enum DlcType
@ -56,13 +56,12 @@ internal class ProgramSelection
|| config.IsFilePathLocked()
|| cache.IsFilePathLocked())
return true;
directory.GetScreamApiComponents(out sdk32, out sdk32_o, out sdk64, out sdk64_o, out config, out cache);
directory.GetScreamApiComponents(out sdk32, out sdk32_o, out sdk64, out sdk64_o, out config);
if (sdk32.IsFilePathLocked()
|| sdk32_o.IsFilePathLocked()
|| sdk64.IsFilePathLocked()
|| sdk64_o.IsFilePathLocked()
|| config.IsFilePathLocked()
|| cache.IsFilePathLocked())
|| config.IsFilePathLocked())
return true;
}
return false;
@ -72,7 +71,7 @@ internal class ProgramSelection
private void Toggle(string dlcAppId, (DlcType type, string name, string icon) dlcApp, bool enabled)
{
if (enabled) SelectedDlc[dlcAppId] = dlcApp;
else SelectedDlc.Remove(dlcAppId);
else _ = SelectedDlc.Remove(dlcAppId);
}
internal void ToggleDlc(string dlcId, bool enabled)
@ -96,23 +95,23 @@ internal class ProgramSelection
{
if (Program.IsGameBlocked(Name, RootDirectory))
{
All.Remove(this);
_ = All.Remove(this);
return;
}
if (!Directory.Exists(RootDirectory))
{
All.Remove(this);
_ = All.Remove(this);
return;
}
DllDirectories.RemoveAll(directory => !Directory.Exists(directory));
if (!DllDirectories.Any()) All.Remove(this);
_ = DllDirectories.RemoveAll(directory => !Directory.Exists(directory));
if (!DllDirectories.Any()) _ = All.Remove(this);
}
internal void Validate(List<(string platform, string id, string name)> programsToScan)
{
if (programsToScan is null || !programsToScan.Any(p => p.id == Id))
{
All.Remove(this);
_ = All.Remove(this);
return;
}
Validate();

View file

@ -31,7 +31,11 @@ internal static class Resources
return false;
}
internal static void GetCreamApiComponents(this string directory, out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config)
internal static void GetCreamApiComponents(
this string directory,
out string sdk32, out string sdk32_o,
out string sdk64, out string sdk64_o,
out string config)
{
sdk32 = directory + @"\steam_api.dll";
sdk32_o = directory + @"\steam_api_o.dll";
@ -40,7 +44,12 @@ internal static class Resources
config = directory + @"\cream_api.ini";
}
internal static void GetSmokeApiComponents(this string directory, out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config, out string cache)
internal static void GetSmokeApiComponents(
this string directory,
out string sdk32, out string sdk32_o,
out string sdk64, out string sdk64_o,
out string config,
out string cache)
{
sdk32 = directory + @"\steam_api.dll";
sdk32_o = directory + @"\steam_api_o.dll";
@ -50,14 +59,48 @@ internal static class Resources
cache = directory + @"\SmokeAPI.cache.json";
}
internal static void GetScreamApiComponents(this string directory, out string sdk32, out string sdk32_o, out string sdk64, out string sdk64_o, out string config, out string cache)
internal static void GetScreamApiComponents(
this string directory,
out string sdk32, out string sdk32_o,
out string sdk64, out string sdk64_o,
out string config
)
{
sdk32 = directory + @"\EOSSDK-Win32-Shipping.dll";
sdk32_o = directory + @"\EOSSDK-Win32-Shipping_o.dll";
sdk64 = directory + @"\EOSSDK-Win64-Shipping.dll";
sdk64_o = directory + @"\EOSSDK-Win64-Shipping_o.dll";
config = directory + @"\ScreamAPI.json";
cache = directory + @"\ScreamAPI.cache.json";
}
internal static void GetUplayR1Components(
this string directory,
out string sdk32, out string sdk32_o,
out string sdk64, out string sdk64_o,
out string config
)
{
sdk32 = directory + @"\uplay_r1_loader.dll";
sdk32_o = directory + @"\uplay_r1_loader_o.dll";
sdk64 = directory + @"\uplay_r1_loader64.dll";
sdk64_o = directory + @"\uplay_r1_loader64_o.dll";
config = directory + @"\UplayR1Unlocker.jsonc";
}
internal static void GetUplayR2Components(
this string directory,
out string old_sdk32, out string old_sdk64,
out string sdk32, out string sdk32_o,
out string sdk64, out string sdk64_o,
out string config)
{
old_sdk32 = directory + @"\uplay_r2_loader.dll";
old_sdk64 = directory + @"\uplay_r2_loader64.dll";
sdk32 = directory + @"\upc_r2_loader.dll";
sdk32_o = directory + @"\upc_r2_loader_o.dll";
sdk64 = directory + @"\upc_r2_loader64.dll";
sdk64_o = directory + @"\upc_r2_loader64_o.dll";
config = directory + @"\UplayR2Unlocker.jsonc";
}
public enum ResourceIdentifier

View file

@ -1,4 +1,9 @@
using System;
using CreamInstaller.Resources;
using CreamInstaller.Utility;
using Gameloop.Vdf.Linq;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
@ -10,11 +15,6 @@ using System.Text;
using System.Threading;
using System.Threading.Tasks;
using CreamInstaller.Resources;
using CreamInstaller.Utility;
using Gameloop.Vdf.Linq;
namespace CreamInstaller.Steam;
internal static class SteamCMD
@ -84,8 +84,7 @@ internal static class SteamCMD
lastOutput = DateTime.UtcNow;
char ch = (char)c;
if (ch == '{') appInfoStarted = true;
if (appInfoStarted) appInfo.Append(ch);
else output.Append(ch);
_ = appInfoStarted ? appInfo.Append(ch) : output.Append(ch);
}
DateTime now = DateTime.UtcNow;
TimeSpan timeDiff = now - lastOutput;
@ -99,13 +98,13 @@ internal static class SteamCMD
processStartInfo.Arguments = GetArguments(appId);
process = Process.Start(processStartInfo);
appInfoStarted = false;
output.Clear();
appInfo.Clear();
_ = output.Clear();
_ = appInfo.Clear();
}
else break;
}
}
Interlocked.Decrement(ref locks[i]);
_ = Interlocked.Decrement(ref locks[i]);
return appInfo.ToString();
}
Thread.Sleep(200);
@ -142,7 +141,7 @@ internal static class SteamCMD
int cur = 0;
progress.Report(cur);
watcher.Changed += (sender, e) => progress.Report(++cur);
await Run(null);
_ = await Run(null);
watcher.Dispose();
}
}

View file

@ -1,16 +1,16 @@
using System.Collections.Generic;
using CreamInstaller.Resources;
using Gameloop.Vdf.Linq;
using Microsoft.Win32;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using CreamInstaller.Resources;
using Gameloop.Vdf.Linq;
using Microsoft.Win32;
namespace CreamInstaller.Steam;
internal static class SteamLibrary

View file

@ -1,12 +1,17 @@
using System.Collections.Generic;
using CreamInstaller.Utility;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using CreamInstaller.Utility;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
#if DEBUG
using System;
using System.Drawing;
#endif
namespace CreamInstaller.Steam;
@ -34,7 +39,7 @@ internal static class SteamStore
string response = await HttpClientManager.EnsureGet($"https://store.steampowered.com/api/appdetails?appids={appId}");
if (response is not null)
{
IDictionary<string, JToken> apps = JsonConvert.DeserializeObject(response) as dynamic;
IDictionary<string, JToken> apps = (IDictionary<string, JToken>)JsonConvert.DeserializeObject(response);
if (apps is not null)
foreach (KeyValuePair<string, JToken> app in apps)
{
@ -47,19 +52,29 @@ internal static class SteamStore
{
File.WriteAllText(cacheFile, JsonConvert.SerializeObject(data, Formatting.Indented));
}
catch //(Exception e)
catch
#if DEBUG
(Exception e)
{
//using DialogForm dialogForm = new(null);
//dialogForm.Show(SystemIcons.Error, "Unsuccessful serialization of query for appid " + appId + ":\n\n" + e.ToString(), "FUCK");
using DialogForm dialogForm = new(null);
dialogForm.Show(SystemIcons.Error, "Unsuccessful serialization of query for appid " + appId + ":\n\n" + e.ToString());
}
#else
{ }
#endif
return data;
}
}
catch //(Exception e)
catch
#if DEBUG
(Exception e)
{
//using DialogForm dialogForm = new(null);
//dialogForm.Show(SystemIcons.Error, "Unsuccessful deserialization of query for appid " + appId + ":\n\n" + e.ToString(), "FUCK");
using DialogForm dialogForm = new(null);
dialogForm.Show(SystemIcons.Error, "Unsuccessful deserialization of query for appid " + appId + ":\n\n" + e.ToString());
}
#else
{ }
#endif
}
}
}

View file

@ -1,9 +1,9 @@
using System;
using Microsoft.Win32;
using System;
using System.Diagnostics;
using System.IO;
using Microsoft.Win32;
namespace CreamInstaller.Utility;
internal static class Diagnostics

View file

@ -15,7 +15,7 @@ internal static class ExceptionHandler
string[] stackTrace = e.StackTrace?.Split('\n');
if (stackTrace is not null && stackTrace.Length > 0)
{
output.Append("STACK TRACE\n");
_ = output.Append("STACK TRACE\n");
for (int i = 0; i < Math.Min(stackTrace.Length, 3); i++)
{
string line = stackTrace[i];
@ -24,7 +24,7 @@ internal static class ExceptionHandler
int ciNum = line.LastIndexOf(@"CreamInstaller\");
int lineNum = line.LastIndexOf(":line ");
if (line is not null && atNum != -1)
output.Append("\n " + (inNum != -1 ? line[atNum..(inNum - 1)] : line[atNum..])
_ = output.Append("\n " + (inNum != -1 ? line[atNum..(inNum - 1)] : line[atNum..])
+ (inNum != -1 ? ("\n "
+ (ciNum != -1 ? ("in "
+ (lineNum != -1 ? line[ciNum..lineNum]
@ -38,13 +38,13 @@ internal static class ExceptionHandler
if (messageLines is not null && messageLines.Length > 0)
{
if (output.Length > 0)
output.Append("\n\n");
output.Append("MESSAGE\n");
_ = output.Append("\n\n");
_ = output.Append("MESSAGE\n");
for (int i = 0; i < messageLines.Length; i++)
{
string line = messageLines[i];
if (line is not null)
output.Append("\n " + line);
_ = output.Append("\n " + line);
}
}
using DialogForm dialogForm = new(form ?? Form.ActiveForm);

View file

@ -1,11 +1,11 @@
using System;
using HtmlAgilityPack;
using System;
using System.Drawing;
using System.Net.Http;
using System.Threading.Tasks;
using System.Windows.Forms;
using HtmlAgilityPack;
namespace CreamInstaller.Utility;
internal static class HttpClientManager
@ -23,7 +23,7 @@ internal static class HttpClientManager
{
using HttpRequestMessage request = new(HttpMethod.Get, url);
using HttpResponseMessage response = await HttpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead);
response.EnsureSuccessStatusCode();
_ = response.EnsureSuccessStatusCode();
return await response.Content.ReadAsStringAsync();
}
catch

View file

@ -29,15 +29,15 @@ internal static class ProgramData
if (Directory.Exists(DirectoryPath)) Directory.Delete(DirectoryPath, true);
Directory.Move(DirectoryPathOld, DirectoryPath);
}
if (!Directory.Exists(DirectoryPath)) Directory.CreateDirectory(DirectoryPath);
if (!Directory.Exists(DirectoryPath)) _ = Directory.CreateDirectory(DirectoryPath);
if (!File.Exists(AppInfoVersionPath) || !Version.TryParse(File.ReadAllText(AppInfoVersionPath, Encoding.UTF8), out Version version) || version < MinimumAppInfoVersion)
{
if (Directory.Exists(AppInfoPath)) Directory.Delete(AppInfoPath, true);
Directory.CreateDirectory(AppInfoPath);
_ = Directory.CreateDirectory(AppInfoPath);
File.WriteAllText(AppInfoVersionPath, Application.ProductVersion, Encoding.UTF8);
}
if (!Directory.Exists(CooldownPath))
Directory.CreateDirectory(CooldownPath);
_ = Directory.CreateDirectory(CooldownPath);
});
internal static bool CheckCooldown(string identifier, int cooldown)
@ -69,7 +69,7 @@ internal static class ProgramData
private static void SetCooldown(string identifier, DateTime time)
{
if (!Directory.Exists(CooldownPath))
Directory.CreateDirectory(CooldownPath);
_ = Directory.CreateDirectory(CooldownPath);
string cooldownFile = CooldownPath + @$"\{identifier}.txt";
try
{