Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show what custom font is used #4024

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Bloxstrap/Paths.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ 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("content\\fonts");
public static string CustomFont => Path.Combine(Fonts, "CustomFont.ttf");

public static bool Initialized => !String.IsNullOrEmpty(Base);

Expand Down
2 changes: 1 addition & 1 deletion Bloxstrap/UI/Elements/Settings/Pages/ModsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
Description="{x:Static resources:Strings.Menu_Mods_Misc_CustomFont_Description}">
<StackPanel>
<ui:Button Icon="DocumentAdd16" Content="{x:Static resources:Strings.Menu_Mods_Misc_CustomFont_Choose}" Command="{Binding ManageCustomFontCommand}" Visibility="{Binding ChooseCustomFontVisibility, Mode=OneWay}" />
<ui:Button Icon="Delete16" Content="{x:Static resources:Strings.Menu_Mods_Misc_CustomFont_Remove}" Appearance="Danger" Command="{Binding ManageCustomFontCommand}" Visibility="{Binding DeleteCustomFontVisibility, Mode=OneWay}" />
<ui:Button Icon="Delete16" FontFamily="{Binding DeleteCustomFontFontFamily}" Content="{x:Static resources:Strings.Menu_Mods_Misc_CustomFont_Remove}" Appearance="Danger" Command="{Binding ManageCustomFontCommand}" Visibility="{Binding DeleteCustomFontVisibility, Mode=OneWay}" />
</StackPanel>
</controls:OptionControl>
</StackPanel>
Expand Down
19 changes: 18 additions & 1 deletion Bloxstrap/UI/ViewModels/Settings/ModsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@

using CommunityToolkit.Mvvm.Input;

using Bloxstrap.Models.SettingTasks;
using Bloxstrap.AppData;
using System.Drawing.Text;
using Wpf.Ui.Controls;
using System.Windows.Media;

namespace Bloxstrap.UI.ViewModels.Settings
{
Expand Down Expand Up @@ -52,9 +54,12 @@ private void ManageCustomFont()

TextFontTask.NewState = dialog.FileName;
}


OnPropertyChanged(nameof(ChooseCustomFontVisibility));
OnPropertyChanged(nameof(DeleteCustomFontVisibility));
OnPropertyChanged(nameof(CustomFontName));
OnPropertyChanged(nameof(DeleteCustomFontFontFamily));
}

public ICommand OpenModsFolderCommand => new RelayCommand(OpenModsFolder);
Expand All @@ -63,6 +68,18 @@ private void ManageCustomFont()

public Visibility DeleteCustomFontVisibility => !String.IsNullOrEmpty(TextFontTask.NewState) ? Visibility.Visible : Visibility.Collapsed;

public System.Windows.Media.FontFamily DeleteCustomFontFontFamily => new System.Windows.Media.FontFamily($"{TextFontTask.NewState}#{CustomFontName}");

public string CustomFontName
{
get
{
var families = Fonts.GetFontFamilies(TextFontTask.NewState);
var first = families.ElementAt(0);
return first.ToString().Split("#").ElementAt(first.ToString().Split("#").Count() - 1);
}
}

public ICommand ManageCustomFontCommand => new RelayCommand(ManageCustomFont);

public ICommand OpenCompatSettingsCommand => new RelayCommand(OpenCompatSettings);
Expand Down