diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index 6f88bae..30070b8 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -13,6 +13,7 @@ using System.Windows; using Microsoft.Win32; using Bloxstrap.Dialogs; +using Bloxstrap.Enums; using Bloxstrap.Integrations; using Bloxstrap.Models; using Bloxstrap.Tools; @@ -225,7 +226,7 @@ namespace Bloxstrap ClientVersion clientVersion = await Deployment.GetInfo(App.Settings.Prop.Channel); // briefly check if current channel is suitable to use - if (App.Settings.Prop.Channel.ToLower() != Deployment.DefaultChannel.ToLower()) + if (App.Settings.Prop.Channel.ToLower() != Deployment.DefaultChannel.ToLower() && App.Settings.Prop.ChannelChangeMode != ChannelChangeMode.Ignore) { string? switchDefaultPrompt = null; ClientVersion? defaultChannelInfo = null; @@ -253,7 +254,7 @@ namespace Bloxstrap if (!String.IsNullOrEmpty(switchDefaultPrompt)) { - MessageBoxResult result = !App.Settings.Prop.PromptChannelChange ? MessageBoxResult.Yes : App.ShowMessageBox(switchDefaultPrompt, MessageBoxImage.Question, MessageBoxButton.YesNo); + MessageBoxResult result = App.Settings.Prop.ChannelChangeMode == ChannelChangeMode.Automatic ? MessageBoxResult.Yes : App.ShowMessageBox(switchDefaultPrompt, MessageBoxImage.Question, MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { diff --git a/Bloxstrap/Enums/ChannelChangeMode.cs b/Bloxstrap/Enums/ChannelChangeMode.cs new file mode 100644 index 0000000..3dc7668 --- /dev/null +++ b/Bloxstrap/Enums/ChannelChangeMode.cs @@ -0,0 +1,9 @@ +namespace Bloxstrap.Enums +{ + public enum ChannelChangeMode + { + Automatic, + Prompt, + Ignore + } +} diff --git a/Bloxstrap/Models/Settings.cs b/Bloxstrap/Models/Settings.cs index 7d4b966..e231bb0 100644 --- a/Bloxstrap/Models/Settings.cs +++ b/Bloxstrap/Models/Settings.cs @@ -18,7 +18,7 @@ namespace Bloxstrap.Models // channel configuration public string Channel { get; set; } = Deployment.DefaultChannel; - public bool PromptChannelChange { get; set; } = false; + public ChannelChangeMode ChannelChangeMode { get; set; } = ChannelChangeMode.Automatic; // integration configuration public bool UseDiscordRichPresence { get; set; } = true; diff --git a/Bloxstrap/ProtocolHandler.cs b/Bloxstrap/ProtocolHandler.cs index 2d6fa2d..ffae5e5 100644 --- a/Bloxstrap/ProtocolHandler.cs +++ b/Bloxstrap/ProtocolHandler.cs @@ -6,6 +6,8 @@ using System.Windows; using Microsoft.Win32; +using Bloxstrap.Enums; + namespace Bloxstrap { static class ProtocolHandler @@ -55,9 +57,9 @@ namespace Bloxstrap if (key == "channel") { - if (val.ToLower() != App.Settings.Prop.Channel.ToLower()) + if (val.ToLower() != App.Settings.Prop.Channel.ToLower() && App.Settings.Prop.ChannelChangeMode != ChannelChangeMode.Ignore) { - MessageBoxResult result = !App.Settings.Prop.PromptChannelChange ? MessageBoxResult.Yes : App.ShowMessageBox( + MessageBoxResult result = App.Settings.Prop.ChannelChangeMode == ChannelChangeMode.Automatic ? MessageBoxResult.Yes : App.ShowMessageBox( $"{App.ProjectName} was launched with the Roblox build channel set to {val}, however your current preferred channel is {App.Settings.Prop.Channel}.\n\n" + $"Would you like to switch channels from {App.Settings.Prop.Channel} to {val}?", MessageBoxImage.Question, diff --git a/Bloxstrap/ViewModels/BehaviourViewModel.cs b/Bloxstrap/ViewModels/BehaviourViewModel.cs index 3c0c91c..be4812e 100644 --- a/Bloxstrap/ViewModels/BehaviourViewModel.cs +++ b/Bloxstrap/ViewModels/BehaviourViewModel.cs @@ -1,4 +1,9 @@ -namespace Bloxstrap.ViewModels +using System.Collections.Generic; +using System.Linq; + +using Bloxstrap.Enums; + +namespace Bloxstrap.ViewModels { public class BehaviourViewModel { @@ -14,16 +19,24 @@ set => App.Settings.Prop.CheckForUpdates = value; } - public bool ChannelChangePromptingEnabled - { - get => App.Settings.Prop.PromptChannelChange; - set => App.Settings.Prop.PromptChannelChange = value; - } - public bool MultiInstanceLaunchingEnabled { get => App.Settings.Prop.MultiInstanceLaunching; set => App.Settings.Prop.MultiInstanceLaunching = value; } + + // todo - move to enum attributes? + public IReadOnlyDictionary ChannelChangeModes => new Dictionary + { + { "Change automatically", ChannelChangeMode.Automatic }, + { "Always prompt", ChannelChangeMode.Prompt }, + { "Never change", ChannelChangeMode.Ignore }, + }; + + public string SelectedChannelChangeMode + { + get => ChannelChangeModes.FirstOrDefault(x => x.Value == App.Settings.Prop.ChannelChangeMode).Key; + set => App.Settings.Prop.ChannelChangeMode = ChannelChangeModes[value]; + } } } diff --git a/Bloxstrap/Views/Pages/BehaviourPage.xaml b/Bloxstrap/Views/Pages/BehaviourPage.xaml index 35ed8ff..0ed442b 100644 --- a/Bloxstrap/Views/Pages/BehaviourPage.xaml +++ b/Bloxstrap/Views/Pages/BehaviourPage.xaml @@ -43,11 +43,11 @@ - - + + - +