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.

This commit is contained in:
rolanmen1 2012-03-24 10:53:26 +00:00
parent 0cf6b0bcb7
commit 661565cf3e
3 changed files with 70 additions and 13 deletions

View File

@ -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;
}
}

View File

@ -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();
}
}
}

View File

@ -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();
}
}
}
}