mirror of
https://github.com/SourMesen/Mesen2.git
synced 2024-06-15 18:57:57 -04:00
UI: Fixed blank setup wizard/window on first run due to default fonts not being initialized correctly
This commit is contained in:
parent
a5fa24a32e
commit
c832e0c619
|
@ -36,6 +36,7 @@ namespace Mesen
|
||||||
if(ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) {
|
if(ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) {
|
||||||
if(ShowConfigWindow) {
|
if(ShowConfigWindow) {
|
||||||
StyleHelper.ApplyTheme(MesenTheme.Light);
|
StyleHelper.ApplyTheme(MesenTheme.Light);
|
||||||
|
new PreferencesConfig().InitializeFontDefaults();
|
||||||
RequestedThemeVariant = ThemeVariant.Light;
|
RequestedThemeVariant = ThemeVariant.Light;
|
||||||
desktop.MainWindow = new SetupWizardWindow();
|
desktop.MainWindow = new SetupWizardWindow();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -81,20 +81,23 @@ namespace Mesen.Config
|
||||||
Debug.ApplyConfig();
|
Debug.ApplyConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InitializeDefaults()
|
public void InitializeFontDefaults()
|
||||||
{
|
{
|
||||||
if(FirstRun) {
|
if(FirstRun) {
|
||||||
Preferences.MesenFont = GetDefaultFont();
|
Preferences.InitializeFontDefaults();
|
||||||
Preferences.MesenMenuFont = GetDefaultMenuFont();
|
|
||||||
Preferences.ApplyFontOptions();
|
|
||||||
|
|
||||||
Debug.Fonts.DisassemblyFont = GetDefaultMonospaceFont();
|
Debug.Fonts.DisassemblyFont = GetDefaultMonospaceFont();
|
||||||
Debug.Fonts.MemoryViewerFont = GetDefaultMonospaceFont();
|
Debug.Fonts.MemoryViewerFont = GetDefaultMonospaceFont();
|
||||||
Debug.Fonts.AssemblerFont = GetDefaultMonospaceFont();
|
Debug.Fonts.AssemblerFont = GetDefaultMonospaceFont();
|
||||||
Debug.Fonts.ScriptWindowFont = GetDefaultMonospaceFont();
|
Debug.Fonts.ScriptWindowFont = GetDefaultMonospaceFont();
|
||||||
Debug.Fonts.OtherMonoFont = GetDefaultMonospaceFont(true);
|
Debug.Fonts.OtherMonoFont = GetDefaultMonospaceFont(true);
|
||||||
Debug.Fonts.ApplyConfig();
|
Debug.Fonts.ApplyConfig();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void InitializeDefaults()
|
||||||
|
{
|
||||||
|
if(FirstRun) {
|
||||||
Snes.InitializeDefaults(DefaultKeyMappings);
|
Snes.InitializeDefaults(DefaultKeyMappings);
|
||||||
Nes.InitializeDefaults(DefaultKeyMappings);
|
Nes.InitializeDefaults(DefaultKeyMappings);
|
||||||
Gameboy.InitializeDefaults(DefaultKeyMappings);
|
Gameboy.InitializeDefaults(DefaultKeyMappings);
|
||||||
|
@ -104,9 +107,9 @@ namespace Mesen.Config
|
||||||
Preferences.InitializeDefaultShortcuts();
|
Preferences.InitializeDefaultShortcuts();
|
||||||
}
|
}
|
||||||
|
|
||||||
private HashSet<string>? _installedFonts = null;
|
private static HashSet<string>? _installedFonts = null;
|
||||||
|
|
||||||
private string FindMatchingFont(string defaultFont, params string[] fontNames)
|
private static string FindMatchingFont(string defaultFont, params string[] fontNames)
|
||||||
{
|
{
|
||||||
if(_installedFonts == null) {
|
if(_installedFonts == null) {
|
||||||
_installedFonts = new(FontManager.Current.GetInstalledFontFamilyNames());
|
_installedFonts = new(FontManager.Current.GetInstalledFontFamilyNames());
|
||||||
|
@ -121,7 +124,7 @@ namespace Mesen.Config
|
||||||
return defaultFont;
|
return defaultFont;
|
||||||
}
|
}
|
||||||
|
|
||||||
private FontConfig GetDefaultFont()
|
public static FontConfig GetDefaultFont()
|
||||||
{
|
{
|
||||||
if(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
|
if(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
|
||||||
return new FontConfig() { FontFamily = "Microsoft Sans Serif", FontSize = 11 };
|
return new FontConfig() { FontFamily = "Microsoft Sans Serif", FontSize = 11 };
|
||||||
|
@ -132,7 +135,7 @@ namespace Mesen.Config
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private FontConfig GetDefaultMenuFont()
|
public static FontConfig GetDefaultMenuFont()
|
||||||
{
|
{
|
||||||
if(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
|
if(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
|
||||||
return new FontConfig() { FontFamily = "Segoe UI", FontSize = 12 };
|
return new FontConfig() { FontFamily = "Segoe UI", FontSize = 12 };
|
||||||
|
@ -143,7 +146,7 @@ namespace Mesen.Config
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private FontConfig GetDefaultMonospaceFont(bool useSmallFont = false)
|
public static FontConfig GetDefaultMonospaceFont(bool useSmallFont = false)
|
||||||
{
|
{
|
||||||
if(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
|
if(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
|
||||||
return new FontConfig() { FontFamily = "Consolas", FontSize = useSmallFont ? 12 : 14 };
|
return new FontConfig() { FontFamily = "Consolas", FontSize = useSmallFont ? 12 : 14 };
|
||||||
|
|
|
@ -201,6 +201,13 @@ namespace Mesen.Config
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void InitializeFontDefaults()
|
||||||
|
{
|
||||||
|
MesenFont = Configuration.GetDefaultFont();
|
||||||
|
MesenMenuFont = Configuration.GetDefaultMenuFont();
|
||||||
|
ApplyFontOptions();
|
||||||
|
}
|
||||||
|
|
||||||
public void ApplyConfig()
|
public void ApplyConfig()
|
||||||
{
|
{
|
||||||
UpdateFonts();
|
UpdateFonts();
|
||||||
|
|
|
@ -191,6 +191,7 @@ namespace Mesen.Windows
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ConfigManager.Config.InitializeFontDefaults();
|
||||||
ConfigManager.Config.Preferences.ApplyFontOptions();
|
ConfigManager.Config.Preferences.ApplyFontOptions();
|
||||||
ConfigManager.Config.Debug.Fonts.ApplyConfig();
|
ConfigManager.Config.Debug.Fonts.ApplyConfig();
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,10 @@ namespace Mesen.Windows
|
||||||
_model = new SetupWizardViewModel();
|
_model = new SetupWizardViewModel();
|
||||||
DataContext = _model;
|
DataContext = _model;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
this.AttachDevTools();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
|
|
Loading…
Reference in a new issue