Clean up "display name" stupidity

* removed CoreAttribute.DisplayName (using IEmulator.SystemId instead)
* fixed ToolManager checking for "(Experimental) " prefix on names of unreleased
cores in ToolAttribute.UnsupportedCores
* corrected display name of UZE sysID to "Uzebox" (was "uzem")
* disabled auto-generated accelerators (&A -> Alt+A) on "current system" menu in
MainForm menubar because they could conflict with hardcoded ones
This commit is contained in:
YoshiRulz 2021-04-09 12:22:58 +10:00
parent 193e9aa7dc
commit 553319ec95
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
25 changed files with 105 additions and 144 deletions

View File

@ -38,61 +38,13 @@ namespace BizHawk.Client.EmuHawk.CoreExtensions
};
}
public static string DisplayName(this IEmulator core)
public static string GetSystemDisplayName(this IEmulator emulator) => emulator switch
{
var attributes = core.Attributes();
var str = (!attributes.Released ? "(Experimental) " : "") +
attributes.CoreName;
return str;
}
public static string GetSystemDisplayName(this IEmulator emulator) => emulator.SystemId switch
{
"NULL" => string.Empty,
"NES" => "NES",
"INTV" => "Intellivision",
"GG" => "Game Gear",
"SG" => "SG-1000",
"SMS" => "Sega Master System",
"PCECD" => "TurboGrafx - 16(CD)",
"PCE" => "TurboGrafx-16",
"SGX" => "SuperGrafx",
"GEN" => "Genesis",
"TI83" => "TI - 83",
"SNES" => "SNES",
NullEmulator => string.Empty,
#if false
"GB" when emulator is IGameboyCommon gb && gb.IsCGBMode() => "Gameboy Color",
IGameboyCommon gb when gb.IsCGBMode() => EmulatorExtensions.SystemIDToDisplayName("GBC"),
#endif
"GB" => "GB",
"A26" => "Atari 2600",
"A78" => "Atari 7800",
"C64" => "Commodore 64",
"Coleco" => "ColecoVision",
"GBA" => "Gameboy Advance",
"NDS" => "NDS",
"N64" => "Nintendo 64",
"SAT" => "Saturn",
"DGB" => "Game Boy Link",
"GB3x" => "Game Boy Link 3x",
"GB4x" => "Game Boy Link 4x",
"WSWAN" => "WonderSwan",
"Lynx" => "Lynx",
"PSX" => "PlayStation",
"AppleII" => "Apple II",
"Libretro" => "Libretro",
"VB" => "Virtual Boy",
"VEC" => "Vectrex",
"NGP" => "Neo-Geo Pocket",
"ZXSpectrum" => "ZX Spectrum",
"AmstradCPC" => "Amstrad CPC",
"ChannelF" => "Channel F",
"O2" => "Odyssey2",
"MAME" => "MAME",
"UZE" => "uzem",
"PCFX" => "PCFX",
_ => string.Empty
_ => EmulatorExtensions.SystemIDToDisplayName(emulator.SystemId)
};
}
}

View File

@ -1790,7 +1790,8 @@ namespace BizHawk.Client.EmuHawk
private void GenericCoreSettingsMenuItem_Click(object sender, EventArgs e)
{
GenericCoreConfig.DoDialog(this, $"{Emulator.DisplayName()} Settings");
var coreName = ((CoreAttribute) Attribute.GetCustomAttribute(Emulator.GetType(), typeof(CoreAttribute))).CoreName;
GenericCoreConfig.DoDialog(this, $"{coreName} Settings");
}
private void AppleIISettingsMenuItem_Click(object sender, EventArgs e)

View File

@ -2006,7 +2006,11 @@ namespace BizHawk.Client.EmuHawk
private void DisplayDefaultCoreMenu()
{
GenericCoreSubMenu.Visible = true;
GenericCoreSubMenu.Text = "&" + EmulatorExtensions.DisplayName(Emulator);
#if true
GenericCoreSubMenu.Text = Emulator.GetSystemDisplayName();
#else //TODO accelerator; I commented out this naive approach which doesn't work --yoshi
GenericCoreSubMenu.Text = $"&{Emulator.GetSystemDisplayName()}";
#endif
GenericCoreSubMenu.DropDownItems.Clear();
var settingsMenuItem = new ToolStripMenuItem { Text = "&Settings" };
@ -2793,7 +2797,8 @@ namespace BizHawk.Client.EmuHawk
private void UpdateCoreStatusBarButton()
{
var coreDispName = CoreExtensions.CoreExtensions.DisplayName(Emulator);
var attributes = Emulator.Attributes();
var coreDispName = attributes.Released ? attributes.CoreName : $"(Experimental) {attributes.CoreName}";
LoadedCoreNameMenuItem.Text = $"Loaded core: {coreDispName} ({Emulator.SystemId})";
if (Emulator.IsNull())
{
@ -2802,7 +2807,6 @@ namespace BizHawk.Client.EmuHawk
}
CoreNameStatusBarButton.Visible = true;
var attributes = Emulator.Attributes();
CoreNameStatusBarButton.Text = coreDispName;
CoreNameStatusBarButton.Image = Emulator.Icon();

View File

@ -740,10 +740,8 @@ namespace BizHawk.Client.EmuHawk
return true; // no ToolAttribute on given type -> assumed all supported
}
var displayName = CoreExtensions.CoreExtensions.DisplayName(_emulator);
var systemId = _emulator.SystemId;
return !attr.UnsupportedCores.Contains(displayName) // not unsupported
&& (!attr.SupportedSystems.Any() || attr.SupportedSystems.Contains(systemId)); // supported (no supported list -> assumed all supported)
return !attr.UnsupportedCores.Contains(_emulator.Attributes().CoreName) // not unsupported
&& (!attr.SupportedSystems.Any() || attr.SupportedSystems.Contains(_emulator.SystemId)); // supported (no supported list -> assumed all supported)
}
public bool IsAvailable<T>() => IsAvailable(typeof(T));

View File

@ -5,7 +5,7 @@ namespace BizHawk.Emulation.Common
[AttributeUsage(AttributeTargets.Class)]
public sealed class CoreAttribute : Attribute
{
public CoreAttribute(string name, string author, bool isPorted, bool isReleased, string portedVersion = null, string portedUrl = null, bool singleInstance = false, string displayName = null)
public CoreAttribute(string name, string author, bool isPorted, bool isReleased, string portedVersion = null, string portedUrl = null, bool singleInstance = false)
{
CoreName = name;
Author = author;
@ -14,11 +14,9 @@ namespace BizHawk.Emulation.Common
PortedVersion = portedVersion ?? string.Empty;
PortedUrl = portedUrl ?? string.Empty;
SingleInstance = singleInstance;
DisplayName = displayName;
}
public string CoreName { get; }
public string DisplayName { get; }
public string Author { get; }
public bool Ported { get; }
public bool Released { get; }

View File

@ -13,22 +13,54 @@ namespace BizHawk.Emulation.Common
{
public static class EmulatorExtensions
{
public static readonly IReadOnlyDictionary<string, string> SystemIDDisplayNames = new Dictionary<string, string>
{
["A26"] = "Atari 2600",
["A78"] = "Atari 7800",
["AmstradCPC"] = "Amstrad CPC",
["AppleII"] = "Apple II",
["C64"] = "Commodore 64",
["ChannelF"] = "Channel F",
["Coleco"] = "ColecoVision",
["DGB"] = "Game Boy Link",
["GB"] = "GB",
["GB3x"] = "Game Boy Link 3x",
["GB4x"] = "Game Boy Link 4x",
["GBA"] = "Gameboy Advance",
["GBC"] = "Gameboy Color",
["GEN"] = "Genesis",
["GG"] = "Game Gear",
["INTV"] = "Intellivision",
["Libretro"] = "Libretro",
["Lynx"] = "Lynx",
["MAME"] = "MAME",
["N64"] = "Nintendo 64",
["NDS"] = "NDS",
["NES"] = "NES",
["NGP"] = "Neo-Geo Pocket",
["O2"] = "Odyssey2",
["PCE"] = "TurboGrafx-16",
["PCECD"] = "TurboGrafx - 16(CD)",
["PCFX"] = "PCFX",
["PSX"] = "PlayStation",
["SAT"] = "Saturn",
["SG"] = "SG-1000",
["SGX"] = "SuperGrafx",
["SMS"] = "Sega Master System",
["SNES"] = "SNES",
["TI83"] = "TI - 83",
["UZE"] = "Uzebox",
["VB"] = "Virtual Boy",
["VEC"] = "Vectrex",
["WSWAN"] = "WonderSwan",
["ZXSpectrum"] = "ZX Spectrum",
};
public static CoreAttribute Attributes(this IEmulator core)
{
return (CoreAttribute)Attribute.GetCustomAttribute(core.GetType(), typeof(CoreAttribute));
}
public static string DisplayName(this IEmulator core)
{
var attr = (CoreAttribute)Attribute.GetCustomAttribute(core.GetType(), typeof(CoreAttribute));
if (attr == null)
{
return core.GetType().Name;
}
return attr.DisplayName ?? attr.CoreName;
}
// todo: most of the special cases involving the NullEmulator should probably go away
public static bool IsNull(this IEmulator core)
{
@ -459,5 +491,8 @@ namespace BizHawk.Emulation.Common
/// <remarks>TODO inline (only change is wrapping strings in <see cref="FirmwareID"/> ctor, these IDs should probably be consts in each core's class)</remarks>
public static byte[] GetFirmwareWithGameInfo(this ICoreFileProvider cfp, string sysId, string firmwareId, bool required, out GameInfo gi, string msg = null)
=> cfp.GetFirmwareWithGameInfo(new(system: sysId, firmware: firmwareId), required: required, out gi, msg: msg);
public static string SystemIDToDisplayName(string sysID)
=> SystemIDDisplayNames.TryGetValue(sysID, out var dispName) ? dispName : string.Empty;
}
}

View File

@ -90,8 +90,7 @@ namespace BizHawk.Emulation.Cores.Arcades.MAME
isReleased: false,
portedVersion: "0.230",
portedUrl: "https://github.com/mamedev/mame.git",
singleInstance: false,
displayName: "Arcade")]
singleInstance: false)]
public partial class MAME : IEmulator, IVideoProvider, ISoundProvider, ISettable<object, MAME.SyncSettings>, IStatable, IInputPollable
{
public MAME(string dir, string file, MAME.SyncSettings syncSettings, out string gamename)

View File

@ -4,12 +4,7 @@ using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Computers.MSX
{
[Core(
"MSXHawk",
"",
isPorted: false,
isReleased: false,
displayName: "MSX")]
[Core("MSXHawk", "", isPorted: false, isReleased: false)]
[ServiceNotApplicable(new[] { typeof(IDriveLight) })]
public partial class MSX : IEmulator, IVideoProvider, ISoundProvider, ISaveRam, IInputPollable, IRegionable, ISettable<MSX.MSXSettings, MSX.MSXSyncSettings>
{

View File

@ -6,12 +6,7 @@ using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Atari.Atari2600
{
[Core(
"Atari2600Hawk",
"Micro500, Alyosha, adelikat, natt",
isPorted: false,
isReleased: true,
displayName: "Atari 2600")]
[Core("Atari2600Hawk", "Micro500, Alyosha, adelikat, natt", isPorted: false, isReleased: true)]
[ServiceNotApplicable(new[] { typeof(IDriveLight), typeof(ISaveRam) })]
public partial class Atari2600 : IEmulator, IDebuggable, IInputPollable, IBoardInfo, IRomInfo,
IRegionable, ICreateGameDBEntries, ISettable<Atari2600.A2600Settings, Atari2600.A2600SyncSettings>

View File

@ -6,12 +6,7 @@ using BizHawk.Emulation.Cores.Components.MC6809;
namespace BizHawk.Emulation.Cores.Consoles.Vectrex
{
[Core(
"VectrexHawk",
"",
isPorted: false,
isReleased: true,
displayName: "Vectrex")]
[Core("VectrexHawk", "", isPorted: false, isReleased: true)]
[ServiceNotApplicable(new[] { typeof(IDriveLight) })]
public partial class VectrexHawk : IEmulator, ISaveRam, IDebuggable, IInputPollable, IRegionable,
ISettable<object, VectrexHawk.VectrexSyncSettings>

View File

@ -6,12 +6,7 @@ using BizHawk.Emulation.Cores.Components.I8048;
namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
{
[Core(
"O2Hawk",
"",
isPorted: false,
isReleased: true,
displayName: "Odyssey 2")]
[Core("O2Hawk", "", isPorted: false, isReleased: true)]
[ServiceNotApplicable(new[] { typeof(IDriveLight) })]
public partial class O2Hawk : IEmulator, ISaveRam, IDebuggable, IInputPollable, IRegionable, ISettable<O2Hawk.O2Settings, O2Hawk.O2SyncSettings>, IBoardInfo
{

View File

@ -9,7 +9,7 @@ using BizHawk.Emulation.Cores.Waterbox;
namespace BizHawk.Emulation.Cores.Consoles.NEC.PCE
{
[Core(CoreNames.HyperNyma, "Mednafen Team", true, true, "1.26.1", "https://mednafen.github.io/releases/", false, "PCE")]
[Core(CoreNames.HyperNyma, "Mednafen Team", true, true, "1.26.1", "https://mednafen.github.io/releases/", false)]
public class HyperNyma : NymaCore, IRegionable, IPceGpuView
{
private readonly LibHyperNyma _hyperNyma;

View File

@ -11,7 +11,7 @@ using BizHawk.Emulation.DiscSystem;
namespace BizHawk.Emulation.Cores.Consoles.NEC.PCE
{
[Core(CoreNames.TurboNyma, "Mednafen Team", true, true, "1.26.1", "https://mednafen.github.io/releases/", false, "PCE")]
[Core(CoreNames.TurboNyma, "Mednafen Team", true, true, "1.26.1", "https://mednafen.github.io/releases/", false)]
public class TurboNyma : NymaCore, IRegionable, IPceGpuView
{
private readonly LibTurboNyma _turboNyma;

View File

@ -5,8 +5,13 @@ using System.Collections.Generic;
namespace BizHawk.Emulation.Cores.Consoles.NEC.PCFX
{
[Core("T. S. T.", "Mednafen Team", true, true, "1.26.1",
"https://mednafen.github.io/releases/", false, "PC-FX")]
[Core("T. S. T.",
author: "Mednafen Team",
isPorted: true,
isReleased: true,
portedVersion: "1.26.1",
portedUrl: "https://mednafen.github.io/releases/",
singleInstance: false)]
public class Tst : NymaCore
{
[CoreConstructor("PCFX")]

View File

@ -6,7 +6,7 @@ using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Nintendo.GBA
{
[Core(CoreNames.Mgba, "endrift", true, true, "0.8", "https://mgba.io/", false, "GBA")]
[Core(CoreNames.Mgba, "endrift", true, true, "0.8", "https://mgba.io/", false)]
[ServiceNotApplicable(new[] { typeof(IDriveLight), typeof(IRegionable) })]
public partial class MGBAHawk : IEmulator, IVideoProvider, ISoundProvider, IGBAGPUViewable,
ISaveRam, IStatable, IInputPollable, ISettable<MGBAHawk.Settings, MGBAHawk.SyncSettings>,

View File

@ -3,12 +3,7 @@ using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink
{
[Core(
"GBHawkLink",
"",
isPorted: false,
isReleased: true,
displayName: "Gameboy")]
[Core("GBHawkLink", "", isPorted: false, isReleased: true)]
[ServiceNotApplicable(new[] { typeof(IDriveLight) })]
public partial class GBHawkLink : IEmulator, ISaveRam, IDebuggable, IStatable, IInputPollable, IRegionable, ILinkable,
ISettable<GBHawkLink.GBLinkSettings, GBHawkLink.GBLinkSyncSettings>

View File

@ -3,12 +3,7 @@ using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x
{
[Core(
"GBHawkLink3x",
"",
isPorted: false,
isReleased: true,
displayName: "Gameboy")]
[Core("GBHawkLink3x", "", isPorted: false, isReleased: true)]
[ServiceNotApplicable(new[] { typeof(IDriveLight) })]
public partial class GBHawkLink3x : IEmulator, ISaveRam, IDebuggable, IStatable, IInputPollable, IRegionable,
ISettable<GBHawkLink3x.GBLink3xSettings, GBHawkLink3x.GBLink3xSyncSettings>

View File

@ -3,12 +3,7 @@ using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x
{
[Core(
"GBHawkLink4x",
"",
isPorted: false,
isReleased: true,
displayName: "Gameboy")]
[Core("GBHawkLink4x", "", isPorted: false, isReleased: true)]
[ServiceNotApplicable(new[] { typeof(IDriveLight) })]
public partial class GBHawkLink4x : IEmulator, ISaveRam, IDebuggable, IStatable, IInputPollable, IRegionable,
ISettable<GBHawkLink4x.GBLink4xSettings, GBHawkLink4x.GBLink4xSyncSettings>

View File

@ -10,8 +10,13 @@ using System.Linq;
namespace BizHawk.Emulation.Cores.Consoles.Nintendo.VB
{
[Core("Virtual Boyee", "Mednafen Team", true, true, "0.9.44.1",
"https://mednafen.github.io/releases/", false, "VirtualBoy")]
[Core("Virtual Boyee",
author: "Mednafen Team",
isPorted: true,
isReleased: true,
portedVersion: "0.9.44.1",
portedUrl: "https://mednafen.github.io/releases/",
singleInstance: false)]
public class VirtualBoyee : WaterboxCore, ISettable<VirtualBoyee.Settings, VirtualBoyee.SyncSettings>
{
private readonly LibVirtualBoyee _boyee;

View File

@ -11,12 +11,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
{
public enum NecSystemType { TurboGrafx, TurboCD, SuperGrafx }
[Core(
CoreNames.PceHawk,
"Vecna",
isPorted: false,
isReleased: true,
displayName: "PCE")]
[Core(CoreNames.PceHawk, "Vecna", isPorted: false, isReleased: true)]
public sealed partial class PCEngine : IEmulator, ISaveRam, IInputPollable, IVideoLogicalOffsets, IRomInfo,
IDebuggable, ISettable<PCEngine.PCESettings, PCEngine.PCESyncSettings>, IDriveLight, ICodeDataLogger,
IPceGpuView

View File

@ -5,8 +5,13 @@ using System.Collections.Generic;
namespace BizHawk.Emulation.Cores.Consoles.SNK
{
[Core("NeoPop", "Thomas Klausner, Mednafen Team", true, true, "1.26.1",
"https://mednafen.github.io/releases/", false, "NeoPop")]
[Core("NeoPop",
author: "Thomas Klausner, Mednafen Team",
isPorted: true,
isReleased: true,
portedVersion: "1.26.1",
portedUrl: "https://mednafen.github.io/releases/",
singleInstance: false)]
public class NeoGeoPort : NymaCore,
ISaveRam // NGP provides its own saveram interface
{

View File

@ -4,12 +4,7 @@ using BizHawk.Emulation.Cores.Sega.MasterSystem;
namespace BizHawk.Emulation.Cores.Sega.GGHawkLink
{
[Core(
"GGHawkLink",
"",
isPorted: false,
isReleased: false,
displayName: "Game Gear")]
[Core("GGHawkLink", "", isPorted: false, isReleased: false)]
[ServiceNotApplicable(new[] { typeof(IDriveLight) })]
public partial class GGHawkLink : IEmulator, ISaveRam, IDebuggable, IStatable, IInputPollable, IRegionable, ILinkable,
ISettable<GGHawkLink.GGLinkSettings, GGHawkLink.GGLinkSyncSettings>

View File

@ -5,8 +5,13 @@ using System.Collections.Generic;
namespace BizHawk.Emulation.Cores.Consoles.Sega.Saturn
{
[Core("Saturnus", "Mednafen Team", true, true, "1.26.1",
"https://mednafen.github.io/releases/", false, "Saturn")]
[Core("Saturnus",
author: "Mednafen Team",
isPorted: true,
isReleased: true,
portedVersion: "1.26.1",
portedUrl: "https://mednafen.github.io/releases/",
singleInstance: false)]
public class Saturnus : NymaCore, IRegionable
{
[CoreConstructor("SAT")]

View File

@ -17,8 +17,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
isReleased: true,
portedVersion: "r874",
portedUrl: "https://code.google.com/p/genplus-gx/",
singleInstance: false,
displayName: "Genesis")]
singleInstance: false)]
public partial class GPGX : IEmulator, IVideoProvider, ISaveRam, IStatable, IRegionable,
IInputPollable, IDebuggable, IDriveLight, ICodeDataLogger, IDisassemblable
{

View File

@ -6,7 +6,7 @@ using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.WonderSwan
{
[Core("Cygne/Mednafen", "Dox, Mednafen Team", true, true, "1.24.3", "https://mednafen.github.io/releases/", false, "WonderSwan")]
[Core("Cygne/Mednafen", "Dox, Mednafen Team", true, true, "1.24.3", "https://mednafen.github.io/releases/", false)]
[ServiceNotApplicable(new[] { typeof(IDriveLight), typeof(IRegionable) })]
public partial class WonderSwan : IEmulator, IVideoProvider, ISoundProvider,
IInputPollable, IDebuggable