From 541a8bdc7391ccdecda99b5accc2f173dadb07c3 Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Wed, 23 Aug 2023 09:57:11 +0100 Subject: [PATCH 01/13] 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 d2f6a8a..8354ced 100644 --- a/Bloxstrap/UI/Elements/ContextMenu/MenuContainer.xaml.cs +++ b/Bloxstrap/UI/Elements/ContextMenu/MenuContainer.xaml.cs @@ -96,7 +96,7 @@ namespace Bloxstrap.UI.Elements.ContextMenu 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 7915ae4..c5cff3a 100644 --- a/Bloxstrap/UI/Elements/Dialogs/ExceptionDialog.xaml.cs +++ b/Bloxstrap/UI/Elements/Dialogs/ExceptionDialog.xaml.cs @@ -33,7 +33,7 @@ namespace Bloxstrap.UI.Elements.Dialogs 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 576d828..d6c477e 100644 --- a/Bloxstrap/UI/ViewModels/ContextMenu/ServerInformationViewModel.cs +++ b/Bloxstrap/UI/ViewModels/ContextMenu/ServerInformationViewModel.cs @@ -30,6 +30,6 @@ namespace Bloxstrap.UI.ViewModels.ContextMenu }); } - 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 02/13] 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 6eaadb6..aa1ab2b 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -121,7 +121,6 @@ namespace Bloxstrap try { await RobloxDeployment.GetInfo(RobloxDeployment.DefaultChannel); - App.Logger.WriteLine(LOG_IDENT, "Connectivity check finished"); } catch (Exception ex) { @@ -140,6 +139,10 @@ namespace Bloxstrap 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 @@ namespace Bloxstrap 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 03/13] 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 3e38a56..72d9c08 100644 --- a/Bloxstrap/FastFlagManager.cs +++ b/Bloxstrap/FastFlagManager.cs @@ -42,7 +42,12 @@ namespace Bloxstrap { "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 @@ namespace Bloxstrap new Dictionary { { "DisableV2", null }, - { "EnableV4", null } + { "EnableV4", null }, + { "ABTest", null } } }, @@ -90,7 +96,8 @@ namespace Bloxstrap new Dictionary { { "DisableV2", "True" }, - { "EnableV4", "False" } + { "EnableV4", "False" }, + { "ABTest", "False" } } }, @@ -99,7 +106,8 @@ namespace Bloxstrap new Dictionary { { "DisableV2", "False" }, - { "EnableV4", "False" } + { "EnableV4", "False" }, + { "ABTest", "False" } } }, @@ -108,7 +116,8 @@ namespace Bloxstrap new Dictionary { { "DisableV2", "True" }, - { "EnableV4", "True" } + { "EnableV4", "True" }, + { "ABTest", "False" } } } }; diff --git a/Bloxstrap/InstallChecker.cs b/Bloxstrap/InstallChecker.cs index a833acb..7e4bb09 100644 --- a/Bloxstrap/InstallChecker.cs +++ b/Bloxstrap/InstallChecker.cs @@ -223,6 +223,10 @@ namespace Bloxstrap 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 8b95d0c..8dee2e5 100644 --- a/Bloxstrap/UI/ViewModels/Menu/FastFlagsViewModel.cs +++ b/Bloxstrap/UI/ViewModels/Menu/FastFlagsViewModel.cs @@ -101,8 +101,11 @@ namespace Bloxstrap.UI.ViewModels.Menu 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 04/13] 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 598812c..cdeda88 100644 --- a/Bloxstrap/RobloxDeployment.cs +++ b/Bloxstrap/RobloxDeployment.cs @@ -52,18 +52,6 @@ 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 1e4b4aa..68bdc7b 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 da81ace..28c4bc7 100644 --- a/Bloxstrap/UI/ViewModels/Menu/BehaviourViewModel.cs +++ b/Bloxstrap/UI/ViewModels/Menu/BehaviourViewModel.cs @@ -81,18 +81,12 @@ 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 05/13] 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 5d74c73..ab920d1 100644 --- a/Bloxstrap/Integrations/DiscordRichPresence.cs +++ b/Bloxstrap/Integrations/DiscordRichPresence.cs @@ -261,6 +261,9 @@ namespace Bloxstrap.Integrations _ => $"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 06/13] 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 aa1ab2b..35b66b2 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -1041,6 +1041,12 @@ namespace Bloxstrap { 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 07/13] 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 bc868bd..f8108ab 100644 --- a/Bloxstrap/UI/ViewModels/Menu/MainWindowViewModel.cs +++ b/Bloxstrap/UI/ViewModels/Menu/MainWindowViewModel.cs @@ -87,6 +87,22 @@ namespace Bloxstrap.UI.ViewModels.Menu 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 08/13] 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 35b66b2..34a4b75 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -178,8 +178,6 @@ namespace Bloxstrap 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 @@ namespace Bloxstrap 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 @@ namespace Bloxstrap // 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 @@ namespace Bloxstrap 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 73260ad..6fee20e 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 989fa65..968dabf 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 68de8d7..1a7631d 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.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/Elements/Menu/Pages/InstallationPage.xaml b/Bloxstrap/UI/Elements/Menu/Pages/InstallationPage.xaml index 7f28503..3c34ffc 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 b58ea4a..a46ae0e 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 f8108ab..0e520ec 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 @@ namespace Bloxstrap.UI.ViewModels.Menu 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 @@ namespace Bloxstrap.UI.ViewModels.Menu 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)); + ConfirmButtonEnabled = false; + OnPropertyChanged(nameof(ConfirmButtonEnabled)); - Task.Run(async delegate - { - await Task.Delay(3000); - - 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 09/13] 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 | 87 ++++++++++--------- 4 files changed, 144 insertions(+), 42 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 06e7cc0..3a47528 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 0000000..4cef49f --- /dev/null +++ b/Bloxstrap/UI/Elements/Dialogs/BulkAddFastFlagDialog.xaml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + Paste in your JSON here... + + + + + + +