diff --git a/CreamInstaller/Components/CustomForm.cs b/CreamInstaller/Components/CustomForm.cs index 9a2807d..7b84a3b 100644 --- a/CreamInstaller/Components/CustomForm.cs +++ b/CreamInstaller/Components/CustomForm.cs @@ -2,22 +2,14 @@ using System.Drawing; using System.Drawing.Drawing2D; using System.Drawing.Imaging; -using System.Runtime.InteropServices; using System.Windows.Forms; using CreamInstaller.Forms; +using CreamInstaller.Utility; namespace CreamInstaller.Components; internal class CustomForm : Form { - internal const short SWP_NOACTIVATE = 0x0010; - internal const short SWP_SHOWWINDOW = 0x0040; - internal const short SWP_NOMOVE = 0x0002; - internal const short SWP_NOSIZE = 0x0001; - - internal static readonly nint HWND_NOTOPMOST = new(-2); - internal static readonly nint HWND_TOPMOST = new(-1); - internal CustomForm() { Icon = Properties.Resources.Icon; @@ -54,7 +46,7 @@ internal class CustomForm : Form { using DialogForm helpDialog = new(this); helpDialog.HelpButton = false; - string acidicoala = "https://github.com/acidicoala"; + const string acidicoala = "https://github.com/acidicoala"; string repository = $"https://github.com/{Program.RepositoryOwner}/{Program.RepositoryName}"; _ = helpDialog.Show(SystemIcons.Information, "Automatically finds all installed Steam, Epic and Ubisoft games with their respective DLC-related DLL locations on the user's computer,\n" @@ -86,15 +78,14 @@ internal class CustomForm : Form private void OnActivation(object sender, EventArgs args) => Activate(); - [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode), DefaultDllImportSearchPaths(DllImportSearchPath.System32)] - private static extern void SetWindowPos(nint hWnd, nint hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags); - internal void BringToFrontWithoutActivation() { bool topMost = TopMost; - SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE); + NativeImports.SetWindowPos(Handle, NativeImports.HWND_TOPMOST, 0, 0, 0, 0, + NativeImports.SWP_NOACTIVATE | NativeImports.SWP_SHOWWINDOW | NativeImports.SWP_NOMOVE | NativeImports.SWP_NOSIZE); if (!topMost) - SetWindowPos(Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE); + NativeImports.SetWindowPos(Handle, NativeImports.HWND_NOTOPMOST, 0, 0, 0, 0, + NativeImports.SWP_NOACTIVATE | NativeImports.SWP_SHOWWINDOW | NativeImports.SWP_NOMOVE | NativeImports.SWP_NOSIZE); } internal void InheritLocation(Form fromForm) diff --git a/CreamInstaller/Components/CustomTreeView.cs b/CreamInstaller/Components/CustomTreeView.cs index 36e1ad3..d307e91 100644 --- a/CreamInstaller/Components/CustomTreeView.cs +++ b/CreamInstaller/Components/CustomTreeView.cs @@ -145,7 +145,7 @@ internal sealed class CustomTreeView : TreeView { comboBoxFont ??= new(font.FontFamily, 6, font.Style, font.Unit, font.GdiCharSet, font.GdiVerticalFont); ComboBoxState comboBoxState = Enabled ? ComboBoxState.Normal : ComboBoxState.Disabled; - text = selection.KoaloaderProxy ?? ProgramSelection.DefaultKoaloaderProxy + ".dll"; + text = (selection.KoaloaderProxy ?? ProgramSelection.DefaultKoaloaderProxy) + ".dll"; size = TextRenderer.MeasureText(graphics, text, comboBoxFont) + new Size(6, 0); const int padding = 2; bounds = new(bounds.X + bounds.Width, bounds.Y + padding / 2, size.Width, bounds.Height - padding); diff --git a/CreamInstaller/CreamInstaller.csproj b/CreamInstaller/CreamInstaller.csproj index 67e2879..a652d8a 100644 --- a/CreamInstaller/CreamInstaller.csproj +++ b/CreamInstaller/CreamInstaller.csproj @@ -4,7 +4,7 @@ net7.0-windows True Resources\ini.ico - 4.8.1.0 + 4.8.1 2021, pointfeev (https://github.com/pointfeev) CreamInstaller Automatic DLC Unlocker Installer & Configuration Generator @@ -145,8 +145,8 @@ - - + + diff --git a/CreamInstaller/Platforms/Epic/EpicLibrary.cs b/CreamInstaller/Platforms/Epic/EpicLibrary.cs index 6fb8c11..3f70e63 100644 --- a/CreamInstaller/Platforms/Epic/EpicLibrary.cs +++ b/CreamInstaller/Platforms/Epic/EpicLibrary.cs @@ -1,10 +1,10 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text.Json; using System.Threading.Tasks; using CreamInstaller.Utility; using Microsoft.Win32; +using Newtonsoft.Json; using static CreamInstaller.Resources.Resources; namespace CreamInstaller.Platforms.Epic; @@ -44,7 +44,7 @@ internal static class EpicLibrary string json = file.ReadFile(); try { - Manifest manifest = JsonSerializer.Deserialize(json); + Manifest manifest = JsonConvert.DeserializeObject(json); if (manifest is not null && manifest.CatalogItemId == manifest.MainGameCatalogItemId && !games.Any(g => g.CatalogItemId == manifest.CatalogItemId && g.InstallLocation == manifest.InstallLocation)) games.Add(manifest); diff --git a/CreamInstaller/Platforms/Steam/SteamCMD.cs b/CreamInstaller/Platforms/Steam/SteamCMD.cs index ff47b05..df197f3 100644 --- a/CreamInstaller/Platforms/Steam/SteamCMD.cs +++ b/CreamInstaller/Platforms/Steam/SteamCMD.cs @@ -298,10 +298,4 @@ internal static class SteamCMD foreach (Task task in tasks) await task; } - - internal static void Dispose() - { - Kill().Wait(); - DirectoryPath.DeleteDirectory(); - } } \ No newline at end of file diff --git a/CreamInstaller/Utility/HttpClientManager.cs b/CreamInstaller/Utility/HttpClientManager.cs index 99cac6a..64815f7 100644 --- a/CreamInstaller/Utility/HttpClientManager.cs +++ b/CreamInstaller/Utility/HttpClientManager.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Drawing; +using System.Globalization; using System.Net; using System.Net.Http; using System.Threading.Tasks; @@ -19,7 +20,8 @@ internal static class HttpClientManager internal static void Setup() { HttpClient = new(); - HttpClient.DefaultRequestHeaders.Add("User-Agent", $"CI{Program.Version.Replace(".", "")}"); + HttpClient.DefaultRequestHeaders.UserAgent.Add(new(Program.Name, Program.Version)); + HttpClient.DefaultRequestHeaders.AcceptLanguage.Add(new(CultureInfo.CurrentCulture.ToString())); } internal static async Task EnsureGet(string url) diff --git a/CreamInstaller/Utility/NativeImports.cs b/CreamInstaller/Utility/NativeImports.cs index 168b0b4..d957684 100644 --- a/CreamInstaller/Utility/NativeImports.cs +++ b/CreamInstaller/Utility/NativeImports.cs @@ -5,7 +5,18 @@ namespace CreamInstaller.Utility; internal static partial class NativeImports { + internal const short SWP_NOACTIVATE = 0x0010; + internal const short SWP_SHOWWINDOW = 0x0040; + internal const short SWP_NOMOVE = 0x0002; + internal const short SWP_NOSIZE = 0x0001; + + internal static readonly nint HWND_NOTOPMOST = new(-2); + internal static readonly nint HWND_TOPMOST = new(-1); + [LibraryImport("kernel32.dll", SetLastError = true), DefaultDllImportSearchPaths(DllImportSearchPath.System32)] [return: MarshalAs(UnmanagedType.Bool)] internal static partial bool GetBinaryType([MarshalAs(UnmanagedType.LPStr)] string lpApplicationName, out BinaryType lpBinaryType); + + [LibraryImport("user32.dll", SetLastError = true), DefaultDllImportSearchPaths(DllImportSearchPath.System32)] + internal static partial void SetWindowPos(nint hWnd, nint hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags); } \ No newline at end of file