mirror of
https://github.com/SourMesen/Mesen2.git
synced 2024-05-23 06:28:10 -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(ShowConfigWindow) {
|
||||
StyleHelper.ApplyTheme(MesenTheme.Light);
|
||||
new PreferencesConfig().InitializeFontDefaults();
|
||||
RequestedThemeVariant = ThemeVariant.Light;
|
||||
desktop.MainWindow = new SetupWizardWindow();
|
||||
} else {
|
||||
|
|
|
@ -81,20 +81,23 @@ namespace Mesen.Config
|
|||
Debug.ApplyConfig();
|
||||
}
|
||||
|
||||
public void InitializeDefaults()
|
||||
public void InitializeFontDefaults()
|
||||
{
|
||||
if(FirstRun) {
|
||||
Preferences.MesenFont = GetDefaultFont();
|
||||
Preferences.MesenMenuFont = GetDefaultMenuFont();
|
||||
Preferences.ApplyFontOptions();
|
||||
|
||||
Preferences.InitializeFontDefaults();
|
||||
|
||||
Debug.Fonts.DisassemblyFont = GetDefaultMonospaceFont();
|
||||
Debug.Fonts.MemoryViewerFont = GetDefaultMonospaceFont();
|
||||
Debug.Fonts.AssemblerFont = GetDefaultMonospaceFont();
|
||||
Debug.Fonts.ScriptWindowFont = GetDefaultMonospaceFont();
|
||||
Debug.Fonts.OtherMonoFont = GetDefaultMonospaceFont(true);
|
||||
Debug.Fonts.ApplyConfig();
|
||||
}
|
||||
}
|
||||
|
||||
public void InitializeDefaults()
|
||||
{
|
||||
if(FirstRun) {
|
||||
Snes.InitializeDefaults(DefaultKeyMappings);
|
||||
Nes.InitializeDefaults(DefaultKeyMappings);
|
||||
Gameboy.InitializeDefaults(DefaultKeyMappings);
|
||||
|
@ -104,9 +107,9 @@ namespace Mesen.Config
|
|||
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) {
|
||||
_installedFonts = new(FontManager.Current.GetInstalledFontFamilyNames());
|
||||
|
@ -121,7 +124,7 @@ namespace Mesen.Config
|
|||
return defaultFont;
|
||||
}
|
||||
|
||||
private FontConfig GetDefaultFont()
|
||||
public static FontConfig GetDefaultFont()
|
||||
{
|
||||
if(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
|
||||
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)) {
|
||||
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)) {
|
||||
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()
|
||||
{
|
||||
UpdateFonts();
|
||||
|
|
|
@ -191,6 +191,7 @@ namespace Mesen.Windows
|
|||
return;
|
||||
}
|
||||
|
||||
ConfigManager.Config.InitializeFontDefaults();
|
||||
ConfigManager.Config.Preferences.ApplyFontOptions();
|
||||
ConfigManager.Config.Debug.Fonts.ApplyConfig();
|
||||
|
||||
|
|
|
@ -19,6 +19,10 @@ namespace Mesen.Windows
|
|||
_model = new SetupWizardViewModel();
|
||||
DataContext = _model;
|
||||
InitializeComponent();
|
||||
|
||||
#if DEBUG
|
||||
this.AttachDevTools();
|
||||
#endif
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
|
|
Loading…
Reference in a new issue