Remove outdated SystemLookup

- closes #4143 by using EmulatorExtensions.SystemIDDisplayNames instead
This commit is contained in:
Morilli 2024-12-22 10:19:12 +01:00
parent 4dc0ec5b87
commit 1526de58ad
3 changed files with 11 additions and 72 deletions

View File

@ -1,18 +1,16 @@
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using BizHawk.Emulation.Common;
using BizHawk.Client.Common;
using BizHawk.Common;
namespace BizHawk.Client.EmuHawk
{
public partial class PlatformChooser : Form
{
private readonly Config _config;
private readonly List<SystemLookup.SystemInfo> _availableSystems = new SystemLookup().AllSystems.ToList();
public PlatformChooser(Config config)
{
@ -35,11 +33,11 @@ namespace BizHawk.Client.EmuHawk
HashBox.Text = RomGame.GameInfo.Hash;
int count = 0;
int spacing = 25;
foreach (var platform in _availableSystems)
foreach (var (systemId, fullName) in EmulatorExtensions.SystemIDDisplayNames)
{
var radio = new RadioButton
{
Text = platform.FullName,
Text = fullName,
Location = UIHelper.Scale(new Point(15, 15 + (count * spacing))),
Size = UIHelper.Scale(new Size(200, 23))
};
@ -62,7 +60,7 @@ namespace BizHawk.Client.EmuHawk
private void OkBtn_Click(object sender, EventArgs e)
{
var selectedValue = SelectedRadio != null ? SelectedRadio.Text : "";
PlatformChoice = _availableSystems.First(x => x.FullName == selectedValue).SystemId;
PlatformChoice = EmulatorExtensions.SystemIDDisplayNames.First(x => x.Value == selectedValue).Key;
if (AlwaysCheckbox.Checked)
{

View File

@ -2,6 +2,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using BizHawk.Common;
using BizHawk.Emulation.Common;
namespace BizHawk.Client.EmuHawk
@ -13,12 +14,9 @@ namespace BizHawk.Client.EmuHawk
public FileExtensionPreferencesPicker(IDictionary<string, string> preferredPlatformsForExtensions)
{
_preferredPlatformsForExtensions = preferredPlatformsForExtensions;
_availableSystems = new SystemLookup().AllSystems.ToList();
InitializeComponent();
}
private readonly List<SystemLookup.SystemInfo> _availableSystems;
public string FileExtension { get; set; }
public string OriginalPreference { get; set; }
@ -28,8 +26,8 @@ namespace BizHawk.Client.EmuHawk
{
if (PlatformDropdown.SelectedIndex > 0)
{
return _availableSystems
.First(x => x.FullName == PlatformDropdown.SelectedItem.ToString()).SystemId;
return EmulatorExtensions.SystemIDDisplayNames
.First(x => x.Value == PlatformDropdown.SelectedItem.ToString()).Key;
}
return "";
@ -39,9 +37,9 @@ namespace BizHawk.Client.EmuHawk
private void PopulatePlatforms()
{
PlatformDropdown.Items.Add("Ask me on load");
foreach (var platform in _availableSystems)
foreach (var (systemId, fullName) in EmulatorExtensions.SystemIDDisplayNames)
{
PlatformDropdown.Items.Add(platform.FullName);
PlatformDropdown.Items.Add(fullName);
}
}
@ -52,8 +50,8 @@ namespace BizHawk.Client.EmuHawk
var selectedSystemId = _preferredPlatformsForExtensions[FileExtension];
if (!string.IsNullOrEmpty(selectedSystemId))
{
var selectedSystem = _availableSystems.Find(s => s.SystemId == selectedSystemId)?.FullName ?? string.Empty;
if (PlatformDropdown.Items.Contains(selectedSystem))
if (EmulatorExtensions.SystemIDDisplayNames.TryGetValue(selectedSystemId, out string selectedSystem)
&& PlatformDropdown.Items.Contains(selectedSystem))
{
PlatformDropdown.SelectedItem = selectedSystem;
}

View File

@ -1,57 +0,0 @@
using System.Collections.Generic;
namespace BizHawk.Emulation.Common
{
// TODO: This should build itself from the Cores assembly, we don't want to maintain this
public class SystemLookup
{
private readonly List<SystemInfo> _systems = new List<SystemInfo>
{
new(VSystemID.Raw.A26, "Atari 2600"),
new(VSystemID.Raw.A78, "Atari 7800"),
new(VSystemID.Raw.Jaguar, "Atari Jaguar"),
new(VSystemID.Raw.Lynx, "Atari Lynx"),
new(VSystemID.Raw.NES, "NES"),
new(VSystemID.Raw.SNES, "Super NES"),
new(VSystemID.Raw.N64, "Nintendo 64"),
new(VSystemID.Raw.GB, "Gameboy"),
new(VSystemID.Raw.GBA, "Gameboy Advance"),
new(VSystemID.Raw.PSX, "Playstation"),
new(VSystemID.Raw.SMS, "Sega Master System"),
new(VSystemID.Raw.GEN, "Sega Genesis/Mega Drive"),
new(VSystemID.Raw.Sega32X, "Sega Genesis 32X/Mega Drive 32X"),
new(VSystemID.Raw.SAT, "Sega Saturn"),
new(VSystemID.Raw.PCE, "PC Engine/TurboGrafx 16"),
new(VSystemID.Raw.Coleco, "ColecoVision"),
new(VSystemID.Raw.TI83, "TI-83 Calculator"),
new(VSystemID.Raw.WSWAN, "WonderSwan"),
new(VSystemID.Raw.C64, "Commodore 64"),
new(VSystemID.Raw.AppleII, "Apple II"),
new(VSystemID.Raw.INTV, "IntelliVision"),
new(VSystemID.Raw.ZXSpectrum, "Sinclair ZX Spectrum"),
new(VSystemID.Raw.AmstradCPC, "Amstrad CPC"),
new(VSystemID.Raw.ChannelF, "Fairchild Channel F"),
new(VSystemID.Raw.O2, "Odyssey2"),
new(VSystemID.Raw.VEC, "Vectrex"),
new(VSystemID.Raw.MSX, "MSX"),
new(VSystemID.Raw.NDS, "Nintendo DS")
};
public SystemInfo this[string systemId]
=> _systems.Find(s => s.SystemId == systemId) ?? new("Unknown", "Unknown");
public IEnumerable<SystemInfo> AllSystems => _systems;
public class SystemInfo
{
public SystemInfo(string systemId, string fullName)
{
SystemId = systemId;
FullName = fullName;
}
public string SystemId { get; }
public string FullName { get; }
}
}
}