From d5aa75e884a357e5d7e9bfbb1bd8280dead511d8 Mon Sep 17 00:00:00 2001 From: intervinn Date: Thu, 19 Jun 2025 10:35:28 +0300 Subject: [PATCH 1/3] updates --- Bloxstrap/Paths.cs | 4 +- .../UI/Elements/Settings/Pages/ModsPage.xaml | 2 +- .../UI/ViewModels/Settings/ModsViewModel.cs | 38 +++++++++++++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/Bloxstrap/Paths.cs b/Bloxstrap/Paths.cs index 43d4a1c06..803e3f6e0 100644 --- a/Bloxstrap/Paths.cs +++ b/Bloxstrap/Paths.cs @@ -25,7 +25,9 @@ static class Paths public static string Application { get; private set; } = ""; - public static string CustomFont => Path.Combine(Modifications, "content\\fonts\\CustomFont.ttf"); + public static string Fonts => Path.Combine(Modifications, "content\\fonts"); + public static string CustomFont => Path.Combine(Fonts, "CustomFont.ttf"); + public static bool Initialized => !String.IsNullOrEmpty(Base); diff --git a/Bloxstrap/UI/Elements/Settings/Pages/ModsPage.xaml b/Bloxstrap/UI/Elements/Settings/Pages/ModsPage.xaml index 2ce0a7354..310af7e69 100644 --- a/Bloxstrap/UI/Elements/Settings/Pages/ModsPage.xaml +++ b/Bloxstrap/UI/Elements/Settings/Pages/ModsPage.xaml @@ -99,7 +99,7 @@ Description="{x:Static resources:Strings.Menu_Mods_Misc_CustomFont_Description}"> - + diff --git a/Bloxstrap/UI/ViewModels/Settings/ModsViewModel.cs b/Bloxstrap/UI/ViewModels/Settings/ModsViewModel.cs index 3a116ff44..496c81d27 100644 --- a/Bloxstrap/UI/ViewModels/Settings/ModsViewModel.cs +++ b/Bloxstrap/UI/ViewModels/Settings/ModsViewModel.cs @@ -11,6 +11,8 @@ using Bloxstrap.Models.SettingTasks; using Bloxstrap.AppData; +using System.Windows.Media; +using System.Drawing.Text; namespace Bloxstrap.UI.ViewModels.Settings { @@ -55,6 +57,8 @@ private void ManageCustomFont() OnPropertyChanged(nameof(ChooseCustomFontVisibility)); OnPropertyChanged(nameof(DeleteCustomFontVisibility)); + OnPropertyChanged(nameof(CustomFontFont)); + OnPropertyChanged(nameof(CustomFontName)); } public ICommand OpenModsFolderCommand => new RelayCommand(OpenModsFolder); @@ -63,6 +67,40 @@ private void ManageCustomFont() public Visibility DeleteCustomFontVisibility => !String.IsNullOrEmpty(TextFontTask.NewState) ? Visibility.Visible : Visibility.Collapsed; + public System.Windows.Media.FontFamily CustomFontFont { + get + { + using (PrivateFontCollection collection = new PrivateFontCollection()) + { + Uri uri; + if (TextFontTask.NewState == String.Empty) + { + uri = new Uri("pack://application:,,,/Resources/Fonts/Rubik-VariableFont_wght.ttf"); + } else + { + uri = new Uri(TextFontTask.NewState, UriKind.Absolute); + } + + var fontFamilies = Fonts.GetFontFamilies(uri); + return fontFamilies.First(); + } + } + } + + public string CustomFontName + { + get + { + if (TextFontTask.NewState == String.Empty) + { + return String.Empty; + } + + var fontFamily = CustomFontFont; + return fontFamily.FamilyNames.Values.First(); + } + } + public ICommand ManageCustomFontCommand => new RelayCommand(ManageCustomFont); public ICommand OpenCompatSettingsCommand => new RelayCommand(OpenCompatSettings); From f2d7271b3d4f0f68cc2aa98365f8cddc16b3b382 Mon Sep 17 00:00:00 2001 From: intervinn Date: Thu, 19 Jun 2025 10:52:06 +0300 Subject: [PATCH 2/3] updates --- Bloxstrap/UI/ViewModels/Settings/ModsViewModel.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Bloxstrap/UI/ViewModels/Settings/ModsViewModel.cs b/Bloxstrap/UI/ViewModels/Settings/ModsViewModel.cs index 496c81d27..42e7ba74d 100644 --- a/Bloxstrap/UI/ViewModels/Settings/ModsViewModel.cs +++ b/Bloxstrap/UI/ViewModels/Settings/ModsViewModel.cs @@ -67,7 +67,8 @@ private void ManageCustomFont() public Visibility DeleteCustomFontVisibility => !String.IsNullOrEmpty(TextFontTask.NewState) ? Visibility.Visible : Visibility.Collapsed; - public System.Windows.Media.FontFamily CustomFontFont { + public System.Windows.Media.FontFamily CustomFontFont + { get { using (PrivateFontCollection collection = new PrivateFontCollection()) From 9fee1d1d5ada0c632e81495b601c0041dd329a58 Mon Sep 17 00:00:00 2001 From: intervinn Date: Thu, 19 Jun 2025 18:31:55 +0300 Subject: [PATCH 3/3] more clear namings --- Bloxstrap/UI/Elements/Settings/Pages/ModsPage.xaml | 2 +- Bloxstrap/UI/ViewModels/Settings/ModsViewModel.cs | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Bloxstrap/UI/Elements/Settings/Pages/ModsPage.xaml b/Bloxstrap/UI/Elements/Settings/Pages/ModsPage.xaml index 310af7e69..d050d09db 100644 --- a/Bloxstrap/UI/Elements/Settings/Pages/ModsPage.xaml +++ b/Bloxstrap/UI/Elements/Settings/Pages/ModsPage.xaml @@ -99,7 +99,7 @@ Description="{x:Static resources:Strings.Menu_Mods_Misc_CustomFont_Description}"> - + diff --git a/Bloxstrap/UI/ViewModels/Settings/ModsViewModel.cs b/Bloxstrap/UI/ViewModels/Settings/ModsViewModel.cs index 42e7ba74d..fcb07fbfa 100644 --- a/Bloxstrap/UI/ViewModels/Settings/ModsViewModel.cs +++ b/Bloxstrap/UI/ViewModels/Settings/ModsViewModel.cs @@ -57,8 +57,8 @@ private void ManageCustomFont() OnPropertyChanged(nameof(ChooseCustomFontVisibility)); OnPropertyChanged(nameof(DeleteCustomFontVisibility)); - OnPropertyChanged(nameof(CustomFontFont)); - OnPropertyChanged(nameof(CustomFontName)); + OnPropertyChanged(nameof(DeleteCustomFontFontFamily)); + OnPropertyChanged(nameof(DeleteCustomFontFontName)); } public ICommand OpenModsFolderCommand => new RelayCommand(OpenModsFolder); @@ -67,7 +67,7 @@ private void ManageCustomFont() public Visibility DeleteCustomFontVisibility => !String.IsNullOrEmpty(TextFontTask.NewState) ? Visibility.Visible : Visibility.Collapsed; - public System.Windows.Media.FontFamily CustomFontFont + public System.Windows.Media.FontFamily DeleteCustomFontFontFamily { get { @@ -88,7 +88,7 @@ public System.Windows.Media.FontFamily CustomFontFont } } - public string CustomFontName + public string DeleteCustomFontFontName { get { @@ -97,8 +97,8 @@ public string CustomFontName return String.Empty; } - var fontFamily = CustomFontFont; - return fontFamily.FamilyNames.Values.First(); + var fontFamily = DeleteCustomFontFontFamily; + return String.Join(" ", fontFamily.FamilyNames.Values); } }