diff --git a/Daybreak/Configuration/ApplicationConfiguration.cs b/Daybreak/Configuration/ApplicationConfiguration.cs index 7999a778..d4dbc7de 100644 --- a/Daybreak/Configuration/ApplicationConfiguration.cs +++ b/Daybreak/Configuration/ApplicationConfiguration.cs @@ -6,6 +6,8 @@ namespace Daybreak.Configuration { public sealed class ApplicationConfiguration { + [JsonProperty("BrowsersEnabled")] + public bool BrowsersEnabled { get; set; } = true; [JsonProperty("ToolboxPath")] public string ToolboxPath { get; set; } [JsonProperty("TexmodPath")] diff --git a/Daybreak/Controls/ChromiumBrowserWrapper.xaml.cs b/Daybreak/Controls/ChromiumBrowserWrapper.xaml.cs index ceca0c1e..b3e453f2 100644 --- a/Daybreak/Controls/ChromiumBrowserWrapper.xaml.cs +++ b/Daybreak/Controls/ChromiumBrowserWrapper.xaml.cs @@ -23,6 +23,7 @@ public partial class ChromiumBrowserWrapper : UserControl public readonly static DependencyProperty AddressProperty = DependencyPropertyExtensions.Register(nameof(Address)); public readonly static DependencyProperty FavoriteAddressProperty = DependencyPropertyExtensions.Register(nameof(FavoriteAddress)); public readonly static DependencyProperty NavigatingProperty = DependencyPropertyExtensions.Register(nameof(Navigating)); + public readonly static DependencyProperty BrowserEnabledProperty = DependencyPropertyExtensions.Register(nameof(BrowserEnabled)); public readonly static DependencyProperty AddressBarReadonlyProperty = DependencyPropertyExtensions.Register(nameof(AddressBarReadonly)); public readonly static DependencyProperty BrowserSupportedProperty = DependencyPropertyExtensions.Register(nameof(BrowserSupported), new PropertyMetadata(true)); @@ -53,6 +54,11 @@ public bool AddressBarReadonly get => this.GetTypedValue(AddressBarReadonlyProperty); private set => this.SetTypedValue(AddressBarReadonlyProperty, value); } + public bool BrowserEnabled + { + get => this.GetTypedValue(BrowserEnabledProperty); + private set => this.SetTypedValue(BrowserEnabledProperty, value); + } public bool BrowserSupported { get => this.GetTypedValue(BrowserSupportedProperty); @@ -77,13 +83,19 @@ protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e) } } - public void ReinitializeBrowser() + public async void ReinitializeBrowser() { - this.InitializeBrowser(); + await this.InitializeBrowser(); } private void InitializeEnvironment() { + if (this.configurationManager.GetConfiguration().BrowsersEnabled is false) + { + this.BrowserSupported = false; + return; + } + try { this.coreWebView2Environment = System.Extensions.TaskExtensions.RunSync(() => CoreWebView2Environment.CreateAsync(null, "BrowserData", null)); diff --git a/Daybreak/Daybreak.csproj b/Daybreak/Daybreak.csproj index ac26357f..279d1a48 100644 --- a/Daybreak/Daybreak.csproj +++ b/Daybreak/Daybreak.csproj @@ -9,7 +9,7 @@ false preview Daybreak.ico - 0.6.3 + 0.6.4 app.manifest diff --git a/Daybreak/Views/MainView.xaml b/Daybreak/Views/MainView.xaml index f01405e0..d7f7170b 100644 --- a/Daybreak/Views/MainView.xaml +++ b/Daybreak/Views/MainView.xaml @@ -36,13 +36,13 @@ Foreground="White" FontSize="24" Width="200" Height="40" Margin="0, 10, 0, 10" IsEnabled="{Binding ElementName=_this, Path=LaunchTexmodButtonEnabled, Mode=OneWay}" Clicked="LaunchTexmodButton_Clicked" Grid.Row="1" Grid.ColumnSpan="2" Grid.Column="1"> - + - + (nameof(LaunchToolboxButtonEnabled)); public static readonly DependencyProperty LaunchTexmodButtonEnabledProperty = DependencyPropertyExtensions.Register(nameof(LaunchTexmodButtonEnabled)); + public static readonly DependencyProperty BrowsersEnabledProperty = + DependencyPropertyExtensions.Register(nameof(BrowsersEnabled), new PropertyMetadata(true)); public static readonly DependencyProperty RightBrowserAddressProperty = DependencyPropertyExtensions.Register(nameof(RightBrowserAddress)); public static readonly DependencyProperty LeftBrowserAddressProperty = @@ -76,6 +78,11 @@ public bool LaunchTexmodButtonEnabled get => this.GetTypedValue(LaunchTexmodButtonEnabledProperty); set => this.SetTypedValue(LaunchTexmodButtonEnabledProperty, value); } + public bool BrowsersEnabled + { + get => this.GetTypedValue(BrowsersEnabledProperty); + set => this.SetTypedValue(BrowsersEnabledProperty, value); + } public MainView( IApplicationLauncher applicationDetector, @@ -93,10 +100,17 @@ public MainView( private void NavigateToDefaults() { var applicationConfiguration = this.configurationManager.GetConfiguration(); - this.LeftBrowserFavoriteAddress = applicationConfiguration.LeftBrowserDefault; - this.RightBrowserFavoriteAddress = applicationConfiguration.RightBrowserDefault; - this.LeftBrowserAddress = applicationConfiguration.LeftBrowserDefault; - this.RightBrowserAddress = applicationConfiguration.RightBrowserDefault; + if (applicationConfiguration.BrowsersEnabled) + { + this.LeftBrowserFavoriteAddress = applicationConfiguration.LeftBrowserDefault; + this.RightBrowserFavoriteAddress = applicationConfiguration.RightBrowserDefault; + this.LeftBrowserAddress = applicationConfiguration.LeftBrowserDefault; + this.RightBrowserAddress = applicationConfiguration.RightBrowserDefault; + } + else + { + this.BrowsersEnabled = false; + } } private void PeriodicallyCheckGameState() diff --git a/Daybreak/Views/SettingsView.xaml b/Daybreak/Views/SettingsView.xaml index fa0a8e44..58dc47c5 100644 --- a/Daybreak/Views/SettingsView.xaml +++ b/Daybreak/Views/SettingsView.xaml @@ -84,7 +84,8 @@ - + + @@ -106,9 +107,11 @@ Clicked="ToolboxFilePickerGlyph_Clicked"> + FontSize="22" Foreground="White" IsChecked="{Binding ElementName=_this, Path=ToolboxAutoLaunch, Mode=TwoWay}"> + FontSize="22" Foreground="White" IsChecked="{Binding ElementName=_this, Path=BrowsersEnabled, Mode=TwoWay}"> + (nameof(ToolboxPath)); public static readonly DependencyProperty AddressBarReadonlyProperty = DependencyPropertyExtensions.Register(nameof(AddressBarReadonly)); + public static readonly DependencyProperty BrowsersEnabledProperty = + DependencyPropertyExtensions.Register(nameof(BrowsersEnabled)); public static readonly DependencyProperty LeftBrowserUrlProperty = DependencyPropertyExtensions.Register(nameof(LeftBrowserUrl)); public static readonly DependencyProperty RightBrowserUrlProperty = @@ -60,6 +62,11 @@ public string RightBrowserUrl get => this.GetTypedValue(RightBrowserUrlProperty); set => this.SetValue(RightBrowserUrlProperty, value); } + public bool BrowsersEnabled + { + get => this.GetTypedValue(BrowsersEnabledProperty); + set => this.SetValue(BrowsersEnabledProperty, value); + } public SettingsView( IConfigurationManager configurationManager, @@ -80,6 +87,7 @@ private void LoadSettings() this.RightBrowserUrl = config.RightBrowserDefault; this.ToolboxAutoLaunch = config.ToolboxAutoLaunch; this.TexmodPath = config.TexmodPath; + this.BrowsersEnabled = config.BrowsersEnabled; } private void SaveButton_Clicked(object sender, EventArgs e) @@ -91,6 +99,7 @@ private void SaveButton_Clicked(object sender, EventArgs e) currentConfig.RightBrowserDefault = this.RightBrowserUrl; currentConfig.ToolboxAutoLaunch = this.ToolboxAutoLaunch; currentConfig.TexmodPath = this.TexmodPath; + currentConfig.BrowsersEnabled = this.BrowsersEnabled; this.configurationManager.SaveConfiguration(currentConfig); this.viewManager.ShowView(); }