Lua Console - logic for hiding/disabling menu items

This commit is contained in:
adelikat 2012-03-17 23:16:11 +00:00
parent 300f68e8b7
commit 338f4230f1
3 changed files with 101 additions and 8 deletions

View File

@ -107,7 +107,8 @@
this.toolStripSeparator4,
this.stopAllScriptsToolStripMenuItem});
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(175, 120);
this.contextMenuStrip1.Size = new System.Drawing.Size(175, 142);
this.contextMenuStrip1.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip1_Opening);
//
// toggleScriptToolStripMenuItem
//
@ -240,18 +241,18 @@
// noneToolStripMenuItem1
//
this.noneToolStripMenuItem1.Name = "noneToolStripMenuItem1";
this.noneToolStripMenuItem1.Size = new System.Drawing.Size(152, 22);
this.noneToolStripMenuItem1.Size = new System.Drawing.Size(103, 22);
this.noneToolStripMenuItem1.Text = "None";
//
// toolStripSeparator8
//
this.toolStripSeparator8.Name = "toolStripSeparator8";
this.toolStripSeparator8.Size = new System.Drawing.Size(149, 6);
this.toolStripSeparator8.Size = new System.Drawing.Size(100, 6);
//
// clearToolStripMenuItem1
//
this.clearToolStripMenuItem1.Name = "clearToolStripMenuItem1";
this.clearToolStripMenuItem1.Size = new System.Drawing.Size(152, 22);
this.clearToolStripMenuItem1.Size = new System.Drawing.Size(103, 22);
this.clearToolStripMenuItem1.Text = "Clear";
//
// recentToolStripMenuItem
@ -313,6 +314,7 @@
this.scriptToolStripMenuItem.Name = "scriptToolStripMenuItem";
this.scriptToolStripMenuItem.Size = new System.Drawing.Size(49, 20);
this.scriptToolStripMenuItem.Text = "&Script";
this.scriptToolStripMenuItem.DropDownOpened += new System.EventHandler(this.scriptToolStripMenuItem_DropDownOpened);
//
// openToolStripMenuItem
//

View File

@ -13,14 +13,10 @@ namespace BizHawk.MultiClient
{
public partial class LuaConsole : Form
{
//track changes
//options - autoload session
//options - disable scripts on load
//TODO: remember column widths
//TODO: restore column width on restore default settings
//TODO: load scripts from recent scripts menu
//TODO: context menu & main menu - Edit is grayed out if seperator is highlighted
//Stop all scripts should be grayed if all lua scripts are disabled
int defaultWidth; //For saving the default size of the dialog, so the user can restore if desired
int defaultHeight;
@ -896,5 +892,99 @@ namespace BizHawk.MultiClient
{
MoveDown();
}
private void scriptToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
{
bool luaRunning = false;
for (int i = 0; i < luaList.Count; i++)
{
if (luaList[i].Enabled)
luaRunning = true;
}
ListView.SelectedIndexCollection indexes = LuaListView.SelectedIndices;
if (indexes.Count > 0)
{
scriptToolStripMenuItem.DropDownItems[1].Enabled = true;
scriptToolStripMenuItem.DropDownItems[3].Enabled = true;
scriptToolStripMenuItem.DropDownItems[6].Enabled = true;
scriptToolStripMenuItem.DropDownItems[7].Enabled = true;
bool allSeparators = true;
for (int i = 0; i < indexes.Count; i++)
{
if (!luaList[indexes[i]].IsSeparator)
allSeparators = false;
}
if (allSeparators)
scriptToolStripMenuItem.DropDownItems[2].Enabled = false;
else
scriptToolStripMenuItem.DropDownItems[2].Enabled = true;
}
else
{
scriptToolStripMenuItem.DropDownItems[1].Enabled = false;
scriptToolStripMenuItem.DropDownItems[2].Enabled = false;
scriptToolStripMenuItem.DropDownItems[3].Enabled = false;
scriptToolStripMenuItem.DropDownItems[6].Enabled = false;
scriptToolStripMenuItem.DropDownItems[7].Enabled = false;
}
if (luaList.Count > 0)
scriptToolStripMenuItem.DropDownItems[8].Enabled = true;
else
scriptToolStripMenuItem.DropDownItems[8].Enabled = false;
if (luaRunning)
scriptToolStripMenuItem.DropDownItems[10].Enabled = true;
else
scriptToolStripMenuItem.DropDownItems[10].Enabled = false;
}
private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
{
ListView.SelectedIndexCollection indexes = LuaListView.SelectedIndices;
bool luaRunning = false;
for (int i = 0; i < luaList.Count; i++)
{
if (luaList[i].Enabled)
luaRunning = true;
}
if (indexes.Count > 0)
{
contextMenuStrip1.Items[0].Enabled = true;
contextMenuStrip1.Items[1].Enabled = true;
contextMenuStrip1.Items[2].Enabled = true;
bool allSeparators = true;
for (int i = 0; i < indexes.Count; i++)
{
if (!luaList[indexes[i]].IsSeparator)
allSeparators = false;
}
if (allSeparators)
contextMenuStrip1.Items[1].Enabled = false;
else
contextMenuStrip1.Items[1].Enabled = true;
}
else
{
contextMenuStrip1.Items[0].Enabled = false;
contextMenuStrip1.Items[1].Enabled = false;
contextMenuStrip1.Items[2].Enabled = false;
}
if (luaRunning)
{
contextMenuStrip1.Items[4].Visible = true;
contextMenuStrip1.Items[5].Visible = true;
}
else
{
contextMenuStrip1.Items[4].Visible = false;
contextMenuStrip1.Items[5].Visible = false;
}
}
}
}

View File

@ -52,6 +52,7 @@
| System.Windows.Forms.AnchorStyles.Right)));
this.FunctionBox.Location = new System.Drawing.Point(12, 12);
this.FunctionBox.Name = "FunctionBox";
this.FunctionBox.ReadOnly = true;
this.FunctionBox.Size = new System.Drawing.Size(237, 269);
this.FunctionBox.TabIndex = 1;
this.FunctionBox.Text = "";