Platform Chooser - show rom information, only invoke dialog on a list of generic rom extensions (currently that is .bin and .rom), remove .rom from the list of intellivision extensions

This commit is contained in:
adelikat 2014-04-14 12:25:57 +00:00
parent 32b4f940a9
commit 449d3fa2e2
5 changed files with 172 additions and 92 deletions

View File

@ -1,6 +1,6 @@
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using BizHawk.Common; using BizHawk.Common;
using BizHawk.Emulation.Common; using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores; using BizHawk.Emulation.Cores;
@ -28,6 +28,13 @@ namespace BizHawk.Client.Common
{ {
public class RomLoader public class RomLoader
{ {
// These extensions will invoke a platform chooser if not found in the database
private readonly List<string> GenericExtensions = new List<string>
{
".bin",
".rom",
};
// helper methods for the settings events // helper methods for the settings events
private object GetCoreSettings<T>() private object GetCoreSettings<T>()
where T : IEmulator where T : IEmulator
@ -265,7 +272,9 @@ namespace BizHawk.Client.Common
else // most extensions else // most extensions
{ {
rom = new RomGame(file); rom = new RomGame(file);
if (string.IsNullOrEmpty(rom.GameInfo.System) && ChoosePlatform != null) if (string.IsNullOrEmpty(rom.GameInfo.System) &&
GenericExtensions.Contains(rom.Extension.ToLower()) &&
ChoosePlatform != null)
{ {
rom.GameInfo.System = ChoosePlatform(rom); rom.GameInfo.System = ChoosePlatform(rom);
} }
@ -314,7 +323,6 @@ namespace BizHawk.Client.Common
nextEmulator = new PCEngine(nextComm, game, rom.RomData, GetCoreSettings<PCEngine>()); nextEmulator = new PCEngine(nextComm, game, rom.RomData, GetCoreSettings<PCEngine>());
break; break;
case "GEN": case "GEN":
// nextEmulator = new Genesis(nextComm, game, rom.RomData);
nextEmulator = new GPGX(nextComm, rom.RomData, null, "GEN", GetCoreSyncSettings<GPGX>()); nextEmulator = new GPGX(nextComm, rom.RomData, null, "GEN", GetCoreSyncSettings<GPGX>());
break; break;
case "TI83": case "TI83":

View File

@ -2785,7 +2785,7 @@ namespace BizHawk.Client.EmuHawk
private string ChoosePlatformForRom(RomGame rom) private string ChoosePlatformForRom(RomGame rom)
{ {
var platformChooser = new PlatformChooser() var platformChooser = new PlatformChooser
{ {
RomGame = rom RomGame = rom
}; };

View File

@ -28,103 +28,165 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.textBox1 = new System.Windows.Forms.TextBox(); this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox(); this.OkBtn = new System.Windows.Forms.Button();
this.OkBtn = new System.Windows.Forms.Button(); this.CancelBtn = new System.Windows.Forms.Button();
this.CancelBtn = new System.Windows.Forms.Button(); this.PlatformsGroupBox = new System.Windows.Forms.Panel();
this.PlatformsGroupBox = new System.Windows.Forms.Panel(); this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout(); this.label2 = new System.Windows.Forms.Label();
// this.label3 = new System.Windows.Forms.Label();
// textBox1 this.ExtensionLabel = new System.Windows.Forms.Label();
// this.RomSizeLabel = new System.Windows.Forms.Label();
this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) this.label6 = new System.Windows.Forms.Label();
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))); | System.Windows.Forms.AnchorStyles.Right)));
this.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.None; this.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.textBox1.Location = new System.Drawing.Point(12, 12); this.textBox1.Location = new System.Drawing.Point(12, 12);
this.textBox1.Multiline = true; this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1"; this.textBox1.Name = "textBox1";
this.textBox1.ReadOnly = true; this.textBox1.ReadOnly = true;
this.textBox1.Size = new System.Drawing.Size(333, 56); this.textBox1.Size = new System.Drawing.Size(414, 35);
this.textBox1.TabIndex = 2; this.textBox1.TabIndex = 2;
this.textBox1.Text = "This Rom was not found in the database. Further more, the extension (*.bin) leav" + this.textBox1.Text = "This Rom was not found in the database. Further more, the extension leaves no cl" +
"es no clue as to which platform should be chosen."; "ue as to which platform should be chosen.";
// //
// textBox2 // OkBtn
// //
this.textBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) this.OkBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
| System.Windows.Forms.AnchorStyles.Right))); this.OkBtn.Location = new System.Drawing.Point(300, 448);
this.textBox2.BorderStyle = System.Windows.Forms.BorderStyle.None; this.OkBtn.Name = "OkBtn";
this.textBox2.Location = new System.Drawing.Point(12, 74); this.OkBtn.Size = new System.Drawing.Size(60, 23);
this.textBox2.Multiline = true; this.OkBtn.TabIndex = 4;
this.textBox2.Name = "textBox2"; this.OkBtn.Text = "&Ok";
this.textBox2.ReadOnly = true; this.OkBtn.UseVisualStyleBackColor = true;
this.textBox2.Size = new System.Drawing.Size(333, 41); this.OkBtn.Click += new System.EventHandler(this.OkBtn_Click);
this.textBox2.TabIndex = 3; //
this.textBox2.Text = "Please choose the intended platform to use for this Rom"; // CancelBtn
// //
// OkBtn 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.OkBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.CancelBtn.Location = new System.Drawing.Point(366, 448);
this.OkBtn.Location = new System.Drawing.Point(219, 439); this.CancelBtn.Name = "CancelBtn";
this.OkBtn.Name = "OkBtn"; this.CancelBtn.Size = new System.Drawing.Size(60, 23);
this.OkBtn.Size = new System.Drawing.Size(60, 23); this.CancelBtn.TabIndex = 5;
this.OkBtn.TabIndex = 4; this.CancelBtn.Text = "&Cancel";
this.OkBtn.Text = "&Ok"; this.CancelBtn.UseVisualStyleBackColor = true;
this.OkBtn.UseVisualStyleBackColor = true; this.CancelBtn.Click += new System.EventHandler(this.CancelButton_Click);
this.OkBtn.Click += new System.EventHandler(this.OkBtn_Click); //
// // PlatformsGroupBox
// CancelBtn //
// this.PlatformsGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
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.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.PlatformsGroupBox.AutoScroll = true; this.PlatformsGroupBox.AutoScroll = true;
this.PlatformsGroupBox.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.PlatformsGroupBox.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.PlatformsGroupBox.Location = new System.Drawing.Point(12, 97); this.PlatformsGroupBox.Location = new System.Drawing.Point(12, 66);
this.PlatformsGroupBox.Name = "PlatformsGroupBox"; this.PlatformsGroupBox.Name = "PlatformsGroupBox";
this.PlatformsGroupBox.Size = new System.Drawing.Size(333, 336); this.PlatformsGroupBox.Size = new System.Drawing.Size(285, 405);
this.PlatformsGroupBox.TabIndex = 6; this.PlatformsGroupBox.TabIndex = 6;
// //
// PlatformChooser // label1
// //
this.AcceptButton = this.OkBtn; this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.label1.AutoSize = true;
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.label1.Location = new System.Drawing.Point(303, 50);
this.CancelButton = this.CancelBtn; this.label1.Name = "label1";
this.ClientSize = new System.Drawing.Size(357, 474); this.label1.Size = new System.Drawing.Size(67, 13);
this.Controls.Add(this.PlatformsGroupBox); this.label1.TabIndex = 7;
this.Controls.Add(this.CancelBtn); this.label1.Text = "Rom Details:";
this.Controls.Add(this.OkBtn); //
this.Controls.Add(this.textBox2); // label2
this.Controls.Add(this.textBox1); //
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.label2.AutoSize = true;
this.Name = "PlatformChooser"; this.label2.Location = new System.Drawing.Point(12, 50);
this.ShowIcon = false; this.label2.Name = "label2";
this.Text = "Choose a Platform"; this.label2.Size = new System.Drawing.Size(270, 13);
this.Load += new System.EventHandler(this.PlatformChooser_Load); this.label2.TabIndex = 8;
this.ResumeLayout(false); this.label2.Text = "Please choose the intended platform to use for this Rom";
this.PerformLayout(); //
// label3
//
this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(303, 74);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(56, 13);
this.label3.TabIndex = 9;
this.label3.Text = "Extension:";
//
// ExtensionLabel
//
this.ExtensionLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.ExtensionLabel.AutoSize = true;
this.ExtensionLabel.Location = new System.Drawing.Point(303, 93);
this.ExtensionLabel.Name = "ExtensionLabel";
this.ExtensionLabel.Size = new System.Drawing.Size(24, 13);
this.ExtensionLabel.TabIndex = 10;
this.ExtensionLabel.Text = ".bin";
//
// RomSizeLabel
//
this.RomSizeLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.RomSizeLabel.AutoSize = true;
this.RomSizeLabel.Location = new System.Drawing.Point(303, 134);
this.RomSizeLabel.Name = "RomSizeLabel";
this.RomSizeLabel.Size = new System.Drawing.Size(25, 13);
this.RomSizeLabel.TabIndex = 12;
this.RomSizeLabel.Text = "4kb";
//
// label6
//
this.label6.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(303, 116);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(30, 13);
this.label6.TabIndex = 11;
this.label6.Text = "Size:";
//
// 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(438, 483);
this.Controls.Add(this.RomSizeLabel);
this.Controls.Add(this.label6);
this.Controls.Add(this.ExtensionLabel);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.PlatformsGroupBox);
this.Controls.Add(this.CancelBtn);
this.Controls.Add(this.OkBtn);
this.Controls.Add(this.textBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Name = "PlatformChooser";
this.ShowIcon = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Choose a Platform";
this.Load += new System.EventHandler(this.PlatformChooser_Load);
this.ResumeLayout(false);
this.PerformLayout();
} }
#endregion #endregion
private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Button OkBtn; private System.Windows.Forms.Button OkBtn;
private System.Windows.Forms.Button CancelBtn; private System.Windows.Forms.Button CancelBtn;
private System.Windows.Forms.Panel PlatformsGroupBox; private System.Windows.Forms.Panel PlatformsGroupBox;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label ExtensionLabel;
private System.Windows.Forms.Label RomSizeLabel;
private System.Windows.Forms.Label label6;
} }
} }

View File

@ -56,6 +56,17 @@ namespace BizHawk.Client.EmuHawk
private void PlatformChooser_Load(object sender, EventArgs e) private void PlatformChooser_Load(object sender, EventArgs e)
{ {
if (RomGame.RomData.Length > 10 * 1024 * 1024) // If 10mb, show in megabytes
{
RomSizeLabel.Text = string.Format("{0:n0}", (RomGame.RomData.Length / 1024 / 1024)) + "mb";
}
else
{
RomSizeLabel.Text = string.Format("{0:n0}", (RomGame.RomData.Length / 1024)) + "kb";
}
ExtensionLabel.Text = RomGame.Extension.ToLower();
int count = 0; int count = 0;
int spacing = 25; int spacing = 25;
foreach (var platform in Platforms) foreach (var platform in Platforms)

View File

@ -194,7 +194,6 @@ namespace BizHawk.Emulation.Common
Game.System = "Coleco"; Game.System = "Coleco";
break; break;
case ".ROM": // TODO: Why does intellivision get to take up this generic extension
case ".INT": case ".INT":
Game.System = "INTV"; Game.System = "INTV";
break; break;