From 05ee956c925c8e9386496a4526376154848e8175 Mon Sep 17 00:00:00 2001 From: "andres.delikat" Date: Sun, 20 Mar 2011 20:48:35 +0000 Subject: [PATCH] Cheats window - Context menu items - toggle & remove selected --- BizHawk.MultiClient/tools/Cheats.Designer.cs | 22 +++++++++++++- BizHawk.MultiClient/tools/Cheats.cs | 32 +++++++++++++++----- 2 files changed, 45 insertions(+), 9 deletions(-) diff --git a/BizHawk.MultiClient/tools/Cheats.Designer.cs b/BizHawk.MultiClient/tools/Cheats.Designer.cs index 06edacb59b..7bd7297145 100644 --- a/BizHawk.MultiClient/tools/Cheats.Designer.cs +++ b/BizHawk.MultiClient/tools/Cheats.Designer.cs @@ -94,6 +94,8 @@ this.toolStripSeparator6 = new System.Windows.Forms.ToolStripSeparator(); this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); this.disableAllCheatsToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.toggleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.removeSelectedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.CheatsMenu.SuspendLayout(); this.toolStrip1.SuspendLayout(); this.AddCheatGroup.SuspendLayout(); @@ -663,9 +665,11 @@ // contextMenuStrip1 // this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toggleToolStripMenuItem, + this.removeSelectedToolStripMenuItem, this.disableAllCheatsToolStripMenuItem1}); this.contextMenuStrip1.Name = "contextMenuStrip1"; - this.contextMenuStrip1.Size = new System.Drawing.Size(171, 48); + this.contextMenuStrip1.Size = new System.Drawing.Size(171, 92); // // disableAllCheatsToolStripMenuItem1 // @@ -674,6 +678,20 @@ this.disableAllCheatsToolStripMenuItem1.Text = "Disable All Cheats"; this.disableAllCheatsToolStripMenuItem1.Click += new System.EventHandler(this.disableAllCheatsToolStripMenuItem1_Click); // + // toggleToolStripMenuItem + // + this.toggleToolStripMenuItem.Name = "toggleToolStripMenuItem"; + this.toggleToolStripMenuItem.Size = new System.Drawing.Size(170, 22); + this.toggleToolStripMenuItem.Text = "Toggle"; + this.toggleToolStripMenuItem.Click += new System.EventHandler(this.toggleToolStripMenuItem_Click); + // + // removeSelectedToolStripMenuItem + // + this.removeSelectedToolStripMenuItem.Name = "removeSelectedToolStripMenuItem"; + this.removeSelectedToolStripMenuItem.Size = new System.Drawing.Size(170, 22); + this.removeSelectedToolStripMenuItem.Text = "Remove Selected"; + this.removeSelectedToolStripMenuItem.Click += new System.EventHandler(this.removeSelectedToolStripMenuItem_Click); + // // Cheats // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -768,5 +786,7 @@ private System.Windows.Forms.ToolStripMenuItem disableAllCheatsToolStripMenuItem; private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; private System.Windows.Forms.ToolStripMenuItem disableAllCheatsToolStripMenuItem1; + private System.Windows.Forms.ToolStripMenuItem toggleToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem removeSelectedToolStripMenuItem; } } \ No newline at end of file diff --git a/BizHawk.MultiClient/tools/Cheats.cs b/BizHawk.MultiClient/tools/Cheats.cs index 0bb75b3cc9..a4accf99fd 100644 --- a/BizHawk.MultiClient/tools/Cheats.cs +++ b/BizHawk.MultiClient/tools/Cheats.cs @@ -16,10 +16,8 @@ namespace BizHawk.MultiClient //Implement Options menu settings //Implement Freeze functions in all memory domains //Restore Window Size should restore column order as well - //Disable all cheats menu & context menu item - //Double click should toggle all selected cheats not just one //TODO: use currently selected memory domain! - line 50 - //Populate context menu + //context menu - enable/disable highlight dependent items int defaultWidth; //For saving the default size of the dialog, so the user can restore if desired int defaultHeight; @@ -729,20 +727,28 @@ namespace BizHawk.MultiClient DuplicateCheat(); } - private void CheatListView_DoubleClick(object sender, EventArgs e) + private void Toggle() { ListView.SelectedIndexCollection indexes = CheatListView.SelectedIndices; if (indexes.Count > 0) { - if (cheatList[indexes[0]].IsEnabled()) - cheatList[indexes[0]].Disable(); - else - cheatList[indexes[0]].Enable(); + for (int x = 0; x < indexes.Count; x++) + { + if (cheatList[indexes[x]].IsEnabled()) + cheatList[indexes[x]].Disable(); + else + cheatList[indexes[x]].Enable(); + } CheatListView.Refresh(); } UpdateNumberOfCheats(); } + private void CheatListView_DoubleClick(object sender, EventArgs e) + { + Toggle(); + } + private void CheatListView_Click(object sender, EventArgs e) { ListView.SelectedIndexCollection indexes = CheatListView.SelectedIndices; @@ -902,5 +908,15 @@ namespace BizHawk.MultiClient { DisableAllCheats(); } + + private void toggleToolStripMenuItem_Click(object sender, EventArgs e) + { + Toggle(); + } + + private void removeSelectedToolStripMenuItem_Click(object sender, EventArgs e) + { + RemoveCheat(); + } } }