From d208fdc6a7d6f981906ddb2de4fca30287b41646 Mon Sep 17 00:00:00 2001 From: Sour Date: Wed, 5 Jun 2024 20:23:31 +0900 Subject: [PATCH] UI: Support for NativeAOT Added Windows & Linux builds using AOT compilation --- .github/workflows/build.yml | 52 +- COMPILING.md | 8 +- README.md | 25 +- UI/App.axaml | 4 +- UI/App.axaml.cs | 13 +- UI/Config/BaseConfig.cs | 4 +- UI/Config/BaseWindowConfig.cs | 40 +- UI/Config/CheatCodes.cs | 6 +- UI/Config/Configuration.cs | 4 +- UI/Config/Debugger/AssemblerConfig.cs | 1 - UI/Config/Debugger/DebuggerConfig.cs | 35 +- UI/Config/Debugger/HexEditorConfig.cs | 2 + UI/Config/Debugger/RegisterViewerConfig.cs | 2 +- UI/Config/GameConfig.cs | 4 +- UI/Controls/ButtonWithIcon.axaml | 4 +- UI/Controls/EnumComboBox.axaml | 4 +- UI/Controls/EnumComboBox.axaml.cs | 3 +- UI/Controls/GroupBox.axaml | 2 +- UI/Controls/InputComboBox.axaml | 6 +- UI/Controls/MesenSlider.axaml | 24 +- UI/Controls/OptionSection.axaml | 2 +- UI/Controls/OverscanInput.axaml | 16 +- UI/Controls/PaletteConfig.axaml | 17 +- UI/Controls/SoftwareRendererView.axaml | 6 +- UI/Controls/StateGridEntry.axaml | 14 +- UI/Debugger/Breakpoints/Breakpoint.cs | 2 +- UI/Debugger/Controls/CodeScrollBar.axaml | 18 +- UI/Debugger/Controls/ColorCheckbox.axaml | 2 +- UI/Debugger/Controls/ColorPickerField.axaml | 2 +- .../Controls/EventViewerCategoryControl.axaml | 6 +- .../Controls/ScrollPictureViewer.axaml | 40 +- UI/Debugger/Controls/SpritePreviewPanel.axaml | 4 +- UI/Debugger/DebuggerDockFactory.cs | 14 +- UI/Debugger/DebuggerViewLocator.cs | 41 - UI/Debugger/Disassembly/BaseStyleProvider.cs | 10 +- UI/Debugger/Disassembly/CodeHighlighting.cs | 22 +- .../Disassembly/SourceViewStyleProvider.cs | 8 +- UI/Debugger/HexEditorDataProvider.cs | 6 +- UI/Debugger/StatusViews/Cx4StatusView.axaml | 64 +- UI/Debugger/StatusViews/GbStatusView.axaml | 48 +- UI/Debugger/StatusViews/GbaStatusView.axaml | 56 +- UI/Debugger/StatusViews/GsuStatusView.axaml | 86 +- .../StatusViews/NecDspStatusView.axaml | 54 +- UI/Debugger/StatusViews/NesStatusView.axaml | 88 +- UI/Debugger/StatusViews/PceStatusView.axaml | 40 +- UI/Debugger/StatusViews/SmsStatusView.axaml | 90 +- UI/Debugger/StatusViews/SnesStatusView.axaml | 62 +- UI/Debugger/StatusViews/SpcStatusView.axaml | 36 +- UI/Debugger/Utilities/CodeCompletionHelper.cs | 2 +- .../Utilities/DebugWorkspaceManager.cs | 6 +- UI/Debugger/Utilities/OpCodeHelper.cs | 144 +- .../ViewModels/BreakpointListViewModel.cs | 30 +- UI/Debugger/ViewModels/CallStackViewModel.cs | 36 +- .../DebuggerConfigWindowViewModel.cs | 3 +- .../ViewModels/FunctionListViewModel.cs | 72 +- UI/Debugger/ViewModels/LabelListViewModel.cs | 78 +- .../ViewModels/MemorySearchViewModel.cs | 236 +- .../ViewModels/NesHeaderEditViewModel.cs | 2 +- UI/Debugger/Views/BreakpointListView.axaml | 18 +- UI/Debugger/Views/CallStackView.axaml | 16 +- UI/Debugger/Views/CallStackView.axaml.cs | 2 +- UI/Debugger/Views/ControllerInputView.axaml | 36 +- UI/Debugger/Views/ControllerListView.axaml | 2 +- .../DebuggerDock/ToolContainerView.axaml | 2 +- UI/Debugger/Views/DebuggerOptionsView.axaml | 104 +- UI/Debugger/Views/DisassemblyView.axaml | 22 +- UI/Debugger/Views/FindResultListView.axaml | 22 +- UI/Debugger/Views/FunctionListView.axaml | 36 +- .../Views/GbEventViewerConfigView.axaml | 50 +- .../Views/GbaEventViewerConfigView.axaml | 54 +- UI/Debugger/Views/LabelListView.axaml | 20 +- .../Views/MemoryToolsDisplayOptionsView.axaml | 56 +- .../Views/NesEventViewerConfigView.axaml | 48 +- .../Views/PceEventViewerConfigView.axaml | 58 +- UI/Debugger/Views/QuickSearchView.axaml | 6 +- UI/Debugger/Views/RefreshTimingView.axaml | 16 +- UI/Debugger/Views/RegisterTabView.axaml | 14 +- .../Views/ScriptCodeCompletionView.axaml | 46 +- .../Views/SmsEventViewerConfigView.axaml | 32 +- .../Views/SnesEventViewerConfigView.axaml | 54 +- UI/Debugger/Views/SourceViewView.axaml | 22 +- UI/Debugger/Views/WatchListView.axaml | 10 +- UI/Debugger/Windows/AssemblerWindow.axaml | 34 +- .../Windows/BreakpointEditWindow.axaml | 34 +- .../Windows/ColorIndexPickerWindow.axaml | 8 +- UI/Debugger/Windows/CommentEditWindow.axaml | 2 +- UI/Debugger/Windows/DebugLogWindow.axaml | 2 +- .../Windows/DebuggerConfigWindow.axaml | 108 +- UI/Debugger/Windows/DebuggerWindow.axaml | 117 +- UI/Debugger/Windows/EventViewerWindow.axaml | 60 +- UI/Debugger/Windows/GoToAllWindow.axaml | 12 +- UI/Debugger/Windows/LabelEditWindow.axaml | 22 +- UI/Debugger/Windows/MemorySearchWindow.axaml | 66 +- UI/Debugger/Windows/MemoryToolsWindow.axaml | 40 +- .../Windows/MemoryViewerFindWindow.axaml | 42 +- UI/Debugger/Windows/NesHeaderEditWindow.axaml | 40 +- UI/Debugger/Windows/PaletteViewerWindow.axaml | 24 +- UI/Debugger/Windows/ProfilerWindow.axaml | 22 +- .../Windows/RegisterViewerWindow.axaml | 12 +- UI/Debugger/Windows/ScriptWindow.axaml | 16 +- UI/Debugger/Windows/SpriteViewerWindow.axaml | 84 +- UI/Debugger/Windows/TileEditorWindow.axaml | 32 +- UI/Debugger/Windows/TileViewerWindow.axaml | 80 +- UI/Debugger/Windows/TilemapViewerWindow.axaml | 66 +- UI/Debugger/Windows/TraceLoggerWindow.axaml | 44 +- UI/Debugger/Windows/WatchWindow.axaml | 6 +- UI/Dependencies/Internal/CheatDb.Nes.json | 13700 ++++++++++++ UI/Dependencies/Internal/CheatDb.Nes.xml | 11379 ---------- UI/Dependencies/Internal/CheatDb.Snes.json | 17596 ++++++++++++++++ UI/Dependencies/Internal/CheatDb.Snes.xml | 15500 -------------- UI/Interop/DebugApi.cs | 47 +- UI/Localization/ResourceHelper.cs | 22 +- UI/Localization/resources.en.xml | 24 - .../PublishProfiles/FolderProfile.pubxml | 19 - UI/Properties/PublishProfiles/Release.pubxml | 9 +- UI/Styles/AvaloniaEditStyles.xaml | 4 +- UI/Styles/DockStyles.xaml | 37 +- UI/Styles/MesenStyles.Dark.xaml | 154 +- UI/Styles/MesenStyles.Light.xaml | 162 +- UI/Styles/MesenStyles.xaml | 24 +- UI/ThirdParty/ColorPicker/ColorPicker.axaml | 135 - UI/ThirdParty/ColorPicker/ColorPicker.cs | 907 - UI/ThirdParty/ColorPicker/Colors/CMYK.cs | 88 - UI/ThirdParty/ColorPicker/Colors/HSV.cs | 122 - UI/ThirdParty/ColorPicker/Colors/RGB.cs | 115 - UI/ThirdParty/DataBox/DataBox.cs | 10 +- UI/UI.csproj | 21 +- UI/Utilities/ColorHelper.cs | 10 + UI/Utilities/CommandLineHelper.cs | 2 + UI/Utilities/Json/ColorConverter.cs | 21 - UI/Utilities/Json/PixelPointConverter.cs | 39 - UI/Utilities/Json/PixelSizeConverter.cs | 39 - UI/Utilities/Json/TimeSpanConverter.cs | 23 - UI/Utilities/JsonHelper.cs | 44 +- UI/Utilities/MesenList.cs | 1 - UI/Utilities/SingleInstance.cs | 17 +- UI/Utilities/StyleHelper.cs | 56 - UI/Utilities/TooltipHelper.cs | 1 - UI/ViewModels/CheatDatabaseViewModel.cs | 6 +- UI/ViewModels/SetupWizardViewModel.cs | 4 + UI/ViewModels/UpdatePromptViewModel.cs | 2 +- UI/Views/AudioConfigView.axaml | 92 +- UI/Views/AudioPlayerView.axaml | 14 +- UI/Views/DefaultControllerView.axaml | 2 +- UI/Views/EmulationConfigView.axaml | 8 +- UI/Views/FontOptionsView.axaml | 6 +- UI/Views/GameboyConfigView.axaml | 36 +- UI/Views/GbaConfigView.axaml | 40 +- UI/Views/GbaControllerView.axaml | 28 +- UI/Views/InputConfigView.axaml | 26 +- UI/Views/MainMenuView.axaml | 12 +- UI/Views/NesConfigView.axaml | 200 +- UI/Views/NesControllerView.axaml | 24 +- UI/Views/NesInputConfigView.axaml | 96 +- UI/Views/PceAvenuePad6View.axaml | 36 +- UI/Views/PceConfigView.axaml | 56 +- UI/Views/PceControllerView.axaml | 20 +- UI/Views/PceInputConfigView.axaml | 40 +- UI/Views/PreferencesConfigView.axaml | 128 +- UI/Views/ShortcutKeysTabView.axaml | 1 + UI/Views/SmsConfigView.axaml | 44 +- UI/Views/SmsControllerView.axaml | 20 +- UI/Views/SmsInputConfigView.axaml | 12 +- UI/Views/SnesConfigView.axaml | 72 +- UI/Views/SnesControllerView.axaml | 36 +- UI/Views/SnesInputConfigView.axaml | 64 +- UI/Views/VideoConfigView.axaml | 104 +- UI/Windows/AboutWindow.axaml | 13 +- UI/Windows/AboutWindow.axaml.cs | 32 +- UI/Windows/CheatDatabaseWindow.axaml | 6 +- UI/Windows/CheatEditWindow.axaml | 16 +- UI/Windows/CheatListWindow.axaml | 19 +- UI/Windows/ColorPickerWindow.axaml | 13 +- UI/Windows/CommandLineHelpWindow.axaml | 7 +- UI/Windows/CommandLineHelpWindow.axaml.cs | 12 +- UI/Windows/ConfigWindow.axaml | 26 +- UI/Windows/ControllerConfigWindow.axaml | 44 +- UI/Windows/GameConfigWindow.axaml | 10 +- UI/Windows/GetKeyWindow.axaml | 2 +- UI/Windows/HdPackBuilderWindow.axaml | 24 +- .../HistoryViewerRangePickerWindow.axaml | 12 +- UI/Windows/HistoryViewerWindow.axaml | 28 +- UI/Windows/InputBarcodeWindow.axaml | 2 +- UI/Windows/LogWindow.axaml | 2 +- UI/Windows/MainWindow.axaml | 24 +- UI/Windows/MainWindow.axaml.cs | 11 - UI/Windows/MovieRecordWindow.axaml | 8 +- UI/Windows/NetplayConnectWindow.axaml | 6 +- UI/Windows/NetplayStartServerWindow.axaml | 4 +- UI/Windows/SelectRomWindow.axaml | 8 +- UI/Windows/SelectStorageFolderWindow.axaml | 12 +- UI/Windows/SetupWizardWindow.axaml | 20 +- UI/Windows/UpdatePromptWindow.axaml | 12 +- UI/Windows/VideoRecordWindow.axaml | 14 +- makefile | 8 +- 195 files changed, 34239 insertions(+), 31138 deletions(-) delete mode 100644 UI/Debugger/DebuggerViewLocator.cs create mode 100644 UI/Dependencies/Internal/CheatDb.Nes.json delete mode 100644 UI/Dependencies/Internal/CheatDb.Nes.xml create mode 100644 UI/Dependencies/Internal/CheatDb.Snes.json delete mode 100644 UI/Dependencies/Internal/CheatDb.Snes.xml delete mode 100644 UI/Properties/PublishProfiles/FolderProfile.pubxml delete mode 100644 UI/ThirdParty/ColorPicker/ColorPicker.axaml delete mode 100644 UI/ThirdParty/ColorPicker/ColorPicker.cs delete mode 100644 UI/ThirdParty/ColorPicker/Colors/CMYK.cs delete mode 100644 UI/ThirdParty/ColorPicker/Colors/HSV.cs delete mode 100644 UI/ThirdParty/ColorPicker/Colors/RGB.cs delete mode 100644 UI/Utilities/Json/ColorConverter.cs delete mode 100644 UI/Utilities/Json/PixelPointConverter.cs delete mode 100644 UI/Utilities/Json/PixelSizeConverter.cs delete mode 100644 UI/Utilities/Json/TimeSpanConverter.cs delete mode 100644 UI/Utilities/StyleHelper.cs diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 715800faa..503483546 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,41 +11,42 @@ jobs: strategy: matrix: platform: [ - {netversion: 6.x, targetframework: net6.0}, - {netversion: 8.x, targetframework: net8.0} + {netversion: 6.x, targetframework: net6.0, aot: false, singleFile: true, aotString: ""}, + {netversion: 8.x, targetframework: net8.0, aot: false, singleFile: true, aotString: ""}, + {netversion: 8.x, targetframework: net8.0, aot: true, singleFile: false, aotString: " - AoT"} ] fail-fast: false runs-on: windows-latest steps: - name: Checkout repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Install .NET Core - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: dotnet-version: ${{ matrix.platform.netversion }} - name: Setup MSBuild.exe - uses: microsoft/setup-msbuild@v1.1 + uses: microsoft/setup-msbuild@v2 with: msbuild-architecture: x64 - name: Restore packages - run: dotnet restore /p:TargetFramework="${{ matrix.platform.targetframework }}" + run: dotnet restore -p:TargetFramework="${{ matrix.platform.targetframework }}" -r win-x64 -p:PublishAot="${{ matrix.platform.aot }}" - name: Build Mesen - run: msbuild -nologo -v:d -clp:ForceConsoleColor -m -p:Configuration=Release -p:Platform=x64 -t:Clean,UI /p:TargetFramework="${{ matrix.platform.targetframework }}" + run: msbuild -nologo -v:d -clp:ForceConsoleColor -m -p:Configuration=Release -p:Platform=x64 -t:Clean,UI -p:TargetFramework="${{ matrix.platform.targetframework }}" - name: Publish Mesen - run: dotnet publish -nologo --no-restore -c Release /p:Platform="Any CPU" /p:OptimizeUi="true" /p:TargetFramework="${{ matrix.platform.targetframework }}" Mesen.sln /p:PublishProfile=UI\Properties\PublishProfiles\Release.pubxml + run: dotnet publish --no-restore -c Release -p:PublishAot="${{ matrix.platform.aot }}" -p:SelfContained="${{ matrix.platform.aot }}" -p:PublishSingleFile="${{ matrix.platform.singleFile }}" -p:OptimizeUi="true" -p:Platform="Any CPU" -p:TargetFramework="${{ matrix.platform.targetframework }}" -r win-x64 Mesen.sln /p:PublishProfile=UI\Properties\PublishProfiles\Release.pubxml - name: Upload Mesen - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: Mesen (Windows - ${{ matrix.platform.targetframework }}) + name: Mesen (Windows - ${{ matrix.platform.targetframework }}${{ matrix.platform.aotString }}) path: | build/TmpReleaseBuild/Mesen.exe @@ -53,28 +54,33 @@ jobs: linux: strategy: matrix: - compiler: [gcc, clang] + compiler: [gcc, clang, clang_aot] os: [ubuntu-22.04, ubuntu-20.04] exclude: # This currently fails to build. - os: ubuntu-20.04 compiler: gcc + # Don't need 2 separate AoT builds + - os: ubuntu-22.04 + compiler: clang_aot include: - compiler: gcc - use_gcc: "USE_GCC=true" + make_flags: "USE_GCC=true" - compiler: clang - use_gcc: "" + make_flags: "" + - compiler: clang_aot + make_flags: "USE_AOT=true" fail-fast: false runs-on: ${{ matrix.os }} steps: - name: Checkout repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Install .NET Core - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: dotnet-version: 8.x @@ -87,10 +93,10 @@ jobs: # forcing colours makes the log a little nicer to read. - name: Build Mesen run: | - make -j$(nproc) -O ${{ matrix.use_gcc }} LTO=true STATICLINK=true SYSTEM_LIBEVDEV=false + make -j$(nproc) -O ${{ matrix.make_flags }} LTO=true STATICLINK=true SYSTEM_LIBEVDEV=false - name: Upload Mesen - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: Mesen (Linux - ${{ matrix.os }} - ${{ matrix.compiler }}) path: bin/linux-x64/Release/linux-x64/publish/Mesen @@ -100,12 +106,12 @@ jobs: steps: - name: Checkout repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Install .NET Core - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: dotnet-version: 8.x @@ -118,7 +124,7 @@ jobs: run: | Linux/appimage/appimage.sh - name: Upload Mesen (AppImage) - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: Mesen (Linux x64 - AppImage) path: Mesen.AppImage @@ -137,12 +143,12 @@ jobs: steps: - name: Checkout repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Install .NET Core - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: dotnet-version: 8.x @@ -186,7 +192,7 @@ jobs: ditto -c -k --sequesterRsrc --keepParent bin/osx-${{ matrix.platform.arch }}/Release/osx-${{ matrix.platform.arch }}/publish/Mesen.app bin/osx-${{ matrix.platform.arch }}/Release/Mesen.app.zip - name: Upload Mesen - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: Mesen (macOS - ${{ matrix.platform.os }}) path: bin/osx-${{ matrix.platform.arch }}/Release/Mesen.app.zip diff --git a/COMPILING.md b/COMPILING.md index 4fd891f63..ec0a4b41a 100644 --- a/COMPILING.md +++ b/COMPILING.md @@ -8,15 +8,15 @@ To build under Linux you need a version of Clang or GCC that supports C++17. -Additionally, SDL2 and the [.NET 6 SDK](https://learn.microsoft.com/en-us/dotnet/core/install/linux) must also be installed. +Additionally, SDL2 and the [.NET 8 SDK](https://learn.microsoft.com/en-us/dotnet/core/install/linux) must also be installed. -Once SDL2 and the .NET 6 SDK are installed, run `make` to compile with Clang. +Once SDL2 and the .NET 8 SDK are installed, run `make` to compile with Clang. To compile with GCC instead, use `USE_GCC=true make`. **Note:** Mesen usually runs faster when built with Clang instead of GCC. ## macOS -To build macOS, install SDL2 (i.e via Homebrew) and the [.NET 6 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/6.0). +To build macOS, install SDL2 (i.e via Homebrew) and the [.NET 8 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/8.0). -Once SDL2 and the .NET 6 SDK are installed, run `make`. \ No newline at end of file +Once SDL2 and the .NET 8 SDK are installed, run `make`. \ No newline at end of file diff --git a/README.md b/README.md index f540df620..74cadb89b 100644 --- a/README.md +++ b/README.md @@ -6,30 +6,31 @@ Mesen is a multi-system emulator (NES, SNES, Game Boy, Game Boy Advance, PC Engi [![Mesen](https://github.com/SourMesen/Mesen2/actions/workflows/build.yml/badge.svg)](https://github.com/SourMesen/Mesen2/actions/workflows/build.yml) -Latest development builds: +#### Native builds #### -* [Windows 10 / 11 (.NET 8)](https://nightly.link/SourMesen/Mesen2/workflows/build/master/Mesen%20%28Windows%20-%20net8.0%29.zip) +These builds don't require .NET to be installed and offer improved start up times. + +* [Windows 10 / 11](https://nightly.link/SourMesen/Mesen2/workflows/build/master/Mesen%20%28Windows%20-%20net8.0%20-%20AoT%29.zip) +* [Linux](https://nightly.link/SourMesen/Mesen2/workflows/build/master/Mesen%20%28Linux%20-%20ubuntu-20.04%20-%20clang_aot%29.zip) (requires **SDL2**) + +#### .NET builds #### + +These builds require **.NET 8** to be installed (except the Windows 7 build which requires .NET 6). +For Linux and macOS, **SDL2** must also be installed. + +* [Windows 10 / 11](https://nightly.link/SourMesen/Mesen2/workflows/build/master/Mesen%20%28Windows%20-%20net8.0%29.zip) * [Windows 7 / 8 (.NET 6)](https://nightly.link/SourMesen/Mesen2/workflows/build/master/Mesen%20%28Windows%20-%20net6.0%29.zip) * [macOS - Intel](https://nightly.link/SourMesen/Mesen2/workflows/build/master/Mesen%20%28macOS%20-%20macos-12%29.zip) * [macOS - Apple Silicon](https://nightly.link/SourMesen/Mesen2/workflows/build/master/Mesen%20%28macOS%20-%20macos-14%29.zip) * [Linux](https://nightly.link/SourMesen/Mesen2/workflows/build/master/Mesen%20%28Linux%20-%20ubuntu-20.04%20-%20clang%29.zip) * [Linux - AppImage](https://nightly.link/SourMesen/Mesen2/workflows/build/master/Mesen%20(Linux%20x64%20-%20AppImage).zip) -#### Notes / limitations +#### Notes / limitations #### **macOS**: The macOS build still has a number of limitations (e.g no gamepad support). **SteamOS**: See [SteamOS.md](SteamOS.md) -## Requirements - -To run Mesen, the following prerequisites must be installed: - -**Windows 10 / 11**: [.NET 8 Runtime](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) -**Windows 7 / 8**: [.NET 6 Runtime](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) (.NET 8 is not supported on Windows 7 / 8) -**Linux**: [.NET 8 Runtime](https://dotnet.microsoft.com/en-us/download/dotnet/8.0), SDL2 -**macOS**: [.NET 8 Runtime](https://dotnet.microsoft.com/en-us/download/dotnet/8.0), SDL2 - ## Compiling See [COMPILING.md](COMPILING.md) diff --git a/UI/App.axaml b/UI/App.axaml index 9f1a2d44e..0241206f7 100644 --- a/UI/App.axaml +++ b/UI/App.axaml @@ -42,14 +42,14 @@ - - + + diff --git a/UI/App.axaml.cs b/UI/App.axaml.cs index c64be2f7d..592b055bf 100644 --- a/UI/App.axaml.cs +++ b/UI/App.axaml.cs @@ -21,13 +21,13 @@ public class App : Application public override void Initialize() { - AvaloniaXamlLoader.Load(this); - StyleHelper.LoadStartupStyles(); - if(Design.IsDesignMode) { - StyleHelper.ApplyTheme(MesenTheme.Light); + if(Design.IsDesignMode || ShowConfigWindow) { RequestedThemeVariant = ThemeVariant.Light; - StyleHelper.LoadDebuggerStyles(); + } else { + RequestedThemeVariant = ConfigManager.Config.Preferences.Theme == MesenTheme.Dark ? ThemeVariant.Dark : ThemeVariant.Light; } + + AvaloniaXamlLoader.Load(this); ResourceHelper.LoadResources(); } @@ -35,12 +35,9 @@ public override void OnFrameworkInitializationCompleted() { if(ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { if(ShowConfigWindow) { - StyleHelper.ApplyTheme(MesenTheme.Light); new PreferencesConfig().InitializeFontDefaults(); - RequestedThemeVariant = ThemeVariant.Light; desktop.MainWindow = new SetupWizardWindow(); } else { - RequestedThemeVariant = ConfigManager.Config.Preferences.Theme == MesenTheme.Dark ? ThemeVariant.Dark : ThemeVariant.Light; desktop.MainWindow = new MainWindow(); } } diff --git a/UI/Config/BaseConfig.cs b/UI/Config/BaseConfig.cs index 212e36ef3..be1ac1b28 100644 --- a/UI/Config/BaseConfig.cs +++ b/UI/Config/BaseConfig.cs @@ -18,8 +18,8 @@ public T Clone() public bool IsIdentical(T other) { - string a = JsonSerializer.Serialize(this, this.GetType(), JsonHelper.Options); - string b = JsonSerializer.Serialize(other, this.GetType(), JsonHelper.Options); + string a = JsonSerializer.Serialize(this, this.GetType(), MesenSerializerContext.Default); + string b = JsonSerializer.Serialize(other, this.GetType(), MesenSerializerContext.Default); return a == b; } } diff --git a/UI/Config/BaseWindowConfig.cs b/UI/Config/BaseWindowConfig.cs index cb8d9ae3a..78ab28541 100644 --- a/UI/Config/BaseWindowConfig.cs +++ b/UI/Config/BaseWindowConfig.cs @@ -7,8 +7,8 @@ namespace Mesen.Config { public class BaseWindowConfig : BaseConfig where T : class { - public PixelSize WindowSize { get; set; } = new PixelSize(0, 0); - public PixelPoint WindowLocation { get; set; } = new PixelPoint(0, 0); + public MesenSize WindowSize { get; set; } = new PixelSize(0, 0); + public MesenPoint WindowLocation { get; set; } = new PixelPoint(0, 0); public bool WindowIsMaximized { get; set; } = false; private PixelRect _restoreBounds; @@ -48,10 +48,10 @@ public void LoadWindowSettings(Window wnd) } else { //Window top left corner is offscreen, adjust position if(WindowLocation.Y < screen.WorkingArea.Position.Y) { - WindowLocation = WindowLocation.WithY(screen.WorkingArea.Position.Y); + WindowLocation = ((PixelPoint)WindowLocation).WithY(screen.WorkingArea.Position.Y); } if(WindowLocation.X < screen.WorkingArea.Position.X) { - WindowLocation = WindowLocation.WithX(screen.WorkingArea.Position.X); + WindowLocation = ((PixelPoint)WindowLocation).WithX(screen.WorkingArea.Position.X); } wndRect = new PixelRect(WindowLocation, WindowSize); @@ -109,4 +109,36 @@ private void UpdateRestoreBounds(Window wnd) } } } + + public struct MesenSize + { + public int Width { get; set; } + public int Height { get; set; } + + public static implicit operator MesenSize(PixelSize size) + { + return new MesenSize { Width = size.Width, Height = size.Height }; + } + + public static implicit operator PixelSize(MesenSize size) + { + return new PixelSize(size.Width, size.Height); + } + } + + public struct MesenPoint + { + public int X { get; set; } + public int Y { get; set; } + + public static implicit operator MesenPoint(PixelPoint point) + { + return new MesenPoint { X = point.X, Y = point.Y }; + } + + public static implicit operator PixelPoint(MesenPoint point) + { + return new PixelPoint(point.X, point.Y); + } + } } diff --git a/UI/Config/CheatCodes.cs b/UI/Config/CheatCodes.cs index 9421a4f36..7874fa02e 100644 --- a/UI/Config/CheatCodes.cs +++ b/UI/Config/CheatCodes.cs @@ -14,7 +14,7 @@ public class CheatCodes { private static string FilePath { get { return Path.Combine(ConfigManager.CheatFolder, EmuApi.GetRomInfo().GetRomName() + ".json"); } } - public List Cheats = new List(); + public List Cheats { get; set; } = new List(); public static CheatCodes LoadCheatCodes() { @@ -27,7 +27,7 @@ private static CheatCodes Deserialize(string path) if(File.Exists(path)) { try { - cheats = JsonSerializer.Deserialize(File.ReadAllText(path), JsonHelper.Options) ?? new CheatCodes(); + cheats = (CheatCodes?)JsonSerializer.Deserialize(File.ReadAllText(path), typeof(CheatCodes), MesenSerializerContext.Default) ?? new CheatCodes(); } catch { } } @@ -38,7 +38,7 @@ public void Save() { try { if(Cheats.Count > 0) { - FileHelper.WriteAllText(CheatCodes.FilePath, JsonSerializer.Serialize(this, JsonHelper.Options)); + FileHelper.WriteAllText(CheatCodes.FilePath, JsonSerializer.Serialize(this, typeof(CheatCodes), MesenSerializerContext.Default)); } else { if(File.Exists(CheatCodes.FilePath)) { File.Delete(CheatCodes.FilePath); diff --git a/UI/Config/Configuration.cs b/UI/Config/Configuration.cs index 02b485477..ceb96bb38 100644 --- a/UI/Config/Configuration.cs +++ b/UI/Config/Configuration.cs @@ -240,7 +240,7 @@ public static Configuration Deserialize(string configFile) try { string fileData = File.ReadAllText(configFile); - config = JsonSerializer.Deserialize(fileData, JsonHelper.Options) ?? Configuration.CreateConfig(); + config = (Configuration?)JsonSerializer.Deserialize(fileData, typeof(Configuration), MesenSerializerContext.Default) ?? Configuration.CreateConfig(); config._fileData = fileData; } catch { try { @@ -260,7 +260,7 @@ public static Configuration Deserialize(string configFile) public void Serialize(string configFile) { try { - string cfgData = JsonSerializer.Serialize(this, typeof(Configuration), JsonHelper.Options); + string cfgData = JsonSerializer.Serialize(this, typeof(Configuration), MesenSerializerContext.Default); if(_fileData != cfgData && !Design.IsDesignMode) { FileHelper.WriteAllText(configFile, cfgData); _fileData = cfgData; diff --git a/UI/Config/Debugger/AssemblerConfig.cs b/UI/Config/Debugger/AssemblerConfig.cs index 9756d6e15..c849c95c4 100644 --- a/UI/Config/Debugger/AssemblerConfig.cs +++ b/UI/Config/Debugger/AssemblerConfig.cs @@ -5,6 +5,5 @@ namespace Mesen.Config { public class AssemblerConfig : BaseWindowConfig { - public int Zoom = 100; } } \ No newline at end of file diff --git a/UI/Config/Debugger/DebuggerConfig.cs b/UI/Config/Debugger/DebuggerConfig.cs index 2b329b09a..cf99f4a3b 100644 --- a/UI/Config/Debugger/DebuggerConfig.cs +++ b/UI/Config/Debugger/DebuggerConfig.cs @@ -6,6 +6,8 @@ using System.Reactive.Linq; using System.Reactive; using System.Collections.Generic; +using ReactiveUI; +using System; namespace Mesen.Config { @@ -65,23 +67,23 @@ public class DebuggerConfig : BaseWindowConfig [Reactive] public bool ShowSelectionLength { get; set; } = false; [Reactive] public WatchFormatStyle WatchFormat { get; set; } = WatchFormatStyle.Hex; - [Reactive] public Color CodeOpcodeColor { get; set; } = Color.FromRgb(22, 37, 37); - [Reactive] public Color CodeLabelDefinitionColor { get; set; } = Colors.Blue; - [Reactive] public Color CodeImmediateColor { get; set; } = Colors.Chocolate; - [Reactive] public Color CodeAddressColor { get; set; } = Colors.DarkRed; - [Reactive] public Color CodeCommentColor { get; set; } = Colors.Green; - [Reactive] public Color CodeEffectiveAddressColor { get; set; } = Colors.SteelBlue; + [Reactive] public UInt32 CodeOpcodeColor { get; set; } = Color.FromRgb(22, 37, 37).ToUInt32(); + [Reactive] public UInt32 CodeLabelDefinitionColor { get; set; } = Colors.Blue.ToUInt32(); + [Reactive] public UInt32 CodeImmediateColor { get; set; } = Colors.Chocolate.ToUInt32(); + [Reactive] public UInt32 CodeAddressColor { get; set; } = Colors.DarkRed.ToUInt32(); + [Reactive] public UInt32 CodeCommentColor { get; set; } = Colors.Green.ToUInt32(); + [Reactive] public UInt32 CodeEffectiveAddressColor { get; set; } = Colors.SteelBlue.ToUInt32(); - [Reactive] public Color CodeVerifiedDataColor { get; set; } = Color.FromRgb(255, 252, 236); - [Reactive] public Color CodeUnidentifiedDataColor { get; set; } = Color.FromRgb(255, 242, 242); - [Reactive] public Color CodeUnexecutedCodeColor { get; set; } = Color.FromRgb(225, 244, 228); + [Reactive] public UInt32 CodeVerifiedDataColor { get; set; } = Color.FromRgb(255, 252, 236).ToUInt32(); + [Reactive] public UInt32 CodeUnidentifiedDataColor { get; set; } = Color.FromRgb(255, 242, 242).ToUInt32(); + [Reactive] public UInt32 CodeUnexecutedCodeColor { get; set; } = Color.FromRgb(225, 244, 228).ToUInt32(); - [Reactive] public Color CodeExecBreakpointColor { get; set; } = Color.FromRgb(140, 40, 40); - [Reactive] public Color CodeWriteBreakpointColor { get; set; } = Color.FromRgb(40, 120, 80); - [Reactive] public Color CodeReadBreakpointColor { get; set; } = Color.FromRgb(40, 40, 200); + [Reactive] public UInt32 CodeExecBreakpointColor { get; set; } = Color.FromRgb(140, 40, 40).ToUInt32(); + [Reactive] public UInt32 CodeWriteBreakpointColor { get; set; } = Color.FromRgb(40, 120, 80).ToUInt32(); + [Reactive] public UInt32 CodeReadBreakpointColor { get; set; } = Color.FromRgb(40, 40, 200).ToUInt32(); - [Reactive] public Color CodeActiveStatementColor { get; set; } = Colors.Yellow; - [Reactive] public Color CodeActiveMidInstructionColor { get; set; } = Color.FromRgb(255, 220, 40); + [Reactive] public UInt32 CodeActiveStatementColor { get; set; } = Colors.Yellow.ToUInt32(); + [Reactive] public UInt32 CodeActiveMidInstructionColor { get; set; } = Color.FromRgb(255, 220, 40).ToUInt32(); [Reactive] public List LabelListColumnWidths { get; set; } = new(); [Reactive] public List FunctionListColumnWidths { get; set; } = new(); @@ -95,6 +97,11 @@ public DebuggerConfig() } } + public class CfgColor : ReactiveObject + { + [Reactive] public UInt32 ColorCode { get; set; } + } + public enum BreakInMetric { CpuInstructions, diff --git a/UI/Config/Debugger/HexEditorConfig.cs b/UI/Config/Debugger/HexEditorConfig.cs index 4bdee6d53..82c14271e 100644 --- a/UI/Config/Debugger/HexEditorConfig.cs +++ b/UI/Config/Debugger/HexEditorConfig.cs @@ -3,6 +3,7 @@ using System.IO; using System.Linq; using System.Text; +using System.Text.Json.Serialization; using System.Threading.Tasks; using System.Xml; using System.Xml.Serialization; @@ -83,6 +84,7 @@ public class HighlightConfig : ReactiveObject [Reactive] public bool Highlight { get; set; } [Reactive] public UInt32 ColorCode { get; set; } + [JsonIgnore] public Color Color { get { return Color.FromUInt32(ColorCode); } diff --git a/UI/Config/Debugger/RegisterViewerConfig.cs b/UI/Config/Debugger/RegisterViewerConfig.cs index fc5805f00..38cfd4312 100644 --- a/UI/Config/Debugger/RegisterViewerConfig.cs +++ b/UI/Config/Debugger/RegisterViewerConfig.cs @@ -5,7 +5,7 @@ namespace Mesen.Config { public class RegisterViewerConfig : BaseWindowConfig { - public RefreshTimingConfig RefreshTiming = new RefreshTimingConfig(); + [Reactive] public RefreshTimingConfig RefreshTiming { get; set; } = new(); [Reactive] public List ColumnWidths { get; set; } = new(); } } diff --git a/UI/Config/GameConfig.cs b/UI/Config/GameConfig.cs index 949b2eea3..baa1281ca 100644 --- a/UI/Config/GameConfig.cs +++ b/UI/Config/GameConfig.cs @@ -38,7 +38,7 @@ public static GameConfig LoadGameConfig(RomInfo romInfo) string? fileData = FileHelper.ReadAllText(path); if(fileData != null) { try { - cfg = JsonSerializer.Deserialize(fileData, JsonHelper.Options); + cfg = (GameConfig?)JsonSerializer.Deserialize(fileData, typeof(GameConfig), MesenSerializerContext.Default); if(cfg != null) { return cfg; } @@ -55,7 +55,7 @@ public void Save() { string romName = MainWindowViewModel.Instance.RomInfo.GetRomName(); string path = Path.Combine(ConfigManager.GameConfigFolder, romName + ".json"); - FileHelper.WriteAllText(path, JsonSerializer.Serialize(this, JsonHelper.Options)); + FileHelper.WriteAllText(path, JsonSerializer.Serialize(this, typeof(GameConfig), MesenSerializerContext.Default)); } } diff --git a/UI/Controls/ButtonWithIcon.axaml b/UI/Controls/ButtonWithIcon.axaml index d207dc5a6..08a86fae3 100644 --- a/UI/Controls/ButtonWithIcon.axaml +++ b/UI/Controls/ButtonWithIcon.axaml @@ -9,7 +9,7 @@ Classes="ButtonWithIcon" > - - + + \ No newline at end of file diff --git a/UI/Controls/EnumComboBox.axaml b/UI/Controls/EnumComboBox.axaml index 72db32fac..e399f7648 100644 --- a/UI/Controls/EnumComboBox.axaml +++ b/UI/Controls/EnumComboBox.axaml @@ -12,7 +12,7 @@ \ No newline at end of file diff --git a/UI/Controls/EnumComboBox.axaml.cs b/UI/Controls/EnumComboBox.axaml.cs index a314da303..52507baa1 100644 --- a/UI/Controls/EnumComboBox.axaml.cs +++ b/UI/Controls/EnumComboBox.axaml.cs @@ -5,6 +5,7 @@ using Avalonia.Markup.Xaml; using Avalonia.Media; using Avalonia.Threading; +using Mesen.Localization; using System; using System.Collections; using System.Linq; @@ -99,7 +100,7 @@ private void InitComboBox(bool updateAvailableValues) Dispatcher.UIThread.Post(() => { if(updateAvailableValues) { if(AvailableValues == null || AvailableValues.Length == 0) { - InternalItems = Enum.GetValues(_enumType); + InternalItems = ResourceHelper.GetEnumValues(_enumType); } else { InternalItems = AvailableValues; } diff --git a/UI/Controls/GroupBox.axaml b/UI/Controls/GroupBox.axaml index cfa22c55f..620bd58ac 100644 --- a/UI/Controls/GroupBox.axaml +++ b/UI/Controls/GroupBox.axaml @@ -17,7 +17,7 @@ diff --git a/UI/Debugger/Controls/ScrollPictureViewer.axaml b/UI/Debugger/Controls/ScrollPictureViewer.axaml index 67c0badcd..406a3b0d3 100644 --- a/UI/Debugger/Controls/ScrollPictureViewer.axaml +++ b/UI/Debugger/Controls/ScrollPictureViewer.axaml @@ -12,33 +12,33 @@ diff --git a/UI/Debugger/Controls/SpritePreviewPanel.axaml b/UI/Debugger/Controls/SpritePreviewPanel.axaml index 682e04aed..41a84cb5f 100644 --- a/UI/Debugger/Controls/SpritePreviewPanel.axaml +++ b/UI/Debugger/Controls/SpritePreviewPanel.axaml @@ -20,8 +20,8 @@ > diff --git a/UI/Debugger/DebuggerDockFactory.cs b/UI/Debugger/DebuggerDockFactory.cs index 72ab95c80..386f91fd5 100644 --- a/UI/Debugger/DebuggerDockFactory.cs +++ b/UI/Debugger/DebuggerDockFactory.cs @@ -258,12 +258,12 @@ public enum DockEntryType public class DockEntryDefinition { - public DockEntryType Type; - public double Proportion = 0; - public Orientation Orientation = Orientation.Horizontal; - public string Name = ""; - public string ToolTypeName = ""; - public int SelectedIndex = 0; - public List? Children; + public DockEntryType Type { get; set; } + public double Proportion { get; set; } = 0; + public Orientation Orientation { get; set; } = Orientation.Horizontal; + public string Name { get; set; } = ""; + public string ToolTypeName { get; set; } = ""; + public int SelectedIndex { get; set; } = 0; + public List? Children { get; set; } } } diff --git a/UI/Debugger/DebuggerViewLocator.cs b/UI/Debugger/DebuggerViewLocator.cs deleted file mode 100644 index 1947d0b8e..000000000 --- a/UI/Debugger/DebuggerViewLocator.cs +++ /dev/null @@ -1,41 +0,0 @@ -using Avalonia.Controls; -using Avalonia.Controls.Templates; -using Dock.Model.Core; -using Mesen.Debugger.Views.DebuggerDock; -using Mesen.ViewModels; -using System; - -namespace Mesen.Debugger -{ - class DebuggerViewLocator : IDataTemplate - { - public Control Build(object? data) - { - string? name = data?.GetType().FullName?.Replace("ViewModel", "View"); - if(name == null) { - return new TextBlock { Text = "Not Found: " + name }; - } - - Type? type = Type.GetType(name); - if(type != null) { - object? obj = Activator.CreateInstance(type); - if(obj is Control) { - return (Control)obj; - } else { - return new TextBlock(); - } - } else { - if(data?.GetType().Name.StartsWith(nameof(ToolContainerView)) == true) { - return new ToolContainerView(); - } else { - return new TextBlock { Text = "Not Found: " + name }; - } - } - } - - public bool Match(object? data) - { - return data is ViewModelBase || data is IDockable; - } - } -} diff --git a/UI/Debugger/Disassembly/BaseStyleProvider.cs b/UI/Debugger/Disassembly/BaseStyleProvider.cs index b92b24b85..9fcae64cf 100644 --- a/UI/Debugger/Disassembly/BaseStyleProvider.cs +++ b/UI/Debugger/Disassembly/BaseStyleProvider.cs @@ -30,9 +30,9 @@ private void ConfigureActiveStatement(LineProperties props) DebuggerFeatures features = DebugApi.GetDebuggerFeatures(CpuType); if(features.ChangeProgramCounter) { - props.TextBgColor = ConfigManager.Config.Debug.Debugger.CodeActiveStatementColor; + props.TextBgColor = Color.FromUInt32(ConfigManager.Config.Debug.Debugger.CodeActiveStatementColor); } else { - props.TextBgColor = ConfigManager.Config.Debug.Debugger.CodeActiveMidInstructionColor; + props.TextBgColor = Color.FromUInt32(ConfigManager.Config.Debug.Debugger.CodeActiveMidInstructionColor); } props.FgColor = ColorHelper.GetContrastTextColor(props.TextBgColor.Value); props.Symbol |= LineSymbol.Arrow; @@ -101,11 +101,11 @@ public LineProperties GetLineStyle(CodeLineData lineData, int lineIndex) } if(lineData.Flags.HasFlag(LineFlags.VerifiedData)) { - props.LineBgColor = cfg.CodeVerifiedDataColor; + props.LineBgColor = Color.FromUInt32(cfg.CodeVerifiedDataColor); } else if(lineData.Flags.HasFlag(LineFlags.UnexecutedCode)) { - props.LineBgColor = cfg.CodeUnexecutedCodeColor; + props.LineBgColor = Color.FromUInt32(cfg.CodeUnexecutedCodeColor); } else if(!lineData.Flags.HasFlag(LineFlags.VerifiedCode)) { - props.LineBgColor = cfg.CodeUnidentifiedDataColor; + props.LineBgColor = Color.FromUInt32(cfg.CodeUnidentifiedDataColor); } return props; diff --git a/UI/Debugger/Disassembly/CodeHighlighting.cs b/UI/Debugger/Disassembly/CodeHighlighting.cs index e04357aba..50cb95436 100644 --- a/UI/Debugger/Disassembly/CodeHighlighting.cs +++ b/UI/Debugger/Disassembly/CodeHighlighting.cs @@ -38,15 +38,15 @@ public static List GetCpuHighlights(CodeLineData lineData, bool highl while(codeString.Length > 0) { Match m; if((m = _comment.Match(codeString)).Success) { - colors.Add(new CodeColor(m.Value, cfg.CodeCommentColor, CodeSegmentType.Comment, pos)); + colors.Add(new CodeColor(m.Value, Color.FromUInt32(cfg.CodeCommentColor), CodeSegmentType.Comment, pos)); } else if(colors.Count == 0 && (m = _labelDef.Match(codeString)).Success) { - colors.Add(new CodeColor(m.Groups[1].Value, cfg.CodeLabelDefinitionColor, CodeSegmentType.LabelDefinition, pos)); + colors.Add(new CodeColor(m.Groups[1].Value, Color.FromUInt32(cfg.CodeLabelDefinitionColor), CodeSegmentType.LabelDefinition, pos)); } else if(!foundOpCode && (m = _directive.Match(codeString)).Success) { foundDirective = true; - colors.Add(new CodeColor(m.Groups[1].Value, cfg.CodeOpcodeColor, CodeSegmentType.Directive, pos)); + colors.Add(new CodeColor(m.Groups[1].Value, Color.FromUInt32(cfg.CodeOpcodeColor), CodeSegmentType.Directive, pos)); } else if(!foundOpCode && (m = _opCode.Match(codeString)).Success) { foundOpCode = true; - colors.Add(new CodeColor(m.Groups[1].Value, textColor ?? cfg.CodeOpcodeColor, CodeSegmentType.OpCode, pos)); + colors.Add(new CodeColor(m.Groups[1].Value, textColor ?? Color.FromUInt32(cfg.CodeOpcodeColor), CodeSegmentType.OpCode, pos)); } else if((foundOpCode || foundDirective) && (m = _operand.Match(codeString)).Success) { string operand = m.Value; Color operandColor = Colors.Black; @@ -54,15 +54,15 @@ public static List GetCpuHighlights(CodeLineData lineData, bool highl if(operand.Length > 0) { switch(operand[0]) { case '#': - operandColor = cfg.CodeImmediateColor; + operandColor = Color.FromUInt32(cfg.CodeImmediateColor); type = CodeSegmentType.ImmediateValue; break; case '$': - operandColor = cfg.CodeAddressColor; + operandColor = Color.FromUInt32(cfg.CodeAddressColor); type = CodeSegmentType.Address; break; default: - operandColor = cfg.CodeLabelDefinitionColor; + operandColor = Color.FromUInt32(cfg.CodeLabelDefinitionColor); type = CodeSegmentType.Label; break; } @@ -94,7 +94,7 @@ public static List GetCpuHighlights(CodeLineData lineData, bool highl if(lineData.ShowEffectiveAddress && lineData.EffectiveAddress >= 0) { string effAddress = lineData.GetEffectiveAddressString(addressFormat, out CodeSegmentType type); - colors.Add(new CodeColor(" " + effAddress, cfg.CodeEffectiveAddressColor, type)); + colors.Add(new CodeColor(" " + effAddress, Color.FromUInt32(cfg.CodeEffectiveAddressColor), type)); } if(showMemoryValues && lineData.ValueSize > 0) { @@ -102,13 +102,13 @@ public static List GetCpuHighlights(CodeLineData lineData, bool highl } if(!string.IsNullOrWhiteSpace(lineData.Comment)) { - colors.Add(new CodeColor(" " + lineData.Comment, cfg.CodeCommentColor, CodeSegmentType.Comment)); + colors.Add(new CodeColor(" " + lineData.Comment, Color.FromUInt32(cfg.CodeCommentColor), CodeSegmentType.Comment)); } } else { if(lineData.Flags.HasFlag(LineFlags.Comment)) { - colors.Add(new CodeColor(lineData.Comment, cfg.CodeCommentColor, CodeSegmentType.Comment)); + colors.Add(new CodeColor(lineData.Comment, Color.FromUInt32(cfg.CodeCommentColor), CodeSegmentType.Comment)); } else if(codeString.EndsWith(":")) { - colors.Add(new CodeColor(codeString, cfg.CodeLabelDefinitionColor, CodeSegmentType.LabelDefinition)); + colors.Add(new CodeColor(codeString, Color.FromUInt32(cfg.CodeLabelDefinitionColor), CodeSegmentType.LabelDefinition)); } else { colors.Add(new CodeColor(codeString, textColor ?? defaultColor, CodeSegmentType.None)); } diff --git a/UI/Debugger/Disassembly/SourceViewStyleProvider.cs b/UI/Debugger/Disassembly/SourceViewStyleProvider.cs index fbff486a9..fb6141d00 100644 --- a/UI/Debugger/Disassembly/SourceViewStyleProvider.cs +++ b/UI/Debugger/Disassembly/SourceViewStyleProvider.cs @@ -62,15 +62,15 @@ public static List GetCHighlights(CodeLineData lineData, bool highlig while(codeString.Length > 0) { Match m; if((m = _comment.Match(codeString)).Success) { - colors.Add(new CodeColor(m.Value, textColor ?? cfg.CodeCommentColor, CodeSegmentType.Comment, pos)); + colors.Add(new CodeColor(m.Value, textColor ?? Color.FromUInt32(cfg.CodeCommentColor), CodeSegmentType.Comment, pos)); } else if((m = _number.Match(codeString)).Success) { - colors.Add(new CodeColor(m.Value, textColor ?? cfg.CodeImmediateColor, CodeSegmentType.ImmediateValue, pos)); + colors.Add(new CodeColor(m.Value, textColor ?? Color.FromUInt32(cfg.CodeImmediateColor), CodeSegmentType.ImmediateValue, pos)); } else if((m = _keywords.Match(codeString)).Success) { - colors.Add(new CodeColor(m.Groups[1].Value, textColor ?? cfg.CodeAddressColor, CodeSegmentType.OpCode, pos)); + colors.Add(new CodeColor(m.Groups[1].Value, textColor ?? Color.FromUInt32(cfg.CodeAddressColor), CodeSegmentType.OpCode, pos)); } else if((m = _text.Match(codeString)).Success) { colors.Add(new CodeColor(m.Groups[1].Value, textColor ?? defaultColor, CodeSegmentType.OpCode, pos)); } else if((m = _syntax.Match(codeString)).Success) { - colors.Add(new CodeColor(m.Value, textColor ?? cfg.CodeEffectiveAddressColor, CodeSegmentType.Syntax, pos)); + colors.Add(new CodeColor(m.Value, textColor ?? Color.FromUInt32(cfg.CodeEffectiveAddressColor), CodeSegmentType.Syntax, pos)); } else if((m = _space.Match(codeString)).Success) { colors.Add(new CodeColor(m.Value, textColor ?? defaultColor, CodeSegmentType.None, pos)); } diff --git a/UI/Debugger/HexEditorDataProvider.cs b/UI/Debugger/HexEditorDataProvider.cs index 34063c26b..51935dd01 100644 --- a/UI/Debugger/HexEditorDataProvider.cs +++ b/UI/Debugger/HexEditorDataProvider.cs @@ -170,13 +170,13 @@ public ByteInfo GetByte(int byteIndex) if(_breakpointTypes != null) { switch(_breakpointTypes[index]) { case BreakpointTypeFlags.Execute: - _byteInfo.BorderColor = ConfigManager.Config.Debug.Debugger.CodeExecBreakpointColor; + _byteInfo.BorderColor = Color.FromUInt32(ConfigManager.Config.Debug.Debugger.CodeExecBreakpointColor); break; case BreakpointTypeFlags.Write: - _byteInfo.BorderColor = ConfigManager.Config.Debug.Debugger.CodeWriteBreakpointColor; + _byteInfo.BorderColor = Color.FromUInt32(ConfigManager.Config.Debug.Debugger.CodeWriteBreakpointColor); break; case BreakpointTypeFlags.Read: - _byteInfo.BorderColor = ConfigManager.Config.Debug.Debugger.CodeReadBreakpointColor; + _byteInfo.BorderColor = Color.FromUInt32(ConfigManager.Config.Debug.Debugger.CodeReadBreakpointColor); break; } } diff --git a/UI/Debugger/StatusViews/Cx4StatusView.axaml b/UI/Debugger/StatusViews/Cx4StatusView.axaml index 4f92886f1..c34897065 100644 --- a/UI/Debugger/StatusViews/Cx4StatusView.axaml +++ b/UI/Debugger/StatusViews/Cx4StatusView.axaml @@ -22,7 +22,7 @@ - + diff --git a/UI/Debugger/Views/CallStackView.axaml.cs b/UI/Debugger/Views/CallStackView.axaml.cs index 45058812a..039611331 100644 --- a/UI/Debugger/Views/CallStackView.axaml.cs +++ b/UI/Debugger/Views/CallStackView.axaml.cs @@ -31,7 +31,7 @@ protected override void OnDataContextChanged(EventArgs e) private void OnCellDoubleClick(DataBoxCell cell) { - if(cell.DataContext is CallStackViewModel.StackInfo stack && DataContext is CallStackViewModel model) { + if(cell.DataContext is StackInfo stack && DataContext is CallStackViewModel model) { model.GoToLocation(stack); } } diff --git a/UI/Debugger/Views/ControllerInputView.axaml b/UI/Debugger/Views/ControllerInputView.axaml index dcb47eb30..a281c2c87 100644 --- a/UI/Debugger/Views/ControllerInputView.axaml +++ b/UI/Debugger/Views/ControllerInputView.axaml @@ -39,7 +39,7 @@ - @@ -61,8 +61,8 @@ -