Files
SourMesen 40335ce735 UI: Update to Avalonia 12, .NET 10 and replace ReactiveUI with MVVM community toolkit (#142)
Also fixes DX11.0 support (for Win7 PCs that aren't fully updated), which stopped working after the recent variable refresh rate changes
2026-07-03 16:04:42 +09:00

60 lines
3.0 KiB
C#

using Avalonia;
using Avalonia.Media;
using CommunityToolkit.Mvvm.ComponentModel;
using Mesen.Interop;
namespace Mesen.Config
{
public partial class DebuggerFontConfig : BaseConfig<DebuggerFontConfig>
{
[ObservableProperty] public partial FontConfig DisassemblyFont { get; set; } = new() { FontFamily = "Consolas", FontSize = 14 };
[ObservableProperty] public partial FontConfig MemoryViewerFont { get; set; } = new() { FontFamily = "Consolas", FontSize = 14 };
[ObservableProperty] public partial FontConfig AssemblerFont { get; set; } = new() { FontFamily = "Consolas", FontSize = 14 };
[ObservableProperty] public partial FontConfig ScriptWindowFont { get; set; } = new() { FontFamily = "Consolas", FontSize = 14 };
[ObservableProperty] public partial FontConfig OtherMonoFont { get; set; } = new() { FontFamily = "Consolas", FontSize = 12 };
public void ApplyConfig()
{
if(Application.Current is Application app) {
string disFont = Configuration.GetValidFontFamily(DisassemblyFont.FontFamily, true);
string memViewerFont = Configuration.GetValidFontFamily(MemoryViewerFont.FontFamily, true);
string assemblerFont = Configuration.GetValidFontFamily(AssemblerFont.FontFamily, true);
string scriptFont = Configuration.GetValidFontFamily(ScriptWindowFont.FontFamily, true);
string otherFont = Configuration.GetValidFontFamily(OtherMonoFont.FontFamily, true);
if((app.Resources["MesenDisassemblyFont"] as FontFamily)?.Name != disFont) {
app.Resources["MesenDisassemblyFont"] = new FontFamily(disFont);
}
if((app.Resources["MesenMemoryViewerFont"] as FontFamily)?.Name != memViewerFont) {
app.Resources["MesenMemoryViewerFont"] = new FontFamily(memViewerFont);
}
if((app.Resources["MesenAssemblerFont"] as FontFamily)?.Name != assemblerFont) {
app.Resources["MesenAssemblerFont"] = new FontFamily(assemblerFont);
}
if((app.Resources["MesenScriptWindowFont"] as FontFamily)?.Name != scriptFont) {
app.Resources["MesenScriptWindowFont"] = new FontFamily(scriptFont);
}
if((app.Resources["MesenMonospaceFont"] as FontFamily)?.Name != otherFont) {
app.Resources["MesenMonospaceFont"] = new FontFamily(otherFont);
}
if((double?)app.Resources["MesenDisassemblyFontSize"] != DisassemblyFont.FontSize) {
app.Resources["MesenDisassemblyFontSize"] = (double)DisassemblyFont.FontSize;
}
if((double?)app.Resources["MesenMemoryViewerFontSize"] != MemoryViewerFont.FontSize) {
app.Resources["MesenMemoryViewerFontSize"] = (double)MemoryViewerFont.FontSize;
}
if((double?)app.Resources["MesenAssemblerFontSize"] != AssemblerFont.FontSize) {
app.Resources["MesenAssemblerFontSize"] = (double)AssemblerFont.FontSize;
}
if((double?)app.Resources["MesenScriptWindowFontSize"] != ScriptWindowFont.FontSize) {
app.Resources["MesenScriptWindowFontSize"] = (double)ScriptWindowFont.FontSize;
}
if((double?)app.Resources["MesenMonospaceFontSize"] != OtherMonoFont.FontSize) {
app.Resources["MesenMonospaceFontSize"] = (double)OtherMonoFont.FontSize;
}
}
}
}
}