From 173494641a124451df30882d91aa5eb4daba8cb7 Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Wed, 2 Aug 2023 10:37:27 +0100 Subject: [PATCH 01/28] Show all inner exceptions for connectivity dialog maybe using a viewmodel isnt a bad idea after all... --- .../Dialogs/ConnectivityDialog.xaml.cs | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Bloxstrap/UI/Elements/Dialogs/ConnectivityDialog.xaml.cs b/Bloxstrap/UI/Elements/Dialogs/ConnectivityDialog.xaml.cs index b34a9051..c16025a7 100644 --- a/Bloxstrap/UI/Elements/Dialogs/ConnectivityDialog.xaml.cs +++ b/Bloxstrap/UI/Elements/Dialogs/ConnectivityDialog.xaml.cs @@ -16,17 +16,12 @@ public partial class ConnectivityDialog { public ConnectivityDialog(string targetName, string description, Exception exception) { - Exception? innerException = exception.InnerException; - InitializeComponent(); TitleTextBlock.Text = $"{App.ProjectName} is unable to connect to {targetName}"; DescriptionTextBlock.Text = description; - ErrorRichTextBox.Selection.Text = $"{exception.GetType()}: {exception.Message}"; - - if (innerException is not null) - ErrorRichTextBox.Selection.Text += $"\n\n===== Inner Exception =====\n{innerException.GetType()}: {innerException.Message}"; + AddException(exception); CloseButton.Click += delegate { @@ -41,5 +36,18 @@ public ConnectivityDialog(string targetName, string description, Exception excep PInvoke.FlashWindow((HWND)hWnd, true); }; } + + private void AddException(Exception exception, bool inner = false) + { + if (!inner) + ErrorRichTextBox.Selection.Text = $"{exception.GetType()}: {exception.Message}"; + + if (exception.InnerException is null) + return; + + ErrorRichTextBox.Selection.Text += $"\n\n[Inner Exception]\n{exception.InnerException.GetType()}: {exception.InnerException.Message}"; + + AddException(exception.InnerException, true); + } } } From ba57d584f0fbfafc8c01bdf63f01663207bd4aa7 Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Wed, 2 Aug 2023 14:59:29 +0100 Subject: [PATCH 02/28] Remove redundant connectivity check keep the single connectivity check for testing if the roblox website can be contacted --- Bloxstrap/App.xaml.cs | 27 ---------------------- Bloxstrap/Bootstrapper.cs | 48 +++++++++++++++++++++++---------------- 2 files changed, 29 insertions(+), 46 deletions(-) diff --git a/Bloxstrap/App.xaml.cs b/Bloxstrap/App.xaml.cs index cfd4ed9b..1651f212 100644 --- a/Bloxstrap/App.xaml.cs +++ b/Bloxstrap/App.xaml.cs @@ -148,33 +148,6 @@ protected override void OnStartup(StartupEventArgs e) IsUpgrade = true; } } - - if (!IsMenuLaunch) - { - Logger.WriteLine(LOG_IDENT, "Performing connectivity check..."); - - try - { - HttpClient.GetAsync("https://detectportal.firefox.com").Wait(); - Logger.WriteLine(LOG_IDENT, "Connectivity check finished"); - } - catch (Exception ex) - { - Logger.WriteLine(LOG_IDENT, "Connectivity check failed!"); - Logger.WriteException(LOG_IDENT, ex); - - if (ex.GetType() == typeof(AggregateException)) - ex = ex.InnerException!; - - Controls.ShowConnectivityDialog( - "the internet", - $"Something may be preventing {ProjectName} from connecting to the internet, or you are currently offline. Please check and try again.", - ex - ); - - Terminate(ErrorCode.ERROR_CANCELLED); - } - } using (var checker = new InstallChecker()) { diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index 024fa9b7..d119c0d5 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -114,6 +114,33 @@ public async Task Run() return; } + // connectivity check + + App.Logger.WriteLine(LOG_IDENT, "Performing connectivity check..."); + + try + { + await RobloxDeployment.GetInfo(RobloxDeployment.DefaultChannel); + App.Logger.WriteLine(LOG_IDENT, "Connectivity check finished"); + } + catch (Exception ex) + { + App.Logger.WriteLine(LOG_IDENT, "Connectivity check failed!"); + App.Logger.WriteException(LOG_IDENT, ex); + + string message = $"It's possible that something is preventing {App.ProjectName} from connecting to the internet. Please check and try again."; + + if (ex.GetType() == typeof(HttpResponseException)) + message = "Roblox may be down right now. See status.roblox.com for more information. Please try again later."; + + if (ex.GetType() == typeof(AggregateException)) + ex = ex.InnerException!; + + Controls.ShowConnectivityDialog("Roblox", message, ex); + + App.Terminate(ErrorCode.ERROR_CANCELLED); + } + #if !DEBUG if (!App.IsFirstRun && App.Settings.Prop.CheckForUpdates) await CheckForUpdates(); @@ -188,25 +215,8 @@ public async Task Run() private async Task CheckLatestVersion() { SetStatus("Connecting to Roblox..."); - - ClientVersion clientVersion; - - try - { - clientVersion = await RobloxDeployment.GetInfo(App.Settings.Prop.Channel); - } - catch (Exception ex) - { - string message = "It's possible that Roblox is being blocked by a firewall. Please check and try again."; - - if (ex.GetType() == typeof(HttpResponseException)) - message = "Roblox may be down right now. See status.roblox.com for more information. Please try again later."; - - Controls.ShowConnectivityDialog("Roblox", message, ex); - - App.Terminate(ErrorCode.ERROR_CANCELLED); - return; - } + + var clientVersion = await RobloxDeployment.GetInfo(App.Settings.Prop.Channel); if (clientVersion.IsBehindDefaultChannel) { From dd06d9c3d1416c00df4611aa7e95f4a4ffdc7c47 Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Wed, 2 Aug 2023 16:51:17 +0100 Subject: [PATCH 03/28] Bump to 2.5.1 --- Bloxstrap/Bloxstrap.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Bloxstrap/Bloxstrap.csproj b/Bloxstrap/Bloxstrap.csproj index 2257c751..48fc5dc0 100644 --- a/Bloxstrap/Bloxstrap.csproj +++ b/Bloxstrap/Bloxstrap.csproj @@ -7,8 +7,8 @@ true True Bloxstrap.ico - 2.5.0 - 2.5.0.0 + 2.5.1 + 2.5.1.0 app.manifest From 81cdede2408013ea990d2ca558119c6ebcf93481 Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Fri, 4 Aug 2023 17:36:14 +0100 Subject: [PATCH 04/28] Remove FastFlag preset for setting MSAA --- Bloxstrap/FastFlagManager.cs | 1 - Bloxstrap/InstallChecker.cs | 16 ++++++++++++---- .../UI/Elements/Menu/Pages/FastFlagsPage.xaml | 9 --------- .../UI/ViewModels/Menu/FastFlagsViewModel.cs | 8 -------- 4 files changed, 12 insertions(+), 22 deletions(-) diff --git a/Bloxstrap/FastFlagManager.cs b/Bloxstrap/FastFlagManager.cs index 0a3e36a8..3e38a566 100644 --- a/Bloxstrap/FastFlagManager.cs +++ b/Bloxstrap/FastFlagManager.cs @@ -25,7 +25,6 @@ public class FastFlagManager : JsonManager> { "Rendering.ManualFullscreen", "FFlagHandleAltEnterFullscreenManually" }, { "Rendering.TexturePack", "FStringPartTexturePackTable2022" }, { "Rendering.DisableScaling", "DFFlagDisableDPIScale" }, - { "Rendering.MSAA", "FIntDebugForceMSAASamples" }, { "Rendering.Mode.D3D11", "FFlagDebugGraphicsPreferD3D11" }, { "Rendering.Mode.D3D10", "FFlagDebugGraphicsPreferD3D11FL10" }, diff --git a/Bloxstrap/InstallChecker.cs b/Bloxstrap/InstallChecker.cs index 285d61dd..75219bf3 100644 --- a/Bloxstrap/InstallChecker.cs +++ b/Bloxstrap/InstallChecker.cs @@ -199,11 +199,19 @@ internal static void CheckUpgrade() // update migrations - if (App.BuildMetadata.CommitRef.StartsWith("tag") && existingVersionInfo.ProductVersion == "2.4.0") + if (App.BuildMetadata.CommitRef.StartsWith("tag")) { - App.FastFlags.SetValue("DFFlagDisableDPIScale", null); - App.FastFlags.SetValue("DFFlagVariableDPIScale2", null); - App.FastFlags.Save(); + if (existingVersionInfo.ProductVersion == "2.4.0") + { + App.FastFlags.SetValue("DFFlagDisableDPIScale", null); + App.FastFlags.SetValue("DFFlagVariableDPIScale2", null); + App.FastFlags.Save(); + } + else if (existingVersionInfo.ProductVersion == "2.5.0") + { + App.FastFlags.SetValue("FIntDebugForceMSAASamples", null); + App.FastFlags.Save(); + } } if (isAutoUpgrade) diff --git a/Bloxstrap/UI/Elements/Menu/Pages/FastFlagsPage.xaml b/Bloxstrap/UI/Elements/Menu/Pages/FastFlagsPage.xaml index 50c0501f..666e6652 100644 --- a/Bloxstrap/UI/Elements/Menu/Pages/FastFlagsPage.xaml +++ b/Bloxstrap/UI/Elements/Menu/Pages/FastFlagsPage.xaml @@ -171,15 +171,6 @@ - - - - - - - - - diff --git a/Bloxstrap/UI/ViewModels/Menu/FastFlagsViewModel.cs b/Bloxstrap/UI/ViewModels/Menu/FastFlagsViewModel.cs index 28ba70dd..8b95d0cb 100644 --- a/Bloxstrap/UI/ViewModels/Menu/FastFlagsViewModel.cs +++ b/Bloxstrap/UI/ViewModels/Menu/FastFlagsViewModel.cs @@ -127,14 +127,6 @@ public string SelectedLightingMode set => App.FastFlags.SetPresetEnum("Rendering.Lighting", LightingModes[value], "True"); } - public IReadOnlyDictionary MSAAModes => FastFlagManager.MSAAModes; - - public string SelectedMSAAMode - { - get => MSAAModes.First(x => x.Value == App.FastFlags.GetPreset("Rendering.MSAA")).Key ?? MSAAModes.First().Key; - set => App.FastFlags.SetPreset("Rendering.MSAA", MSAAModes[value]); - } - public bool GuiHidingEnabled { get => App.FastFlags.GetPreset("UI.Hide") == "32380007"; From e2041d56317d858bd83b1e3afcd36fdd1fe30395 Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Fri, 4 Aug 2023 17:36:43 +0100 Subject: [PATCH 05/28] Fix typo in server location notification --- Bloxstrap/UI/NotifyIconWrapper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Bloxstrap/UI/NotifyIconWrapper.cs b/Bloxstrap/UI/NotifyIconWrapper.cs index 87c6b833..77940a63 100644 --- a/Bloxstrap/UI/NotifyIconWrapper.cs +++ b/Bloxstrap/UI/NotifyIconWrapper.cs @@ -82,7 +82,7 @@ public async void OnGameJoin() string serverLocation = await _activityWatcher!.GetServerLocation(); ShowAlert( - $"Connnected to {_activityWatcher.ActivityServerType.ToString().ToLower()} server", + $"Connected to {_activityWatcher.ActivityServerType.ToString().ToLower()} server", $"Located at {serverLocation}\nClick for more information", 10, (_, _) => _menuContainer?.ShowServerInformationWindow() From 292d07cdec9c699568f9888d964339ebc242eece Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Fri, 4 Aug 2023 22:14:09 +0100 Subject: [PATCH 06/28] Set channel as production by default (#509) --- Bloxstrap/Bootstrapper.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index d119c0d5..c3961a16 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -276,8 +276,12 @@ private async Task StartRoblox() _launchCommandLine = _launchCommandLine.Replace("LAUNCHTIMEPLACEHOLDER", DateTimeOffset.Now.ToUnixTimeMilliseconds().ToString()); - if (App.Settings.Prop.Channel.ToLowerInvariant() != RobloxDeployment.DefaultChannel.ToLowerInvariant()) - _launchCommandLine += " -channel " + App.Settings.Prop.Channel.ToLowerInvariant(); + _launchCommandLine += " -channel "; + + if (App.Settings.Prop.Channel.ToLowerInvariant() == RobloxDeployment.DefaultChannel.ToLowerInvariant()) + _launchCommandLine += "production"; + else + _launchCommandLine += App.Settings.Prop.Channel.ToLowerInvariant(); // whether we should wait for roblox to exit to handle stuff in the background or clean up after roblox closes bool shouldWait = false; From 871bf2f9b1d3b36cb0772575661d712423aa32d3 Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Sat, 5 Aug 2023 00:22:29 +0100 Subject: [PATCH 07/28] Prompt to validate install location correction --- Bloxstrap/InstallChecker.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Bloxstrap/InstallChecker.cs b/Bloxstrap/InstallChecker.cs index 75219bf3..a833acb1 100644 --- a/Bloxstrap/InstallChecker.cs +++ b/Bloxstrap/InstallChecker.cs @@ -1,5 +1,4 @@ using System.Windows; - using Microsoft.Win32; namespace Bloxstrap @@ -29,9 +28,23 @@ internal void Check() return; } + App.Logger.WriteLine(LOG_IDENT, "Installation registry key is likely malformed"); + _installLocation = Path.GetDirectoryName(Paths.Process)!; - App.Logger.WriteLine(LOG_IDENT, $"Registry key is likely malformed. Setting install location as '{_installLocation}'"); + var result = Controls.ShowMessageBox( + $"It appears as if {App.ProjectName} hasn't been properly installed. Is it supposed to be installed at {_installLocation}?", + MessageBoxImage.Warning, + MessageBoxButton.YesNo + ); + + if (result != MessageBoxResult.Yes) + { + FirstTimeRun(); + return; + } + + App.Logger.WriteLine(LOG_IDENT, $"Setting install location as '{_installLocation}'"); if (_registryKey is null) _registryKey = Registry.CurrentUser.CreateSubKey($"Software\\{App.ProjectName}"); From b22d72a1b8bbc1829abccb78493485b48cebb3d8 Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Sat, 5 Aug 2023 01:03:33 +0100 Subject: [PATCH 08/28] Allow for rich presence to be set on game join better title: Allow for rich presence to be set through BloxstrapRPC on immediate game join --- Bloxstrap/Integrations/DiscordRichPresence.cs | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/Bloxstrap/Integrations/DiscordRichPresence.cs b/Bloxstrap/Integrations/DiscordRichPresence.cs index 1444b369..5d74c73d 100644 --- a/Bloxstrap/Integrations/DiscordRichPresence.cs +++ b/Bloxstrap/Integrations/DiscordRichPresence.cs @@ -9,6 +9,7 @@ public class DiscordRichPresence : IDisposable private DiscordRPC.RichPresence? _currentPresence; private DiscordRPC.RichPresence? _currentPresenceCopy; + private Message? _stashedRPCMessage; private bool _visible = true; private long _currentUniverseId; @@ -55,6 +56,13 @@ public void ProcessRPCMessage(Message message) if (_currentPresence is null || _currentPresenceCopy is null) { + if (_activityWatcher.ActivityInGame) + { + App.Logger.WriteLine(LOG_IDENT, "Presence is not yet set, but is currently in game, stashing presence set request"); + _stashedRPCMessage = message; + return; + } + App.Logger.WriteLine(LOG_IDENT, "Presence is not set, aborting"); return; } @@ -173,7 +181,10 @@ public async Task SetCurrentGame() if (!_activityWatcher.ActivityInGame) { App.Logger.WriteLine(LOG_IDENT, "Not in game, clearing presence"); - _currentPresence = _currentPresenceCopy = null; + + _currentPresence = _currentPresenceCopy = null; + _stashedRPCMessage = null; + UpdatePresence(); return true; } @@ -268,7 +279,16 @@ public async Task SetCurrentGame() // this is used for configuration from BloxstrapRPC _currentPresenceCopy = _currentPresence.Clone(); - UpdatePresence(); + if (_stashedRPCMessage is not null) + { + App.Logger.WriteLine(LOG_IDENT, "Found stashed RPC message, invoking presence set command now"); + ProcessRPCMessage(_stashedRPCMessage); + _stashedRPCMessage = null; + } + else + { + UpdatePresence(); + } return true; } From b6de3645b7394b8ab1d785cda60f565a7f368594 Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Sun, 6 Aug 2023 14:21:27 +0100 Subject: [PATCH 09/28] Catch exceptions when deleting files/folders --- Bloxstrap/Bootstrapper.cs | 11 ++++++++++- Bloxstrap/Logger.cs | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index c3961a16..30e3b02f 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -920,7 +920,16 @@ private async Task InstallLatestVersion() continue; App.Logger.WriteLine(LOG_IDENT, $"Removing old version folder for {dir.Name}"); - dir.Delete(true); + + try + { + dir.Delete(true); + } + catch (Exception ex) + { + App.Logger.WriteLine(LOG_IDENT, "Failed to delete version folder!"); + App.Logger.WriteException(LOG_IDENT, ex); + } } } } diff --git a/Bloxstrap/Logger.cs b/Bloxstrap/Logger.cs index b2760a1e..503741e6 100644 --- a/Bloxstrap/Logger.cs +++ b/Bloxstrap/Logger.cs @@ -64,7 +64,16 @@ public void Initialize(bool useTempDir = false) continue; WriteLine(LOG_IDENT, $"Cleaning up old log file '{log.Name}'"); - log.Delete(); + + try + { + log.Delete(); + } + catch (Exception ex) + { + WriteLine(LOG_IDENT, "Failed to delete log!"); + WriteException(LOG_IDENT, ex); + } } } } From 53ccac4b37eff76d04cd046e53e7985df44626f8 Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Sun, 6 Aug 2023 14:24:17 +0100 Subject: [PATCH 10/28] (Attempt to) fix duplicate exception dialogs --- Bloxstrap/App.xaml.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Bloxstrap/App.xaml.cs b/Bloxstrap/App.xaml.cs index 1651f212..d7603903 100644 --- a/Bloxstrap/App.xaml.cs +++ b/Bloxstrap/App.xaml.cs @@ -49,6 +49,8 @@ public partial class App : Application ) ); + private static bool _showingExceptionDialog = false; + public static void Terminate(ErrorCode exitCode = ErrorCode.ERROR_SUCCESS) { if (IsFirstRun) @@ -85,6 +87,11 @@ public static void FinalizeExceptionHandling(Exception exception, bool log = tru #if DEBUG throw exception; #else + if (_showingExceptionDialog) + return; + + _showingExceptionDialog = true; + if (!IsQuiet) Controls.ShowExceptionDialog(exception); From f6177004578583996f3f343a79c560c79bb5dfcc Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Sun, 6 Aug 2023 14:32:58 +0100 Subject: [PATCH 11/28] Unwrap inner exceptions when showing exception --- .../UI/Elements/Dialogs/ExceptionDialog.xaml | 2 +- .../UI/Elements/Dialogs/ExceptionDialog.xaml.cs | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Bloxstrap/UI/Elements/Dialogs/ExceptionDialog.xaml b/Bloxstrap/UI/Elements/Dialogs/ExceptionDialog.xaml index 54d8a51f..a2c54182 100644 --- a/Bloxstrap/UI/Elements/Dialogs/ExceptionDialog.xaml +++ b/Bloxstrap/UI/Elements/Dialogs/ExceptionDialog.xaml @@ -6,7 +6,7 @@ xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" xmlns:local="clr-namespace:Bloxstrap.UI.Elements.Dialogs" mc:Ignorable="d" - Width="480" + Width="540" MinHeight="0" SizeToContent="Height" Background="{ui:ThemeResource ApplicationBackgroundBrush}" diff --git a/Bloxstrap/UI/Elements/Dialogs/ExceptionDialog.xaml.cs b/Bloxstrap/UI/Elements/Dialogs/ExceptionDialog.xaml.cs index e53485d4..7915ae4f 100644 --- a/Bloxstrap/UI/Elements/Dialogs/ExceptionDialog.xaml.cs +++ b/Bloxstrap/UI/Elements/Dialogs/ExceptionDialog.xaml.cs @@ -22,10 +22,8 @@ public ExceptionDialog(Exception exception) InitializeComponent(); Title = RootTitleBar.Title = $"{App.ProjectName} Exception"; - ErrorRichTextBox.Selection.Text = $"{exception.GetType()}: {exception.Message}"; - if (innerException is not null) - ErrorRichTextBox.Selection.Text += $"\n\n===== Inner Exception =====\n{innerException.GetType()}: {innerException.Message}"; + AddException(exception); if (!App.Logger.Initialized) LocateLogFileButton.Content = "Copy log contents"; @@ -66,5 +64,18 @@ public ExceptionDialog(Exception exception) PInvoke.FlashWindow((HWND)hWnd, true); }; } + + private void AddException(Exception exception, bool inner = false) + { + if (!inner) + ErrorRichTextBox.Selection.Text = $"{exception.GetType()}: {exception.Message}"; + + if (exception.InnerException is null) + return; + + ErrorRichTextBox.Selection.Text += $"\n\n[Inner Exception]\n{exception.InnerException.GetType()}: {exception.InnerException.Message}"; + + AddException(exception.InnerException, true); + } } } From e5bd4f3678f3f3484770b234de7471532ab74c87 Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Sun, 6 Aug 2023 14:44:12 +0100 Subject: [PATCH 12/28] Fix bug with duplicate launch checking --- Bloxstrap/Logger.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Bloxstrap/Logger.cs b/Bloxstrap/Logger.cs index 503741e6..e193c322 100644 --- a/Bloxstrap/Logger.cs +++ b/Bloxstrap/Logger.cs @@ -43,6 +43,7 @@ public void Initialize(bool useTempDir = false) catch (IOException) { WriteLine(LOG_IDENT, "Failed to initialize because log file already exists"); + return; } From 473cb5c70caf493277c52d226c847921f8753abd Mon Sep 17 00:00:00 2001 From: sewn Date: Sat, 19 Aug 2023 13:20:23 +0300 Subject: [PATCH 13/28] Fix Typos --- Bloxstrap/Bootstrapper.cs | 2 +- Bloxstrap/RobloxDeployment.cs | 2 +- Bloxstrap/UI/NotifyIconWrapper.cs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index 024fa9b7..8d2e9d1e 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -783,7 +783,7 @@ private void Uninstall() }; } - Dialog?.ShowSuccess($"{App.ProjectName} has succesfully uninstalled", callback); + Dialog?.ShowSuccess($"{App.ProjectName} has successfully uninstalled", callback); } #endregion diff --git a/Bloxstrap/RobloxDeployment.cs b/Bloxstrap/RobloxDeployment.cs index 30267d2a..598812cf 100644 --- a/Bloxstrap/RobloxDeployment.cs +++ b/Bloxstrap/RobloxDeployment.cs @@ -7,7 +7,7 @@ public static class RobloxDeployment private static Dictionary ClientVersionCache = new(); - // a list of roblox delpoyment locations that we check for, in case one of them don't work + // a list of roblox deployment locations that we check for, in case one of them don't work private static List BaseUrls = new() { "https://setup.rbxcdn.com", diff --git a/Bloxstrap/UI/NotifyIconWrapper.cs b/Bloxstrap/UI/NotifyIconWrapper.cs index 87c6b833..6eb8e065 100644 --- a/Bloxstrap/UI/NotifyIconWrapper.cs +++ b/Bloxstrap/UI/NotifyIconWrapper.cs @@ -82,7 +82,7 @@ public async void OnGameJoin() string serverLocation = await _activityWatcher!.GetServerLocation(); ShowAlert( - $"Connnected to {_activityWatcher.ActivityServerType.ToString().ToLower()} server", + $"Connected to {_activityWatcher.ActivityServerType.ToString().ToLower()} server", $"Located at {serverLocation}\nClick for more information", 10, (_, _) => _menuContainer?.ShowServerInformationWindow() @@ -124,7 +124,7 @@ public void ShowAlert(string caption, string message, int duration, EventHandler if (_alertClickHandler == clickHandler) _alertClickHandler = null; else - App.Logger.WriteLine(LOG_IDENT, "Click handler has been overriden by another alert"); + App.Logger.WriteLine(LOG_IDENT, "Click handler has been overridden by another alert"); }); } From 541a8bdc7391ccdecda99b5accc2f173dadb07c3 Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Wed, 23 Aug 2023 09:57:11 +0100 Subject: [PATCH 14/28] Fix clipboard copying (#522) --- Bloxstrap/UI/Elements/ContextMenu/MenuContainer.xaml.cs | 2 +- Bloxstrap/UI/Elements/Dialogs/ExceptionDialog.xaml.cs | 2 +- .../UI/ViewModels/ContextMenu/ServerInformationViewModel.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Bloxstrap/UI/Elements/ContextMenu/MenuContainer.xaml.cs b/Bloxstrap/UI/Elements/ContextMenu/MenuContainer.xaml.cs index d2f6a8aa..8354ced9 100644 --- a/Bloxstrap/UI/Elements/ContextMenu/MenuContainer.xaml.cs +++ b/Bloxstrap/UI/Elements/ContextMenu/MenuContainer.xaml.cs @@ -96,7 +96,7 @@ private void Window_Loaded(object? sender, RoutedEventArgs e) private void RichPresenceMenuItem_Click(object sender, RoutedEventArgs e) => _richPresenceHandler?.SetVisibility(((MenuItem)sender).IsChecked); - private void InviteDeeplinkMenuItem_Click(object sender, RoutedEventArgs e) => Clipboard.SetText($"roblox://experiences/start?placeId={_activityWatcher?.ActivityPlaceId}&gameInstanceId={_activityWatcher?.ActivityJobId}"); + private void InviteDeeplinkMenuItem_Click(object sender, RoutedEventArgs e) => Clipboard.SetDataObject($"roblox://experiences/start?placeId={_activityWatcher?.ActivityPlaceId}&gameInstanceId={_activityWatcher?.ActivityJobId}"); private void ServerDetailsMenuItem_Click(object sender, RoutedEventArgs e) => ShowServerInformationWindow(); diff --git a/Bloxstrap/UI/Elements/Dialogs/ExceptionDialog.xaml.cs b/Bloxstrap/UI/Elements/Dialogs/ExceptionDialog.xaml.cs index 7915ae4f..c5cff3a1 100644 --- a/Bloxstrap/UI/Elements/Dialogs/ExceptionDialog.xaml.cs +++ b/Bloxstrap/UI/Elements/Dialogs/ExceptionDialog.xaml.cs @@ -33,7 +33,7 @@ public ExceptionDialog(Exception exception) if (App.Logger.Initialized) Process.Start("explorer.exe", $"/select,\"{App.Logger.FileLocation}\""); else - Clipboard.SetText(String.Join("\r\n", App.Logger.Backlog)); + Clipboard.SetDataObject(String.Join("\r\n", App.Logger.Backlog)); }; ReportOptions.DropDownClosed += (sender, e) => diff --git a/Bloxstrap/UI/ViewModels/ContextMenu/ServerInformationViewModel.cs b/Bloxstrap/UI/ViewModels/ContextMenu/ServerInformationViewModel.cs index 576d8288..d6c477e7 100644 --- a/Bloxstrap/UI/ViewModels/ContextMenu/ServerInformationViewModel.cs +++ b/Bloxstrap/UI/ViewModels/ContextMenu/ServerInformationViewModel.cs @@ -30,6 +30,6 @@ public ServerInformationViewModel(Window window, ActivityWatcher activityWatcher }); } - private void CopyInstanceId() => Clipboard.SetText(InstanceId); + private void CopyInstanceId() => Clipboard.SetDataObject(InstanceId); } } From 47dcec060b9ec0e806af1b0582de1e356604ec9e Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Wed, 23 Aug 2023 10:10:33 +0100 Subject: [PATCH 15/28] Revert to LIVE if there's no Windows build (#526) --- Bloxstrap/Bootstrapper.cs | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index 6eaadb69..aa1ab2be 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -121,7 +121,6 @@ public async Task Run() try { await RobloxDeployment.GetInfo(RobloxDeployment.DefaultChannel); - App.Logger.WriteLine(LOG_IDENT, "Connectivity check finished"); } catch (Exception ex) { @@ -140,6 +139,10 @@ public async Task Run() App.Terminate(ErrorCode.ERROR_CANCELLED); } + finally + { + App.Logger.WriteLine(LOG_IDENT, "Connectivity check finished"); + } #if !DEBUG if (!App.IsFirstRun && App.Settings.Prop.CheckForUpdates) @@ -214,9 +217,25 @@ public async Task Run() private async Task CheckLatestVersion() { + const string LOG_IDENT = "Bootstrapper::CheckLatestVersion"; + SetStatus("Connecting to Roblox..."); - - var clientVersion = await RobloxDeployment.GetInfo(App.Settings.Prop.Channel); + + ClientVersion clientVersion; + + try + { + clientVersion = await RobloxDeployment.GetInfo(App.Settings.Prop.Channel); + } + catch (HttpResponseException ex) + { + if (ex.ResponseMessage.StatusCode != HttpStatusCode.NotFound) + throw; + + App.Logger.WriteLine(LOG_IDENT, $"Reverting enrolled channel to {RobloxDeployment.DefaultChannel} because a WindowsPlayer build does not exist for {App.Settings.Prop.Channel}"); + App.Settings.Prop.Channel = RobloxDeployment.DefaultChannel; + clientVersion = await RobloxDeployment.GetInfo(App.Settings.Prop.Channel); + } if (clientVersion.IsBehindDefaultChannel) { From 1e8a4359d78ae6144124903ef1b97a0dc796ad2f Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Wed, 23 Aug 2023 10:27:30 +0100 Subject: [PATCH 16/28] Fix selected menu version not applying (#528) --- Bloxstrap/FastFlagManager.cs | 19 ++++++++++++++----- Bloxstrap/InstallChecker.cs | 4 ++++ .../UI/ViewModels/Menu/FastFlagsViewModel.cs | 7 +++++-- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Bloxstrap/FastFlagManager.cs b/Bloxstrap/FastFlagManager.cs index 3e38a566..72d9c08d 100644 --- a/Bloxstrap/FastFlagManager.cs +++ b/Bloxstrap/FastFlagManager.cs @@ -42,7 +42,12 @@ public class FastFlagManager : JsonManager> { "UI.Menu.GraphicsSlider", "FFlagFixGraphicsQuality" }, { "UI.Menu.Style.DisableV2", "FFlagDisableNewIGMinDUA" }, - { "UI.Menu.Style.EnableV4", "FFlagEnableInGameMenuControls" } + { "UI.Menu.Style.EnableV4", "FFlagEnableInGameMenuControls" }, + + { "UI.Menu.Style.ABTest.1", "FFlagEnableMenuControlsABTest" }, + { "UI.Menu.Style.ABTest.2", "FFlagEnableMenuModernizationABTest" }, + { "UI.Menu.Style.ABTest.3", "FFlagEnableMenuModernizationABTest2" }, + { "UI.Menu.Style.ABTest.4", "FFlagEnableV3MenuABTest3" } }; // only one missing here is Metal because lol @@ -81,7 +86,8 @@ public class FastFlagManager : JsonManager> new Dictionary { { "DisableV2", null }, - { "EnableV4", null } + { "EnableV4", null }, + { "ABTest", null } } }, @@ -90,7 +96,8 @@ public class FastFlagManager : JsonManager> new Dictionary { { "DisableV2", "True" }, - { "EnableV4", "False" } + { "EnableV4", "False" }, + { "ABTest", "False" } } }, @@ -99,7 +106,8 @@ public class FastFlagManager : JsonManager> new Dictionary { { "DisableV2", "False" }, - { "EnableV4", "False" } + { "EnableV4", "False" }, + { "ABTest", "False" } } }, @@ -108,7 +116,8 @@ public class FastFlagManager : JsonManager> new Dictionary { { "DisableV2", "True" }, - { "EnableV4", "True" } + { "EnableV4", "True" }, + { "ABTest", "False" } } } }; diff --git a/Bloxstrap/InstallChecker.cs b/Bloxstrap/InstallChecker.cs index a833acb1..7e4bb096 100644 --- a/Bloxstrap/InstallChecker.cs +++ b/Bloxstrap/InstallChecker.cs @@ -223,6 +223,10 @@ internal static void CheckUpgrade() else if (existingVersionInfo.ProductVersion == "2.5.0") { App.FastFlags.SetValue("FIntDebugForceMSAASamples", null); + + if (App.FastFlags.GetPreset("UI.Menu.Style.DisableV2") is not null) + App.FastFlags.SetPreset("UI.Menu.Style.ABTest", false); + App.FastFlags.Save(); } } diff --git a/Bloxstrap/UI/ViewModels/Menu/FastFlagsViewModel.cs b/Bloxstrap/UI/ViewModels/Menu/FastFlagsViewModel.cs index 8b95d0cb..8dee2e5d 100644 --- a/Bloxstrap/UI/ViewModels/Menu/FastFlagsViewModel.cs +++ b/Bloxstrap/UI/ViewModels/Menu/FastFlagsViewModel.cs @@ -101,8 +101,11 @@ public string SelectedIGMenuVersion foreach (var flag in version.Value) { - if (App.FastFlags.GetPreset($"UI.Menu.Style.{flag.Key}") != flag.Value) - flagsMatch = false; + foreach (var presetFlag in FastFlagManager.PresetFlags.Where(x => x.Key.StartsWith($"UI.Menu.Style.{flag.Key}"))) + { + if (App.FastFlags.GetValue(presetFlag.Value) != flag.Value) + flagsMatch = false; + } } if (flagsMatch) From ee8f583bae9f83cf61a05c601b45e0691a610e32 Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Wed, 23 Aug 2023 10:35:10 +0100 Subject: [PATCH 17/28] Gatekeep channel selection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 👍 --- Bloxstrap/RobloxDeployment.cs | 12 ------------ Bloxstrap/UI/Elements/Menu/Pages/BehaviourPage.xaml | 2 +- Bloxstrap/UI/ViewModels/Menu/BehaviourViewModel.cs | 6 ------ 3 files changed, 1 insertion(+), 19 deletions(-) diff --git a/Bloxstrap/RobloxDeployment.cs b/Bloxstrap/RobloxDeployment.cs index 598812cf..cdeda888 100644 --- a/Bloxstrap/RobloxDeployment.cs +++ b/Bloxstrap/RobloxDeployment.cs @@ -52,18 +52,6 @@ public static string BaseUrl return _baseUrl; } } - - // most commonly used/interesting channels - public static readonly List SelectableChannels = new() - { - "LIVE", - "ZFlag", - "ZNext", - "ZCanary", - "ZIntegration", - "ZAvatarTeam", - "ZSocialTeam" - }; #endregion public static string GetLocation(string resource, string? channel = null) diff --git a/Bloxstrap/UI/Elements/Menu/Pages/BehaviourPage.xaml b/Bloxstrap/UI/Elements/Menu/Pages/BehaviourPage.xaml index 1e4b4aa8..68bdc7b1 100644 --- a/Bloxstrap/UI/Elements/Menu/Pages/BehaviourPage.xaml +++ b/Bloxstrap/UI/Elements/Menu/Pages/BehaviourPage.xaml @@ -46,7 +46,7 @@ - + diff --git a/Bloxstrap/UI/ViewModels/Menu/BehaviourViewModel.cs b/Bloxstrap/UI/ViewModels/Menu/BehaviourViewModel.cs index da81ace4..28c4bc78 100644 --- a/Bloxstrap/UI/ViewModels/Menu/BehaviourViewModel.cs +++ b/Bloxstrap/UI/ViewModels/Menu/BehaviourViewModel.cs @@ -81,18 +81,12 @@ public bool UpdateCheckingEnabled set => App.Settings.Prop.CheckForUpdates = value; } - public IEnumerable Channels => RobloxDeployment.SelectableChannels; - public string SelectedChannel { get => App.Settings.Prop.Channel; set { value = value.Trim(); - - if (String.IsNullOrEmpty(value)) - value = RobloxDeployment.DefaultChannel; - Task.Run(() => LoadChannelDeployInfo(value)); App.Settings.Prop.Channel = value; } From 85c19a5e0d0d7d8c04e3dafa31c739fa1611689d Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Wed, 23 Aug 2023 10:43:07 +0100 Subject: [PATCH 18/28] Fix single-letter game names Again --- Bloxstrap/Integrations/DiscordRichPresence.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Bloxstrap/Integrations/DiscordRichPresence.cs b/Bloxstrap/Integrations/DiscordRichPresence.cs index 5d74c73d..ab920d12 100644 --- a/Bloxstrap/Integrations/DiscordRichPresence.cs +++ b/Bloxstrap/Integrations/DiscordRichPresence.cs @@ -261,6 +261,9 @@ public async Task SetCurrentGame() _ => $"by {universeDetails.Creator.Name}" + (universeDetails.Creator.HasVerifiedBadge ? " ☑️" : ""), }; + if (universeDetails.Name.Length < 2) + universeDetails.Name = $"{universeDetails.Name}\x2800\x2800\x2800"; + _currentPresence = new DiscordRPC.RichPresence { Details = $"Playing {universeDetails.Name}", From 1f86996d7dbfea47fb89a82e811ebd273fdc8845 Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Wed, 23 Aug 2023 11:12:48 +0100 Subject: [PATCH 19/28] Skip mod check if Roblox is running --- Bloxstrap/Bootstrapper.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index aa1ab2be..35b66b21 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -1041,6 +1041,12 @@ private async Task ApplyModifications() { const string LOG_IDENT = "Bootstrapper::ApplyModifications"; + if (Process.GetProcessesByName("RobloxPlayerBeta").Where(x => x.MainModule!.FileName == _playerLocation).Any()) + { + App.Logger.WriteLine(LOG_IDENT, "Roblox is running, aborting mod check"); + return; + } + SetStatus("Applying Roblox modifications..."); // set executable flags for fullscreen optimizations From cf09956258b83f37dd73a2c7e23555bf978360cc Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Wed, 23 Aug 2023 11:27:45 +0100 Subject: [PATCH 20/28] Add more restrictions on install path selection --- .../UI/ViewModels/Menu/MainWindowViewModel.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Bloxstrap/UI/ViewModels/Menu/MainWindowViewModel.cs b/Bloxstrap/UI/ViewModels/Menu/MainWindowViewModel.cs index bc868bd7..f8108abe 100644 --- a/Bloxstrap/UI/ViewModels/Menu/MainWindowViewModel.cs +++ b/Bloxstrap/UI/ViewModels/Menu/MainWindowViewModel.cs @@ -87,6 +87,22 @@ private void ConfirmSettings() else if (result == MessageBoxResult.Cancel) return; } + + if ( + App.BaseDirectory.Length <= 3 || // prevent from installing to the root of a drive + App.BaseDirectory.StartsWith("\\\\") || // i actually haven't encountered anyone doing this and i dont even know if this is possible but this is just to be safe lmao + App.BaseDirectory.ToLowerInvariant().Contains("onedrive") || // prevent from installing to a onedrive folder + Directory.GetParent(App.BaseDirectory)!.ToString().ToLowerInvariant() == Paths.UserProfile.ToLowerInvariant() // prevent from installing to an essential user profile folder + ) + { + Controls.ShowMessageBox( + $"{App.ProjectName} cannot be installed here. Please choose a different location, or resort to using the default location by clicking the reset button.", + MessageBoxImage.Error, + MessageBoxButton.OK + ); + + return; + } } if (App.IsFirstRun) From 517546087c36385ce8de27fdaccfe279ea183fbd Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Wed, 23 Aug 2023 12:43:10 +0100 Subject: [PATCH 21/28] Remove install location changing post installation --- Bloxstrap/Bootstrapper.cs | 72 +--------- Bloxstrap/UI/Elements/Menu/MainWindow.xaml | 42 +++--- Bloxstrap/UI/Elements/Menu/MainWindow.xaml.cs | 4 +- .../Elements/Menu/Pages/BehaviourPage.xaml.cs | 5 +- .../Elements/Menu/Pages/InstallationPage.xaml | 125 ++++++++++-------- .../Menu/Pages/InstallationPage.xaml.cs | 17 ++- .../UI/ViewModels/Menu/MainWindowViewModel.cs | 71 ++++------ 7 files changed, 137 insertions(+), 199 deletions(-) diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index 35b66b21..34a4b75c 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -178,8 +178,6 @@ public async Task Run() await CheckLatestVersion(); - CheckInstallMigration(); - // install/update roblox if we're running for the first time, needs updating, or the player location doesn't exist if (App.IsFirstRun || _latestVersionGuid != App.State.Prop.VersionGuid || !File.Exists(_playerLocation)) await InstallLatestVersion(); @@ -477,71 +475,6 @@ public void RegisterProgramSize() App.Logger.WriteLine(LOG_IDENT, $"Registered as {totalSize} KB"); } - private void CheckInstallMigration() - { - const string LOG_IDENT = "Bootstrapper::CheckInstallMigration"; - - // check if we've changed our install location since the last time we started - // in which case, we'll have to copy over all our folders so we don't lose any mods and stuff - - using RegistryKey? applicationKey = Registry.CurrentUser.OpenSubKey($@"Software\{App.ProjectName}", true); - - string? oldInstallLocation = (string?)applicationKey?.GetValue("OldInstallLocation"); - - if (applicationKey is null || oldInstallLocation is null || oldInstallLocation == Paths.Base) - return; - - SetStatus("Migrating install location..."); - - if (Directory.Exists(oldInstallLocation)) - { - App.Logger.WriteLine(LOG_IDENT, $"Moving all files in {oldInstallLocation} to {Paths.Base}..."); - - foreach (string oldFileLocation in Directory.GetFiles(oldInstallLocation, "*.*", SearchOption.AllDirectories)) - { - string relativeFile = oldFileLocation.Substring(oldInstallLocation.Length + 1); - string newFileLocation = Path.Combine(Paths.Base, relativeFile); - string? newDirectory = Path.GetDirectoryName(newFileLocation); - - try - { - if (!String.IsNullOrEmpty(newDirectory)) - Directory.CreateDirectory(newDirectory); - - File.Move(oldFileLocation, newFileLocation, true); - } - catch (Exception ex) - { - App.Logger.WriteLine(LOG_IDENT, $"Failed to move {oldFileLocation} to {newFileLocation}! {ex}"); - } - } - - try - { - Directory.Delete(oldInstallLocation, true); - App.Logger.WriteLine(LOG_IDENT, "Deleted old install location"); - } - catch (Exception ex) - { - App.Logger.WriteLine(LOG_IDENT, $"Failed to delete old install location! {ex}"); - } - } - - applicationKey.DeleteValue("OldInstallLocation"); - - // allow shortcuts to be re-registered - if (Directory.Exists(Paths.StartMenu)) - Directory.Delete(Paths.StartMenu, true); - - if (File.Exists(DesktopShortcutLocation)) - { - File.Delete(DesktopShortcutLocation); - App.Settings.Prop.CreateDesktopIcon = true; - } - - App.Logger.WriteLine(LOG_IDENT, "Finished migrating install location!"); - } - public static void CheckInstall() { const string LOG_IDENT = "Bootstrapper::CheckInstall"; @@ -746,7 +679,7 @@ private void Uninstall() // if the folder we're installed to does not end with "Bloxstrap", we're installed to a user-selected folder // in which case, chances are they chose to install to somewhere they didn't really mean to (prior to the added warning in 2.4.0) // if so, we're walking on eggshells and have to ensure we only clean up what we need to clean up - bool cautiousUninstall = !Paths.Base.EndsWith(App.ProjectName); + bool cautiousUninstall = !Paths.Base.ToLower().EndsWith(App.ProjectName.ToLower()); var cleanupSequence = new List { @@ -1418,7 +1351,8 @@ private async Task DownloadPackage(Package package) App.Logger.WriteLine(LOG_IDENT, $"An exception occurred after downloading {totalBytesRead} bytes. ({i}/{maxTries})"); App.Logger.WriteException(LOG_IDENT, ex); - File.Delete(packageLocation); + if (File.Exists(packageLocation)) + File.Delete(packageLocation); if (i >= maxTries) throw; diff --git a/Bloxstrap/UI/Elements/Menu/MainWindow.xaml b/Bloxstrap/UI/Elements/Menu/MainWindow.xaml index 73260ad1..6fee20ef 100644 --- a/Bloxstrap/UI/Elements/Menu/MainWindow.xaml +++ b/Bloxstrap/UI/Elements/Menu/MainWindow.xaml @@ -59,26 +59,24 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/Bloxstrap/UI/Elements/Menu/MainWindow.xaml.cs b/Bloxstrap/UI/Elements/Menu/MainWindow.xaml.cs index 989fa65b..968dabf7 100644 --- a/Bloxstrap/UI/Elements/Menu/MainWindow.xaml.cs +++ b/Bloxstrap/UI/Elements/Menu/MainWindow.xaml.cs @@ -15,16 +15,14 @@ namespace Bloxstrap.UI.Elements.Menu public partial class MainWindow : INavigationWindow { private readonly IThemeService _themeService = new ThemeService(); - private readonly IDialogService _dialogService = new DialogService(); public MainWindow() { App.Logger.WriteLine("MainWindow::MainWindow", "Initializing menu"); - DataContext = new MainWindowViewModel(this, _dialogService); + DataContext = new MainWindowViewModel(this); SetTheme(); InitializeComponent(); - _dialogService.SetDialogControl(RootDialog); } public void SetTheme() diff --git a/Bloxstrap/UI/Elements/Menu/Pages/BehaviourPage.xaml.cs b/Bloxstrap/UI/Elements/Menu/Pages/BehaviourPage.xaml.cs index 68de8d7e..1a7631d1 100644 --- a/Bloxstrap/UI/Elements/Menu/Pages/BehaviourPage.xaml.cs +++ b/Bloxstrap/UI/Elements/Menu/Pages/BehaviourPage.xaml.cs @@ -1,5 +1,4 @@ -using Bloxstrap.UI.ViewModels.Menu; -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -14,6 +13,8 @@ using System.Windows.Navigation; using System.Windows.Shapes; +using Bloxstrap.UI.ViewModels.Menu; + namespace Bloxstrap.UI.Elements.Menu.Pages { /// diff --git a/Bloxstrap/UI/Elements/Menu/Pages/InstallationPage.xaml b/Bloxstrap/UI/Elements/Menu/Pages/InstallationPage.xaml index 7f285030..3c34ffc3 100644 --- a/Bloxstrap/UI/Elements/Menu/Pages/InstallationPage.xaml +++ b/Bloxstrap/UI/Elements/Menu/Pages/InstallationPage.xaml @@ -1,66 +1,79 @@  - - + Title="InstallationPage"> + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + - - - - - - - - - + + + + - - - - - - + + + + + + - - - - - - - - + + + + + + + + diff --git a/Bloxstrap/UI/Elements/Menu/Pages/InstallationPage.xaml.cs b/Bloxstrap/UI/Elements/Menu/Pages/InstallationPage.xaml.cs index b58ea4a7..a46ae0e7 100644 --- a/Bloxstrap/UI/Elements/Menu/Pages/InstallationPage.xaml.cs +++ b/Bloxstrap/UI/Elements/Menu/Pages/InstallationPage.xaml.cs @@ -1,4 +1,19 @@ -using Bloxstrap.UI.ViewModels.Menu; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +using Bloxstrap.UI.ViewModels.Menu; namespace Bloxstrap.UI.Elements.Menu.Pages { diff --git a/Bloxstrap/UI/ViewModels/Menu/MainWindowViewModel.cs b/Bloxstrap/UI/ViewModels/Menu/MainWindowViewModel.cs index f8108abe..0e520ec7 100644 --- a/Bloxstrap/UI/ViewModels/Menu/MainWindowViewModel.cs +++ b/Bloxstrap/UI/ViewModels/Menu/MainWindowViewModel.cs @@ -14,8 +14,6 @@ namespace Bloxstrap.UI.ViewModels.Menu public class MainWindowViewModel : NotifyPropertyChangedViewModel { private readonly Window _window; - private readonly IDialogService _dialogService; - private readonly string _originalBaseDirectory = App.BaseDirectory; // we need this to check if the basedirectory changes public ICommand CloseWindowCommand => new RelayCommand(CloseWindow); public ICommand ConfirmSettingsCommand => new RelayCommand(ConfirmSettings); @@ -24,25 +22,31 @@ public class MainWindowViewModel : NotifyPropertyChangedViewModel public string ConfirmButtonText => App.IsFirstRun ? "Install" : "Save"; public bool ConfirmButtonEnabled { get; set; } = true; - public MainWindowViewModel(Window window, IDialogService dialogService) + public MainWindowViewModel(Window window) { _window = window; - _dialogService = dialogService; } private void CloseWindow() => _window.Close(); private void ConfirmSettings() { + if (!App.IsFirstRun) + { + App.ShouldSaveConfigs = true; + App.FastFlags.Save(); + CloseWindow(); + + return; + } + if (string.IsNullOrEmpty(App.BaseDirectory)) { Controls.ShowMessageBox("You must set an install location", MessageBoxImage.Error); return; } - bool shouldCheckInstallLocation = App.IsFirstRun || App.BaseDirectory != _originalBaseDirectory; - - if (shouldCheckInstallLocation && NavigationVisibility == Visibility.Visible) + if (NavigationVisibility == Visibility.Visible) { try { @@ -104,53 +108,28 @@ private void ConfirmSettings() return; } } - - if (App.IsFirstRun) + + if (NavigationVisibility == Visibility.Visible) { - if (NavigationVisibility == Visibility.Visible) - { - ((INavigationWindow)_window).Navigate(typeof(PreInstallPage)); + ((INavigationWindow)_window).Navigate(typeof(PreInstallPage)); - NavigationVisibility = Visibility.Collapsed; - OnPropertyChanged(nameof(NavigationVisibility)); + NavigationVisibility = Visibility.Collapsed; + OnPropertyChanged(nameof(NavigationVisibility)); - ConfirmButtonEnabled = false; - OnPropertyChanged(nameof(ConfirmButtonEnabled)); - - Task.Run(async delegate - { - await Task.Delay(3000); + ConfirmButtonEnabled = false; + OnPropertyChanged(nameof(ConfirmButtonEnabled)); - ConfirmButtonEnabled = true; - OnPropertyChanged(nameof(ConfirmButtonEnabled)); - }); - } - else + Task.Run(async delegate { - App.IsSetupComplete = true; - CloseWindow(); - } + await Task.Delay(3000); + + ConfirmButtonEnabled = true; + OnPropertyChanged(nameof(ConfirmButtonEnabled)); + }); } else { - App.ShouldSaveConfigs = true; - App.FastFlags.Save(); - - if (shouldCheckInstallLocation) - { - App.Logger.WriteLine("MainWindowViewModel::ConfirmSettings", $"Changing install location from {_originalBaseDirectory} to {App.BaseDirectory}"); - - Controls.ShowMessageBox( - $"{App.ProjectName} will install to the new location you've set the next time it runs.", - MessageBoxImage.Information - ); - - using RegistryKey registryKey = Registry.CurrentUser.CreateSubKey($@"Software\{App.ProjectName}"); - registryKey.SetValue("InstallLocation", App.BaseDirectory); - registryKey.SetValue("OldInstallLocation", _originalBaseDirectory); - Paths.Initialize(App.BaseDirectory); - } - + App.IsSetupComplete = true; CloseWindow(); } } From 5f8e1401c7f3e743ad07bc2f57150fe4c7f02123 Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Wed, 23 Aug 2023 13:25:37 +0100 Subject: [PATCH 22/28] Allow flag JSON importing to be done by copy-paste --- .../Elements/Dialogs/AddFastFlagDialog.xaml | 4 +- .../Dialogs/BulkAddFastFlagDialog.xaml | 60 ++++++++++++++ .../Dialogs/BulkAddFastFlagDialog.xaml.cs | 35 ++++++++ .../Menu/Pages/FastFlagEditorPage.xaml.cs | 81 ++++++++++--------- 4 files changed, 141 insertions(+), 39 deletions(-) create mode 100644 Bloxstrap/UI/Elements/Dialogs/BulkAddFastFlagDialog.xaml create mode 100644 Bloxstrap/UI/Elements/Dialogs/BulkAddFastFlagDialog.xaml.cs diff --git a/Bloxstrap/UI/Elements/Dialogs/AddFastFlagDialog.xaml b/Bloxstrap/UI/Elements/Dialogs/AddFastFlagDialog.xaml index 06e7cc08..3a475280 100644 --- a/Bloxstrap/UI/Elements/Dialogs/AddFastFlagDialog.xaml +++ b/Bloxstrap/UI/Elements/Dialogs/AddFastFlagDialog.xaml @@ -33,10 +33,10 @@ - + - + diff --git a/Bloxstrap/UI/Elements/Dialogs/BulkAddFastFlagDialog.xaml b/Bloxstrap/UI/Elements/Dialogs/BulkAddFastFlagDialog.xaml new file mode 100644 index 00000000..4cef49fb --- /dev/null +++ b/Bloxstrap/UI/Elements/Dialogs/BulkAddFastFlagDialog.xaml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + Paste in your JSON here... + + + + + + +