From be5e29cc5ac69bbe7378af69942786d1b3f10e92 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Thu, 18 Nov 2021 21:53:18 +1000 Subject: [PATCH] Don't serialise `PathEntry.Ordinal` --- default.nix | 2 +- src/BizHawk.Client.Common/config/PathEntry.cs | 43 ++++++++++++++++-- .../config/PathEntryCollection.cs | 44 +++++++++---------- 3 files changed, 63 insertions(+), 26 deletions(-) diff --git a/default.nix b/default.nix index 77d3751da4..2e209ae5a8 100644 --- a/default.nix +++ b/default.nix @@ -85,7 +85,7 @@ let LastWrittenFrom = if builtins.length (builtins.splitVersion hawkVersion) < 3 then "${hawkVersion}.0" else hawkVersion; PathEntries = { Paths = [ - { "System" = "Global_NULL"; "Ordinal" = 1; Type = "Base"; Path = "%%BIZHAWK_DATA_HOME%%"; } + ({ "System" = "Global_NULL"; Type = "Base"; Path = "%%BIZHAWK_DATA_HOME%%"; } // lib.optionalAttrs (!versionAtLeast "2.7.1" bizhawk) { "Ordinal" = 1; }) ]; }; } // initConfig)); diff --git a/src/BizHawk.Client.Common/config/PathEntry.cs b/src/BizHawk.Client.Common/config/PathEntry.cs index d9bfce8cb1..8f45d2910f 100644 --- a/src/BizHawk.Client.Common/config/PathEntry.cs +++ b/src/BizHawk.Client.Common/config/PathEntry.cs @@ -13,11 +13,48 @@ namespace BizHawk.Client.Common set => _path = value.Replace('\\', '/'); } public string System { get; set; } - public int Ordinal { get; set; } - public PathEntry(string system, int ordinal, string type, string path) + [JsonIgnore] + public readonly int Ordinal; + + public PathEntry(string system, string type, string path) { - Ordinal = ordinal; + Ordinal = type switch + { + // all + "Base" => 0x00, + "ROM" => 0x01, + + // only Global + "Firmware" => 0x10, + "Movies" => 0x11, + "Movie backups" => 0x12, + "A/V Dumps" => 0x13, + "Tools" => 0x14, + "Lua" => 0x15, + "Watch (.wch)" => 0x16, + "Debug Logs" => 0x17, + "Macros" => 0x18, + "TAStudio states" => 0x19, + "Multi-Disk Bundles" => 0x1A, + "External Tools" => 0x1B, + "Temp Files" => 0x1C, + + // only Libretro + "Cores" => 0x10, + "System" => 0x11, + + // all cores incl. Libretro + "Savestates" => 0x20, + "Save RAM" => 0x21, + "Screenshots" => 0x22, + "Cheats" => 0x23, + + // some cores + "Palettes" => 0x30, + + _ => 0x40 + }; Path = path; System = system; Type = type; diff --git a/src/BizHawk.Client.Common/config/PathEntryCollection.cs b/src/BizHawk.Client.Common/config/PathEntryCollection.cs index fccf0045b3..56e6b75d10 100644 --- a/src/BizHawk.Client.Common/config/PathEntryCollection.cs +++ b/src/BizHawk.Client.Common/config/PathEntryCollection.cs @@ -64,10 +64,10 @@ namespace BizHawk.Client.Common }; private static PathEntry BaseEntryFor(string sysID, string path) - => new(sysID, 0x00, "Base", path); + => new(sysID, "Base", path); private static PathEntry CheatsEntryFor(string sysID) - => new(sysID, 0x23, "Cheats", Path.Combine(".", "Cheats")); + => new(sysID, "Cheats", Path.Combine(".", "Cheats")); private static IEnumerable CommonEntriesFor(string sysID, string basePath, bool omitSaveRAM = false) { @@ -91,19 +91,19 @@ namespace BizHawk.Client.Common => sysID == group || group.Split('_').Contains(sysID); private static PathEntry PalettesEntryFor(string sysID) - => new(sysID, 0x30, "Palettes", Path.Combine(".", "Palettes")); + => new(sysID, "Palettes", Path.Combine(".", "Palettes")); private static PathEntry ROMEntryFor(string sysID, string path = ".") - => new(sysID, 0x01, "ROM", path); + => new(sysID, "ROM", path); private static PathEntry SaveRAMEntryFor(string sysID) - => new(sysID, 0x21, "Save RAM", Path.Combine(".", "SaveRAM")); + => new(sysID, "Save RAM", Path.Combine(".", "SaveRAM")); private static PathEntry SavestatesEntryFor(string sysID) - => new(sysID, 0x20, "Savestates", Path.Combine(".", "State")); + => new(sysID, "Savestates", Path.Combine(".", "State")); private static PathEntry ScreenshotsEntryFor(string sysID) - => new(sysID, 0x22, "Screenshots", Path.Combine(".", "Screenshots")); + => new(sysID, "Screenshots", Path.Combine(".", "Screenshots")); public List Paths { get; } @@ -180,19 +180,19 @@ namespace BizHawk.Client.Common new[] { BaseEntryFor(GLOBAL, "."), ROMEntryFor(GLOBAL), - new(GLOBAL, 0x10, "Firmware", Path.Combine(".", "Firmware")), - new(GLOBAL, 0x11, "Movies", Path.Combine(".", "Movies")), - new(GLOBAL, 0x12, "Movie backups", Path.Combine(".", "Movies", "backup")), - new(GLOBAL, 0x13, "A/V Dumps", "."), - new(GLOBAL, 0x14, "Tools", Path.Combine(".", "Tools")), - new(GLOBAL, 0x15, "Lua", Path.Combine(".", "Lua")), - new(GLOBAL, 0x16, "Watch (.wch)", Path.Combine(".", ".")), - new(GLOBAL, 0x17, "Debug Logs", Path.Combine(".", "")), - new(GLOBAL, 0x18, "Macros", Path.Combine(".", "Movies", "Macros")), - new(GLOBAL, 0x19, "TAStudio states", Path.Combine(".", "Movies", "TAStudio states")), - new(GLOBAL, 0x1A, "Multi-Disk Bundles", Path.Combine(".", "")), - new(GLOBAL, 0x1B, "External Tools", Path.Combine(".", "ExternalTools")), - new(GLOBAL, 0x1C, "Temp Files", ""), + new(GLOBAL, "Firmware", Path.Combine(".", "Firmware")), + new(GLOBAL, "Movies", Path.Combine(".", "Movies")), + new(GLOBAL, "Movie backups", Path.Combine(".", "Movies", "backup")), + new(GLOBAL, "A/V Dumps", "."), + new(GLOBAL, "Tools", Path.Combine(".", "Tools")), + new(GLOBAL, "Lua", Path.Combine(".", "Lua")), + new(GLOBAL, "Watch (.wch)", Path.Combine(".", ".")), + new(GLOBAL, "Debug Logs", Path.Combine(".", "")), + new(GLOBAL, "Macros", Path.Combine(".", "Movies", "Macros")), + new(GLOBAL, "TAStudio states", Path.Combine(".", "Movies", "TAStudio states")), + new(GLOBAL, "Multi-Disk Bundles", Path.Combine(".", "")), + new(GLOBAL, "External Tools", Path.Combine(".", "ExternalTools")), + new(GLOBAL, "Temp Files", ""), }, CommonEntriesFor(VSystemID.Raw.Sega32X, basePath: Path.Combine(".", "32X")), @@ -245,8 +245,8 @@ namespace BizHawk.Client.Common // Really, "Open Rom" for instance doesn't make sense when you have a libretro core open. // Well, this is better than nothing. ROMEntryFor(VSystemID.Raw.Libretro, "%recent%"), - new(VSystemID.Raw.Libretro, 0x10, "Cores", Path.Combine(".", "Cores")), - new(VSystemID.Raw.Libretro, 0x11, "System", Path.Combine(".", "System")), + new(VSystemID.Raw.Libretro, "Cores", Path.Combine(".", "Cores")), + new(VSystemID.Raw.Libretro, "System", Path.Combine(".", "System")), SavestatesEntryFor(VSystemID.Raw.Libretro), SaveRAMEntryFor(VSystemID.Raw.Libretro), ScreenshotsEntryFor(VSystemID.Raw.Libretro),