From 661565cf3eadc8ffbe36bc253d806683526f1ee4 Mon Sep 17 00:00:00 2001 From: rolanmen1 Date: Sat, 24 Mar 2012 10:53:26 +0000 Subject: [PATCH] Added Pause Property To Scripts, Menu Option To Pause/Resume Scripts, Enabled And Paused Scripts Change It's Background To Red (May need to change this). Label Above ListView Shows How Many Scripts Are Paused. Need To Add Pause Icon To The Menu Option. --- .../tools/LuaConsole.Designer.cs | 18 +++++-- BizHawk.MultiClient/tools/LuaConsole.cs | 51 +++++++++++++++---- BizHawk.MultiClient/tools/LuaFiles.cs | 14 +++++ 3 files changed, 70 insertions(+), 13 deletions(-) diff --git a/BizHawk.MultiClient/tools/LuaConsole.Designer.cs b/BizHawk.MultiClient/tools/LuaConsole.Designer.cs index b075df7dd7..662b53be71 100644 --- a/BizHawk.MultiClient/tools/LuaConsole.Designer.cs +++ b/BizHawk.MultiClient/tools/LuaConsole.Designer.cs @@ -92,6 +92,7 @@ this.LuaListView = new BizHawk.VirtualListView(); this.Script = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.PathName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.pauseResumeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.contextMenuStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout(); this.contextMenuStrip2.SuspendLayout(); @@ -272,18 +273,18 @@ // noneToolStripMenuItem // this.noneToolStripMenuItem.Name = "noneToolStripMenuItem"; - this.noneToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.noneToolStripMenuItem.Size = new System.Drawing.Size(103, 22); this.noneToolStripMenuItem.Text = "None"; // // toolStripSeparator3 // this.toolStripSeparator3.Name = "toolStripSeparator3"; - this.toolStripSeparator3.Size = new System.Drawing.Size(149, 6); + this.toolStripSeparator3.Size = new System.Drawing.Size(100, 6); // // clearToolStripMenuItem // this.clearToolStripMenuItem.Name = "clearToolStripMenuItem"; - this.clearToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.clearToolStripMenuItem.Size = new System.Drawing.Size(103, 22); this.clearToolStripMenuItem.Text = "Clear"; // // toolStripSeparator1 @@ -304,6 +305,7 @@ this.scriptToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.openToolStripMenuItem, this.toggleToolStripMenuItem, + this.pauseResumeToolStripMenuItem, this.editToolStripMenuItem, this.removeScriptToolStripMenuItem1, this.insertSeparatorToolStripMenuItem, @@ -644,6 +646,13 @@ this.PathName.Text = "Path"; this.PathName.Width = 195; // + // pauseResumeToolStripMenuItem + // + this.pauseResumeToolStripMenuItem.Name = "pauseResumeToolStripMenuItem"; + this.pauseResumeToolStripMenuItem.Size = new System.Drawing.Size(195, 22); + this.pauseResumeToolStripMenuItem.Text = "Resume/Pause"; + this.pauseResumeToolStripMenuItem.Click += new System.EventHandler(this.pauseResumeToolStripMenuItem_Click); + // // LuaConsole // this.AllowDrop = true; @@ -738,6 +747,7 @@ private System.Windows.Forms.ContextMenuStrip contextMenuStrip2; private System.Windows.Forms.ToolStripMenuItem clearToolStripMenuItem2; private System.Windows.Forms.ToolStripMenuItem disableScriptsOnLoadToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem autoloadSessionToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem autoloadSessionToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem pauseResumeToolStripMenuItem; } } \ No newline at end of file diff --git a/BizHawk.MultiClient/tools/LuaConsole.cs b/BizHawk.MultiClient/tools/LuaConsole.cs index af89edfbd4..b356f3b814 100644 --- a/BizHawk.MultiClient/tools/LuaConsole.cs +++ b/BizHawk.MultiClient/tools/LuaConsole.cs @@ -58,10 +58,12 @@ namespace BizHawk.MultiClient { if (column == 0) { - if (luaList[index].IsSeparator) - color = this.BackColor; - else if (luaList[index].Enabled) - color = Color.LightCyan; + if (luaList[index].IsSeparator) + color = this.BackColor; + else if (luaList[index].Enabled && !luaList[index].Paused) + color = Color.LightCyan; + else if (luaList[index].Enabled && luaList[index].Paused) + color = Color.IndianRed; } } @@ -177,6 +179,7 @@ namespace BizHawk.MultiClient l.Enabled = true; } else l.Enabled = false; + l.Paused = false; changes = true; } else @@ -267,20 +270,24 @@ namespace BizHawk.MultiClient private void UpdateNumberOfScripts() { string message = ""; - int active = 0; + int active = 0, paused = 0; for (int x = 0; x < luaList.Count; x++) { - if (luaList[x].Enabled) - active++; + if (luaList[x].Enabled) + { + active++; + if (luaList[x].Paused) + paused++; + } } int L = luaList.Count; if (L == 1) - message += L.ToString() + " script (" + active.ToString() + " active)"; + message += L.ToString() + " script (" + active.ToString() + " active, " + paused.ToString() + " paused)"; else if (L == 0) message += L.ToString() + " script"; else - message += L.ToString() + " scripts (" + active.ToString() + " active)"; + message += L.ToString() + " scripts (" + active.ToString() + " active, " + paused.ToString() + " paused)"; NumberOfScripts.Text = message; } @@ -1053,5 +1060,31 @@ namespace BizHawk.MultiClient { Global.Config.AutoLoadLuaSession ^= true; } + + private void toolStripButton1_Click(object sender, EventArgs e) + { + TogglePause(); + } + + private void TogglePause() + { + ListView.SelectedIndexCollection indexes = LuaListView.SelectedIndices; + if (indexes.Count > 0) + { + for (int x = 0; x < indexes.Count; x++) + { + var item = luaList[indexes[x]]; + item.TogglePause(); + } + } + LuaListView.Refresh(); + UpdateNumberOfScripts(); + changes = true; + } + + private void pauseResumeToolStripMenuItem_Click(object sender, EventArgs e) + { + TogglePause(); + } } } diff --git a/BizHawk.MultiClient/tools/LuaFiles.cs b/BizHawk.MultiClient/tools/LuaFiles.cs index 7279f79afe..5977526581 100644 --- a/BizHawk.MultiClient/tools/LuaFiles.cs +++ b/BizHawk.MultiClient/tools/LuaFiles.cs @@ -10,6 +10,7 @@ namespace BizHawk.MultiClient public string Name; public string Path; public bool Enabled; + public bool Paused; public bool IsSeparator; public LuaInterface.Lua Thread; public bool FrameWaiting; @@ -19,6 +20,7 @@ namespace BizHawk.MultiClient Name = ""; Path = path; Enabled = true; + Paused = false; FrameWaiting = false; } @@ -48,12 +50,24 @@ namespace BizHawk.MultiClient Name = l.Name; Path = l.Path; Enabled = l.Enabled; + Paused = l.Paused; IsSeparator = l.IsSeparator; } public void Toggle() { Enabled ^= true; + if (Enabled) + Paused = false; } + + public void TogglePause() + { + Paused ^= true; + if (Paused) + { + Thread.Dispose(); + } + } } }