Platform Chooser - add "Always use this system for this extension" checkbox and save the user's core preference, and don't show the dialog again for that extension if they do pick this option

This commit is contained in:
adelikat 2014-04-14 12:42:04 +00:00
parent 449d3fa2e2
commit a32ba998f2
4 changed files with 198 additions and 145 deletions

View File

@ -272,12 +272,20 @@ namespace BizHawk.Client.Common
else // most extensions
{
rom = new RomGame(file);
if (string.IsNullOrEmpty(rom.GameInfo.System) &&
GenericExtensions.Contains(rom.Extension.ToLower()) &&
if (string.IsNullOrEmpty(rom.GameInfo.System))
{
// Has the user picked a preference for this extension?
if (!string.IsNullOrEmpty(Global.Config.PreferredPlatformsForExtensions[rom.Extension.ToLower()]))
{
rom.GameInfo.System = Global.Config.PreferredPlatformsForExtensions[rom.Extension.ToLower()];
}
else if (GenericExtensions.Contains(rom.Extension.ToLower()) &&
ChoosePlatform != null)
{
rom.GameInfo.System = ChoosePlatform(rom);
}
}
game = rom.GameInfo;

View File

@ -35,6 +35,13 @@ namespace BizHawk.Client.Common
HotkeyBindings.ResolveWithDefaults();
}
// Core preference for generic file extension, key: file extension, value: a systemID or empty if no preference
public Dictionary<string, string> PreferredPlatformsForExtensions = new Dictionary<string, string>
{
{ ".bin", "" },
{ ".rom", "" },
};
// Path Settings ************************************/
public bool UseRecentForROMs = false;
public string LastRomPath = ".";

View File

@ -38,6 +38,8 @@
this.ExtensionLabel = new System.Windows.Forms.Label();
this.RomSizeLabel = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.AlwaysCheckbox = new System.Windows.Forms.CheckBox();
this.label4 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// textBox1
@ -148,6 +150,27 @@
this.label6.TabIndex = 11;
this.label6.Text = "Size:";
//
// AlwaysCheckbox
//
this.AlwaysCheckbox.AutoSize = true;
this.AlwaysCheckbox.Location = new System.Drawing.Point(300, 396);
this.AlwaysCheckbox.Name = "AlwaysCheckbox";
this.AlwaysCheckbox.Size = new System.Drawing.Size(138, 17);
this.AlwaysCheckbox.TabIndex = 13;
this.AlwaysCheckbox.Text = "Always use this platform";
this.AlwaysCheckbox.UseVisualStyleBackColor = true;
//
// label4
//
this.label4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(300, 416);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(86, 13);
this.label4.TabIndex = 14;
this.label4.Text = "for this extension";
this.label4.Click += new System.EventHandler(this.label4_Click);
//
// PlatformChooser
//
this.AcceptButton = this.OkBtn;
@ -155,6 +178,8 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.CancelBtn;
this.ClientSize = new System.Drawing.Size(438, 483);
this.Controls.Add(this.label4);
this.Controls.Add(this.AlwaysCheckbox);
this.Controls.Add(this.RomSizeLabel);
this.Controls.Add(this.label6);
this.Controls.Add(this.ExtensionLabel);
@ -188,5 +213,7 @@
private System.Windows.Forms.Label ExtensionLabel;
private System.Windows.Forms.Label RomSizeLabel;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.CheckBox AlwaysCheckbox;
private System.Windows.Forms.Label label4;
}
}

View File

@ -97,7 +97,18 @@ namespace BizHawk.Client.EmuHawk
{
var selectedValue = SelectedRadio != null ? SelectedRadio.Text : string.Empty;
PlatformChoice = Platforms.FirstOrDefault(x => x.Value == selectedValue).Key;
if (AlwaysCheckbox.Checked)
{
Global.Config.PreferredPlatformsForExtensions[RomGame.Extension.ToLower()] = PlatformChoice;
}
Close();
}
private void label4_Click(object sender, EventArgs e)
{
AlwaysCheckbox.Checked ^= true;
}
}
}