From f742d4b45bb316682a50df0c36d0892e08803b4f Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Mon, 13 May 2024 00:02:42 +0100 Subject: [PATCH] strip down channel functions to stock behaviour --- Bloxstrap/App.xaml.cs | 27 ++-- Bloxstrap/Bootstrapper.cs | 21 +-- Bloxstrap/Enums/ChannelChangeMode.cs | 9 -- Bloxstrap/Models/Settings.cs | 1 - Bloxstrap/ProtocolHandler.cs | 26 ++-- .../UI/Elements/Menu/Pages/BehaviourPage.xaml | 125 ------------------ .../UI/ViewModels/Menu/BehaviourViewModel.cs | 89 ------------- 7 files changed, 27 insertions(+), 271 deletions(-) delete mode 100644 Bloxstrap/Enums/ChannelChangeMode.cs diff --git a/Bloxstrap/App.xaml.cs b/Bloxstrap/App.xaml.cs index 2a42aa2..d7ce739 100644 --- a/Bloxstrap/App.xaml.cs +++ b/Bloxstrap/App.xaml.cs @@ -126,6 +126,22 @@ namespace Bloxstrap // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); + using (var checker = new InstallChecker()) + { + checker.Check(); + } + + Paths.Initialize(BaseDirectory); + + // we shouldn't save settings on the first run until the first installation is finished, + // just in case the user decides to cancel the install + if (!IsFirstRun) + { + Settings.Load(); + State.Load(); + FastFlags.Load(); + } + LaunchSettings = new LaunchSettings(e.Args); HttpClient.Timeout = TimeSpan.FromSeconds(30); @@ -134,13 +150,6 @@ namespace Bloxstrap // TEMPORARY FILL-IN FOR NEW FUNCTIONALITY // REMOVE WHEN LARGER REFACTORING IS DONE await RobloxDeployment.InitializeConnectivity(); - - using (var checker = new InstallChecker()) - { - checker.Check(); - } - - Paths.Initialize(BaseDirectory); // disallow running as administrator except for uninstallation if (Utilities.IsAdministrator && !LaunchSettings.IsUninstall) @@ -168,10 +177,6 @@ namespace Bloxstrap Logger.WriteLine(LOG_IDENT, "Possible duplicate launch detected, terminating."); Terminate(); } - - Settings.Load(); - State.Load(); - FastFlags.Load(); } if (!LaunchSettings.IsUninstall && !LaunchSettings.IsMenuLaunch) diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index 615196e..c328e5b 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -257,25 +257,10 @@ namespace Bloxstrap if (clientVersion.IsBehindDefaultChannel) { - MessageBoxResult action = App.Settings.Prop.ChannelChangeMode switch - { - ChannelChangeMode.Prompt => Frontend.ShowMessageBox( - string.Format(Resources.Strings.Bootstrapper_ChannelOutOfDate, App.Settings.Prop.Channel, RobloxDeployment.DefaultChannel), - MessageBoxImage.Warning, - MessageBoxButton.YesNo - ), - ChannelChangeMode.Automatic => MessageBoxResult.Yes, - ChannelChangeMode.Ignore => MessageBoxResult.No, - _ => MessageBoxResult.None - }; + App.Logger.WriteLine(LOG_IDENT, $"Changed Roblox channel from {App.Settings.Prop.Channel} to {RobloxDeployment.DefaultChannel}"); - if (action == MessageBoxResult.Yes) - { - App.Logger.WriteLine("Bootstrapper::CheckLatestVersion", $"Changed Roblox channel from {App.Settings.Prop.Channel} to {RobloxDeployment.DefaultChannel}"); - - App.Settings.Prop.Channel = RobloxDeployment.DefaultChannel; - clientVersion = await RobloxDeployment.GetInfo(App.Settings.Prop.Channel, binaryType: binaryType); - } + App.Settings.Prop.Channel = RobloxDeployment.DefaultChannel; + clientVersion = await RobloxDeployment.GetInfo(App.Settings.Prop.Channel, binaryType: binaryType); } _latestVersionGuid = clientVersion.VersionGuid; diff --git a/Bloxstrap/Enums/ChannelChangeMode.cs b/Bloxstrap/Enums/ChannelChangeMode.cs deleted file mode 100644 index 3dc7668..0000000 --- a/Bloxstrap/Enums/ChannelChangeMode.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Bloxstrap.Enums -{ - public enum ChannelChangeMode - { - Automatic, - Prompt, - Ignore - } -} diff --git a/Bloxstrap/Models/Settings.cs b/Bloxstrap/Models/Settings.cs index 416d17c..0bb535f 100644 --- a/Bloxstrap/Models/Settings.cs +++ b/Bloxstrap/Models/Settings.cs @@ -20,7 +20,6 @@ namespace Bloxstrap.Models // channel configuration public string Channel { get; set; } = RobloxDeployment.DefaultChannel; - public ChannelChangeMode ChannelChangeMode { get; set; } = ChannelChangeMode.Automatic; // integration configuration public bool EnableActivityTracking { get; set; } = true; diff --git a/Bloxstrap/ProtocolHandler.cs b/Bloxstrap/ProtocolHandler.cs index d1f78a7..9d5d66f 100644 --- a/Bloxstrap/ProtocolHandler.cs +++ b/Bloxstrap/ProtocolHandler.cs @@ -51,26 +51,16 @@ namespace Bloxstrap if (channel.ToLowerInvariant() == App.Settings.Prop.Channel.ToLowerInvariant()) return; - if (App.Settings.Prop.ChannelChangeMode == ChannelChangeMode.Ignore) - return; - - if (App.Settings.Prop.ChannelChangeMode != ChannelChangeMode.Automatic) + // don't change if roblox is already running + if (Process.GetProcessesByName("RobloxPlayerBeta").Any()) { - if (channel == App.State.Prop.LastEnrolledChannel) - return; - - MessageBoxResult result = Frontend.ShowMessageBox( - string.Format(Resources.Strings.ProtocolHandler_RobloxSwitchedChannel, channel, App.Settings.Prop.Channel), - MessageBoxImage.Question, - MessageBoxButton.YesNo - ); - - if (result != MessageBoxResult.Yes) - return; + App.Logger.WriteLine("ProtocolHandler::ChangeChannel", $"Ignored channel change from {App.Settings.Prop.Channel} to {channel} because Roblox is already running"); + } + else + { + App.Logger.WriteLine("ProtocolHandler::ChangeChannel", $"Changed Roblox channel from {App.Settings.Prop.Channel} to {channel}"); + App.Settings.Prop.Channel = channel; } - - App.Logger.WriteLine("Protocol::ParseUri", $"Changed Roblox channel from {App.Settings.Prop.Channel} to {channel}"); - App.Settings.Prop.Channel = channel; } public static void EnrollChannel(string channel) diff --git a/Bloxstrap/UI/Elements/Menu/Pages/BehaviourPage.xaml b/Bloxstrap/UI/Elements/Menu/Pages/BehaviourPage.xaml index 53c0ae1..e9dcca8 100644 --- a/Bloxstrap/UI/Elements/Menu/Pages/BehaviourPage.xaml +++ b/Bloxstrap/UI/Elements/Menu/Pages/BehaviourPage.xaml @@ -29,131 +29,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Bloxstrap/UI/ViewModels/Menu/BehaviourViewModel.cs b/Bloxstrap/UI/ViewModels/Menu/BehaviourViewModel.cs index 4e5fda0..77040f2 100644 --- a/Bloxstrap/UI/ViewModels/Menu/BehaviourViewModel.cs +++ b/Bloxstrap/UI/ViewModels/Menu/BehaviourViewModel.cs @@ -5,71 +5,6 @@ private string _oldPlayerVersionGuid = ""; private string _oldStudioVersionGuid = ""; - public BehaviourViewModel() - { - Task.Run(() => LoadChannelDeployInfo(App.Settings.Prop.Channel)); - } - - private async Task LoadChannelDeployInfo(string channel) - { - const string LOG_IDENT = "BehaviourViewModel::LoadChannelDeployInfo"; - - ShowLoadingError = false; - OnPropertyChanged(nameof(ShowLoadingError)); - - ChannelInfoLoadingText = Resources.Strings.Menu_Behaviour_Channel_Fetching; - OnPropertyChanged(nameof(ChannelInfoLoadingText)); - - ChannelDeployInfo = null; - OnPropertyChanged(nameof(ChannelDeployInfo)); - - try - { - ClientVersion info = await RobloxDeployment.GetInfo(channel, true); - - ShowChannelWarning = info.IsBehindDefaultChannel; - OnPropertyChanged(nameof(ShowChannelWarning)); - - ChannelDeployInfo = new DeployInfo - { - Version = info.Version, - VersionGuid = info.VersionGuid, - Timestamp = info.Timestamp?.ToFriendlyString()! - }; - - OnPropertyChanged(nameof(ChannelDeployInfo)); - } - catch (HttpResponseException ex) - { - ShowLoadingError = true; - OnPropertyChanged(nameof(ShowLoadingError)); - - ChannelInfoLoadingText = ex.ResponseMessage.StatusCode switch - { - HttpStatusCode.NotFound => Resources.Strings.Menu_Behaviour_Channel_DoesNotExist, - _ => $"{Resources.Strings.Menu_Behaviour_Channel_FetchFailed} (HTTP {(int)ex.ResponseMessage.StatusCode} - {ex.ResponseMessage.ReasonPhrase})", - }; - OnPropertyChanged(nameof(ChannelInfoLoadingText)); - } - catch (Exception ex) - { - App.Logger.WriteLine(LOG_IDENT, "An exception occurred while fetching channel information"); - App.Logger.WriteException(LOG_IDENT, ex); - - ShowLoadingError = true; - OnPropertyChanged(nameof(ShowLoadingError)); - - ChannelInfoLoadingText = $"{Resources.Strings.Menu_Behaviour_Channel_FetchFailed} ({ex.Message})"; - OnPropertyChanged(nameof(ChannelInfoLoadingText)); - } - } - - public bool ShowLoadingError { get; set; } = false; - public bool ShowChannelWarning { get; set; } = false; - - public DeployInfo? ChannelDeployInfo { get; private set; } = null; - public string ChannelInfoLoadingText { get; private set; } = null!; - public bool CreateDesktopIcon { get => App.Settings.Prop.CreateDesktopIcon; @@ -82,30 +17,6 @@ set => App.Settings.Prop.CheckForUpdates = value; } - public string SelectedChannel - { - get => App.Settings.Prop.Channel; - set - { - value = value.Trim(); - Task.Run(() => LoadChannelDeployInfo(value)); - App.Settings.Prop.Channel = value; - } - } - - public IReadOnlyCollection ChannelChangeModes => new ChannelChangeMode[] - { - ChannelChangeMode.Automatic, - ChannelChangeMode.Prompt, - ChannelChangeMode.Ignore, - }; - - public ChannelChangeMode SelectedChannelChangeMode - { - get => App.Settings.Prop.ChannelChangeMode; - set => App.Settings.Prop.ChannelChangeMode = value; - } - public bool ForceRobloxReinstallation { // wouldnt it be better to check old version guids?