Lua - open/close rom, open tool dialogs, fix memory_readbyte to read from a selected memory domain instead of hardcoded main memory (with main memory as the default), small fix ups to lua console

This commit is contained in:
andres.delikat 2012-01-22 22:42:40 +00:00
parent 78cc4d5cae
commit defbe971c4
5 changed files with 89 additions and 31 deletions

View File

@ -14,6 +14,7 @@ namespace BizHawk.MultiClient
Lua lua = new Lua();
LuaConsole Caller;
public String LuaLibraryList = "";
private int CurrentMemoryDomain = 0; //Main memory by default
public LuaImplementation(LuaConsole passed)
{
@ -139,7 +140,15 @@ namespace BizHawk.MultiClient
};
public static string[] MultiClientFunctions = new string[] {
"openramwatch"
"openrom",
"closerom",
"opentoolbox",
"openramwatch",
"openramsearch",
"openrampoke",
"openhexeditor",
"opentasstudio",
"opencheats"
};
/****************************************************/
@ -220,13 +229,13 @@ namespace BizHawk.MultiClient
byte x;
if (lua_input.GetType() == typeof(string))
{
x = Global.Emulator.MainMemory.PeekByte(int.Parse((string)lua_input));
x = Global.Emulator.MemoryDomains[CurrentMemoryDomain].PeekByte(int.Parse((string)lua_input));
return x.ToString();
}
else
{
double y = (double)lua_input;
x = Global.Emulator.MainMemory.PeekByte(Convert.ToInt32(y));
x = Global.Emulator.MemoryDomains[CurrentMemoryDomain].PeekByte(Convert.ToInt32(y));
return x.ToString();
}
@ -278,9 +287,10 @@ namespace BizHawk.MultiClient
//Joypad library
//----------------------------------------------------
public void joypad_get(object lua_input)
//Currently sends all controllers, needs to control which ones it sends
public string joypad_get(object lua_input)
{
return Global.GetOutputControllersAsMnemonic();
}
public void joypad_set(object lua_input)
@ -291,10 +301,49 @@ namespace BizHawk.MultiClient
//----------------------------------------------------
//Client library
//----------------------------------------------------
public void client_openrom(object lua_input)
{
Global.MainForm.LoadRom(lua_input.ToString());
}
public void client_closerom()
{
Global.MainForm.CloseROM();
}
public void client_opentoolbox()
{
Global.MainForm.LoadToolBox();
}
public void client_openramwatch()
{
Global.MainForm.LoadRamWatch();
}
public void client_openramsearch()
{
Global.MainForm.LoadRamSearch();
}
public void client_openrampoke()
{
Global.MainForm.LoadRamPoke();
}
public void client_openhexeditor()
{
Global.MainForm.LoadHexEditor();
}
public void client_opentasstudio()
{
Global.MainForm.LoadTAStudio();
}
public void client_opencheats()
{
Global.MainForm.LoadCheatsWindow();
}
}
}

View File

@ -31,8 +31,7 @@ namespace BizHawk.MultiClient
private void RAMPokeToolStripMenuItem_Click(object sender, EventArgs e)
{
RamPoke r = new RamPoke();
r.Show();
LoadRamPoke();
}
private void saveWindowPositionToolStripMenuItem_Click(object sender, EventArgs e)

View File

@ -2177,7 +2177,7 @@ namespace BizHawk.MultiClient
LoadRom(file.FullName);
}
private void CloseROM()
public void CloseROM()
{
CloseGame();
Global.Emulator = new NullEmulator();
@ -2482,5 +2482,11 @@ namespace BizHawk.MultiClient
gbDebugger.Show();
}
}
public void LoadRamPoke()
{
RamPoke r = new RamPoke();
r.Show();
}
}
}

View File

@ -74,6 +74,8 @@
this.autoloadConsoleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator();
this.restoreWindowSizeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.luaFunctionsListToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.OutputBox = new System.Windows.Forms.RichTextBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.NumberOfScripts = new System.Windows.Forms.Label();
@ -86,8 +88,6 @@
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripButtonMoveUp = new System.Windows.Forms.ToolStripButton();
this.toolStripButtonMoveDown = new System.Windows.Forms.ToolStripButton();
this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.luaFunctionsListToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.contextMenuStrip1.SuspendLayout();
this.menuStrip1.SuspendLayout();
this.groupBox1.SuspendLayout();
@ -225,9 +225,10 @@
//
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.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
| System.Windows.Forms.Keys.O)));
this.openSessionToolStripMenuItem.Size = new System.Drawing.Size(243, 22);
this.openSessionToolStripMenuItem.Text = "&Open Session";
this.openSessionToolStripMenuItem.Text = "&Open Session...";
//
// saveToolStripMenuItem
//
@ -343,8 +344,9 @@
//
this.openToolStripMenuItem.Image = global::BizHawk.MultiClient.Properties.Resources.OpenFile;
this.openToolStripMenuItem.Name = "openToolStripMenuItem";
this.openToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O)));
this.openToolStripMenuItem.Size = new System.Drawing.Size(201, 22);
this.openToolStripMenuItem.Text = "&Open Script";
this.openToolStripMenuItem.Text = "&Open Script...";
this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click_1);
//
// toggleToolStripMenuItem
@ -463,6 +465,21 @@
this.restoreWindowSizeToolStripMenuItem.Text = "Restore Default Settings";
this.restoreWindowSizeToolStripMenuItem.Click += new System.EventHandler(this.restoreWindowSizeToolStripMenuItem_Click);
//
// helpToolStripMenuItem
//
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";
//
// luaFunctionsListToolStripMenuItem
//
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);
//
// OutputBox
//
this.OutputBox.Location = new System.Drawing.Point(6, 17);
@ -517,7 +534,7 @@
this.openToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta;
this.openToolStripButton.Name = "openToolStripButton";
this.openToolStripButton.Size = new System.Drawing.Size(23, 22);
this.openToolStripButton.Text = "&Open Script";
this.openToolStripButton.Text = "Open Script";
//
// copyToolStripButton
//
@ -584,21 +601,6 @@
this.toolStripButtonMoveDown.Text = "Move Down";
this.toolStripButtonMoveDown.Click += new System.EventHandler(this.toolStripButtonMoveDown_Click);
//
// helpToolStripMenuItem
//
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";
//
// luaFunctionsListToolStripMenuItem
//
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
//
this.AllowDrop = true;

View File

@ -99,6 +99,7 @@ namespace BizHawk.MultiClient
public void Restart()
{
StopAllScripts();
LuaImp = new LuaImplementation(this);
}
private void SaveConfigSettings()
@ -111,7 +112,7 @@ namespace BizHawk.MultiClient
private void LoadConfigSettings()
{
defaultWidth = Size.Width; //Save these first so that the user can restore to its original size
defaultWidth = Size.Width; //Save these first so that the user can restore to its original size
defaultHeight = Size.Height;
if (Global.Config.LuaConsoleSaveWindowPosition && Global.Config.LuaConsoleWndx >= 0 && Global.Config.LuaConsoleWndy >= 0)
@ -121,7 +122,6 @@ namespace BizHawk.MultiClient
{
Size = new System.Drawing.Size(Global.Config.LuaConsoleWidth, Global.Config.LuaConsoleHeight);
}
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
@ -568,5 +568,7 @@ namespace BizHawk.MultiClient
{
MessageBox.Show(LuaImp.LuaLibraryList);
}
}
}