Lua Console - lua functions list menu item. Lua - console.clear, console.getluafunctionslist, emu.getsystemid

This commit is contained in:
andres.delikat 2012-01-22 03:14:31 +00:00
parent 5f66de57ec
commit 48c651cfc7
3 changed files with 142 additions and 63 deletions

View File

@ -12,47 +12,55 @@ namespace BizHawk.MultiClient
{
Lua lua = new Lua();
LuaConsole Caller;
public String LuaLibraryList = "";
public LuaImplementation(LuaConsole passed)
{
LuaLibraryList = "";
Caller = passed.get();
lua.RegisterFunction("print", this, this.GetType().GetMethod("print"));
//Register libraries
lua.NewTable("console");
for (int i = 0; i < ConsoleFunctions.Length; i++)
{
lua.RegisterFunction("console." + ConsoleFunctions[i], this, this.GetType().GetMethod("console_" + ConsoleFunctions[i]));
LuaLibraryList += "console." + ConsoleFunctions[i] + "\n";
}
lua.NewTable("emu");
for (int i = 0; i < EmuFunctions.Length; i++)
{
lua.RegisterFunction("emu." + EmuFunctions[i], this, this.GetType().GetMethod("emu_" + EmuFunctions[i]));
LuaLibraryList += "emu." + EmuFunctions[i] + "\n";
}
lua.NewTable("memory");
for (int i = 0; i < MemoryFunctions.Length; i++)
{
lua.RegisterFunction("memory." + MemoryFunctions[i], this, this.GetType().GetMethod("memory_" + MemoryFunctions[i]));
LuaLibraryList += "memory." + MemoryFunctions[i] + "\n";
}
lua.NewTable("savestate");
for (int i = 0; i < SaveStateFunctions.Length; i++)
{
//lua.RegisterFunction("statestate." + SaveStateFunctions[i], this, this.GetType().GetMethod("savestate_" + SaveStateFunctions[i]));
//LuaLibraryList += "savestate." + SaveStateFunctions[i] + "\n";
}
lua.NewTable("movie");
for (int i = 0; i < MovieFunctions.Length; i++)
{
lua.RegisterFunction("movie." + MovieFunctions[i], this, this.GetType().GetMethod("movie_" + MovieFunctions[i]));
LuaLibraryList += "movie." + MovieFunctions[i] + "\n";
}
lua.NewTable("joypad");
for (int i = 0; i < JoypadFunctions.Length; i++)
{
lua.RegisterFunction("joypad." + MemoryFunctions[i], this, this.GetType().GetMethod("joypad_" + JoypadFunctions[i]));
lua.RegisterFunction("joypad." + JoypadFunctions[i], this, this.GetType().GetMethod("joypad_" + JoypadFunctions[i]));
LuaLibraryList += "joypad." + JoypadFunctions[i] + "\n";
}
}
@ -70,18 +78,21 @@ namespace BizHawk.MultiClient
/*************library definitions********************/
/****************************************************/
public static string[] ConsoleFunctions = new string[] {
"output"
"output",
"clear",
"getluafunctionslist"
};
public static string[] EmuFunctions = new string[] {
//"frameadvance",
"frameadvance",
"pause",
"unpause",
"togglepause",
//"speedmode",
//"framecount",
//"lagcount",
//"islagged",
"framecount",
"lagcount",
"islagged",
"getsystemid"
//"registerbefore",
//"registerafter",
//"register"
@ -129,9 +140,25 @@ namespace BizHawk.MultiClient
Global.MainForm.LuaConsole1.WriteToOutputWindow(lua_input.ToString());
}
public void console_clear(object lua_input)
{
Global.MainForm.LuaConsole1.ClearOutputWindow();
}
public string console_getluafunctionslist()
{
return LuaLibraryList;
}
//----------------------------------------------------
//Emu library
//----------------------------------------------------
public void emu_frameadvance()
{
//Global.MainForm.PressFrameAdvance = true;
//Global.Emulator.FrameAdvance(true);
}
public void emu_pause()
{
@ -148,6 +175,26 @@ namespace BizHawk.MultiClient
Global.MainForm.TogglePause();
}
public int emu_framecount()
{
return Global.Emulator.Frame;
}
public int emu_lagcount()
{
return Global.Emulator.LagCount;
}
public bool emu_islagged()
{
return Global.Emulator.IsLagFrame;
}
public string emu_getsystemid()
{
return Global.Emulator.SystemId;
}
//----------------------------------------------------
//Memory library
//----------------------------------------------------

View File

@ -43,8 +43,14 @@
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.newToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.openSessionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator9 = new System.Windows.Forms.ToolStripSeparator();
this.recentSessionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.noneToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator8 = new System.Windows.Forms.ToolStripSeparator();
this.clearToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.recentToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.noneToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
@ -52,6 +58,7 @@
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.scriptToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toggleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.removeScriptToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
@ -79,13 +86,8 @@
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripButtonMoveUp = new System.Windows.Forms.ToolStripButton();
this.toolStripButtonMoveDown = new System.Windows.Forms.ToolStripButton();
this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.recentSessionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.noneToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator8 = new System.Windows.Forms.ToolStripSeparator();
this.clearToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator9 = new System.Windows.Forms.ToolStripSeparator();
this.openSessionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.luaFunctionsListToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.contextMenuStrip1.SuspendLayout();
this.menuStrip1.SuspendLayout();
this.groupBox1.SuspendLayout();
@ -186,7 +188,8 @@
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.fileToolStripMenuItem,
this.scriptToolStripMenuItem,
this.optionsToolStripMenuItem});
this.optionsToolStripMenuItem,
this.helpToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(584, 24);
@ -218,6 +221,14 @@
this.newToolStripMenuItem.Text = "&New Session";
this.newToolStripMenuItem.Click += new System.EventHandler(this.newToolStripMenuItem_Click);
//
// openSessionToolStripMenuItem
//
this.openSessionToolStripMenuItem.Image = global::BizHawk.MultiClient.Properties.Resources.OpenFile;
this.openSessionToolStripMenuItem.Name = "openSessionToolStripMenuItem";
this.openSessionToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O)));
this.openSessionToolStripMenuItem.Size = new System.Drawing.Size(243, 22);
this.openSessionToolStripMenuItem.Text = "&Open Session";
//
// saveToolStripMenuItem
//
this.saveToolStripMenuItem.Image = global::BizHawk.MultiClient.Properties.Resources.SaveAs;
@ -236,6 +247,38 @@
this.saveAsToolStripMenuItem.Text = "Save Session &As...";
this.saveAsToolStripMenuItem.Click += new System.EventHandler(this.saveAsToolStripMenuItem_Click);
//
// toolStripSeparator9
//
this.toolStripSeparator9.Name = "toolStripSeparator9";
this.toolStripSeparator9.Size = new System.Drawing.Size(240, 6);
//
// recentSessionsToolStripMenuItem
//
this.recentSessionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.noneToolStripMenuItem1,
this.toolStripSeparator8,
this.clearToolStripMenuItem1});
this.recentSessionsToolStripMenuItem.Name = "recentSessionsToolStripMenuItem";
this.recentSessionsToolStripMenuItem.Size = new System.Drawing.Size(243, 22);
this.recentSessionsToolStripMenuItem.Text = "Recent Sessions";
//
// noneToolStripMenuItem1
//
this.noneToolStripMenuItem1.Name = "noneToolStripMenuItem1";
this.noneToolStripMenuItem1.Size = new System.Drawing.Size(110, 22);
this.noneToolStripMenuItem1.Text = "None";
//
// toolStripSeparator8
//
this.toolStripSeparator8.Name = "toolStripSeparator8";
this.toolStripSeparator8.Size = new System.Drawing.Size(107, 6);
//
// clearToolStripMenuItem1
//
this.clearToolStripMenuItem1.Name = "clearToolStripMenuItem1";
this.clearToolStripMenuItem1.Size = new System.Drawing.Size(110, 22);
this.clearToolStripMenuItem1.Text = "Clear";
//
// recentToolStripMenuItem
//
this.recentToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
@ -251,18 +294,18 @@
// noneToolStripMenuItem
//
this.noneToolStripMenuItem.Name = "noneToolStripMenuItem";
this.noneToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.noneToolStripMenuItem.Size = new System.Drawing.Size(110, 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(107, 6);
//
// clearToolStripMenuItem
//
this.clearToolStripMenuItem.Name = "clearToolStripMenuItem";
this.clearToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.clearToolStripMenuItem.Size = new System.Drawing.Size(110, 22);
this.clearToolStripMenuItem.Text = "Clear";
//
// toolStripSeparator1
@ -296,6 +339,14 @@
this.scriptToolStripMenuItem.Size = new System.Drawing.Size(46, 20);
this.scriptToolStripMenuItem.Text = "&Script";
//
// openToolStripMenuItem
//
this.openToolStripMenuItem.Image = global::BizHawk.MultiClient.Properties.Resources.OpenFile;
this.openToolStripMenuItem.Name = "openToolStripMenuItem";
this.openToolStripMenuItem.Size = new System.Drawing.Size(201, 22);
this.openToolStripMenuItem.Text = "&Open Script";
this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click_1);
//
// toggleToolStripMenuItem
//
this.toggleToolStripMenuItem.Image = global::BizHawk.MultiClient.Properties.Resources.Refresh1;
@ -533,53 +584,20 @@
this.toolStripButtonMoveDown.Text = "Move Down";
this.toolStripButtonMoveDown.Click += new System.EventHandler(this.toolStripButtonMoveDown_Click);
//
// openToolStripMenuItem
// helpToolStripMenuItem
//
this.openToolStripMenuItem.Image = global::BizHawk.MultiClient.Properties.Resources.OpenFile;
this.openToolStripMenuItem.Name = "openToolStripMenuItem";
this.openToolStripMenuItem.Size = new System.Drawing.Size(201, 22);
this.openToolStripMenuItem.Text = "&Open Script";
this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click_1);
this.helpToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.luaFunctionsListToolStripMenuItem});
this.helpToolStripMenuItem.Name = "helpToolStripMenuItem";
this.helpToolStripMenuItem.Size = new System.Drawing.Size(40, 20);
this.helpToolStripMenuItem.Text = "&Help";
//
// recentSessionsToolStripMenuItem
// luaFunctionsListToolStripMenuItem
//
this.recentSessionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.noneToolStripMenuItem1,
this.toolStripSeparator8,
this.clearToolStripMenuItem1});
this.recentSessionsToolStripMenuItem.Name = "recentSessionsToolStripMenuItem";
this.recentSessionsToolStripMenuItem.Size = new System.Drawing.Size(243, 22);
this.recentSessionsToolStripMenuItem.Text = "Recent Sessions";
//
// noneToolStripMenuItem1
//
this.noneToolStripMenuItem1.Name = "noneToolStripMenuItem1";
this.noneToolStripMenuItem1.Size = new System.Drawing.Size(152, 22);
this.noneToolStripMenuItem1.Text = "None";
//
// toolStripSeparator8
//
this.toolStripSeparator8.Name = "toolStripSeparator8";
this.toolStripSeparator8.Size = new System.Drawing.Size(149, 6);
//
// clearToolStripMenuItem1
//
this.clearToolStripMenuItem1.Name = "clearToolStripMenuItem1";
this.clearToolStripMenuItem1.Size = new System.Drawing.Size(152, 22);
this.clearToolStripMenuItem1.Text = "Clear";
//
// toolStripSeparator9
//
this.toolStripSeparator9.Name = "toolStripSeparator9";
this.toolStripSeparator9.Size = new System.Drawing.Size(240, 6);
//
// openSessionToolStripMenuItem
//
this.openSessionToolStripMenuItem.Image = global::BizHawk.MultiClient.Properties.Resources.OpenFile;
this.openSessionToolStripMenuItem.Name = "openSessionToolStripMenuItem";
this.openSessionToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O)));
this.openSessionToolStripMenuItem.Size = new System.Drawing.Size(243, 22);
this.openSessionToolStripMenuItem.Text = "&Open Session";
this.luaFunctionsListToolStripMenuItem.Name = "luaFunctionsListToolStripMenuItem";
this.luaFunctionsListToolStripMenuItem.Size = new System.Drawing.Size(170, 22);
this.luaFunctionsListToolStripMenuItem.Text = "&Lua Functions List";
this.luaFunctionsListToolStripMenuItem.Click += new System.EventHandler(this.luaFunctionsListToolStripMenuItem_Click);
//
// LuaConsole
//
@ -669,5 +687,7 @@
private System.Windows.Forms.ToolStripMenuItem noneToolStripMenuItem1;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator8;
private System.Windows.Forms.ToolStripMenuItem clearToolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem luaFunctionsListToolStripMenuItem;
}
}

View File

@ -25,7 +25,8 @@ namespace BizHawk.MultiClient
//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
//Free lua object when toggling a lua script off?
//Fix up lua functions list display
int defaultWidth; //For saving the default size of the dialog, so the user can restore if desired
int defaultHeight;
@ -552,9 +553,20 @@ namespace BizHawk.MultiClient
OutputBox.Refresh();
}
public void ClearOutputWindow()
{
OutputBox.Text = "";
OutputBox.Refresh();
}
private void openToolStripMenuItem_Click_1(object sender, EventArgs e)
{
OpenLuaFile();
}
private void luaFunctionsListToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show(LuaImp.LuaLibraryList);
}
}
}