From c3c3fd6c20286bcbd6ce6434972ff4491870d66a Mon Sep 17 00:00:00 2001 From: adelikat Date: Sun, 23 Sep 2012 15:09:29 +0000 Subject: [PATCH] Ram Search - add Unfreeze All context menu item, conditional upon there being at least one cheat in the system. Also, show an OSD message when removing all cheats --- BizHawk.MultiClient/MainForm.MenuItems.cs | 2 +- BizHawk.MultiClient/tools/CheatList.cs | 13 ++++--- BizHawk.MultiClient/tools/Cheats.cs | 5 +++ .../tools/RamSearch.Designer.cs | 39 ++++++++++++++----- BizHawk.MultiClient/tools/RamSearch.cs | 15 +++++++ 5 files changed, 58 insertions(+), 16 deletions(-) diff --git a/BizHawk.MultiClient/MainForm.MenuItems.cs b/BizHawk.MultiClient/MainForm.MenuItems.cs index 5ea06a9fa5..3da009bc4a 100644 --- a/BizHawk.MultiClient/MainForm.MenuItems.cs +++ b/BizHawk.MultiClient/MainForm.MenuItems.cs @@ -1592,7 +1592,7 @@ namespace BizHawk.MultiClient public void UpdateCheatStatus() { - if (Global.CheatList.HasActiveCheat()) + if (Global.CheatList.HasActiveCheats) { CheatStatus.ToolTipText = "Cheats are currently active"; CheatStatus.Image = BizHawk.MultiClient.Properties.Resources.Freeze; diff --git a/BizHawk.MultiClient/tools/CheatList.cs b/BizHawk.MultiClient/tools/CheatList.cs index 3da413106b..6666aaba9c 100644 --- a/BizHawk.MultiClient/tools/CheatList.cs +++ b/BizHawk.MultiClient/tools/CheatList.cs @@ -373,16 +373,19 @@ namespace BizHawk.MultiClient Global.MainForm.UpdateCheatStatus(); } - public bool HasActiveCheat() + public bool HasActiveCheats { - for (int x = 0; x < cheatList.Count; x++) + get { - if (cheatList[x].IsEnabled()) + for (int x = 0; x < cheatList.Count; x++) { - return true; + if (cheatList[x].IsEnabled()) + { + return true; + } } + return false; } - return false; } } } diff --git a/BizHawk.MultiClient/tools/Cheats.cs b/BizHawk.MultiClient/tools/Cheats.cs index 826f663090..d527bb094a 100644 --- a/BizHawk.MultiClient/tools/Cheats.cs +++ b/BizHawk.MultiClient/tools/Cheats.cs @@ -942,9 +942,13 @@ namespace BizHawk.MultiClient public void DisableAllCheats() { if (Global.CheatList.cheatList.Count > 0) + { Global.OSD.AddMessage("All cheats disabled."); + } for (int x = 0; x < Global.CheatList.cheatList.Count; x++) + { Global.CheatList.cheatList[x].Disable(); + } MemoryPulse.Clear(); CheatListView.Refresh(); UpdateNumberOfCheats(); @@ -957,6 +961,7 @@ namespace BizHawk.MultiClient if (!this.IsHandleCreated || this.IsDisposed) return; CheatListView.Refresh(); UpdateNumberOfCheats(); + Global.OSD.AddMessage("All cheats removed"); } private void disableAllCheatsToolStripMenuItem_Click(object sender, EventArgs e) diff --git a/BizHawk.MultiClient/tools/RamSearch.Designer.cs b/BizHawk.MultiClient/tools/RamSearch.Designer.cs index 68dc547e04..246795d56b 100644 --- a/BizHawk.MultiClient/tools/RamSearch.Designer.cs +++ b/BizHawk.MultiClient/tools/RamSearch.Designer.cs @@ -53,8 +53,10 @@ this.toolStripSeparator9 = new System.Windows.Forms.ToolStripSeparator(); this.removeSelectedToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.addToRamWatchToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.pokeAddressToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.freezeAddressToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.pokeAddressToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.unfreezeAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator12 = new System.Windows.Forms.ToolStripSeparator(); this.viewInHexEditorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip1 = new MenuStripEx(); this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -337,11 +339,13 @@ this.toolStripSeparator9, this.removeSelectedToolStripMenuItem1, this.addToRamWatchToolStripMenuItem, - this.pokeAddressToolStripMenuItem1, this.freezeAddressToolStripMenuItem1, + this.pokeAddressToolStripMenuItem1, + this.unfreezeAllToolStripMenuItem, + this.toolStripSeparator12, this.viewInHexEditorToolStripMenuItem}); this.contextMenuStrip1.Name = "contextMenuStrip1"; - this.contextMenuStrip1.Size = new System.Drawing.Size(216, 164); + this.contextMenuStrip1.Size = new System.Drawing.Size(216, 214); this.contextMenuStrip1.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip1_Opening); // // startNewSearchToolStripMenuItem @@ -383,6 +387,15 @@ this.addToRamWatchToolStripMenuItem.Text = "Add to Ram Watch"; this.addToRamWatchToolStripMenuItem.Click += new System.EventHandler(this.addToRamWatchToolStripMenuItem_Click); // + // freezeAddressToolStripMenuItem1 + // + this.freezeAddressToolStripMenuItem1.Image = global::BizHawk.MultiClient.Properties.Resources.Freeze; + this.freezeAddressToolStripMenuItem1.Name = "freezeAddressToolStripMenuItem1"; + this.freezeAddressToolStripMenuItem1.ShortcutKeyDisplayString = "Ctrl+F"; + this.freezeAddressToolStripMenuItem1.Size = new System.Drawing.Size(215, 22); + this.freezeAddressToolStripMenuItem1.Text = "Freeze Address"; + this.freezeAddressToolStripMenuItem1.Click += new System.EventHandler(this.freezeAddressToolStripMenuItem1_Click); + // // pokeAddressToolStripMenuItem1 // this.pokeAddressToolStripMenuItem1.Image = global::BizHawk.MultiClient.Properties.Resources.poke; @@ -392,14 +405,18 @@ this.pokeAddressToolStripMenuItem1.Text = "Poke Address"; this.pokeAddressToolStripMenuItem1.Click += new System.EventHandler(this.pokeAddressToolStripMenuItem1_Click); // - // freezeAddressToolStripMenuItem1 + // unfreezeAllToolStripMenuItem // - this.freezeAddressToolStripMenuItem1.Image = global::BizHawk.MultiClient.Properties.Resources.Freeze; - this.freezeAddressToolStripMenuItem1.Name = "freezeAddressToolStripMenuItem1"; - this.freezeAddressToolStripMenuItem1.ShortcutKeyDisplayString = "Ctrl+F"; - this.freezeAddressToolStripMenuItem1.Size = new System.Drawing.Size(215, 22); - this.freezeAddressToolStripMenuItem1.Text = "Freeze Address"; - this.freezeAddressToolStripMenuItem1.Click += new System.EventHandler(this.freezeAddressToolStripMenuItem1_Click); + this.unfreezeAllToolStripMenuItem.Image = global::BizHawk.MultiClient.Properties.Resources.Unfreeze; + this.unfreezeAllToolStripMenuItem.Name = "unfreezeAllToolStripMenuItem"; + this.unfreezeAllToolStripMenuItem.Size = new System.Drawing.Size(215, 22); + this.unfreezeAllToolStripMenuItem.Text = "Unfreeze &All"; + this.unfreezeAllToolStripMenuItem.Click += new System.EventHandler(this.unfreezeAllToolStripMenuItem_Click); + // + // toolStripSeparator12 + // + this.toolStripSeparator12.Name = "toolStripSeparator12"; + this.toolStripSeparator12.Size = new System.Drawing.Size(212, 6); // // viewInHexEditorToolStripMenuItem // @@ -1385,5 +1402,7 @@ private System.Windows.Forms.ToolStripMenuItem sinceLastChangeToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem autoloadDialogToolStripMenuItem; private System.Windows.Forms.ToolStripSeparator toolStripSeparator11; + private System.Windows.Forms.ToolStripMenuItem unfreezeAllToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator12; } } \ No newline at end of file diff --git a/BizHawk.MultiClient/tools/RamSearch.cs b/BizHawk.MultiClient/tools/RamSearch.cs index 6db703cec6..1eedfa95c8 100644 --- a/BizHawk.MultiClient/tools/RamSearch.cs +++ b/BizHawk.MultiClient/tools/RamSearch.cs @@ -2437,6 +2437,15 @@ namespace BizHawk.MultiClient } } } + + if (Global.CheatList.HasActiveCheats) + { + unfreezeAllToolStripMenuItem.Visible = true; + } + else + { + unfreezeAllToolStripMenuItem.Visible = false; + } } private void removeSelectedToolStripMenuItem1_Click(object sender, EventArgs e) @@ -2647,5 +2656,11 @@ namespace BizHawk.MultiClient { Global.Config.AutoLoadRamSearch ^= true; } + + private void unfreezeAllToolStripMenuItem_Click(object sender, EventArgs e) + { + Global.MainForm.Cheats1.RemoveAllCheats(); + UpdateValues(); + } } }