Add more options for channel change behaviour

This commit is contained in:
pizzaboxer 2023-04-30 00:59:23 +01:00
parent b82241bbd3
commit 93694a5ff4
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8
6 changed files with 40 additions and 15 deletions

View File

@ -13,6 +13,7 @@ using System.Windows;
using Microsoft.Win32; using Microsoft.Win32;
using Bloxstrap.Dialogs; using Bloxstrap.Dialogs;
using Bloxstrap.Enums;
using Bloxstrap.Integrations; using Bloxstrap.Integrations;
using Bloxstrap.Models; using Bloxstrap.Models;
using Bloxstrap.Tools; using Bloxstrap.Tools;
@ -225,7 +226,7 @@ namespace Bloxstrap
ClientVersion clientVersion = await Deployment.GetInfo(App.Settings.Prop.Channel); ClientVersion clientVersion = await Deployment.GetInfo(App.Settings.Prop.Channel);
// briefly check if current channel is suitable to use // 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; string? switchDefaultPrompt = null;
ClientVersion? defaultChannelInfo = null; ClientVersion? defaultChannelInfo = null;
@ -253,7 +254,7 @@ namespace Bloxstrap
if (!String.IsNullOrEmpty(switchDefaultPrompt)) 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) if (result == MessageBoxResult.Yes)
{ {

View File

@ -0,0 +1,9 @@
namespace Bloxstrap.Enums
{
public enum ChannelChangeMode
{
Automatic,
Prompt,
Ignore
}
}

View File

@ -18,7 +18,7 @@ namespace Bloxstrap.Models
// channel configuration // channel configuration
public string Channel { get; set; } = Deployment.DefaultChannel; public string Channel { get; set; } = Deployment.DefaultChannel;
public bool PromptChannelChange { get; set; } = false; public ChannelChangeMode ChannelChangeMode { get; set; } = ChannelChangeMode.Automatic;
// integration configuration // integration configuration
public bool UseDiscordRichPresence { get; set; } = true; public bool UseDiscordRichPresence { get; set; } = true;

View File

@ -6,6 +6,8 @@ using System.Windows;
using Microsoft.Win32; using Microsoft.Win32;
using Bloxstrap.Enums;
namespace Bloxstrap namespace Bloxstrap
{ {
static class ProtocolHandler static class ProtocolHandler
@ -55,9 +57,9 @@ namespace Bloxstrap
if (key == "channel") 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" + $"{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}?", $"Would you like to switch channels from {App.Settings.Prop.Channel} to {val}?",
MessageBoxImage.Question, MessageBoxImage.Question,

View File

@ -1,4 +1,9 @@
namespace Bloxstrap.ViewModels using System.Collections.Generic;
using System.Linq;
using Bloxstrap.Enums;
namespace Bloxstrap.ViewModels
{ {
public class BehaviourViewModel public class BehaviourViewModel
{ {
@ -14,16 +19,24 @@
set => App.Settings.Prop.CheckForUpdates = value; set => App.Settings.Prop.CheckForUpdates = value;
} }
public bool ChannelChangePromptingEnabled
{
get => App.Settings.Prop.PromptChannelChange;
set => App.Settings.Prop.PromptChannelChange = value;
}
public bool MultiInstanceLaunchingEnabled public bool MultiInstanceLaunchingEnabled
{ {
get => App.Settings.Prop.MultiInstanceLaunching; get => App.Settings.Prop.MultiInstanceLaunching;
set => App.Settings.Prop.MultiInstanceLaunching = value; set => App.Settings.Prop.MultiInstanceLaunching = value;
} }
// todo - move to enum attributes?
public IReadOnlyDictionary<string, ChannelChangeMode> ChannelChangeModes => new Dictionary<string, ChannelChangeMode>
{
{ "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];
}
} }
} }

View File

@ -43,11 +43,11 @@
<ui:CardControl Margin="0,8,0,0" Padding="16,13,16,12"> <ui:CardControl Margin="0,8,0,0" Padding="16,13,16,12">
<ui:CardControl.Header> <ui:CardControl.Header>
<StackPanel> <StackPanel>
<TextBlock FontSize="14" Text="Prompt on automatic channel change" /> <TextBlock FontSize="14" Text="Choose what to do on suggested channel change" />
<TextBlock Margin="0,2,0,0" FontSize="12" Text="Bloxstrap may automatically change your preferred release channel. Enabling will ask you before changing." Foreground="{DynamicResource TextFillColorTertiaryBrush}" /> <TextBlock Margin="0,2,0,0" FontSize="12" Text="Roblox or Bloxstrap may try to change your preferred release channel." Foreground="{DynamicResource TextFillColorTertiaryBrush}" />
</StackPanel> </StackPanel>
</ui:CardControl.Header> </ui:CardControl.Header>
<ui:ToggleSwitch IsChecked="{Binding ChannelChangePromptingEnabled, Mode=TwoWay}" /> <ComboBox Margin="5,0,0,0" Padding="10,5,10,5" Width="200" ItemsSource="{Binding ChannelChangeModes.Keys, Mode=OneTime}" Text="{Binding SelectedChannelChangeMode, Mode=TwoWay}" />
</ui:CardControl> </ui:CardControl>
</StackPanel> </StackPanel>
</ui:UiPage> </ui:UiPage>