From 267441cc37cb7565e14d39fe7ccc2878caacbfba Mon Sep 17 00:00:00 2001 From: adelikat Date: Mon, 14 Apr 2014 16:48:45 +0000 Subject: [PATCH] Add a Extension Preferences dialog in the Config menu, currently it will show .bin and .rom and allow the user to pick a platform or pick "ask me on load" to be asked every time (the default) --- BizHawk.Client.Common/RomLoader.cs | 22 +-- .../BizHawk.Client.EmuHawk.csproj | 18 +++ BizHawk.Client.EmuHawk/MainForm.Designer.cs | 52 ++++--- BizHawk.Client.EmuHawk/MainForm.cs | 45 ++++++ BizHawk.Client.EmuHawk/PlatformChooser.cs | 29 +--- .../FileExtensionPreferences.Designer.cs | 131 ++++++++++++++++++ .../config/FileExtensionPreferences.cs | 57 ++++++++ .../config/FileExtensionPreferences.resx | 120 ++++++++++++++++ ...FileExtensionPreferencesPicker.Designer.cs | 72 ++++++++++ .../config/FileExtensionPreferencesPicker.cs | 90 ++++++++++++ .../FileExtensionPreferencesPicker.resx | 120 ++++++++++++++++ 11 files changed, 698 insertions(+), 58 deletions(-) create mode 100644 BizHawk.Client.EmuHawk/config/FileExtensionPreferences.Designer.cs create mode 100644 BizHawk.Client.EmuHawk/config/FileExtensionPreferences.cs create mode 100644 BizHawk.Client.EmuHawk/config/FileExtensionPreferences.resx create mode 100644 BizHawk.Client.EmuHawk/config/FileExtensionPreferencesPicker.Designer.cs create mode 100644 BizHawk.Client.EmuHawk/config/FileExtensionPreferencesPicker.cs create mode 100644 BizHawk.Client.EmuHawk/config/FileExtensionPreferencesPicker.resx diff --git a/BizHawk.Client.Common/RomLoader.cs b/BizHawk.Client.Common/RomLoader.cs index 4f61c6373d..d57728bf83 100644 --- a/BizHawk.Client.Common/RomLoader.cs +++ b/BizHawk.Client.Common/RomLoader.cs @@ -28,13 +28,6 @@ namespace BizHawk.Client.Common { public class RomLoader { - // These extensions will invoke a platform chooser if not found in the database - private readonly List GenericExtensions = new List - { - ".bin", - ".rom", - }; - // helper methods for the settings events private object GetCoreSettings() where T : IEmulator @@ -126,6 +119,16 @@ namespace BizHawk.Client.Common } } + private bool PreferredPlatformIsDefined(string extension) + { + if (Global.Config.PreferredPlatformsForExtensions.ContainsKey(extension)) + { + return !string.IsNullOrEmpty(Global.Config.PreferredPlatformsForExtensions[extension]); + } + + return false; + } + public bool LoadRom(string path, CoreComm nextComm) { if (path == null) @@ -276,12 +279,11 @@ namespace BizHawk.Client.Common if (string.IsNullOrEmpty(rom.GameInfo.System)) { // Has the user picked a preference for this extension? - if (!string.IsNullOrEmpty(Global.Config.PreferredPlatformsForExtensions[rom.Extension.ToLower()])) + if (PreferredPlatformIsDefined(rom.Extension.ToLower())) { rom.GameInfo.System = Global.Config.PreferredPlatformsForExtensions[rom.Extension.ToLower()]; } - else if (GenericExtensions.Contains(rom.Extension.ToLower()) && - ChoosePlatform != null) + else if (ChoosePlatform != null) { rom.GameInfo.System = ChoosePlatform(rom); } diff --git a/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj b/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj index 3f38833a9e..59fb334d18 100644 --- a/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj +++ b/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj @@ -197,6 +197,18 @@ DisplayConfigLite.cs + + Form + + + FileExtensionPreferences.cs + + + UserControl + + + FileExtensionPreferencesPicker.cs + Form @@ -936,6 +948,12 @@ DisplayConfigLite.cs + + FileExtensionPreferences.cs + + + FileExtensionPreferencesPicker.cs + FirmwaresConfig.cs diff --git a/BizHawk.Client.EmuHawk/MainForm.Designer.cs b/BizHawk.Client.EmuHawk/MainForm.Designer.cs index c239906844..a89e753502 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Designer.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Designer.cs @@ -134,6 +134,7 @@ this.MessagesMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.AutofireMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.RewindOptionsMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.extensionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator9 = new System.Windows.Forms.ToolStripSeparator(); this.ConfigEnableSubMenu = new System.Windows.Forms.ToolStripMenuItem(); this.EnableContextMenuMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -388,7 +389,7 @@ this.MainformMenu.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.Flow; this.MainformMenu.Location = new System.Drawing.Point(0, 0); this.MainformMenu.Name = "MainformMenu"; - this.MainformMenu.Size = new System.Drawing.Size(470, 42); + this.MainformMenu.Size = new System.Drawing.Size(470, 61); this.MainformMenu.TabIndex = 0; this.MainformMenu.Text = "menuStrip1"; this.MainformMenu.MenuActivate += new System.EventHandler(this.MainformMenu_MenuActivate); @@ -1238,6 +1239,7 @@ this.MessagesMenuItem, this.AutofireMenuItem, this.RewindOptionsMenuItem, + this.extensionsToolStripMenuItem, this.toolStripSeparator9, this.ConfigEnableSubMenu, this.GuiSubMenu, @@ -1258,7 +1260,7 @@ // this.ControllersMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.GameController; this.ControllersMenuItem.Name = "ControllersMenuItem"; - this.ControllersMenuItem.Size = new System.Drawing.Size(152, 22); + this.ControllersMenuItem.Size = new System.Drawing.Size(159, 22); this.ControllersMenuItem.Text = "&Controllers..."; this.ControllersMenuItem.Click += new System.EventHandler(this.ControllersMenuItem_Click); // @@ -1266,7 +1268,7 @@ // this.HotkeysMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.HotKeys; this.HotkeysMenuItem.Name = "HotkeysMenuItem"; - this.HotkeysMenuItem.Size = new System.Drawing.Size(152, 22); + this.HotkeysMenuItem.Size = new System.Drawing.Size(159, 22); this.HotkeysMenuItem.Text = "&Hotkeys..."; this.HotkeysMenuItem.Click += new System.EventHandler(this.HotkeysMenuItem_Click); // @@ -1274,7 +1276,7 @@ // this.DisplayConfigMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("DisplayConfigMenuItem.Image"))); this.DisplayConfigMenuItem.Name = "DisplayConfigMenuItem"; - this.DisplayConfigMenuItem.Size = new System.Drawing.Size(152, 22); + this.DisplayConfigMenuItem.Size = new System.Drawing.Size(159, 22); this.DisplayConfigMenuItem.Text = "Display..."; this.DisplayConfigMenuItem.Click += new System.EventHandler(this.DisplayConfigMenuItem_Click); // @@ -1282,7 +1284,7 @@ // this.SoundMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.AudioHS; this.SoundMenuItem.Name = "SoundMenuItem"; - this.SoundMenuItem.Size = new System.Drawing.Size(152, 22); + this.SoundMenuItem.Size = new System.Drawing.Size(159, 22); this.SoundMenuItem.Text = "&Sound..."; this.SoundMenuItem.Click += new System.EventHandler(this.SoundMenuItem_Click); // @@ -1290,7 +1292,7 @@ // this.PathsMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.CopyFolderHS; this.PathsMenuItem.Name = "PathsMenuItem"; - this.PathsMenuItem.Size = new System.Drawing.Size(152, 22); + this.PathsMenuItem.Size = new System.Drawing.Size(159, 22); this.PathsMenuItem.Text = "Paths..."; this.PathsMenuItem.Click += new System.EventHandler(this.PathsMenuItem_Click); // @@ -1298,7 +1300,7 @@ // this.FirmwaresMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("FirmwaresMenuItem.Image"))); this.FirmwaresMenuItem.Name = "FirmwaresMenuItem"; - this.FirmwaresMenuItem.Size = new System.Drawing.Size(152, 22); + this.FirmwaresMenuItem.Size = new System.Drawing.Size(159, 22); this.FirmwaresMenuItem.Text = "&Firmwares"; this.FirmwaresMenuItem.Click += new System.EventHandler(this.FirmwaresMenuItem_Click); // @@ -1306,7 +1308,7 @@ // this.MessagesMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.MessageConfig; this.MessagesMenuItem.Name = "MessagesMenuItem"; - this.MessagesMenuItem.Size = new System.Drawing.Size(152, 22); + this.MessagesMenuItem.Size = new System.Drawing.Size(159, 22); this.MessagesMenuItem.Text = "&Messages..."; this.MessagesMenuItem.Click += new System.EventHandler(this.MessagesMenuItem_Click); // @@ -1314,7 +1316,7 @@ // this.AutofireMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.Lightning; this.AutofireMenuItem.Name = "AutofireMenuItem"; - this.AutofireMenuItem.Size = new System.Drawing.Size(152, 22); + this.AutofireMenuItem.Size = new System.Drawing.Size(159, 22); this.AutofireMenuItem.Text = "&Autofire..."; this.AutofireMenuItem.Click += new System.EventHandler(this.AutofireMenuItem_Click); // @@ -1322,14 +1324,21 @@ // this.RewindOptionsMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.Previous; this.RewindOptionsMenuItem.Name = "RewindOptionsMenuItem"; - this.RewindOptionsMenuItem.Size = new System.Drawing.Size(152, 22); + this.RewindOptionsMenuItem.Size = new System.Drawing.Size(159, 22); this.RewindOptionsMenuItem.Text = "&Rewind..."; this.RewindOptionsMenuItem.Click += new System.EventHandler(this.RewindOptionsMenuItem_Click); // + // extensionsToolStripMenuItem + // + this.extensionsToolStripMenuItem.Name = "extensionsToolStripMenuItem"; + this.extensionsToolStripMenuItem.Size = new System.Drawing.Size(159, 22); + this.extensionsToolStripMenuItem.Text = "File Extensions..."; + this.extensionsToolStripMenuItem.Click += new System.EventHandler(this.extensionsToolStripMenuItem_Click); + // // toolStripSeparator9 // this.toolStripSeparator9.Name = "toolStripSeparator9"; - this.toolStripSeparator9.Size = new System.Drawing.Size(149, 6); + this.toolStripSeparator9.Size = new System.Drawing.Size(156, 6); // // ConfigEnableSubMenu // @@ -1341,7 +1350,7 @@ this.FrameAdvanceSkipLagMenuItem, this.BackupSaveramMenuItem}); this.ConfigEnableSubMenu.Name = "ConfigEnableSubMenu"; - this.ConfigEnableSubMenu.Size = new System.Drawing.Size(152, 22); + this.ConfigEnableSubMenu.Size = new System.Drawing.Size(159, 22); this.ConfigEnableSubMenu.Text = "&Enable"; this.ConfigEnableSubMenu.DropDownOpened += new System.EventHandler(this.EnableMenuItem_DropDownOpened); // @@ -1403,7 +1412,7 @@ this.toolStripSeparator23, this.LogWindowAsConsoleMenuItem}); this.GuiSubMenu.Name = "GuiSubMenu"; - this.GuiSubMenu.Size = new System.Drawing.Size(152, 22); + this.GuiSubMenu.Size = new System.Drawing.Size(159, 22); this.GuiSubMenu.Text = "GUI"; this.GuiSubMenu.DropDownOpened += new System.EventHandler(this.GuiSubMenu_DropDownOpened); // @@ -1514,7 +1523,7 @@ this.Speed150MenuItem, this.Speed200MenuItem}); this.SpeedSkipSubMenu.Name = "SpeedSkipSubMenu"; - this.SpeedSkipSubMenu.Size = new System.Drawing.Size(152, 22); + this.SpeedSkipSubMenu.Size = new System.Drawing.Size(159, 22); this.SpeedSkipSubMenu.Text = "Speed/Skip"; this.SpeedSkipSubMenu.DropDownOpened += new System.EventHandler(this.FrameSkipMenuItem_DropDownOpened); // @@ -1680,7 +1689,7 @@ this.InputOverHkMenuItem, this.HkOverInputMenuItem}); this.KeyPrioritySubMenu.Name = "KeyPrioritySubMenu"; - this.KeyPrioritySubMenu.Size = new System.Drawing.Size(152, 22); + this.KeyPrioritySubMenu.Size = new System.Drawing.Size(159, 22); this.KeyPrioritySubMenu.Text = "Key Priority"; this.KeyPrioritySubMenu.DropDownOpened += new System.EventHandler(this.KeyPriorityMenuItem_DropDownOpened); // @@ -1712,7 +1721,7 @@ this.SavestateBinaryMenuItem, this.SavestateTextMenuItem}); this.SavestateTypeSubMenu.Name = "SavestateTypeSubMenu"; - this.SavestateTypeSubMenu.Size = new System.Drawing.Size(152, 22); + this.SavestateTypeSubMenu.Size = new System.Drawing.Size(159, 22); this.SavestateTypeSubMenu.Text = "Savestate Type"; this.SavestateTypeSubMenu.DropDownOpened += new System.EventHandler(this.SavestateTypeMenuItem_DropDownOpened); // @@ -1740,13 +1749,13 @@ // toolStripSeparator10 // this.toolStripSeparator10.Name = "toolStripSeparator10"; - this.toolStripSeparator10.Size = new System.Drawing.Size(149, 6); + this.toolStripSeparator10.Size = new System.Drawing.Size(156, 6); // // SaveConfigMenuItem // this.SaveConfigMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.Save; this.SaveConfigMenuItem.Name = "SaveConfigMenuItem"; - this.SaveConfigMenuItem.Size = new System.Drawing.Size(152, 22); + this.SaveConfigMenuItem.Size = new System.Drawing.Size(159, 22); this.SaveConfigMenuItem.Text = "Save Config"; this.SaveConfigMenuItem.Click += new System.EventHandler(this.SaveConfigMenuItem_Click); // @@ -1754,14 +1763,14 @@ // this.LoadConfigMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.LoadConfig; this.LoadConfigMenuItem.Name = "LoadConfigMenuItem"; - this.LoadConfigMenuItem.Size = new System.Drawing.Size(152, 22); + this.LoadConfigMenuItem.Size = new System.Drawing.Size(159, 22); this.LoadConfigMenuItem.Text = "Load Config"; this.LoadConfigMenuItem.Click += new System.EventHandler(this.LoadConfigMenuItem_Click); // // toolStripSeparator8 // this.toolStripSeparator8.Name = "toolStripSeparator8"; - this.toolStripSeparator8.Size = new System.Drawing.Size(149, 6); + this.toolStripSeparator8.Size = new System.Drawing.Size(156, 6); // // coreSelectionToolStripMenuItem // @@ -1769,7 +1778,7 @@ this.gBInSGBToolStripMenuItem, this.nESInQuickNESToolStripMenuItem}); this.coreSelectionToolStripMenuItem.Name = "coreSelectionToolStripMenuItem"; - this.coreSelectionToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.coreSelectionToolStripMenuItem.Size = new System.Drawing.Size(159, 22); this.coreSelectionToolStripMenuItem.Text = "Core Selection"; this.coreSelectionToolStripMenuItem.DropDownOpened += new System.EventHandler(this.coreSelectionToolStripMenuItem_DropDownOpened); this.coreSelectionToolStripMenuItem.Click += new System.EventHandler(this.coreSelectionToolStripMenuItem_Click); @@ -3485,6 +3494,7 @@ private System.Windows.Forms.ToolStripMenuItem SMSdisplayPalToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem SMSdisplayAutoToolStripMenuItem; private System.Windows.Forms.ToolStripSeparator toolStripSeparator26; + private System.Windows.Forms.ToolStripMenuItem extensionsToolStripMenuItem; } } diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs index b87f439b66..9e3cf28c59 100644 --- a/BizHawk.Client.EmuHawk/MainForm.cs +++ b/BizHawk.Client.EmuHawk/MainForm.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Drawing; using System.Drawing.Imaging; using System.IO; @@ -492,6 +493,45 @@ namespace BizHawk.Client.EmuHawk public bool UpdateFrame = false; public bool EmulatorPaused { get; private set; } + // Because we don't have enough places where we list SystemID's + public Dictionary SupportedPlatforms + { + get + { + var released = new Dictionary + { + { "A26", "Atari 2600" }, + { "A78", "Atari 7800" }, + + { "NES", "Nintendo Entertainment System/Famicom" }, + { "SNES", "Super Nintendo" }, + { "N64", "Nintendo 64" }, + + { "GB", "Game Boy" }, + { "GBC", "Game Boy Color" }, + + { "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" } + }; + + if (VersionInfo.INTERIM) + { + released.Add("GBA", "Gameboy Advance"); + released.Add("C64", "Commodore 64"); + } + + return released; + } + } + #endregion #region Public Methods @@ -3118,5 +3158,10 @@ namespace BizHawk.Client.EmuHawk { GlobalWin.Tools.Load(); } + + private void extensionsToolStripMenuItem_Click(object sender, EventArgs e) + { + new FileExtensionPreferences().ShowDialog(); + } } } diff --git a/BizHawk.Client.EmuHawk/PlatformChooser.cs b/BizHawk.Client.EmuHawk/PlatformChooser.cs index 24ed7e7bab..bb66d86844 100644 --- a/BizHawk.Client.EmuHawk/PlatformChooser.cs +++ b/BizHawk.Client.EmuHawk/PlatformChooser.cs @@ -13,31 +13,6 @@ namespace BizHawk.Client.EmuHawk { public partial class PlatformChooser : Form { - // Because we don't have enough places where we list SystemID's - private readonly Dictionary Platforms = new Dictionary - { - - { "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; } @@ -69,7 +44,7 @@ namespace BizHawk.Client.EmuHawk int count = 0; int spacing = 25; - foreach (var platform in Platforms) + foreach (var platform in GlobalWin.MainForm.SupportedPlatforms) { var radio = new RadioButton { @@ -96,7 +71,7 @@ namespace BizHawk.Client.EmuHawk private void OkBtn_Click(object sender, EventArgs e) { var selectedValue = SelectedRadio != null ? SelectedRadio.Text : string.Empty; - PlatformChoice = Platforms.FirstOrDefault(x => x.Value == selectedValue).Key; + PlatformChoice = GlobalWin.MainForm.SupportedPlatforms.FirstOrDefault(x => x.Value == selectedValue).Key; if (AlwaysCheckbox.Checked) { diff --git a/BizHawk.Client.EmuHawk/config/FileExtensionPreferences.Designer.cs b/BizHawk.Client.EmuHawk/config/FileExtensionPreferences.Designer.cs new file mode 100644 index 0000000000..abbd358b16 --- /dev/null +++ b/BizHawk.Client.EmuHawk/config/FileExtensionPreferences.Designer.cs @@ -0,0 +1,131 @@ +namespace BizHawk.Client.EmuHawk +{ + partial class FileExtensionPreferences + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.OkBtn = new System.Windows.Forms.Button(); + this.CancelBtn = new System.Windows.Forms.Button(); + this.PrefPanel = new System.Windows.Forms.Panel(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // 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(232, 187); + this.OkBtn.Name = "OkBtn"; + this.OkBtn.Size = new System.Drawing.Size(60, 23); + this.OkBtn.TabIndex = 0; + 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(298, 187); + this.CancelBtn.Name = "CancelBtn"; + this.CancelBtn.Size = new System.Drawing.Size(60, 23); + this.CancelBtn.TabIndex = 1; + this.CancelBtn.Text = "&Cancel"; + this.CancelBtn.UseVisualStyleBackColor = true; + this.CancelBtn.Click += new System.EventHandler(this.CancelBtn_Click); + // + // PrefPanel + // + this.PrefPanel.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.PrefPanel.Location = new System.Drawing.Point(12, 55); + this.PrefPanel.Name = "PrefPanel"; + this.PrefPanel.Size = new System.Drawing.Size(346, 126); + this.PrefPanel.TabIndex = 2; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 9); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(296, 13); + this.label1.TabIndex = 3; + this.label1.Text = "Select a preferred Platform to run for the given file extensions."; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(12, 24); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(352, 13); + this.label2.TabIndex = 4; + this.label2.Text = "Note: The game database overrides these options. They only take effect"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(12, 39); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(245, 13); + this.label3.TabIndex = 5; + this.label3.Text = "when a Rom is unable to be found in the database"; + // + // FileExtensionPreferences + // + 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(370, 222); + this.Controls.Add(this.label3); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Controls.Add(this.PrefPanel); + this.Controls.Add(this.CancelBtn); + this.Controls.Add(this.OkBtn); + this.Name = "FileExtensionPreferences"; + this.ShowIcon = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "File Extension Preferences"; + this.Load += new System.EventHandler(this.FileExtensionPreferences_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button OkBtn; + private System.Windows.Forms.Button CancelBtn; + private System.Windows.Forms.Panel PrefPanel; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; + } +} \ No newline at end of file diff --git a/BizHawk.Client.EmuHawk/config/FileExtensionPreferences.cs b/BizHawk.Client.EmuHawk/config/FileExtensionPreferences.cs new file mode 100644 index 0000000000..9304a1330a --- /dev/null +++ b/BizHawk.Client.EmuHawk/config/FileExtensionPreferences.cs @@ -0,0 +1,57 @@ +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 FileExtensionPreferences : Form + { + public FileExtensionPreferences() + { + InitializeComponent(); + } + + private void FileExtensionPreferences_Load(object sender, EventArgs e) + { + int spacing = 30; + int count = 0; + foreach (var kvp in Global.Config.PreferredPlatformsForExtensions) + { + FileExtensionPreferencesPicker picker = new FileExtensionPreferencesPicker + { + FileExtension = kvp.Key, + OriginalPreference = kvp.Value, + Location = new Point(15, 15 + (spacing * count)) + }; + + count++; + PrefPanel.Controls.Add(picker); + } + } + + private void OkBtn_Click(object sender, EventArgs e) + { + + foreach (var picker in PrefPanel.Controls.OfType()) + { + Global.Config.PreferredPlatformsForExtensions[picker.FileExtension] = picker.CurrentlySelectedSystemId; + } + + GlobalWin.OSD.AddMessage("Rom Extension Preferences changed"); + Close(); + } + + private void CancelBtn_Click(object sender, EventArgs e) + { + GlobalWin.OSD.AddMessage("Rom Extension Preferences cancelled"); + Close(); + } + } +} diff --git a/BizHawk.Client.EmuHawk/config/FileExtensionPreferences.resx b/BizHawk.Client.EmuHawk/config/FileExtensionPreferences.resx new file mode 100644 index 0000000000..29dcb1b3a3 --- /dev/null +++ b/BizHawk.Client.EmuHawk/config/FileExtensionPreferences.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/BizHawk.Client.EmuHawk/config/FileExtensionPreferencesPicker.Designer.cs b/BizHawk.Client.EmuHawk/config/FileExtensionPreferencesPicker.Designer.cs new file mode 100644 index 0000000000..f4032be5c6 --- /dev/null +++ b/BizHawk.Client.EmuHawk/config/FileExtensionPreferencesPicker.Designer.cs @@ -0,0 +1,72 @@ +namespace BizHawk.Client.EmuHawk +{ + partial class FileExtensionPreferencesPicker + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.FileExtensionLabel = new System.Windows.Forms.Label(); + this.PlatformDropdown = new System.Windows.Forms.ComboBox(); + this.SuspendLayout(); + // + // FileExtensionLabel + // + this.FileExtensionLabel.AutoSize = true; + this.FileExtensionLabel.Location = new System.Drawing.Point(3, 5); + this.FileExtensionLabel.Name = "FileExtensionLabel"; + this.FileExtensionLabel.Size = new System.Drawing.Size(24, 13); + this.FileExtensionLabel.TabIndex = 0; + this.FileExtensionLabel.Text = ".bin"; + // + // PlatformDropdown + // + this.PlatformDropdown.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.PlatformDropdown.FormattingEnabled = true; + this.PlatformDropdown.Location = new System.Drawing.Point(37, 2); + this.PlatformDropdown.Name = "PlatformDropdown"; + this.PlatformDropdown.Size = new System.Drawing.Size(142, 21); + this.PlatformDropdown.TabIndex = 1; + // + // FileExtensionPreferencesPicker + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.PlatformDropdown); + this.Controls.Add(this.FileExtensionLabel); + this.Name = "FileExtensionPreferencesPicker"; + this.Size = new System.Drawing.Size(182, 29); + this.Load += new System.EventHandler(this.FileExtensionPreferencesPicker_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label FileExtensionLabel; + private System.Windows.Forms.ComboBox PlatformDropdown; + } +} diff --git a/BizHawk.Client.EmuHawk/config/FileExtensionPreferencesPicker.cs b/BizHawk.Client.EmuHawk/config/FileExtensionPreferencesPicker.cs new file mode 100644 index 0000000000..9570f75650 --- /dev/null +++ b/BizHawk.Client.EmuHawk/config/FileExtensionPreferencesPicker.cs @@ -0,0 +1,90 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Windows.Forms; + +using BizHawk.Client.Common; + +namespace BizHawk.Client.EmuHawk +{ + public partial class FileExtensionPreferencesPicker : UserControl + { + public FileExtensionPreferencesPicker() + { + InitializeComponent(); + } + + public string FileExtension { get; set; } + public string OriginalPreference { get; set; } + + public string CurrentlySelectedSystemId + { + get + { + if (PlatformDropdown.SelectedIndex > 0) + { + return GlobalWin.MainForm.SupportedPlatforms + .FirstOrDefault(x => x.Value == PlatformDropdown.SelectedItem.ToString()).Key; + } + + return string.Empty; + } + } + + private void PopulatePlatforms() + { + PlatformDropdown.Items.Add("Ask me on load"); + foreach (var platform in GlobalWin.MainForm.SupportedPlatforms) + { + PlatformDropdown.Items.Add(platform.Value); + } + } + + private IEnumerable DropdownSystemIds + { + get + { + var dispVals = PlatformDropdown.Items.OfType(); + + foreach (var val in dispVals) + { + yield return GlobalWin.MainForm.SupportedPlatforms.FirstOrDefault(x => x.Value == val).Key ?? string.Empty; + } + } + } + + private void FileExtensionPreferencesPicker_Load(object sender, EventArgs e) + { + PopulatePlatforms(); + + var selectedSystemId = Global.Config.PreferredPlatformsForExtensions[FileExtension]; + if (!string.IsNullOrEmpty(selectedSystemId)) + { + var selectedDispString = GlobalWin.MainForm.SupportedPlatforms[selectedSystemId]; + + var selectedItem = PlatformDropdown.Items + .OfType() + .FirstOrDefault(item => item == selectedDispString); + + if (selectedItem != null) + { + PlatformDropdown.SelectedItem = selectedItem; + } + else + { + PlatformDropdown.SelectedIndex = 0; + } + } + else + { + PlatformDropdown.SelectedIndex = 0; + } + + FileExtensionLabel.Text = FileExtension; + } + } +} diff --git a/BizHawk.Client.EmuHawk/config/FileExtensionPreferencesPicker.resx b/BizHawk.Client.EmuHawk/config/FileExtensionPreferencesPicker.resx new file mode 100644 index 0000000000..29dcb1b3a3 --- /dev/null +++ b/BizHawk.Client.EmuHawk/config/FileExtensionPreferencesPicker.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file