From 63593b4e2c0550b708248d5611c6eb8fb0fcceed Mon Sep 17 00:00:00 2001 From: Asnivor Date: Tue, 12 Jun 2018 11:40:11 +0100 Subject: [PATCH] ZXHawk: Media menu to change tapes and disks --- BizHawk.Client.EmuHawk/MainForm.Designer.cs | 65 +++++++++++++++++-- BizHawk.Client.EmuHawk/MainForm.Events.cs | 72 +++++++++++++++++++++ 2 files changed, 130 insertions(+), 7 deletions(-) diff --git a/BizHawk.Client.EmuHawk/MainForm.Designer.cs b/BizHawk.Client.EmuHawk/MainForm.Designer.cs index d2d28f2b94..57df31fabc 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Designer.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Designer.cs @@ -386,6 +386,10 @@ this.ZXSpectrumControllerConfigurationMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.ZXSpectrumAudioSettingsMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.ZXSpectrumNonSyncSettingsMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.ZXSpectrumPokeMemoryMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.ZXSpectrumMediaMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.ZXSpectrumTapesSubMenu = new System.Windows.Forms.ToolStripMenuItem(); + this.ZXSpectrumDisksSubMenu = new System.Windows.Forms.ToolStripMenuItem(); this.Atari7800HawkCoreMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.MainStatusBar = new StatusStripEx(); this.DumpStatusButton = new System.Windows.Forms.ToolStripDropDownButton(); @@ -458,7 +462,8 @@ this.ShowMenuContextMenuSeparator = new System.Windows.Forms.ToolStripSeparator(); this.ShowMenuContextMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.timerMouseIdle = new System.Windows.Forms.Timer(this.components); - this.ZXSpectrumPokeMemoryMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.zxt1ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.zxt2ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.MainformMenu.SuspendLayout(); this.MainStatusBar.SuspendLayout(); this.MainFormContextMenu.SuspendLayout(); @@ -3403,7 +3408,8 @@ this.ZXSpectrumControllerConfigurationMenuItem, this.ZXSpectrumAudioSettingsMenuItem, this.ZXSpectrumNonSyncSettingsMenuItem, - this.ZXSpectrumPokeMemoryMenuItem}); + this.ZXSpectrumPokeMemoryMenuItem, + this.ZXSpectrumMediaMenuItem}); this.zXSpectrumToolStripMenuItem.Name = "zXSpectrumToolStripMenuItem"; this.zXSpectrumToolStripMenuItem.Size = new System.Drawing.Size(87, 19); this.zXSpectrumToolStripMenuItem.Text = "ZX Spectrum"; @@ -3437,6 +3443,41 @@ this.ZXSpectrumNonSyncSettingsMenuItem.Text = "Non-Sync Settings"; this.ZXSpectrumNonSyncSettingsMenuItem.Click += new System.EventHandler(this.ZXSpectrumNonSyncSettingsMenuItem_Click); // + // ZXSpectrumPokeMemoryMenuItem + // + this.ZXSpectrumPokeMemoryMenuItem.Name = "ZXSpectrumPokeMemoryMenuItem"; + this.ZXSpectrumPokeMemoryMenuItem.Size = new System.Drawing.Size(201, 22); + this.ZXSpectrumPokeMemoryMenuItem.Text = "POKE Memory"; + this.ZXSpectrumPokeMemoryMenuItem.Click += new System.EventHandler(this.ZXSpectrumPokeMemoryMenuItem_Click); + // + // ZXSpectrumMediaMenuItem + // + this.ZXSpectrumMediaMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.ZXSpectrumTapesSubMenu, + this.ZXSpectrumDisksSubMenu}); + this.ZXSpectrumMediaMenuItem.Name = "ZXSpectrumMediaMenuItem"; + this.ZXSpectrumMediaMenuItem.Size = new System.Drawing.Size(201, 22); + this.ZXSpectrumMediaMenuItem.Text = "Media"; + this.ZXSpectrumMediaMenuItem.DropDownOpened += new System.EventHandler(this.ZXSpectrumMediaMenuItem_DropDownOpened); + // + // ZXSpectrumTapesSubMenu + // + this.ZXSpectrumTapesSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.zxt1ToolStripMenuItem}); + this.ZXSpectrumTapesSubMenu.Name = "ZXSpectrumTapesSubMenu"; + this.ZXSpectrumTapesSubMenu.Size = new System.Drawing.Size(152, 22); + this.ZXSpectrumTapesSubMenu.Text = "Tapes"; + this.ZXSpectrumTapesSubMenu.DropDownOpened += new System.EventHandler(this.ZXSpectrumTapesSubMenu_DropDownOpened); + // + // ZXSpectrumDisksSubMenu + // + this.ZXSpectrumDisksSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.zxt2ToolStripMenuItem}); + this.ZXSpectrumDisksSubMenu.Name = "ZXSpectrumDisksSubMenu"; + this.ZXSpectrumDisksSubMenu.Size = new System.Drawing.Size(152, 22); + this.ZXSpectrumDisksSubMenu.Text = "Disks"; + this.ZXSpectrumDisksSubMenu.DropDownOpened += new System.EventHandler(this.ZXSpectrumDisksSubMenu_DropDownOpened); + // // Atari7800HawkCoreMenuItem // this.Atari7800HawkCoreMenuItem.Name = "Atari7800HawkCoreMenuItem"; @@ -4063,12 +4104,17 @@ this.timerMouseIdle.Interval = 2000; this.timerMouseIdle.Tick += new System.EventHandler(this.TimerMouseIdle_Tick); // - // ZXSpectrumPokeMemoryMenuItem + // zxt1ToolStripMenuItem // - this.ZXSpectrumPokeMemoryMenuItem.Name = "ZXSpectrumPokeMemoryMenuItem"; - this.ZXSpectrumPokeMemoryMenuItem.Size = new System.Drawing.Size(201, 22); - this.ZXSpectrumPokeMemoryMenuItem.Text = "POKE Memory"; - this.ZXSpectrumPokeMemoryMenuItem.Click += new System.EventHandler(this.ZXSpectrumPokeMemoryMenuItem_Click); + this.zxt1ToolStripMenuItem.Name = "zxt1ToolStripMenuItem"; + this.zxt1ToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.zxt1ToolStripMenuItem.Text = "zxt1"; + // + // zxt2ToolStripMenuItem + // + this.zxt2ToolStripMenuItem.Name = "zxt2ToolStripMenuItem"; + this.zxt2ToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.zxt2ToolStripMenuItem.Text = "zxt2"; // // MainForm // @@ -4540,5 +4586,10 @@ private System.Windows.Forms.ToolStripMenuItem ZXSpectrumNonSyncSettingsMenuItem; private System.Windows.Forms.ToolStripMenuItem ZXSpectrumAudioSettingsMenuItem; private System.Windows.Forms.ToolStripMenuItem ZXSpectrumPokeMemoryMenuItem; + private System.Windows.Forms.ToolStripMenuItem ZXSpectrumMediaMenuItem; + private System.Windows.Forms.ToolStripMenuItem ZXSpectrumTapesSubMenu; + private System.Windows.Forms.ToolStripMenuItem ZXSpectrumDisksSubMenu; + private System.Windows.Forms.ToolStripMenuItem zxt1ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem zxt2ToolStripMenuItem; } } diff --git a/BizHawk.Client.EmuHawk/MainForm.Events.cs b/BizHawk.Client.EmuHawk/MainForm.Events.cs index 3cbf90c572..e9048cab55 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Events.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Events.cs @@ -25,6 +25,7 @@ using BizHawk.Emulation.Cores.Computers.AppleII; using BizHawk.Client.ApiHawk; using BizHawk.Emulation.Cores.Computers.Commodore64; using BizHawk.Emulation.Cores.Nintendo.Gameboy; +using BizHawk.Emulation.Cores.Computers.SinclairSpectrum; namespace BizHawk.Client.EmuHawk { @@ -2492,6 +2493,77 @@ namespace BizHawk.Client.EmuHawk new ZXSpectrumPokeMemory().ShowDialog(); } + private void ZXSpectrumMediaMenuItem_DropDownOpened(object sender, EventArgs e) + { + if (Emulator is ZXSpectrum) + { + ZXSpectrumTapesSubMenu.Enabled = ((ZXSpectrum)Emulator)._tapeInfo.Count > 0; + ZXSpectrumDisksSubMenu.Enabled = ((ZXSpectrum)Emulator)._diskInfo.Count > 0; + } + } + + private void ZXSpectrumTapesSubMenu_DropDownOpened(object sender, EventArgs e) + { + ZXSpectrumTapesSubMenu.DropDownItems.Clear(); + + if (Emulator is ZXSpectrum) + { + var speccy = (ZXSpectrum)Emulator; + var currSel = speccy._machine.TapeMediaIndex; + + for (int i = 0; i < speccy._tapeInfo.Count; i++) + { + string name = speccy._tapeInfo[i].Name; + + var menuItem = new ToolStripMenuItem + { + Name = i + "_" + name, + Text = i + ": " + name, + Checked = currSel == i + }; + + int dummy = i; + menuItem.Click += (o, ev) => + { + speccy._machine.TapeMediaIndex = dummy; + }; + + ZXSpectrumTapesSubMenu.DropDownItems.Add(menuItem); + } + } + } + + private void ZXSpectrumDisksSubMenu_DropDownOpened(object sender, EventArgs e) + { + ZXSpectrumDisksSubMenu.DropDownItems.Clear(); + + if (Emulator is ZXSpectrum) + { + var speccy = (ZXSpectrum)Emulator; + var currSel = speccy._machine.DiskMediaIndex; + + for (int i = 0; i < speccy._diskInfo.Count; i++) + { + string name = speccy._diskInfo[i].Name; + + var menuItem = new ToolStripMenuItem + { + Name = i + "_" + name, + Text = i + ": " + name, + Checked = currSel == i + }; + + int dummy = i; + menuItem.Click += (o, ev) => + { + speccy._machine.DiskMediaIndex = dummy; + }; + + ZXSpectrumDisksSubMenu.DropDownItems.Add(menuItem); + } + } + } + #endregion #region Help