diff --git a/Bloxstrap.sln b/Bloxstrap.sln index 62d830d..95d2b53 100644 --- a/Bloxstrap.sln +++ b/Bloxstrap.sln @@ -1,9 +1,9 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 -VisualStudioVersion = 17.0.32014.148 +VisualStudioVersion = 17.3.32819.101 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bloxstrap", "Bloxstrap\Bloxstrap.csproj", "{646D1D58-C9CA-48C9-BBCD-30585A1DAAF1}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bloxstrap", "Bloxstrap\Bloxstrap.csproj", "{0D75146E-DA24-4B05-B6C9-250C8F81B0C7}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -11,15 +11,15 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {646D1D58-C9CA-48C9-BBCD-30585A1DAAF1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {646D1D58-C9CA-48C9-BBCD-30585A1DAAF1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {646D1D58-C9CA-48C9-BBCD-30585A1DAAF1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {646D1D58-C9CA-48C9-BBCD-30585A1DAAF1}.Release|Any CPU.Build.0 = Release|Any CPU + {0D75146E-DA24-4B05-B6C9-250C8F81B0C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0D75146E-DA24-4B05-B6C9-250C8F81B0C7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0D75146E-DA24-4B05-B6C9-250C8F81B0C7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0D75146E-DA24-4B05-B6C9-250C8F81B0C7}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {F989AC04-B48F-4BB4-B940-1E7D082F14DA} + SolutionGuid = {ED269E5D-8C72-49B4-A76F-51CF163511C1} EndGlobalSection EndGlobal diff --git a/Bloxstrap/App.xaml b/Bloxstrap/App.xaml new file mode 100644 index 0000000..de6837b --- /dev/null +++ b/Bloxstrap/App.xaml @@ -0,0 +1,13 @@ + + + + + + + + + + diff --git a/Bloxstrap/Program.cs b/Bloxstrap/App.xaml.cs similarity index 77% rename from Bloxstrap/Program.cs rename to Bloxstrap/App.xaml.cs index fb6d8c2..6e6eb7b 100644 --- a/Bloxstrap/Program.cs +++ b/Bloxstrap/App.xaml.cs @@ -1,21 +1,25 @@ +using System; using System.Diagnostics; using System.Globalization; using System.IO; using System.Net.Http; using System.Net; using System.Reflection; +using System.Windows; using Microsoft.Win32; -using Bloxstrap.Enums; -using Bloxstrap.Helpers; using Bloxstrap.Models; using Bloxstrap.Dialogs.Menu; - +using Bloxstrap.Enums; +using Bloxstrap.Helpers; namespace Bloxstrap { - internal static class Program + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application { public const StringComparison StringFormat = StringComparison.InvariantCulture; public static readonly CultureInfo CultureFormat = CultureInfo.InvariantCulture; @@ -39,51 +43,49 @@ namespace Bloxstrap public static readonly HttpClient HttpClient = new(new HttpClientHandler { AutomaticDecompression = DecompressionMethods.All }); // shorthand - public static DialogResult ShowMessageBox(string message, MessageBoxIcon icon = MessageBoxIcon.None, MessageBoxButtons buttons = MessageBoxButtons.OK) + public static MessageBoxResult ShowMessageBox(string message, MessageBoxImage icon = MessageBoxImage.None, MessageBoxButton buttons = MessageBoxButton.OK) { if (IsQuiet) - return DialogResult.None; + return MessageBoxResult.None; return MessageBox.Show(message, ProjectName, buttons, icon); } - public static void Exit(int code = Bootstrapper.ERROR_SUCCESS) + public static void Terminate(int code = Bootstrapper.ERROR_SUCCESS) { SettingsManager.Save(); Environment.Exit(code); } - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main(string[] args) + protected override void OnStartup(StartupEventArgs e) { + base.OnStartup(e); + // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - LaunchArgs = args; + LaunchArgs = e.Args; HttpClient.Timeout = TimeSpan.FromMinutes(5); HttpClient.DefaultRequestHeaders.Add("User-Agent", ProjectRepository); - if (args.Length > 0) + if (LaunchArgs.Length > 0) { - if (Array.IndexOf(args, "-quiet") != -1) + if (Array.IndexOf(LaunchArgs, "-quiet") != -1) IsQuiet = true; - if (Array.IndexOf(args, "-uninstall") != -1) + if (Array.IndexOf(LaunchArgs, "-uninstall") != -1) IsUninstall = true; - if (Array.IndexOf(args, "-nolaunch") != -1) + if (Array.IndexOf(LaunchArgs, "-nolaunch") != -1) IsNoLaunch = true; - if (Array.IndexOf(args, "-upgrade") != -1) + if (Array.IndexOf(LaunchArgs, "-upgrade") != -1) IsUpgrade = true; } - // check if installed + // check if installed RegistryKey? registryKey = Registry.CurrentUser.OpenSubKey($@"Software\{ProjectName}"); if (registryKey is null) @@ -126,28 +128,28 @@ namespace Bloxstrap string commandLine = ""; -#if false//DEBUG +#if DEBUG new Preferences().ShowDialog(); #else - if (args.Length > 0) + if (LaunchArgs.Length > 0) { - if (args[0] == "-preferences") + if (LaunchArgs[0] == "-preferences") { if (Process.GetProcessesByName(ProjectName).Length > 1) { - ShowMessageBox($"{ProjectName} is already running. Please close any currently open Bloxstrap or Roblox window before opening the configuration menu.", MessageBoxIcon.Error); + ShowMessageBox($"{ProjectName} is already running. Please close any currently open Bloxstrap or Roblox window before opening the configuration menu.", MessageBoxImage.Error); return; } new Preferences().ShowDialog(); } - else if (args[0].StartsWith("roblox-player:")) + else if (LaunchArgs[0].StartsWith("roblox-player:")) { - commandLine = Protocol.ParseUri(args[0]); + commandLine = Protocol.ParseUri(LaunchArgs[0]); } - else if (args[0].StartsWith("roblox:")) + else if (LaunchArgs[0].StartsWith("roblox:")) { - commandLine = $"--app --deeplink {args[0]}"; + commandLine = $"--app --deeplink {LaunchArgs[0]}"; } else { diff --git a/Bloxstrap/AssemblyInfo.cs b/Bloxstrap/AssemblyInfo.cs new file mode 100644 index 0000000..8b5504e --- /dev/null +++ b/Bloxstrap/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Windows; + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/Bloxstrap/Bloxstrap.csproj b/Bloxstrap/Bloxstrap.csproj index ba22c11..7ea46c8 100644 --- a/Bloxstrap/Bloxstrap.csproj +++ b/Bloxstrap/Bloxstrap.csproj @@ -4,14 +4,11 @@ WinExe net6.0-windows enable - true true - enable - AnyCPU - AnyCPU;x86 + True Bloxstrap.ico - 1.7.0 - 1.7.0.0 + 2.0.0 + 2.0.0.0 @@ -30,32 +27,4 @@ - - - - True - True - Resources.resx - - - True - True - Settings.settings - - - - - - ResXFileCodeGenerator - Resources.Designer.cs - - - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - \ No newline at end of file + diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index 2768b0d..244c251 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -1,18 +1,21 @@ -using System.Diagnostics; +using System; +using System.Collections.Generic; +using System.Diagnostics; using System.IO; using System.IO.Compression; +using System.Linq; using System.Net.Http; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.Windows; using Microsoft.Win32; -using Bloxstrap.Enums; using Bloxstrap.Dialogs.BootstrapperDialogs; using Bloxstrap.Helpers; using Bloxstrap.Helpers.Integrations; using Bloxstrap.Helpers.RSMM; using Bloxstrap.Models; -using System.Net; -using Bloxstrap.Properties; namespace Bloxstrap { @@ -82,23 +85,20 @@ namespace Bloxstrap public Bootstrapper(string? launchCommandLine = null) { LaunchCommandLine = launchCommandLine; - FreshInstall = String.IsNullOrEmpty(Program.Settings.VersionGuid); + FreshInstall = String.IsNullOrEmpty(App.Settings.VersionGuid); } // this is called from BootstrapperStyleForm.SetupDialog() public async Task Run() { - if (Program.IsQuiet) - Dialog.CloseDialog(); - - if (Program.IsUninstall) + if (App.IsUninstall) { Uninstall(); return; } #if !DEBUG - if (!Program.IsFirstRun && Program.Settings.CheckForUpdates) + if (!App.IsFirstRun && App.Settings.CheckForUpdates) await CheckForUpdates(); #endif @@ -106,39 +106,39 @@ namespace Bloxstrap // if bloxstrap is installing for the first time but is running, prompt to close roblox // if roblox needs updating but is running, ignore update for now - if (!Directory.Exists(VersionFolder) && CheckIfRunning(true) || Program.Settings.VersionGuid != VersionGuid && !CheckIfRunning(false)) + if (!Directory.Exists(VersionFolder) && CheckIfRunning(true) || App.Settings.VersionGuid != VersionGuid && !CheckIfRunning(false)) await InstallLatestVersion(); await ApplyModifications(); - if (Program.IsFirstRun) - Program.SettingsManager.ShouldSave = true; + if (App.IsFirstRun) + App.SettingsManager.ShouldSave = true; - if (Program.IsFirstRun || FreshInstall) + if (App.IsFirstRun || FreshInstall) Register(); CheckInstall(); await RbxFpsUnlocker.CheckInstall(); - Program.SettingsManager.Save(); + App.SettingsManager.Save(); - if (Program.IsFirstRun && Program.IsNoLaunch) - Dialog.ShowSuccess($"{Program.ProjectName} has successfully installed"); - else if (!Program.IsNoLaunch) + if (App.IsFirstRun && App.IsNoLaunch) + Dialog.ShowSuccess($"{App.ProjectName} has successfully installed"); + else if (!App.IsNoLaunch) await StartRoblox(); } private async Task CheckForUpdates() { - string currentVersion = $"Bloxstrap v{Program.Version}"; + string currentVersion = $"{App.ProjectName} v{App.Version}"; - var releaseInfo = await Utilities.GetJson($"https://api.github.com/repos/{Program.ProjectRepository}/releases/latest"); + var releaseInfo = await Utilities.GetJson($"https://api.github.com/repos/{App.ProjectRepository}/releases/latest"); if (releaseInfo is null || releaseInfo.Name is null || releaseInfo.Assets is null || currentVersion == releaseInfo.Name) return; - Dialog.Message = "Getting the latest Bloxstrap..."; + Dialog.Message = $"Getting the latest {App.ProjectName}..."; // 64-bit is always the first option GithubReleaseAsset asset = releaseInfo.Assets[Environment.Is64BitOperatingSystem ? 0 : 1]; @@ -150,7 +150,7 @@ namespace Bloxstrap if (!File.Exists(downloadLocation)) { - var response = await Program.HttpClient.GetAsync(asset.BrowserDownloadUrl); + var response = await App.HttpClient.GetAsync(asset.BrowserDownloadUrl); using (var fileStream = new FileStream(Path.Combine(Directories.Updates, asset.Name), FileMode.CreateNew)) { @@ -165,10 +165,10 @@ namespace Bloxstrap FileName = downloadLocation, }; - foreach (string arg in Program.LaunchArgs) + foreach (string arg in App.LaunchArgs) startInfo.ArgumentList.Add(arg); - Program.SettingsManager.Save(); + App.SettingsManager.Save(); Process.Start(startInfo); @@ -179,7 +179,7 @@ namespace Bloxstrap { Dialog.Message = "Connecting to Roblox..."; - ClientVersion clientVersion = await DeployManager.GetLastDeploy(Program.Settings.Channel); + ClientVersion clientVersion = await DeployManager.GetLastDeploy(App.Settings.Channel); VersionGuid = clientVersion.VersionGuid; VersionFolder = Path.Combine(Directories.Versions, VersionGuid); VersionPackageManifest = await PackageManifest.Get(VersionGuid); @@ -214,11 +214,11 @@ namespace Bloxstrap private async Task StartRoblox() { - string startEventName = Program.ProjectName.Replace(" ", "") + "StartEvent"; + string startEventName = App.ProjectName.Replace(" ", "") + "StartEvent"; Dialog.Message = "Starting Roblox..."; - if (LaunchCommandLine == "--app" && Program.Settings.UseDisableAppPatch) + if (LaunchCommandLine == "--app" && App.Settings.UseDisableAppPatch) { Utilities.OpenWebsite("https://www.roblox.com/games"); return; @@ -227,8 +227,8 @@ namespace Bloxstrap // launch time isn't really required for all launches, but it's usually just safest to do this LaunchCommandLine += " --launchtime=" + DateTimeOffset.Now.ToUnixTimeMilliseconds(); - if (Program.Settings.Channel.ToLower() != DeployManager.DefaultChannel.ToLower()) - LaunchCommandLine += " -channel " + Program.Settings.Channel.ToLower(); + if (App.Settings.Channel.ToLower() != DeployManager.DefaultChannel.ToLower()) + LaunchCommandLine += " -channel " + App.Settings.Channel.ToLower(); LaunchCommandLine += " -startEvent " + startEventName; @@ -247,7 +247,7 @@ namespace Bloxstrap if (!startEventFired) return; - if (Program.Settings.RFUEnabled && Process.GetProcessesByName("rbxfpsunlocker").Length == 0) + if (App.Settings.RFUEnabled && Process.GetProcessesByName("rbxfpsunlocker").Length == 0) { ProcessStartInfo startInfo = new() { @@ -257,7 +257,7 @@ namespace Bloxstrap rbxFpsUnlocker = Process.Start(startInfo); - if (Program.Settings.RFUAutoclose) + if (App.Settings.RFUAutoclose) shouldWait = true; } @@ -265,7 +265,7 @@ namespace Bloxstrap await Task.Delay(3000); // now we move onto handling rich presence - if (Program.Settings.UseDiscordRichPresence) + if (App.Settings.UseDiscordRichPresence) { richPresence = new DiscordRichPresence(); richPresence.MonitorGameActivity(); @@ -283,7 +283,7 @@ namespace Bloxstrap if (richPresence is not null) richPresence.Dispose(); - if (Program.Settings.RFUAutoclose && rbxFpsUnlocker is not null) + if (App.Settings.RFUAutoclose && rbxFpsUnlocker is not null) rbxFpsUnlocker.Kill(); } } @@ -292,7 +292,7 @@ namespace Bloxstrap { if (!Dialog.CancelEnabled) { - Program.Exit(ERROR_INSTALL_USEREXIT); + App.Terminate(ERROR_INSTALL_USEREXIT); return; } @@ -300,21 +300,21 @@ namespace Bloxstrap try { - if (Program.IsFirstRun) + if (App.IsFirstRun) Directory.Delete(Directories.Base, true); else if (Directory.Exists(VersionFolder)) Directory.Delete(VersionFolder, true); } catch (Exception) { } - Program.Exit(ERROR_INSTALL_USEREXIT); + App.Terminate(ERROR_INSTALL_USEREXIT); } #endregion -#region App Install + #region App Install public static void Register() { - RegistryKey applicationKey = Registry.CurrentUser.CreateSubKey($@"Software\{Program.ProjectName}"); + RegistryKey applicationKey = Registry.CurrentUser.CreateSubKey($@"Software\{App.ProjectName}"); // new install location selected, delete old one string? oldInstallLocation = (string?)applicationKey.GetValue("OldInstallLocation"); @@ -334,10 +334,10 @@ namespace Bloxstrap applicationKey.Close(); // set uninstall key - RegistryKey uninstallKey = Registry.CurrentUser.CreateSubKey($@"Software\Microsoft\Windows\CurrentVersion\Uninstall\{Program.ProjectName}"); - uninstallKey.SetValue("DisplayIcon", $"{Directories.App},0"); - uninstallKey.SetValue("DisplayName", Program.ProjectName); - uninstallKey.SetValue("DisplayVersion", Program.Version); + RegistryKey uninstallKey = Registry.CurrentUser.CreateSubKey($@"Software\Microsoft\Windows\CurrentVersion\Uninstall\{App.ProjectName}"); + uninstallKey.SetValue("DisplayIcon", $"{Directories.Application},0"); + uninstallKey.SetValue("DisplayName", App.ProjectName); + uninstallKey.SetValue("DisplayVersion", App.Version); if (uninstallKey.GetValue("InstallDate") is null) uninstallKey.SetValue("InstallDate", DateTime.Now.ToString("yyyyMMdd")); @@ -345,11 +345,11 @@ namespace Bloxstrap uninstallKey.SetValue("InstallLocation", Directories.Base); uninstallKey.SetValue("NoRepair", 1); uninstallKey.SetValue("Publisher", "pizzaboxer"); - uninstallKey.SetValue("ModifyPath", $"\"{Directories.App}\" -preferences"); - uninstallKey.SetValue("QuietUninstallString", $"\"{Directories.App}\" -uninstall -quiet"); - uninstallKey.SetValue("UninstallString", $"\"{Directories.App}\" -uninstall"); - uninstallKey.SetValue("URLInfoAbout", $"https://github.com/{Program.ProjectRepository}"); - uninstallKey.SetValue("URLUpdateInfo", $"https://github.com/{Program.ProjectRepository}/releases/latest"); + uninstallKey.SetValue("ModifyPath", $"\"{Directories.Application}\" -preferences"); + uninstallKey.SetValue("QuietUninstallString", $"\"{Directories.Application}\" -uninstall -quiet"); + uninstallKey.SetValue("UninstallString", $"\"{Directories.Application}\" -uninstall"); + uninstallKey.SetValue("URLInfoAbout", $"https://github.com/{App.ProjectRepository}"); + uninstallKey.SetValue("URLUpdateInfo", $"https://github.com/{App.ProjectRepository}/releases/latest"); uninstallKey.Close(); } @@ -359,16 +359,16 @@ namespace Bloxstrap // this doesn't go under register, so we check every launch // just in case the stock bootstrapper changes it back - Protocol.Register("roblox", "Roblox", Directories.App); - Protocol.Register("roblox-player", "Roblox", Directories.App); + Protocol.Register("roblox", "Roblox", Directories.Application); + Protocol.Register("roblox-player", "Roblox", Directories.Application); // in case the user is reinstalling - if (File.Exists(Directories.App) && Program.IsFirstRun) - File.Delete(Directories.App); + if (File.Exists(Directories.Application) && App.IsFirstRun) + File.Delete(Directories.Application); // check to make sure bootstrapper is in the install folder - if (!File.Exists(Directories.App) && Environment.ProcessPath is not null) - File.Copy(Environment.ProcessPath, Directories.App); + if (!File.Exists(Directories.Application) && Environment.ProcessPath is not null) + File.Copy(Environment.ProcessPath, Directories.Application); // this SHOULD go under Register(), // but then people who have Bloxstrap v1.0.0 installed won't have this without a reinstall @@ -377,16 +377,16 @@ namespace Bloxstrap { Directory.CreateDirectory(Directories.StartMenu); - ShellLink.Shortcut.CreateShortcut(Directories.App, "", Directories.App, 0) + ShellLink.Shortcut.CreateShortcut(Directories.Application, "", Directories.Application, 0) .WriteToFile(Path.Combine(Directories.StartMenu, "Play Roblox.lnk")); - ShellLink.Shortcut.CreateShortcut(Directories.App, "-preferences", Directories.App, 0) - .WriteToFile(Path.Combine(Directories.StartMenu, $"Configure {Program.ProjectName}.lnk")); + ShellLink.Shortcut.CreateShortcut(Directories.Application, "-preferences", Directories.Application, 0) + .WriteToFile(Path.Combine(Directories.StartMenu, $"Configure {App.ProjectName}.lnk")); } - if (Program.Settings.CreateDesktopIcon && !File.Exists(Path.Combine(Directories.Desktop, "Play Roblox.lnk"))) + if (App.Settings.CreateDesktopIcon && !File.Exists(Path.Combine(Directories.Desktop, "Play Roblox.lnk"))) { - ShellLink.Shortcut.CreateShortcut(Directories.App, "", Directories.App, 0) + ShellLink.Shortcut.CreateShortcut(Directories.Application, "", Directories.Application, 0) .WriteToFile(Path.Combine(Directories.Desktop, "Play Roblox.lnk")); } } @@ -395,9 +395,9 @@ namespace Bloxstrap { CheckIfRunning(true); - Dialog.Message = $"Uninstalling {Program.ProjectName}..."; + Dialog.Message = $"Uninstalling {App.ProjectName}..."; - Program.SettingsManager.ShouldSave = false; + App.SettingsManager.ShouldSave = false; // check if stock bootstrapper is still installed RegistryKey? bootstrapperKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall\roblox-player"); @@ -419,7 +419,7 @@ namespace Bloxstrap try { // delete application key - Registry.CurrentUser.DeleteSubKey($@"Software\{Program.ProjectName}"); + Registry.CurrentUser.DeleteSubKey($@"Software\{App.ProjectName}"); // delete start menu folder Directory.Delete(Directories.StartMenu, true); @@ -428,7 +428,7 @@ namespace Bloxstrap File.Delete(Path.Combine(Directories.Desktop, "Play Roblox.lnk")); // delete uninstall key - Registry.CurrentUser.DeleteSubKey($@"Software\Microsoft\Windows\CurrentVersion\Uninstall\{Program.ProjectName}"); + Registry.CurrentUser.DeleteSubKey($@"Software\Microsoft\Windows\CurrentVersion\Uninstall\{App.ProjectName}"); // delete installation folder // (should delete everything except bloxstrap itself) @@ -439,13 +439,13 @@ namespace Bloxstrap Debug.WriteLine($"Could not fully uninstall! ({e})"); } - Dialog.ShowSuccess($"{Program.ProjectName} has succesfully uninstalled"); + Dialog.ShowSuccess($"{App.ProjectName} has succesfully uninstalled"); - Program.Exit(); + App.Terminate(); } #endregion -#region Roblox Install + #region Roblox Install private void UpdateProgressbar() { int newProgress = (int)Math.Floor(ProgressIncrement * TotalDownloadedBytes); @@ -462,8 +462,8 @@ namespace Bloxstrap // check if we have at least 300 megabytes of free disk space if (Utilities.GetFreeDiskSpace(Directories.Base) < 1024*1024*300) { - Program.ShowMessageBox($"{Program.ProjectName} requires at least 300 MB of disk space to install Roblox. Please free up some disk space and try again.", MessageBoxIcon.Error); - Program.Exit(ERROR_INSTALL_FAILURE); + App.ShowMessageBox($"{App.ProjectName} requires at least 300 MB of disk space to install Roblox. Please free up some disk space and try again.", MessageBoxImage.Error); + App.Terminate(ERROR_INSTALL_FAILURE); return; } @@ -518,9 +518,9 @@ namespace Bloxstrap File.Delete(filename); } - string oldVersionFolder = Path.Combine(Directories.Versions, Program.Settings.VersionGuid); + string oldVersionFolder = Path.Combine(Directories.Versions, App.Settings.VersionGuid); - if (VersionGuid != Program.Settings.VersionGuid && Directory.Exists(oldVersionFolder)) + if (VersionGuid != App.Settings.VersionGuid && Directory.Exists(oldVersionFolder)) { // and also to delete our old version folder Directory.Delete(oldVersionFolder, true); @@ -529,7 +529,7 @@ namespace Bloxstrap Dialog.CancelEnabled = false; - Program.Settings.VersionGuid = VersionGuid; + App.Settings.VersionGuid = VersionGuid; } private async Task ApplyModifications() @@ -545,10 +545,10 @@ namespace Bloxstrap if (!Directory.Exists(modFolder)) Directory.CreateDirectory(modFolder); - await CheckModPreset(Program.Settings.UseOldDeathSound, @"content\sounds\ouch.ogg", "OldDeath.ogg"); - await CheckModPreset(Program.Settings.UseOldMouseCursor, @"content\textures\Cursors\KeyboardMouse\ArrowCursor.png", "OldCursor.png"); - await CheckModPreset(Program.Settings.UseOldMouseCursor, @"content\textures\Cursors\KeyboardMouse\ArrowFarCursor.png", "OldFarCursor.png"); - await CheckModPreset(Program.Settings.UseDisableAppPatch, @"ExtraContent\places\Mobile.rbxl", ""); + await CheckModPreset(App.Settings.UseOldDeathSound, @"content\sounds\ouch.ogg", "OldDeath.ogg"); + await CheckModPreset(App.Settings.UseOldMouseCursor, @"content\textures\Cursors\KeyboardMouse\ArrowCursor.png", "OldCursor.png"); + await CheckModPreset(App.Settings.UseOldMouseCursor, @"content\textures\Cursors\KeyboardMouse\ArrowFarCursor.png", "OldFarCursor.png"); + await CheckModPreset(App.Settings.UseDisableAppPatch, @"ExtraContent\places\Mobile.rbxl", ""); await ReShade.CheckModifications(); @@ -697,7 +697,7 @@ namespace Bloxstrap if (CancelFired) return; - var response = await Program.HttpClient.GetAsync(packageUrl, HttpCompletionOption.ResponseHeadersRead); + var response = await App.HttpClient.GetAsync(packageUrl, HttpCompletionOption.ResponseHeadersRead); var buffer = new byte[8192]; diff --git a/Bloxstrap/Dialogs/BootstrapperDialogs/BootstrapperDialogForm.cs b/Bloxstrap/Dialogs/BootstrapperDialogs/BootstrapperDialogForm.cs index 963b3b6..fc60e59 100644 --- a/Bloxstrap/Dialogs/BootstrapperDialogs/BootstrapperDialogForm.cs +++ b/Bloxstrap/Dialogs/BootstrapperDialogs/BootstrapperDialogForm.cs @@ -1,4 +1,9 @@ -using Bloxstrap.Enums; +using System; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Forms; + +using Bloxstrap.Enums; using Bloxstrap.Helpers; namespace Bloxstrap.Dialogs.BootstrapperDialogs @@ -74,11 +79,8 @@ namespace Bloxstrap.Dialogs.BootstrapperDialogs public void SetupDialog() { - if (Program.IsQuiet) - this.Hide(); - - this.Text = Program.ProjectName; - this.Icon = Program.Settings.BootstrapperIcon.GetIcon(); + this.Text = App.ProjectName; + this.Icon = App.Settings.BootstrapperIcon.GetIcon(); if (Bootstrapper is null) { @@ -113,19 +115,19 @@ namespace Bloxstrap.Dialogs.BootstrapperDialogs } #endif - Program.Exit(); + App.Terminate(); } public virtual void ShowSuccess(string message) { - Program.ShowMessageBox(message, MessageBoxIcon.Information); - Program.Exit(); + App.ShowMessageBox(message, MessageBoxImage.Information); + App.Terminate(); } public virtual void ShowError(string message) { - Program.ShowMessageBox($"An error occurred while starting Roblox\n\nDetails: {message}", MessageBoxIcon.Error); - Program.Exit(Bootstrapper.ERROR_INSTALL_FAILURE); + App.ShowMessageBox($"An error occurred while starting Roblox\n\nDetails: {message}", MessageBoxImage.Error); + App.Terminate(Bootstrapper.ERROR_INSTALL_FAILURE); } public virtual void CloseDialog() @@ -138,13 +140,13 @@ namespace Bloxstrap.Dialogs.BootstrapperDialogs public void PromptShutdown() { - DialogResult result = Program.ShowMessageBox( + MessageBoxResult result = App.ShowMessageBox( "Roblox is currently running, but needs to close. Would you like close Roblox now?", - MessageBoxIcon.Information, - MessageBoxButtons.OKCancel + MessageBoxImage.Information, + MessageBoxButton.OKCancel ); - if (result != DialogResult.OK) + if (result != MessageBoxResult.OK) Environment.Exit(Bootstrapper.ERROR_INSTALL_USEREXIT); } diff --git a/Bloxstrap/Dialogs/BootstrapperDialogs/IBootstrapperDialog.cs b/Bloxstrap/Dialogs/BootstrapperDialogs/IBootstrapperDialog.cs index 394056d..772ecee 100644 --- a/Bloxstrap/Dialogs/BootstrapperDialogs/IBootstrapperDialog.cs +++ b/Bloxstrap/Dialogs/BootstrapperDialogs/IBootstrapperDialog.cs @@ -1,4 +1,6 @@ -namespace Bloxstrap.Dialogs.BootstrapperDialogs +using System.Windows.Forms; + +namespace Bloxstrap.Dialogs.BootstrapperDialogs { public interface IBootstrapperDialog { diff --git a/Bloxstrap/Dialogs/BootstrapperDialogs/LegacyDialog2009.Designer.cs b/Bloxstrap/Dialogs/BootstrapperDialogs/LegacyDialog2009.Designer.cs index 0f161e2..af757c5 100644 --- a/Bloxstrap/Dialogs/BootstrapperDialogs/LegacyDialog2009.Designer.cs +++ b/Bloxstrap/Dialogs/BootstrapperDialogs/LegacyDialog2009.Designer.cs @@ -1,4 +1,6 @@ -namespace Bloxstrap.Dialogs.BootstrapperDialogs +using System.Windows.Forms; + +namespace Bloxstrap.Dialogs.BootstrapperDialogs { partial class LegacyDialog2009 { diff --git a/Bloxstrap/Dialogs/BootstrapperDialogs/LegacyDialog2009.cs b/Bloxstrap/Dialogs/BootstrapperDialogs/LegacyDialog2009.cs index 24224d8..0592603 100644 --- a/Bloxstrap/Dialogs/BootstrapperDialogs/LegacyDialog2009.cs +++ b/Bloxstrap/Dialogs/BootstrapperDialogs/LegacyDialog2009.cs @@ -1,3 +1,6 @@ +using System; +using System.Windows.Forms; + namespace Bloxstrap.Dialogs.BootstrapperDialogs { // windows: https://youtu.be/VpduiruysuM?t=18 diff --git a/Bloxstrap/Dialogs/BootstrapperDialogs/LegacyDialog2011.Designer.cs b/Bloxstrap/Dialogs/BootstrapperDialogs/LegacyDialog2011.Designer.cs index 10c1a31..2c490ce 100644 --- a/Bloxstrap/Dialogs/BootstrapperDialogs/LegacyDialog2011.Designer.cs +++ b/Bloxstrap/Dialogs/BootstrapperDialogs/LegacyDialog2011.Designer.cs @@ -1,4 +1,6 @@ -namespace Bloxstrap.Dialogs.BootstrapperDialogs +using System.Windows.Forms; + +namespace Bloxstrap.Dialogs.BootstrapperDialogs { partial class LegacyDialog2011 { diff --git a/Bloxstrap/Dialogs/BootstrapperDialogs/LegacyDialog2011.cs b/Bloxstrap/Dialogs/BootstrapperDialogs/LegacyDialog2011.cs index 8b5e8d5..124127d 100644 --- a/Bloxstrap/Dialogs/BootstrapperDialogs/LegacyDialog2011.cs +++ b/Bloxstrap/Dialogs/BootstrapperDialogs/LegacyDialog2011.cs @@ -1,3 +1,6 @@ +using System; +using System.Windows.Forms; + using Bloxstrap.Enums; namespace Bloxstrap.Dialogs.BootstrapperDialogs @@ -37,7 +40,7 @@ namespace Bloxstrap.Dialogs.BootstrapperDialogs Bootstrapper = bootstrapper; // have to convert icon -> bitmap since winforms scaling is poop - this.IconBox.BackgroundImage = Program.Settings.BootstrapperIcon.GetIcon().ToBitmap(); + this.IconBox.BackgroundImage = App.Settings.BootstrapperIcon.GetIcon().ToBitmap(); ScaleWindow(); SetupDialog(); diff --git a/Bloxstrap/Dialogs/BootstrapperDialogs/ProgressDialog.Designer.cs b/Bloxstrap/Dialogs/BootstrapperDialogs/ProgressDialog.Designer.cs index 548d731..3beb221 100644 --- a/Bloxstrap/Dialogs/BootstrapperDialogs/ProgressDialog.Designer.cs +++ b/Bloxstrap/Dialogs/BootstrapperDialogs/ProgressDialog.Designer.cs @@ -1,4 +1,6 @@ -namespace Bloxstrap.Dialogs.BootstrapperDialogs +using System.Windows.Forms; + +namespace Bloxstrap.Dialogs.BootstrapperDialogs { partial class ProgressDialog { diff --git a/Bloxstrap/Dialogs/BootstrapperDialogs/ProgressDialog.cs b/Bloxstrap/Dialogs/BootstrapperDialogs/ProgressDialog.cs index fae383c..487ed49 100644 --- a/Bloxstrap/Dialogs/BootstrapperDialogs/ProgressDialog.cs +++ b/Bloxstrap/Dialogs/BootstrapperDialogs/ProgressDialog.cs @@ -1,4 +1,8 @@ -using Bloxstrap.Enums; +using System; +using System.Drawing; +using System.Windows.Forms; + +using Bloxstrap.Enums; namespace Bloxstrap.Dialogs.BootstrapperDialogs { @@ -34,7 +38,7 @@ namespace Bloxstrap.Dialogs.BootstrapperDialogs { InitializeComponent(); - if (Program.Settings.Theme.GetFinal() == Theme.Dark) + if (App.Settings.Theme.GetFinal() == Theme.Dark) { this.labelMessage.ForeColor = SystemColors.Window; this.buttonCancel.Image = Properties.Resources.DarkCancelButton; @@ -44,14 +48,14 @@ namespace Bloxstrap.Dialogs.BootstrapperDialogs Bootstrapper = bootstrapper; - this.IconBox.BackgroundImage = Program.Settings.BootstrapperIcon.GetBitmap(); + this.IconBox.BackgroundImage = App.Settings.BootstrapperIcon.GetBitmap(); SetupDialog(); } private void ButtonCancel_MouseEnter(object sender, EventArgs e) { - if (Program.Settings.Theme.GetFinal() == Theme.Dark) + if (App.Settings.Theme.GetFinal() == Theme.Dark) { this.buttonCancel.Image = Properties.Resources.DarkCancelButtonHover; } @@ -63,7 +67,7 @@ namespace Bloxstrap.Dialogs.BootstrapperDialogs private void ButtonCancel_MouseLeave(object sender, EventArgs e) { - if (Program.Settings.Theme.GetFinal() == Theme.Dark) + if (App.Settings.Theme.GetFinal() == Theme.Dark) { this.buttonCancel.Image = Properties.Resources.DarkCancelButton; } diff --git a/Bloxstrap/Dialogs/BootstrapperDialogs/VistaDialog.cs b/Bloxstrap/Dialogs/BootstrapperDialogs/VistaDialog.cs index e1e8e0a..25e1186 100644 --- a/Bloxstrap/Dialogs/BootstrapperDialogs/VistaDialog.cs +++ b/Bloxstrap/Dialogs/BootstrapperDialogs/VistaDialog.cs @@ -1,4 +1,7 @@ -using Bloxstrap.Enums; +using System; +using System.Windows.Forms; + +using Bloxstrap.Enums; namespace Bloxstrap.Dialogs.BootstrapperDialogs { @@ -65,8 +68,8 @@ namespace Bloxstrap.Dialogs.BootstrapperDialogs Dialog = new TaskDialogPage() { - Icon = new TaskDialogIcon(Program.Settings.BootstrapperIcon.GetIcon()), - Caption = Program.ProjectName, + Icon = new TaskDialogIcon(App.Settings.BootstrapperIcon.GetIcon()), + Caption = App.ProjectName, Buttons = { TaskDialogButton.Cancel }, ProgressBar = new TaskDialogProgressBar() @@ -94,14 +97,14 @@ namespace Bloxstrap.Dialogs.BootstrapperDialogs TaskDialogPage successDialog = new() { Icon = TaskDialogIcon.ShieldSuccessGreenBar, - Caption = Program.ProjectName, + Caption = App.ProjectName, Heading = message, Buttons = { TaskDialogButton.OK } }; - successDialog.Buttons[0].Click += (sender, e) => Program.Exit(); + successDialog.Buttons[0].Click += (sender, e) => App.Terminate(); - if (!Program.IsQuiet) + if (!App.IsQuiet) Dialog.Navigate(successDialog); Dialog = successDialog; @@ -119,7 +122,7 @@ namespace Bloxstrap.Dialogs.BootstrapperDialogs TaskDialogPage errorDialog = new() { Icon = TaskDialogIcon.Error, - Caption = Program.ProjectName, + Caption = App.ProjectName, Heading = "An error occurred while starting Roblox", Buttons = { TaskDialogButton.Close }, Expander = new TaskDialogExpander() @@ -131,9 +134,9 @@ namespace Bloxstrap.Dialogs.BootstrapperDialogs } }; - errorDialog.Buttons[0].Click += (sender, e) => Program.Exit(Bootstrapper.ERROR_INSTALL_FAILURE); + errorDialog.Buttons[0].Click += (sender, e) => App.Terminate(Bootstrapper.ERROR_INSTALL_FAILURE); - if (!Program.IsQuiet) + if (!App.IsQuiet) Dialog.Navigate(errorDialog); Dialog = errorDialog; @@ -158,7 +161,7 @@ namespace Bloxstrap.Dialogs.BootstrapperDialogs private void VistaDialog_Load(object sender, EventArgs e) { - if (!Program.IsQuiet) + if (!App.IsQuiet) TaskDialog.ShowDialog(Dialog); } } diff --git a/Bloxstrap/Dialogs/Menu/ModHelp.xaml b/Bloxstrap/Dialogs/Menu/ModHelp.xaml index 4775db9..e346bf4 100644 --- a/Bloxstrap/Dialogs/Menu/ModHelp.xaml +++ b/Bloxstrap/Dialogs/Menu/ModHelp.xaml @@ -10,14 +10,6 @@ SizeToContent="WidthAndHeight" ResizeMode="NoResize" WindowStartupLocation="CenterScreen"> - - - - - - - - diff --git a/Bloxstrap/Dialogs/Menu/ModHelp.xaml.cs b/Bloxstrap/Dialogs/Menu/ModHelp.xaml.cs index 00b042c..433d001 100644 --- a/Bloxstrap/Dialogs/Menu/ModHelp.xaml.cs +++ b/Bloxstrap/Dialogs/Menu/ModHelp.xaml.cs @@ -1,6 +1,5 @@ -using System.Windows; - -using Bloxstrap.Enums; +using System; +using System.Windows; namespace Bloxstrap.Dialogs.Menu { @@ -12,17 +11,6 @@ namespace Bloxstrap.Dialogs.Menu public ModHelp() { InitializeComponent(); - SetTheme(); - } - - public void SetTheme() - { - string theme = "Light"; - - if (Program.Settings.Theme.GetFinal() == Theme.Dark) - theme = "ColourfulDark"; - - this.Resources.MergedDictionaries[0] = new ResourceDictionary() { Source = new Uri($"Dialogs/Menu/Themes/{theme}Theme.xaml", UriKind.Relative) }; } private void ButtonClose_Click(object sender, EventArgs e) diff --git a/Bloxstrap/Dialogs/Menu/Preferences.xaml b/Bloxstrap/Dialogs/Menu/Preferences.xaml index a815976..734ce82 100644 --- a/Bloxstrap/Dialogs/Menu/Preferences.xaml +++ b/Bloxstrap/Dialogs/Menu/Preferences.xaml @@ -10,14 +10,6 @@ SizeToContent="WidthAndHeight" ResizeMode="NoResize" WindowStartupLocation="CenterScreen"> - - - - - - - - diff --git a/Bloxstrap/Dialogs/Menu/Preferences.xaml.cs b/Bloxstrap/Dialogs/Menu/Preferences.xaml.cs index 6b0bcba..6c64246 100644 --- a/Bloxstrap/Dialogs/Menu/Preferences.xaml.cs +++ b/Bloxstrap/Dialogs/Menu/Preferences.xaml.cs @@ -1,7 +1,11 @@ -using System.ComponentModel; +using System; +using System.Collections.Generic; +using System.ComponentModel; using System.Diagnostics; using System.IO; +using System.Linq; using System.Runtime.CompilerServices; +using System.Threading.Tasks; using System.Windows; using System.Windows.Interop; using System.Windows.Media.Imaging; @@ -29,7 +33,7 @@ namespace Bloxstrap.Dialogs.Menu ViewModel = new(this); this.DataContext = ViewModel; - Program.SettingsManager.ShouldSave = false; + App.SettingsManager.ShouldSave = false; this.Icon = Imaging.CreateBitmapSourceFromHIcon( Properties.Resources.IconBloxstrap_ico.Handle, @@ -37,7 +41,7 @@ namespace Bloxstrap.Dialogs.Menu BitmapSizeOptions.FromEmptyOptions() ); - this.Title = Program.ProjectName; + this.Title = App.ProjectName; // just in case i guess? if (!Environment.Is64BitOperatingSystem) @@ -48,10 +52,10 @@ namespace Bloxstrap.Dialogs.Menu { string theme = "Light"; - if (Program.Settings.Theme.GetFinal() == Theme.Dark) + if (App.Settings.Theme.GetFinal() == Theme.Dark) theme = "ColourfulDark"; - this.Resources.MergedDictionaries[0] = new ResourceDictionary() { Source = new Uri($"Dialogs/Menu/Themes/{theme}Theme.xaml", UriKind.Relative) }; + Application.Current.Resources.MergedDictionaries[0] = new ResourceDictionary() { Source = new Uri($"Dialogs/Menu/Themes/{theme}Theme.xaml", UriKind.Relative) }; } private void ButtonOpenReShadeFolder_Click(object sender, EventArgs e) @@ -76,11 +80,9 @@ namespace Bloxstrap.Dialogs.Menu private void ButtonLocationBrowse_Click(object sender, EventArgs e) { - using (var dialog = new FolderBrowserDialog()) + using (var dialog = new System.Windows.Forms.FolderBrowserDialog()) { - DialogResult result = dialog.ShowDialog(); - - if (result == System.Windows.Forms.DialogResult.OK) + if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) ViewModel.InstallLocation = dialog.SelectedPath; } } @@ -88,7 +90,7 @@ namespace Bloxstrap.Dialogs.Menu private void ButtonPreview_Click(object sender, EventArgs e) { //this.Visible = false; - Program.Settings.BootstrapperStyle.Show(); + App.Settings.BootstrapperStyle.Show(); //this.Visible = true; } @@ -103,7 +105,7 @@ namespace Bloxstrap.Dialogs.Menu if (String.IsNullOrEmpty(installLocation)) { - Program.ShowMessageBox("You must set an install location", MessageBoxIcon.Error); + App.ShowMessageBox("You must set an install location", MessageBoxImage.Error); return; } @@ -126,42 +128,42 @@ namespace Bloxstrap.Dialogs.Menu } catch (UnauthorizedAccessException) { - Program.ShowMessageBox($"{Program.ProjectName} does not have write access to the install location you selected. Please choose another install location.", MessageBoxIcon.Error); + App.ShowMessageBox($"{App.ProjectName} does not have write access to the install location you selected. Please choose another install location.", MessageBoxImage.Error); return; } catch (Exception ex) { - Program.ShowMessageBox(ex.Message, MessageBoxIcon.Error); + App.ShowMessageBox(ex.Message, MessageBoxImage.Error); return; } - if (Program.IsFirstRun) + if (App.IsFirstRun) { // this will be set in the registry after first install - Program.BaseDirectory = installLocation; + App.BaseDirectory = installLocation; } else { - Program.SettingsManager.ShouldSave = true; + App.SettingsManager.ShouldSave = true; - if (Program.BaseDirectory is not null && Program.BaseDirectory != installLocation) + if (App.BaseDirectory is not null && App.BaseDirectory != installLocation) { - Program.ShowMessageBox($"{Program.ProjectName} will install to the new location you've set the next time it runs.", MessageBoxIcon.Information); + App.ShowMessageBox($"{App.ProjectName} will install to the new location you've set the next time it runs.", MessageBoxImage.Information); - Program.Settings.VersionGuid = ""; + App.Settings.VersionGuid = ""; - using (RegistryKey registryKey = Registry.CurrentUser.CreateSubKey($@"Software\{Program.ProjectName}")) + using (RegistryKey registryKey = Registry.CurrentUser.CreateSubKey($@"Software\{App.ProjectName}")) { registryKey.SetValue("InstallLocation", installLocation); - registryKey.SetValue("OldInstallLocation", Program.BaseDirectory); + registryKey.SetValue("OldInstallLocation", App.BaseDirectory); } // preserve settings // we don't need to copy the bootstrapper over since the install process will do that automatically - Program.SettingsManager.Save(); + App.SettingsManager.Save(); - File.Copy(Path.Combine(Program.BaseDirectory, "Settings.json"), Path.Combine(installLocation, "Settings.json")); + File.Copy(Path.Combine(App.BaseDirectory, "Settings.json"), Path.Combine(installLocation, "Settings.json")); } } @@ -180,89 +182,89 @@ namespace Bloxstrap.Dialogs.Menu private readonly Preferences _window; public event PropertyChangedEventHandler? PropertyChanged; - public string BloxstrapVersion { get; } = $"Version {Program.Version}"; + public string BloxstrapVersion { get; } = $"Version {App.Version}"; #region Integrations public bool DRPEnabled { - get => Program.Settings.UseDiscordRichPresence; + get => App.Settings.UseDiscordRichPresence; set { // if user wants discord rpc, auto-enable buttons by default _window.CheckBoxDRPButtons.IsChecked = value; - Program.Settings.UseDiscordRichPresence = value; + App.Settings.UseDiscordRichPresence = value; } } public bool DRPButtons { - get => !Program.Settings.HideRPCButtons; - set => Program.Settings.HideRPCButtons = !value; + get => !App.Settings.HideRPCButtons; + set => App.Settings.HideRPCButtons = !value; } public bool RFUEnabled { - get => Program.Settings.RFUEnabled; + get => App.Settings.RFUEnabled; set { // if user wants to use rbxfpsunlocker, auto-enable autoclosing by default _window.CheckBoxRFUAutoclose.IsChecked = value; - Program.Settings.RFUEnabled = value; + App.Settings.RFUEnabled = value; } } public bool RFUAutoclose { - get => Program.Settings.RFUAutoclose; - set => Program.Settings.RFUAutoclose = value; + get => App.Settings.RFUAutoclose; + set => App.Settings.RFUAutoclose = value; } public bool UseReShade { - get => Program.Settings.UseReShade; + get => App.Settings.UseReShade; set { // if user wants to use reshade, auto-enable use of extravi's presets by default _window.CheckBoxUseReShadeExtraviPresets.IsChecked = value; - Program.Settings.UseReShade = value; + App.Settings.UseReShade = value; } } public bool UseReShadeExtraviPresets { - get => Program.Settings.UseReShadeExtraviPresets; - set => Program.Settings.UseReShadeExtraviPresets = value; + get => App.Settings.UseReShadeExtraviPresets; + set => App.Settings.UseReShadeExtraviPresets = value; } - public bool ReShadeFolderButtonEnabled { get; } = !Program.IsFirstRun; - public string ReShadeFolderButtonTooltip { get; } = Program.IsFirstRun ? "Bloxstrap must first be installed before managing ReShade" : "This is the folder that contains all your ReShade resources for presets, shaders and textures."; + public bool ReShadeFolderButtonEnabled { get; } = !App.IsFirstRun; + public string ReShadeFolderButtonTooltip { get; } = App.IsFirstRun ? "Bloxstrap must first be installed before managing ReShade" : "This is the folder that contains all your ReShade resources for presets, shaders and textures."; #endregion #region Modifications public bool ModOldDeathSound { - get => Program.Settings.UseOldDeathSound; - set => Program.Settings.UseOldDeathSound = value; + get => App.Settings.UseOldDeathSound; + set => App.Settings.UseOldDeathSound = value; } public bool ModOldMouseCursor { - get => Program.Settings.UseOldMouseCursor; - set => Program.Settings.UseOldMouseCursor = value; + get => App.Settings.UseOldMouseCursor; + set => App.Settings.UseOldMouseCursor = value; } public bool ModDisableAppPatch { - get => Program.Settings.UseDisableAppPatch; - set => Program.Settings.UseDisableAppPatch = value; + get => App.Settings.UseDisableAppPatch; + set => App.Settings.UseDisableAppPatch = value; } - public bool ModFolderButtonEnabled { get; } = !Program.IsFirstRun; - public string ModFolderButtonTooltip { get; } = Program.IsFirstRun ? "Bloxstrap must first be installed before managing mods" : "This is the folder that contains all your file modifications, including presets and any ReShade files needed."; + public bool ModFolderButtonEnabled { get; } = !App.IsFirstRun; + public string ModFolderButtonTooltip { get; } = App.IsFirstRun ? "Bloxstrap must first be installed before managing mods" : "This is the folder that contains all your file modifications, including presets and any ReShade files needed."; #endregion #region Installation - private string installLocation = Program.IsFirstRun ? Path.Combine(Directories.LocalAppData, Program.ProjectName) : Program.BaseDirectory; + private string installLocation = App.IsFirstRun ? Path.Combine(Directories.LocalAppData, App.ProjectName) : App.BaseDirectory; public string InstallLocation { get => installLocation; @@ -273,7 +275,7 @@ namespace Bloxstrap.Dialogs.Menu } } - private bool showAllChannels = !DeployManager.ChannelsAbstracted.Contains(Program.Settings.Channel); + private bool showAllChannels = !DeployManager.ChannelsAbstracted.Contains(App.Settings.Channel); public bool ShowAllChannels { get => showAllChannels; @@ -294,7 +296,7 @@ namespace Bloxstrap.Dialogs.Menu } } - private IEnumerable channels = DeployManager.ChannelsAbstracted.Contains(Program.Settings.Channel) ? DeployManager.ChannelsAbstracted : DeployManager.ChannelsAll; + private IEnumerable channels = DeployManager.ChannelsAbstracted.Contains(App.Settings.Channel) ? DeployManager.ChannelsAbstracted : DeployManager.ChannelsAll; public IEnumerable Channels { get => channels; @@ -307,11 +309,11 @@ namespace Bloxstrap.Dialogs.Menu public string Channel { - get => Program.Settings.Channel; + get => App.Settings.Channel; set { Task.Run(() => GetChannelInfo(value)); - Program.Settings.Channel = value; + App.Settings.Channel = value; } } @@ -328,8 +330,8 @@ namespace Bloxstrap.Dialogs.Menu public bool PromptChannelChange { - get => Program.Settings.PromptChannelChange; - set => Program.Settings.PromptChannelChange = value; + get => App.Settings.PromptChannelChange; + set => App.Settings.PromptChannelChange = value; } #endregion @@ -343,10 +345,10 @@ namespace Bloxstrap.Dialogs.Menu public string Theme { - get => Themes.FirstOrDefault(x => x.Value == Program.Settings.Theme).Key; + get => Themes.FirstOrDefault(x => x.Value == App.Settings.Theme).Key; set { - Program.Settings.Theme = Themes[value]; + App.Settings.Theme = Themes[value]; _window.SetTheme(); } } @@ -361,8 +363,8 @@ namespace Bloxstrap.Dialogs.Menu public string Dialog { - get => Dialogs.FirstOrDefault(x => x.Value == Program.Settings.BootstrapperStyle).Key; - set => Program.Settings.BootstrapperStyle = Dialogs[value]; + get => Dialogs.FirstOrDefault(x => x.Value == App.Settings.BootstrapperStyle).Key; + set => App.Settings.BootstrapperStyle = Dialogs[value]; } public IReadOnlyDictionary Icons { get; set; } = new Dictionary() @@ -379,29 +381,29 @@ namespace Bloxstrap.Dialogs.Menu public string Icon { - get => Icons.FirstOrDefault(x => x.Value == Program.Settings.BootstrapperIcon).Key; - set => Program.Settings.BootstrapperIcon = Icons[value]; + get => Icons.FirstOrDefault(x => x.Value == App.Settings.BootstrapperIcon).Key; + set => App.Settings.BootstrapperIcon = Icons[value]; } public bool CreateDesktopIcon { - get => Program.Settings.CreateDesktopIcon; - set => Program.Settings.CreateDesktopIcon = value; + get => App.Settings.CreateDesktopIcon; + set => App.Settings.CreateDesktopIcon = value; } public bool CheckForUpdates { - get => Program.Settings.CheckForUpdates; - set => Program.Settings.CheckForUpdates = value; + get => App.Settings.CheckForUpdates; + set => App.Settings.CheckForUpdates = value; } #endregion - public string ConfirmButtonText { get; } = Program.IsFirstRun ? "Install" : "Save"; + public string ConfirmButtonText { get; } = App.IsFirstRun ? "Install" : "Save"; public PreferencesViewModel(Preferences window) { _window = window; - Task.Run(() => GetChannelInfo(Program.Settings.Channel)); + Task.Run(() => GetChannelInfo(App.Settings.Channel)); } protected void OnPropertyChanged([CallerMemberName] string? name = null) @@ -414,7 +416,7 @@ namespace Bloxstrap.Dialogs.Menu ChannelInfo = "Getting latest version info, please wait...\n"; ClientVersion info = await DeployManager.GetLastDeploy(channel, true); - string? strTimestamp = info.Timestamp?.ToString("MM/dd/yyyy h:mm:ss tt", Program.CultureFormat); + string? strTimestamp = info.Timestamp?.ToString("MM/dd/yyyy h:mm:ss tt", App.CultureFormat); ChannelInfo = $"Version: v{info.Version} ({info.VersionGuid})\nDeployed: {strTimestamp}"; } diff --git a/Bloxstrap/Dialogs/Menu/ReShadeHelp.xaml b/Bloxstrap/Dialogs/Menu/ReShadeHelp.xaml index b44ccfe..69de0f4 100644 --- a/Bloxstrap/Dialogs/Menu/ReShadeHelp.xaml +++ b/Bloxstrap/Dialogs/Menu/ReShadeHelp.xaml @@ -10,14 +10,6 @@ SizeToContent="WidthAndHeight" ResizeMode="NoResize" WindowStartupLocation="CenterScreen"> - - - - - - - - diff --git a/Bloxstrap/Dialogs/Menu/ReShadeHelp.xaml.cs b/Bloxstrap/Dialogs/Menu/ReShadeHelp.xaml.cs index d0e8e32..60bd9f2 100644 --- a/Bloxstrap/Dialogs/Menu/ReShadeHelp.xaml.cs +++ b/Bloxstrap/Dialogs/Menu/ReShadeHelp.xaml.cs @@ -1,6 +1,5 @@ -using System.Windows; - -using Bloxstrap.Enums; +using System; +using System.Windows; namespace Bloxstrap.Dialogs.Menu { @@ -12,17 +11,6 @@ namespace Bloxstrap.Dialogs.Menu public ReShadeHelp() { InitializeComponent(); - SetTheme(); - } - - public void SetTheme() - { - string theme = "Light"; - - if (Program.Settings.Theme.GetFinal() == Theme.Dark) - theme = "ColourfulDark"; - - this.Resources.MergedDictionaries[0] = new ResourceDictionary() { Source = new Uri($"Dialogs/Menu/Themes/{theme}Theme.xaml", UriKind.Relative) }; } private void ButtonClose_Click(object sender, EventArgs e) diff --git a/Bloxstrap/Enums/BootstrapperIcon.cs b/Bloxstrap/Enums/BootstrapperIcon.cs index 3df6ee2..dc3897f 100644 --- a/Bloxstrap/Enums/BootstrapperIcon.cs +++ b/Bloxstrap/Enums/BootstrapperIcon.cs @@ -1,4 +1,6 @@ -namespace Bloxstrap.Enums +using System.Drawing; + +namespace Bloxstrap.Enums { public enum BootstrapperIcon { diff --git a/Bloxstrap/Enums/BootstrapperStyle.cs b/Bloxstrap/Enums/BootstrapperStyle.cs index 0402aa7..3816bbd 100644 --- a/Bloxstrap/Enums/BootstrapperStyle.cs +++ b/Bloxstrap/Enums/BootstrapperStyle.cs @@ -1,4 +1,6 @@ -using Bloxstrap.Dialogs.BootstrapperDialogs; +using System.Windows.Forms; + +using Bloxstrap.Dialogs.BootstrapperDialogs; namespace Bloxstrap.Enums { @@ -35,15 +37,9 @@ namespace Bloxstrap.Enums dialog = new ProgressDialog(bootstrapper); break; } - - if (bootstrapper is null) - { + + if (!App.IsQuiet) dialog.ShowDialog(); - } - else - { - Application.Run(dialog); - } } } } diff --git a/Bloxstrap/Helpers/DeployManager.cs b/Bloxstrap/Helpers/DeployManager.cs index ec61651..3a8032d 100644 --- a/Bloxstrap/Helpers/DeployManager.cs +++ b/Bloxstrap/Helpers/DeployManager.cs @@ -1,5 +1,10 @@ -using System.Net.Http; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Http; using System.Text.Json; +using System.Threading.Tasks; + using Bloxstrap.Models; namespace Bloxstrap.Helpers @@ -55,7 +60,7 @@ namespace Bloxstrap.Helpers public static async Task GetLastDeploy(string channel, bool timestamp = false) { - HttpResponseMessage deployInfoResponse = await Program.HttpClient.GetAsync($"https://clientsettings.roblox.com/v2/client-version/WindowsPlayer/channel/{channel}"); + HttpResponseMessage deployInfoResponse = await App.HttpClient.GetAsync($"https://clientsettings.roblox.com/v2/client-version/WindowsPlayer/channel/{channel}"); if (!deployInfoResponse.IsSuccessStatusCode) { @@ -75,7 +80,7 @@ namespace Bloxstrap.Helpers string channelUrl = BuildBaseUrl(channel); // get an approximate deploy time from rbxpkgmanifest's last modified date - HttpResponseMessage pkgResponse = await Program.HttpClient.GetAsync($"{channelUrl}/{clientVersion.VersionGuid}-rbxPkgManifest.txt"); + HttpResponseMessage pkgResponse = await App.HttpClient.GetAsync($"{channelUrl}/{clientVersion.VersionGuid}-rbxPkgManifest.txt"); if (pkgResponse.Content.Headers.TryGetValues("last-modified", out var values)) { string lastModified = values.First(); diff --git a/Bloxstrap/Helpers/Directories.cs b/Bloxstrap/Helpers/Directories.cs index 25bab70..73dd709 100644 --- a/Bloxstrap/Helpers/Directories.cs +++ b/Bloxstrap/Helpers/Directories.cs @@ -1,4 +1,5 @@ -using System.IO; +using System; +using System.IO; namespace Bloxstrap.Helpers { @@ -8,7 +9,7 @@ namespace Bloxstrap.Helpers // so these can safely be called before initialization public static string LocalAppData { get => Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); } public static string Desktop { get => Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); } - public static string StartMenu { get => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "Programs", Program.ProjectName); } + public static string StartMenu { get => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "Programs", App.ProjectName); } public static string Base { get; private set; } = ""; public static string Downloads { get; private set; } = ""; @@ -18,7 +19,7 @@ namespace Bloxstrap.Helpers public static string Updates { get; private set; } = ""; public static string ReShade { get; private set; } = ""; - public static string App { get; private set; } = ""; + public static string Application { get; private set; } = ""; public static bool Initialized { get => String.IsNullOrEmpty(Base); } @@ -32,7 +33,7 @@ namespace Bloxstrap.Helpers Updates = Path.Combine(Base, "Updates"); ReShade = Path.Combine(Base, "ReShade"); - App = Path.Combine(Base, $"{Program.ProjectName}.exe"); + Application = Path.Combine(Base, $"{App.ProjectName}.exe"); } } } diff --git a/Bloxstrap/Helpers/Integrations/DiscordRichPresence.cs b/Bloxstrap/Helpers/Integrations/DiscordRichPresence.cs index 32b716e..fbd3a42 100644 --- a/Bloxstrap/Helpers/Integrations/DiscordRichPresence.cs +++ b/Bloxstrap/Helpers/Integrations/DiscordRichPresence.cs @@ -1,6 +1,11 @@ -using System.Diagnostics; +using System; +using System.Collections.Generic; +using System.Diagnostics; using System.IO; +using System.Linq; using System.Text.RegularExpressions; +using System.Threading; +using System.Threading.Tasks; using Bloxstrap.Models; @@ -169,7 +174,7 @@ namespace Bloxstrap.Helpers.Integrations } }; - if (!Program.Settings.HideRPCButtons) + if (!App.Settings.HideRPCButtons) { buttons.Insert(0, new DiscordRPC.Button() { diff --git a/Bloxstrap/Helpers/Integrations/RbxFpsUnlocker.cs b/Bloxstrap/Helpers/Integrations/RbxFpsUnlocker.cs index dfeeb9c..f162a3e 100644 --- a/Bloxstrap/Helpers/Integrations/RbxFpsUnlocker.cs +++ b/Bloxstrap/Helpers/Integrations/RbxFpsUnlocker.cs @@ -1,7 +1,8 @@ -using System.Diagnostics; +using System; +using System.Diagnostics; using System.IO; using System.IO.Compression; -using System.Net.Http; +using System.Threading.Tasks; using Bloxstrap.Models; @@ -40,7 +41,7 @@ namespace Bloxstrap.Helpers.Integrations if (process.MainModule is null || process.MainModule.FileName is null) continue; - if (!process.MainModule.FileName.Contains(Program.BaseDirectory)) + if (!process.MainModule.FileName.Contains(App.BaseDirectory)) continue; process.Kill(); @@ -52,14 +53,14 @@ namespace Bloxstrap.Helpers.Integrations public static async Task CheckInstall() { - if (Program.BaseDirectory is null) + if (App.BaseDirectory is null) return; - string folderLocation = Path.Combine(Program.BaseDirectory, "Integrations\\rbxfpsunlocker"); + string folderLocation = Path.Combine(App.BaseDirectory, "Integrations\\rbxfpsunlocker"); string fileLocation = Path.Combine(folderLocation, "rbxfpsunlocker.exe"); string settingsLocation = Path.Combine(folderLocation, "settings"); - if (!Program.Settings.RFUEnabled) + if (!App.Settings.RFUEnabled) { if (Directory.Exists(folderLocation)) { @@ -82,7 +83,7 @@ namespace Bloxstrap.Helpers.Integrations if (File.Exists(fileLocation)) { // no new release published, return - if (Program.Settings.RFUVersion == releaseInfo.TagName) + if (App.Settings.RFUVersion == releaseInfo.TagName) return; CheckIfRunning(); @@ -92,7 +93,7 @@ namespace Bloxstrap.Helpers.Integrations Debug.WriteLine("Installing/Updating rbxfpsunlocker..."); { - byte[] bytes = await Program.HttpClient.GetByteArrayAsync(downloadUrl); + byte[] bytes = await App.HttpClient.GetByteArrayAsync(downloadUrl); using MemoryStream zipStream = new(bytes); using ZipArchive archive = new(zipStream); @@ -103,7 +104,7 @@ namespace Bloxstrap.Helpers.Integrations if (!File.Exists(settingsLocation)) await File.WriteAllTextAsync(settingsLocation, Settings); - Program.Settings.RFUVersion = releaseInfo.TagName; + App.Settings.RFUVersion = releaseInfo.TagName; } } } diff --git a/Bloxstrap/Helpers/Integrations/ReShade.cs b/Bloxstrap/Helpers/Integrations/ReShade.cs index 11538e6..77e6057 100644 --- a/Bloxstrap/Helpers/Integrations/ReShade.cs +++ b/Bloxstrap/Helpers/Integrations/ReShade.cs @@ -1,6 +1,10 @@ -using System.Diagnostics; +using System; +using System.Collections.Generic; +using System.Diagnostics; using System.IO; using System.IO.Compression; +using System.Linq; +using System.Threading.Tasks; using Bloxstrap.Models; @@ -65,7 +69,7 @@ namespace Bloxstrap.Helpers.Integrations Debug.WriteLine("[ReShade] Downloading/Upgrading config file..."); { - byte[] bytes = await Program.HttpClient.GetByteArrayAsync($"{BaseUrl}/config.zip"); + byte[] bytes = await App.HttpClient.GetByteArrayAsync($"{BaseUrl}/config.zip"); using MemoryStream zipStream = new(bytes); using ZipArchive archive = new(zipStream); @@ -121,7 +125,7 @@ namespace Bloxstrap.Helpers.Integrations // config synchronization will be done whenever roblox updates or whenever we launch roblox string modFolderConfigPath = ConfigLocation; - string versionFolderConfigPath = Path.Combine(Directories.Versions, Program.Settings.VersionGuid, "ReShade.ini"); + string versionFolderConfigPath = Path.Combine(Directories.Versions, App.Settings.VersionGuid, "ReShade.ini"); // we shouldn't be here if the mod config doesn't already exist if (!File.Exists(modFolderConfigPath)) @@ -172,7 +176,7 @@ namespace Bloxstrap.Helpers.Integrations Debug.WriteLine($"[ReShade] Downloading shaders for {name}"); { - byte[] bytes = await Program.HttpClient.GetByteArrayAsync(downloadUrl); + byte[] bytes = await App.HttpClient.GetByteArrayAsync(downloadUrl); using MemoryStream zipStream = new(bytes); using ZipArchive archive = new(zipStream); @@ -273,7 +277,7 @@ namespace Bloxstrap.Helpers.Integrations foreach (string name in ExtraviPresetsShaders) await DownloadShaders(name); - byte[] bytes = await Program.HttpClient.GetByteArrayAsync($"{BaseUrl}/reshade-presets.zip"); + byte[] bytes = await App.HttpClient.GetByteArrayAsync($"{BaseUrl}/reshade-presets.zip"); using MemoryStream zipStream = new(bytes); using ZipArchive archive = new(zipStream); @@ -320,13 +324,13 @@ namespace Bloxstrap.Helpers.Integrations Directory.CreateDirectory(Path.Combine(Directories.ReShade, "Textures")); Directory.CreateDirectory(Path.Combine(Directories.ReShade, "Presets")); - if (!Program.Settings.UseReShadeExtraviPresets) + if (!App.Settings.UseReShadeExtraviPresets) { UninstallExtraviPresets(); - Program.Settings.ExtraviPresetsVersion = ""; + App.Settings.ExtraviPresetsVersion = ""; } - if (!Program.Settings.UseReShade) + if (!App.Settings.UseReShade) { Debug.WriteLine("[ReShade] Uninstalling ReShade..."); @@ -334,7 +338,7 @@ namespace Bloxstrap.Helpers.Integrations File.Delete(injectorLocation); File.Delete(ConfigLocation); - Program.Settings.ReShadeConfigVersion = ""; + App.Settings.ReShadeConfigVersion = ""; DeleteShaders("Stock"); @@ -361,7 +365,7 @@ namespace Bloxstrap.Helpers.Integrations // check if we should download a fresh copy of the config // extravi may need to update the config ota, in which case we'll redownload it - if (!File.Exists(ConfigLocation) || versionManifest is not null && Program.Settings.ReShadeConfigVersion != versionManifest.ConfigFile) + if (!File.Exists(ConfigLocation) || versionManifest is not null && App.Settings.ReShadeConfigVersion != versionManifest.ConfigFile) shouldFetchConfig = true; if (shouldFetchReShade) @@ -369,7 +373,7 @@ namespace Bloxstrap.Helpers.Integrations Debug.WriteLine("[ReShade] Installing/Upgrading ReShade..."); { - byte[] bytes = await Program.HttpClient.GetByteArrayAsync($"{BaseUrl}/dxgi.zip"); + byte[] bytes = await App.HttpClient.GetByteArrayAsync($"{BaseUrl}/dxgi.zip"); using MemoryStream zipStream = new(bytes); using ZipArchive archive = new(zipStream); archive.ExtractToDirectory(Directories.Modifications, true); @@ -381,15 +385,15 @@ namespace Bloxstrap.Helpers.Integrations await DownloadConfig(); if (versionManifest is not null) - Program.Settings.ReShadeConfigVersion = versionManifest.ConfigFile; + App.Settings.ReShadeConfigVersion = versionManifest.ConfigFile; } await DownloadShaders("Stock"); - if (Program.Settings.UseReShadeExtraviPresets && Program.Settings.ExtraviPresetsVersion != versionManifest!.Presets) + if (App.Settings.UseReShadeExtraviPresets && App.Settings.ExtraviPresetsVersion != versionManifest!.Presets) { await InstallExtraviPresets(); - Program.Settings.ExtraviPresetsVersion = versionManifest.Presets; + App.Settings.ExtraviPresetsVersion = versionManifest.Presets; } SynchronizeConfigFile(); diff --git a/Bloxstrap/Helpers/Protocol.cs b/Bloxstrap/Helpers/Protocol.cs index 370f89a..b50daff 100644 --- a/Bloxstrap/Helpers/Protocol.cs +++ b/Bloxstrap/Helpers/Protocol.cs @@ -1,6 +1,10 @@ -using System.Diagnostics; +using System; +using System.Collections.Generic; +using System.Diagnostics; using System.Text; using System.Web; +using System.Windows; + using Microsoft.Win32; namespace Bloxstrap.Helpers @@ -36,7 +40,7 @@ namespace Bloxstrap.Helpers key = keyvalPair[0]; val = keyvalPair[1]; - if (!UriKeyArgMap.ContainsKey(key) || String.IsNullOrEmpty(val)) + if (!UriKeyArgMap.ContainsKey(key) || string.IsNullOrEmpty(val)) continue; if (key == "launchmode" && val == "play") @@ -47,17 +51,17 @@ namespace Bloxstrap.Helpers if (key == "channel") { - if (val.ToLower() != Program.Settings.Channel.ToLower()) + if (val.ToLower() != App.Settings.Channel.ToLower()) { - DialogResult result = !Program.Settings.PromptChannelChange ? DialogResult.Yes : Program.ShowMessageBox( - $"{Program.ProjectName} was launched with the Roblox build channel set to {val}, however your current preferred channel is {Program.Settings.Channel}.\n\n" + - $"Would you like to switch channels from {Program.Settings.Channel} to {val}?", - MessageBoxIcon.Question, - MessageBoxButtons.YesNo + MessageBoxResult result = !App.Settings.PromptChannelChange ? MessageBoxResult.Yes : App.ShowMessageBox( + $"{App.ProjectName} was launched with the Roblox build channel set to {val}, however your current preferred channel is {App.Settings.Channel}.\n\n" + + $"Would you like to switch channels from {App.Settings.Channel} to {val}?", + MessageBoxImage.Question, + MessageBoxButton.YesNo ); - if (result == DialogResult.Yes) - Program.Settings.Channel = val; + if (result == MessageBoxResult.Yes) + App.Settings.Channel = val; } // we'll set the arg when launching diff --git a/Bloxstrap/Helpers/RSMM/PackageManifest.cs b/Bloxstrap/Helpers/RSMM/PackageManifest.cs index a3dbd59..bdd20d4 100644 --- a/Bloxstrap/Helpers/RSMM/PackageManifest.cs +++ b/Bloxstrap/Helpers/RSMM/PackageManifest.cs @@ -1,7 +1,9 @@ // https://github.com/MaximumADHD/Roblox-Studio-Mod-Manager/blob/main/ProjectSrc/Bootstrapper/PackageManifest.cs +using System; +using System.Collections.Generic; using System.IO; -using System.Net.Http; +using System.Threading.Tasks; namespace Bloxstrap.Helpers.RSMM { @@ -49,7 +51,7 @@ namespace Bloxstrap.Helpers.RSMM public static async Task Get(string versionGuid) { string pkgManifestUrl = $"{DeployManager.BaseUrl}/{versionGuid}-rbxPkgManifest.txt"; - var pkgManifestData = await Program.HttpClient.GetStringAsync(pkgManifestUrl); + var pkgManifestData = await App.HttpClient.GetStringAsync(pkgManifestUrl); return new PackageManifest(pkgManifestData); } diff --git a/Bloxstrap/Helpers/RSMM/SystemEvent.cs b/Bloxstrap/Helpers/RSMM/SystemEvent.cs index ce0a191..752fc28 100644 --- a/Bloxstrap/Helpers/RSMM/SystemEvent.cs +++ b/Bloxstrap/Helpers/RSMM/SystemEvent.cs @@ -1,5 +1,9 @@ // https://github.com/MaximumADHD/Roblox-Studio-Mod-Manager/blob/main/ProjectSrc/Utility/SystemEvent.cs +using System; +using System.Threading; +using System.Threading.Tasks; + namespace Bloxstrap.Helpers.RSMM { public class SystemEvent : EventWaitHandle diff --git a/Bloxstrap/Helpers/ResourceHelper.cs b/Bloxstrap/Helpers/ResourceHelper.cs index f61776a..def71f9 100644 --- a/Bloxstrap/Helpers/ResourceHelper.cs +++ b/Bloxstrap/Helpers/ResourceHelper.cs @@ -1,5 +1,7 @@ using System.IO; +using System.Linq; using System.Reflection; +using System.Threading.Tasks; namespace Bloxstrap.Helpers { diff --git a/Bloxstrap/Helpers/Updater.cs b/Bloxstrap/Helpers/Updater.cs index 853b563..1eee9d9 100644 --- a/Bloxstrap/Helpers/Updater.cs +++ b/Bloxstrap/Helpers/Updater.cs @@ -1,5 +1,7 @@ -using System.Diagnostics; +using System; +using System.Diagnostics; using System.IO; +using System.Windows; using Bloxstrap.Dialogs.Menu; @@ -9,55 +11,55 @@ namespace Bloxstrap.Helpers { public static void CheckInstalledVersion() { - if (Environment.ProcessPath is null || !File.Exists(Directories.App) || Environment.ProcessPath == Directories.App) + if (Environment.ProcessPath is null || !File.Exists(Directories.Application) || Environment.ProcessPath == Directories.Application) return; bool isAutoUpgrade = Environment.ProcessPath.StartsWith(Directories.Updates); // if downloaded version doesn't match, replace installed version with downloaded version FileVersionInfo currentVersionInfo = FileVersionInfo.GetVersionInfo(Environment.ProcessPath); - FileVersionInfo installedVersionInfo = FileVersionInfo.GetVersionInfo(Directories.App); + FileVersionInfo installedVersionInfo = FileVersionInfo.GetVersionInfo(Directories.Application); if (installedVersionInfo.ProductVersion == currentVersionInfo.ProductVersion) return; - DialogResult result; + MessageBoxResult result; // silently upgrade version if the command line flag is set or if we're launching from an auto update - if (Program.IsUpgrade || isAutoUpgrade) + if (App.IsUpgrade || isAutoUpgrade) { - result = DialogResult.Yes; + result = MessageBoxResult.Yes; } else { - result = Program.ShowMessageBox( - $"The version of {Program.ProjectName} you've launched is different to the version you currently have installed.\nWould you like to upgrade your currently installed version?", - MessageBoxIcon.Question, - MessageBoxButtons.YesNo + result = App.ShowMessageBox( + $"The version of {App.ProjectName} you've launched is different to the version you currently have installed.\nWould you like to upgrade your currently installed version?", + MessageBoxImage.Question, + MessageBoxButton.YesNo ); } - if (result != DialogResult.Yes) + if (result != MessageBoxResult.Yes) return; - File.Delete(Directories.App); - File.Copy(Environment.ProcessPath, Directories.App); + File.Delete(Directories.Application); + File.Copy(Environment.ProcessPath, Directories.Application); Bootstrapper.Register(); - if (Program.IsQuiet || isAutoUpgrade) + if (App.IsQuiet || isAutoUpgrade) return; - Program.ShowMessageBox( - $"{Program.ProjectName} has been updated to v{currentVersionInfo.ProductVersion}", - MessageBoxIcon.Information, - MessageBoxButtons.OK + App.ShowMessageBox( + $"{App.ProjectName} has been updated to v{currentVersionInfo.ProductVersion}", + MessageBoxImage.Information, + MessageBoxButton.OK ); new Preferences().ShowDialog(); - Program.Exit(); + App.Terminate(); } } } \ No newline at end of file diff --git a/Bloxstrap/Helpers/Utilities.cs b/Bloxstrap/Helpers/Utilities.cs index 066c081..b6237df 100644 --- a/Bloxstrap/Helpers/Utilities.cs +++ b/Bloxstrap/Helpers/Utilities.cs @@ -1,8 +1,10 @@ -using System.Diagnostics; +using System; +using System.Diagnostics; using System.IO; -using System.IO.Compression; +using System.Linq; using System.Security.Cryptography; using System.Text.Json; +using System.Threading.Tasks; namespace Bloxstrap.Helpers { @@ -33,7 +35,7 @@ namespace Bloxstrap.Helpers { try { - string json = await Program.HttpClient.GetStringAsync(url); + string json = await App.HttpClient.GetStringAsync(url); return JsonSerializer.Deserialize(json); } catch (Exception) diff --git a/Bloxstrap/Helpers/WindowScaling.cs b/Bloxstrap/Helpers/WindowScaling.cs index 9954f34..fe09ee0 100644 --- a/Bloxstrap/Helpers/WindowScaling.cs +++ b/Bloxstrap/Helpers/WindowScaling.cs @@ -1,9 +1,6 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows; +using System.Windows.Forms; namespace Bloxstrap.Helpers { diff --git a/Bloxstrap/Models/ClientVersion.cs b/Bloxstrap/Models/ClientVersion.cs index ee7c422..4f18c47 100644 --- a/Bloxstrap/Models/ClientVersion.cs +++ b/Bloxstrap/Models/ClientVersion.cs @@ -1,4 +1,5 @@ -using System.Text.Json.Serialization; +using System; +using System.Text.Json.Serialization; namespace Bloxstrap.Models { diff --git a/Bloxstrap/Models/GithubRelease.cs b/Bloxstrap/Models/GithubRelease.cs index fccb971..a388586 100644 --- a/Bloxstrap/Models/GithubRelease.cs +++ b/Bloxstrap/Models/GithubRelease.cs @@ -1,4 +1,5 @@ -using System.Text.Json.Serialization; +using System.Collections.Generic; +using System.Text.Json.Serialization; namespace Bloxstrap.Models { diff --git a/Bloxstrap/Models/RobloxThumbnails.cs b/Bloxstrap/Models/RobloxThumbnails.cs index 45e642a..f3b1e58 100644 --- a/Bloxstrap/Models/RobloxThumbnails.cs +++ b/Bloxstrap/Models/RobloxThumbnails.cs @@ -1,4 +1,5 @@ -using System.Text.Json.Serialization; +using System.Collections.Generic; +using System.Text.Json.Serialization; namespace Bloxstrap.Models { diff --git a/Bloxstrap/Properties/launchSettings.json b/Bloxstrap/Properties/launchSettings.json new file mode 100644 index 0000000..4ac77ad --- /dev/null +++ b/Bloxstrap/Properties/launchSettings.json @@ -0,0 +1,7 @@ +{ + "profiles": { + "Bloxstrap": { + "commandName": "Project" + } + } +} \ No newline at end of file diff --git a/Bloxstrap/SettingsManager.cs b/Bloxstrap/SettingsManager.cs index 022a598..f66b227 100644 --- a/Bloxstrap/SettingsManager.cs +++ b/Bloxstrap/SettingsManager.cs @@ -1,6 +1,8 @@ -using System.Diagnostics; +using System; +using System.Diagnostics; using System.IO; using System.Text.Json; +using System.Threading; using Bloxstrap.Models;