Add a Platform Chooser that activates when the user attempts to load a .bin file that is not in the game database. Still todo: more platforms, and interim flag logic on some unreleased cores

This commit is contained in:
adelikat 2014-04-14 01:59:57 +00:00
parent 3e2a1e9835
commit 32b4f940a9
7 changed files with 371 additions and 1 deletions

View File

@ -99,6 +99,8 @@ namespace BizHawk.Client.Common
public Func<HawkFile, int?> ChooseArchive { get; set; }
public Func<RomGame, string> ChoosePlatform { get; set; }
private int? HandleArchive(HawkFile file)
{
if (ChooseArchive != null)
@ -263,6 +265,11 @@ namespace BizHawk.Client.Common
else // most extensions
{
rom = new RomGame(file);
if (string.IsNullOrEmpty(rom.GameInfo.System) && ChoosePlatform != null)
{
rom.GameInfo.System = ChoosePlatform(rom);
}
game = rom.GameInfo;
var isXml = false;

View File

@ -467,6 +467,12 @@
<Compile Include="NameStateForm.Designer.cs">
<DependentUpon>NameStateForm.cs</DependentUpon>
</Compile>
<Compile Include="PlatformChooser.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="PlatformChooser.Designer.cs">
<DependentUpon>PlatformChooser.cs</DependentUpon>
</Compile>
<Compile Include="PresentationPanel.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
@ -1016,6 +1022,9 @@
<DependentUpon>NameStateForm.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="PlatformChooser.resx">
<DependentUpon>PlatformChooser.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<SubType>Designer</SubType>

View File

@ -2783,6 +2783,17 @@ namespace BizHawk.Client.EmuHawk
GlobalWin.OSD.AddMessage(message);
}
private string ChoosePlatformForRom(RomGame rom)
{
var platformChooser = new PlatformChooser()
{
RomGame = rom
};
platformChooser.ShowDialog();
return platformChooser.PlatformChoice;
}
// Still needs a good bit of refactoring
public bool LoadRom(string path, bool deterministicemulation = false, bool hasmovie = false)
{
@ -2794,6 +2805,7 @@ namespace BizHawk.Client.EmuHawk
var loader = new RomLoader
{
ChooseArchive = LoadArhiveChooser,
ChoosePlatform = ChoosePlatformForRom
};
loader.OnLoadError += ShowLoadError;

View File

@ -0,0 +1,130 @@
namespace BizHawk.Client.EmuHawk
{
partial class PlatformChooser
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.OkBtn = new System.Windows.Forms.Button();
this.CancelBtn = new System.Windows.Forms.Button();
this.PlatformsGroupBox = new System.Windows.Forms.Panel();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.textBox1.Location = new System.Drawing.Point(12, 12);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.ReadOnly = true;
this.textBox1.Size = new System.Drawing.Size(333, 56);
this.textBox1.TabIndex = 2;
this.textBox1.Text = "This Rom was not found in the database. Further more, the extension (*.bin) leav" +
"es no clue as to which platform should be chosen.";
//
// textBox2
//
this.textBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textBox2.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.textBox2.Location = new System.Drawing.Point(12, 74);
this.textBox2.Multiline = true;
this.textBox2.Name = "textBox2";
this.textBox2.ReadOnly = true;
this.textBox2.Size = new System.Drawing.Size(333, 41);
this.textBox2.TabIndex = 3;
this.textBox2.Text = "Please choose the intended platform to use for this Rom";
//
// OkBtn
//
this.OkBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.OkBtn.Location = new System.Drawing.Point(219, 439);
this.OkBtn.Name = "OkBtn";
this.OkBtn.Size = new System.Drawing.Size(60, 23);
this.OkBtn.TabIndex = 4;
this.OkBtn.Text = "&Ok";
this.OkBtn.UseVisualStyleBackColor = true;
this.OkBtn.Click += new System.EventHandler(this.OkBtn_Click);
//
// CancelBtn
//
this.CancelBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.CancelBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.CancelBtn.Location = new System.Drawing.Point(285, 439);
this.CancelBtn.Name = "CancelBtn";
this.CancelBtn.Size = new System.Drawing.Size(60, 23);
this.CancelBtn.TabIndex = 5;
this.CancelBtn.Text = "&Cancel";
this.CancelBtn.UseVisualStyleBackColor = true;
this.CancelBtn.Click += new System.EventHandler(this.CancelButton_Click);
//
// PlatformsGroupBox
//
this.PlatformsGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.PlatformsGroupBox.AutoScroll = true;
this.PlatformsGroupBox.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.PlatformsGroupBox.Location = new System.Drawing.Point(12, 97);
this.PlatformsGroupBox.Name = "PlatformsGroupBox";
this.PlatformsGroupBox.Size = new System.Drawing.Size(333, 336);
this.PlatformsGroupBox.TabIndex = 6;
//
// PlatformChooser
//
this.AcceptButton = this.OkBtn;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.CancelBtn;
this.ClientSize = new System.Drawing.Size(357, 474);
this.Controls.Add(this.PlatformsGroupBox);
this.Controls.Add(this.CancelBtn);
this.Controls.Add(this.OkBtn);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Name = "PlatformChooser";
this.ShowIcon = false;
this.Text = "Choose a Platform";
this.Load += new System.EventHandler(this.PlatformChooser_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Button OkBtn;
private System.Windows.Forms.Button CancelBtn;
private System.Windows.Forms.Panel PlatformsGroupBox;
}
}

View File

@ -0,0 +1,92 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk
{
public partial class PlatformChooser : Form
{
// Because we don't have enough places where we list SystemID's
private readonly Dictionary<string, string> Platforms = new Dictionary<string,string>
{
{ "A26", "Atari 2600" },
{ "A78", "Atari 7800" },
{ "NES", "Nintendo Entertainment System" },
{ "SNES", "Super Nintendo" },
{ "N64", "Nintendo 64" },
{ "GB", "Game Boy" },
{ "GBC", "Game Boy Color" },
{ "PCE", "PC Engine/TurboGrafx 16" },
{ "SGX", "Super Grafx" },
{ "SMS", "Sega Master System" },
{ "GG", "Sega Game Gear" },
{ "SG", "SG-1000" },
{ "GEN", "Sega Genesis" },
{ "Coleco", "Colecovision" },
};
public RomGame RomGame { get; set; }
public string PlatformChoice { get; set; }
private RadioButton SelectedRadio
{
get
{
return PlatformsGroupBox.Controls.OfType<RadioButton>().FirstOrDefault(x => x.Checked);
}
}
public PlatformChooser()
{
InitializeComponent();
}
private void PlatformChooser_Load(object sender, EventArgs e)
{
int count = 0;
int spacing = 25;
foreach (var platform in Platforms)
{
var radio = new RadioButton
{
Text = platform.Value,
Location = new Point(15, 15 + (count * spacing)),
Size = new Size(200, 23)
};
PlatformsGroupBox.Controls.Add(radio);
count++;
}
PlatformsGroupBox.Controls
.OfType<RadioButton>()
.First()
.Select();
}
private void CancelButton_Click(object sender, EventArgs e)
{
Close();
}
private void OkBtn_Click(object sender, EventArgs e)
{
var selectedValue = SelectedRadio != null ? SelectedRadio.Text : string.Empty;
PlatformChoice = Platforms.FirstOrDefault(x => x.Value == selectedValue).Key;
Close();
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -165,7 +165,7 @@ namespace BizHawk.Emulation.Common
Game.System = "SG";
break;
case ".BIN":
//case ".BIN":
case ".GEN":
case ".MD":
case ".SMD":