From f564e409ba5cbf0f66eb0e27a56a6e22b838c34f Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Thu, 26 Oct 2023 22:37:42 +0100 Subject: [PATCH] Rework Appearance tab of menu (and other things) --- Bloxstrap/Extensions/BootstrapperIconEx.cs | 18 ++++-- Bloxstrap/Models/BootstrapperIconEntry.cs | 11 ++++ Bloxstrap/Resources/Strings.Designer.cs | 62 ++++++++++++------- Bloxstrap/Resources/Strings.resx | 26 +++++--- .../UI/Elements/Controls/MarkdownTextBlock.cs | 29 +++------ .../UI/Elements/Controls/OptionControl.xaml | 12 +++- .../Elements/Dialogs/ExceptionDialog.xaml.cs | 4 +- Bloxstrap/UI/Elements/Menu/MainWindow.xaml.cs | 4 -- .../Elements/Menu/Pages/AppearancePage.xaml | 57 +++++++++-------- .../UI/Elements/Menu/Pages/FastFlagsPage.xaml | 2 +- .../Elements/Menu/Pages/IntegrationsPage.xaml | 4 +- .../UI/ViewModels/Menu/AppearanceViewModel.cs | 58 ++++++----------- 12 files changed, 155 insertions(+), 132 deletions(-) create mode 100644 Bloxstrap/Models/BootstrapperIconEntry.cs diff --git a/Bloxstrap/Extensions/BootstrapperIconEx.cs b/Bloxstrap/Extensions/BootstrapperIconEx.cs index 49df969..6e8ceec 100644 --- a/Bloxstrap/Extensions/BootstrapperIconEx.cs +++ b/Bloxstrap/Extensions/BootstrapperIconEx.cs @@ -16,15 +16,23 @@ namespace Bloxstrap.Extensions if (icon == BootstrapperIcon.IconCustom) { Icon? customIcon = null; + string location = App.Settings.Prop.BootstrapperIconCustomLocation; - try + if (String.IsNullOrEmpty(location)) { - customIcon = new Icon(App.Settings.Prop.BootstrapperIconCustomLocation); + App.Logger.WriteLine(LOG_IDENT, "Warning: custom icon is not set."); } - catch (Exception ex) + else { - App.Logger.WriteLine(LOG_IDENT, $"Failed to load custom icon!"); - App.Logger.WriteException(LOG_IDENT, ex); + try + { + customIcon = new Icon(location); + } + catch (Exception ex) + { + App.Logger.WriteLine(LOG_IDENT, $"Failed to load custom icon!"); + App.Logger.WriteException(LOG_IDENT, ex); + } } return customIcon ?? Properties.Resources.IconBloxstrap; diff --git a/Bloxstrap/Models/BootstrapperIconEntry.cs b/Bloxstrap/Models/BootstrapperIconEntry.cs new file mode 100644 index 0000000..009cba3 --- /dev/null +++ b/Bloxstrap/Models/BootstrapperIconEntry.cs @@ -0,0 +1,11 @@ +using System.Windows.Media; + +namespace Bloxstrap.Models +{ + public class BootstrapperIconEntry + { + public BootstrapperIcon IconType { get; set; } + public string Name => IconType.ToString(); + public ImageSource ImageSource => IconType.GetIcon().GetImageSource(); + } +} diff --git a/Bloxstrap/Resources/Strings.Designer.cs b/Bloxstrap/Resources/Strings.Designer.cs index 524b783..b5fe355 100644 --- a/Bloxstrap/Resources/Strings.Designer.cs +++ b/Bloxstrap/Resources/Strings.Designer.cs @@ -1435,7 +1435,25 @@ namespace Bloxstrap.Resources { } /// - /// Looks up a localized string similar to Configure other customisable Bootstrapper options.. + /// Looks up a localized string similar to You can make it look different, retro, or even just like Roblox.. + /// + public static string Menu_Appearance_Bootstrapper_Description { + get { + return ResourceManager.GetString("Menu.Appearance.Bootstrapper.Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Bootstrapper. + /// + public static string Menu_Appearance_Bootstrapper_Title { + get { + return ResourceManager.GetString("Menu.Appearance.Bootstrapper.Title", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Configure other miscellaneous customisable options.. /// public static string Menu_Appearance_Customisation_Description { get { @@ -1444,7 +1462,7 @@ namespace Bloxstrap.Resources { } /// - /// Looks up a localized string similar to Bootstrapper customisation. + /// Looks up a localized string similar to Customisation. /// public static string Menu_Appearance_Customisation_Title { get { @@ -1498,7 +1516,25 @@ namespace Bloxstrap.Resources { } /// - /// Looks up a localized string similar to Choose what icon the bootstrapper should use.. + /// Looks up a localized string similar to Dark theme does not apply to Legacy or Vista styles.. + /// + public static string Menu_Appearance_Global_Theme_Description { + get { + return ResourceManager.GetString("Menu.Appearance.Global.Theme.Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Global Theme. + /// + public static string Menu_Appearance_Global_Theme_Title { + get { + return ResourceManager.GetString("Menu.Appearance.Global.Theme.Title", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Choose what icon it should use.. /// public static string Menu_Appearance_Icon_Description { get { @@ -1525,7 +1561,7 @@ namespace Bloxstrap.Resources { } /// - /// Looks up a localized string similar to Choose how the bootstrapper should look.. + /// Looks up a localized string similar to Choose how it should look. Dark theme does not apply to Legacy/Vista.. /// public static string Menu_Appearance_Style_Description { get { @@ -1542,24 +1578,6 @@ namespace Bloxstrap.Resources { } } - /// - /// Looks up a localized string similar to Dark theme does not apply to Legacy or Vista styles.. - /// - public static string Menu_Appearance_Theme_Description { - get { - return ResourceManager.GetString("Menu.Appearance.Theme.Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Theme. - /// - public static string Menu_Appearance_Theme_Title { - get { - return ResourceManager.GetString("Menu.Appearance.Theme.Title", resourceCulture); - } - } - /// /// Looks up a localized string similar to Appearance. /// diff --git a/Bloxstrap/Resources/Strings.resx b/Bloxstrap/Resources/Strings.resx index 87592c8..18b03f3 100644 --- a/Bloxstrap/Resources/Strings.resx +++ b/Bloxstrap/Resources/Strings.resx @@ -579,11 +579,17 @@ Would you like to upgrade your currently installed version? Bloxstrap is currently running, likely as a background Roblox process. Please note that not all your changes will immediately apply until you close all currently open Roblox instances." + + You can make it look different, retro, or even just like Roblox. + + + Bootstrapper + - Configure other customisable Bootstrapper options. + Configure other miscellaneous customisable options. - Bootstrapper customisation + Customisation Must be a multi-size .ico file with sizes 16px to 128px. Set Icon as 'Custom' to use it. @@ -600,8 +606,14 @@ Would you like to upgrade your currently installed version? Configure how Bloxstrap should look. + + Dark theme does not apply to Legacy or Vista styles. + + + Global Theme + - Choose what icon the bootstrapper should use. + Choose what icon it should use. Icon @@ -610,17 +622,11 @@ Would you like to upgrade your currently installed version? Preview - Choose how the bootstrapper should look. + Choose how it should look. Dark theme does not apply to Legacy/Vista. Style - - Dark theme does not apply to Legacy or Vista styles. - - - Theme - Appearance diff --git a/Bloxstrap/UI/Elements/Controls/MarkdownTextBlock.cs b/Bloxstrap/UI/Elements/Controls/MarkdownTextBlock.cs index dc3359b..6e1e0d7 100644 --- a/Bloxstrap/UI/Elements/Controls/MarkdownTextBlock.cs +++ b/Bloxstrap/UI/Elements/Controls/MarkdownTextBlock.cs @@ -17,23 +17,9 @@ namespace Bloxstrap.UI.Elements.Controls [Localizability(LocalizationCategory.Text)] class MarkdownTextBlock : TextBlock { - public static readonly DependencyProperty MarkdownTextProperty = DependencyProperty.Register( - "MarkdownText", - typeof(string), - typeof(MarkdownTextBlock), - new FrameworkPropertyMetadata( - string.Empty, - FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender, - OnTextMarkdownChanged)); - - public MarkdownTextBlock(string markdownText) - { - MarkdownText = markdownText; - } - - public MarkdownTextBlock() - { - } + public static readonly DependencyProperty MarkdownTextProperty = + DependencyProperty.Register(nameof(MarkdownText), typeof(string), typeof(MarkdownTextBlock), + new FrameworkPropertyMetadata(string.Empty,FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender, OnTextMarkdownChanged)); [Localizability(LocalizationCategory.Text)] public string MarkdownText @@ -44,12 +30,13 @@ namespace Bloxstrap.UI.Elements.Controls private static void OnTextMarkdownChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs) { - var markdownTextBlock = dependencyObject as MarkdownTextBlock; - - if (markdownTextBlock == null) + if (dependencyObject is not MarkdownTextBlock markdownTextBlock) return; - MarkdownDocument document = Markdown.Parse((string)dependencyPropertyChangedEventArgs.NewValue); + if (dependencyPropertyChangedEventArgs.NewValue is not string rawDocument) + return; + + MarkdownDocument document = Markdown.Parse(rawDocument); markdownTextBlock.Inlines.Clear(); diff --git a/Bloxstrap/UI/Elements/Controls/OptionControl.xaml b/Bloxstrap/UI/Elements/Controls/OptionControl.xaml index e2d7213..86919ee 100644 --- a/Bloxstrap/UI/Elements/Controls/OptionControl.xaml +++ b/Bloxstrap/UI/Elements/Controls/OptionControl.xaml @@ -48,7 +48,17 @@ - + + + + + diff --git a/Bloxstrap/UI/Elements/Dialogs/ExceptionDialog.xaml.cs b/Bloxstrap/UI/Elements/Dialogs/ExceptionDialog.xaml.cs index 7cf90e6..3d8c372 100644 --- a/Bloxstrap/UI/Elements/Dialogs/ExceptionDialog.xaml.cs +++ b/Bloxstrap/UI/Elements/Dialogs/ExceptionDialog.xaml.cs @@ -37,9 +37,7 @@ namespace Bloxstrap.UI.Elements.Dialogs ReportOptions.DropDownClosed += (sender, e) => { - ComboBoxItem? comboBoxItem = ReportOptions.SelectedItem as ComboBoxItem; - - if (comboBoxItem is null) + if (ReportOptions.SelectedItem is not ComboBoxItem comboBoxItem) return; ReportOptions.SelectedIndex = 0; diff --git a/Bloxstrap/UI/Elements/Menu/MainWindow.xaml.cs b/Bloxstrap/UI/Elements/Menu/MainWindow.xaml.cs index 54d7712..dfa4e1f 100644 --- a/Bloxstrap/UI/Elements/Menu/MainWindow.xaml.cs +++ b/Bloxstrap/UI/Elements/Menu/MainWindow.xaml.cs @@ -1,10 +1,6 @@ using System.Windows.Controls; - -using Wpf.Ui.Appearance; using Wpf.Ui.Controls.Interfaces; using Wpf.Ui.Mvvm.Contracts; -using Wpf.Ui.Mvvm.Services; - using Bloxstrap.UI.ViewModels.Menu; namespace Bloxstrap.UI.Elements.Menu diff --git a/Bloxstrap/UI/Elements/Menu/Pages/AppearancePage.xaml b/Bloxstrap/UI/Elements/Menu/Pages/AppearancePage.xaml index e3490bb..ec89f42 100644 --- a/Bloxstrap/UI/Elements/Menu/Pages/AppearancePage.xaml +++ b/Bloxstrap/UI/Elements/Menu/Pages/AppearancePage.xaml @@ -11,11 +11,10 @@ Title="AppearancePage" Scrollable="True"> - + - + @@ -25,6 +24,18 @@ + + + + + + + + + + + + @@ -38,26 +49,23 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + @@ -69,7 +77,7 @@ - + @@ -94,12 +102,11 @@ - + - diff --git a/Bloxstrap/UI/Elements/Menu/Pages/FastFlagsPage.xaml b/Bloxstrap/UI/Elements/Menu/Pages/FastFlagsPage.xaml index a0ce253..ca35943 100644 --- a/Bloxstrap/UI/Elements/Menu/Pages/FastFlagsPage.xaml +++ b/Bloxstrap/UI/Elements/Menu/Pages/FastFlagsPage.xaml @@ -59,7 +59,7 @@ - + - + - + diff --git a/Bloxstrap/UI/ViewModels/Menu/AppearanceViewModel.cs b/Bloxstrap/UI/ViewModels/Menu/AppearanceViewModel.cs index 1460b11..3f160e4 100644 --- a/Bloxstrap/UI/ViewModels/Menu/AppearanceViewModel.cs +++ b/Bloxstrap/UI/ViewModels/Menu/AppearanceViewModel.cs @@ -1,7 +1,7 @@ -using System.Windows; +using System.Collections.ObjectModel; +using System.Windows; using System.Windows.Controls; using System.Windows.Input; -using System.Windows.Media; using CommunityToolkit.Mvvm.Input; @@ -48,14 +48,12 @@ namespace Bloxstrap.UI.ViewModels.Menu public AppearanceViewModel(Page page) { _page = page; + + foreach (var entry in Enum.GetValues(typeof(BootstrapperIcon)).Cast()) + Icons.Add(new BootstrapperIconEntry { IconType = entry }); } - public IReadOnlyCollection Themes { get; set; } = new Theme[] - { - Theme.Default, - Theme.Light, - Theme.Dark - }; + public IEnumerable Themes { get; } = Enum.GetValues(typeof(Theme)).Cast(); public Theme Theme { @@ -67,15 +65,7 @@ namespace Bloxstrap.UI.ViewModels.Menu } } - public IReadOnlyCollection Dialogs { get; set; } = new BootstrapperStyle[] - { - BootstrapperStyle.FluentDialog, - BootstrapperStyle.ProgressDialog, - BootstrapperStyle.LegacyDialog2011, - BootstrapperStyle.LegacyDialog2008, - BootstrapperStyle.VistaDialog, - BootstrapperStyle.ByfronDialog - }; + public IEnumerable Dialogs { get; } = Enum.GetValues(typeof(BootstrapperStyle)).Cast(); public BootstrapperStyle Dialog { @@ -83,31 +73,14 @@ namespace Bloxstrap.UI.ViewModels.Menu set => App.Settings.Prop.BootstrapperStyle = value; } - public IReadOnlyCollection Icons { get; set; } = new BootstrapperIcon[] - { - BootstrapperIcon.IconBloxstrap, - BootstrapperIcon.Icon2022, - BootstrapperIcon.Icon2019, - BootstrapperIcon.Icon2017, - BootstrapperIcon.IconLate2015, - BootstrapperIcon.IconEarly2015, - BootstrapperIcon.Icon2011, - BootstrapperIcon.Icon2008, - BootstrapperIcon.IconCustom - }; + public ObservableCollection Icons { get; set; } = new(); public BootstrapperIcon Icon { get => App.Settings.Prop.BootstrapperIcon; - set - { - App.Settings.Prop.BootstrapperIcon = value; - OnPropertyChanged(nameof(IconPreviewSource)); - } + set => App.Settings.Prop.BootstrapperIcon = value; } - public ImageSource IconPreviewSource => App.Settings.Prop.BootstrapperIcon.GetIcon().GetImageSource(); - public string Title { get => App.Settings.Prop.BootstrapperTitle; @@ -119,11 +92,20 @@ namespace Bloxstrap.UI.ViewModels.Menu get => App.Settings.Prop.BootstrapperIconCustomLocation; set { - App.Settings.Prop.BootstrapperIcon = BootstrapperIcon.IconCustom; + if (String.IsNullOrEmpty(value)) + { + if (App.Settings.Prop.BootstrapperIcon == BootstrapperIcon.IconCustom) + App.Settings.Prop.BootstrapperIcon = BootstrapperIcon.IconBloxstrap; + } + else + { + App.Settings.Prop.BootstrapperIcon = BootstrapperIcon.IconCustom; + } + App.Settings.Prop.BootstrapperIconCustomLocation = value; OnPropertyChanged(nameof(Icon)); - OnPropertyChanged(nameof(IconPreviewSource)); + OnPropertyChanged(nameof(Icons)); } } }