Move MainForm.SupportedPlatforms to Emulation.Common.SystemLookup

This commit is contained in:
adelikat 2015-02-22 17:15:09 +00:00
parent 66a9b8eb5a
commit 7e763408e2
5 changed files with 92 additions and 55 deletions

View File

@ -601,51 +601,6 @@ namespace BizHawk.Client.EmuHawk
}
}
// TODO: SystemInfo should be able to do this
// Because we don't have enough places where we list SystemID's
public Dictionary<string, string> SupportedPlatforms
{
get
{
var released = new Dictionary<string, string>
{
{ "A26", "Atari 2600" },
{ "A78", "Atari 7800" },
{ "Lynx", "Atari Lynx" },
{ "NES", "Nintendo Entertainment System/Famicom" },
{ "SNES", "Super Nintendo" },
{ "N64", "Nintendo 64" },
{ "GB", "Game Boy" },
{ "GBC", "Game Boy Color" },
{ "GBA", "Gameboy Advance" },
{ "PSX", "Playstation" },
{ "SMS", "Sega Master System" },
{ "GG", "Sega Game Gear" },
{ "SG", "SG-1000" },
{ "GEN", "Sega Genesis/Megadrive" },
{ "SAT", "Sega Saturn" },
{ "PCE", "PC Engine/TurboGrafx 16" },
{ "Coleco", "Colecovision" },
{ "TI83", "TI-83 Calculator" },
{ "WSWAN", "WonderSwan" },
};
if (VersionInfo.DeveloperBuild)
{
released.Add("C64", "Commodore 64");
}
return released;
}
}
#endregion
#region Public Methods

View File

@ -7,6 +7,7 @@ using System.Linq;
using System.Text;
using System.Windows.Forms;
using BizHawk.Emulation.Common;
using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk
@ -27,8 +28,11 @@ namespace BizHawk.Client.EmuHawk
public PlatformChooser()
{
InitializeComponent();
AvailableSystems = new SystemLookup().AllSystems.ToList();
}
private readonly List<SystemLookup.SystemInfo> AvailableSystems;
private void PlatformChooser_Load(object sender, EventArgs e)
{
if (RomGame.RomData.Length > 10 * 1024 * 1024) // If 10mb, show in megabytes
@ -44,11 +48,11 @@ namespace BizHawk.Client.EmuHawk
HashBox.Text = RomGame.GameInfo.Hash;
int count = 0;
int spacing = 25;
foreach (var platform in GlobalWin.MainForm.SupportedPlatforms)
foreach (var platform in AvailableSystems)
{
var radio = new RadioButton
{
Text = platform.Value,
Text = platform.FullName,
Location = UIHelper.Scale(new Point(15, 15 + (count * spacing))),
Size = UIHelper.Scale(new Size(200, 23))
};
@ -71,7 +75,7 @@ namespace BizHawk.Client.EmuHawk
private void OkBtn_Click(object sender, EventArgs e)
{
var selectedValue = SelectedRadio != null ? SelectedRadio.Text : string.Empty;
PlatformChoice = GlobalWin.MainForm.SupportedPlatforms.FirstOrDefault(x => x.Value == selectedValue).Key;
PlatformChoice = AvailableSystems.FirstOrDefault(x => x.FullName == selectedValue).SystemId;
if (AlwaysCheckbox.Checked)
{

View File

@ -7,6 +7,7 @@ using System.Linq;
using System.Text;
using System.Windows.Forms;
using BizHawk.Emulation.Common;
using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk
@ -16,8 +17,11 @@ namespace BizHawk.Client.EmuHawk
public FileExtensionPreferencesPicker()
{
InitializeComponent();
AvailableSystems = new SystemLookup().AllSystems.ToList();
}
private readonly List<SystemLookup.SystemInfo> AvailableSystems;
public string FileExtension { get; set; }
public string OriginalPreference { get; set; }
@ -27,8 +31,8 @@ namespace BizHawk.Client.EmuHawk
{
if (PlatformDropdown.SelectedIndex > 0)
{
return GlobalWin.MainForm.SupportedPlatforms
.FirstOrDefault(x => x.Value == PlatformDropdown.SelectedItem.ToString()).Key;
return AvailableSystems
.FirstOrDefault(x => x.SystemId == PlatformDropdown.SelectedItem.ToString()).FullName;
}
return string.Empty;
@ -38,9 +42,9 @@ namespace BizHawk.Client.EmuHawk
private void PopulatePlatforms()
{
PlatformDropdown.Items.Add("Ask me on load");
foreach (var platform in GlobalWin.MainForm.SupportedPlatforms)
foreach (var platform in AvailableSystems)
{
PlatformDropdown.Items.Add(platform.Value);
PlatformDropdown.Items.Add(platform.FullName);
}
}
@ -52,7 +56,7 @@ namespace BizHawk.Client.EmuHawk
foreach (var val in dispVals)
{
yield return GlobalWin.MainForm.SupportedPlatforms.FirstOrDefault(x => x.Value == val).Key ?? string.Empty;
yield return AvailableSystems.FirstOrDefault(x => x.FullName == val).SystemId ?? string.Empty;
}
}
}
@ -64,11 +68,11 @@ namespace BizHawk.Client.EmuHawk
var selectedSystemId = Global.Config.PreferredPlatformsForExtensions[FileExtension];
if (!string.IsNullOrEmpty(selectedSystemId))
{
var selectedDispString = GlobalWin.MainForm.SupportedPlatforms[selectedSystemId];
var selectedSystem = AvailableSystems.FirstOrDefault(s => s.SystemId == selectedSystemId);
var selectedItem = PlatformDropdown.Items
.OfType<string>()
.FirstOrDefault(item => item == selectedDispString);
.FirstOrDefault(item => item == (selectedSystem != null ? selectedSystem.FullName : string.Empty));
if (selectedItem != null)
{

View File

@ -109,6 +109,7 @@
<Compile Include="Sound\VRC6Alt.cs" />
<Compile Include="Sound\YM2413.cs" />
<Compile Include="Sound\YM2612.cs" />
<Compile Include="SystemLookup.cs" />
<Compile Include="TextState.cs" />
</ItemGroup>
<ItemGroup>

View File

@ -0,0 +1,73 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
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 SystemInfo { SystemId = "A26", FullName = "Atari 2600" },
new SystemInfo { SystemId = "A78", FullName = "Atari 7800" },
new SystemInfo { SystemId = "Lynx", FullName = "Atari Lynx" },
new SystemInfo { SystemId = "NES", FullName = "NES" },
new SystemInfo { SystemId = "SNES", FullName = "Super NES" },
new SystemInfo { SystemId = "N64", FullName = "Nintendo 64" },
new SystemInfo { SystemId = "GB", FullName = "Gameboy" },
new SystemInfo { SystemId = "GBA", FullName = "Gameboy Advance" },
new SystemInfo { SystemId = "PSX", FullName = "Playstation" },
new SystemInfo { SystemId = "SMS", FullName = "Sega Master System" },
new SystemInfo { SystemId = "GEN", FullName = "Sega Genesis/Megadrive" },
new SystemInfo { SystemId = "SAT", FullName = "Sega Saturn" },
new SystemInfo { SystemId = "PCE", FullName = "PC Engine/TurboGrafx 16" },
new SystemInfo { SystemId = "Coleco", FullName = "Colecovision" },
new SystemInfo { SystemId = "TI83", FullName = "TI-83 Calculator" },
new SystemInfo { SystemId = "WSWAN", FullName = "WonderSwan" },
new SystemInfo { SystemId = "C64", FullName = "Commodore 64" }
};
public SystemInfo this[string systemId]
{
get
{
var system = Systems.FirstOrDefault(s => s.SystemId == systemId);
if (system != null)
{
return system;
}
return new SystemInfo { SystemId = "Unknown", FullName = "Unknown" };
}
}
public IEnumerable<SystemInfo> AllSystems
{
get
{
if (VersionInfo.DeveloperBuild)
{
return Systems;
}
return Systems.Where(s => s.SystemId != "C64");
}
}
public class SystemInfo
{
public string SystemId { get; set; }
public string FullName { get; set; }
}
}
}