Lua console - hook up lua file loading! Lua library - Added a console library with an implemented console.output(), registered all lua libraries, implemented movie.stop, movie.rerecords, movie.mode
This commit is contained in:
parent
ab9de22644
commit
955cee21b6
|
@ -12,6 +12,57 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
Lua lua = new Lua();
|
||||
LuaConsole Caller;
|
||||
|
||||
public LuaImplementation(LuaConsole passed)
|
||||
{
|
||||
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]));
|
||||
}
|
||||
|
||||
lua.NewTable("emu");
|
||||
for (int i = 0; i < EmuFunctions.Length; i++)
|
||||
{
|
||||
lua.RegisterFunction("emu." + EmuFunctions[i], this, this.GetType().GetMethod("emu_" + EmuFunctions[i]));
|
||||
}
|
||||
|
||||
lua.NewTable("memory");
|
||||
for (int i = 0; i < MemoryFunctions.Length; i++)
|
||||
{
|
||||
lua.RegisterFunction("memory." + MemoryFunctions[i], this, this.GetType().GetMethod("memory_" + MemoryFunctions[i]));
|
||||
}
|
||||
|
||||
lua.NewTable("savestate");
|
||||
for (int i = 0; i < SaveStateFunctions.Length; i++)
|
||||
{
|
||||
lua.RegisterFunction("statestate." + SaveStateFunctions[i], this, this.GetType().GetMethod("savestate_" + SaveStateFunctions[i]));
|
||||
}
|
||||
|
||||
lua.NewTable("movie");
|
||||
for (int i = 0; i < MovieFunctions.Length; i++)
|
||||
{
|
||||
lua.RegisterFunction("movie." + MovieFunctions[i], this, this.GetType().GetMethod("movie_" + MovieFunctions[i]));
|
||||
}
|
||||
|
||||
lua.NewTable("joypad");
|
||||
for (int i = 0; i < JoypadFunctions.Length; i++)
|
||||
{
|
||||
lua.RegisterFunction("joypad." + MemoryFunctions[i], this, this.GetType().GetMethod("joypad_" + JoypadFunctions[i]));
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************/
|
||||
/*************library definitions********************/
|
||||
/****************************************************/
|
||||
public static string[] ConsoleFunctions = new string[] {
|
||||
"output"
|
||||
};
|
||||
|
||||
public static string[] EmuFunctions = new string[] {
|
||||
"frameadvance",
|
||||
"pause",
|
||||
|
@ -53,25 +104,14 @@ namespace BizHawk.MultiClient
|
|||
"set",
|
||||
//"get",
|
||||
};
|
||||
public LuaImplementation(LuaConsole passed)
|
||||
{
|
||||
Caller = passed.get();
|
||||
lua.RegisterFunction("print", this, this.GetType().GetMethod("print"));
|
||||
lua.NewTable("memory");
|
||||
for (int i = 0; i < MemoryFunctions.Length; i++)
|
||||
{
|
||||
lua.RegisterFunction("memory." + MemoryFunctions[i], this, this.GetType().GetMethod("memory_" + MemoryFunctions[i]));
|
||||
}
|
||||
lua.NewTable("joypad");
|
||||
for (int i = 0; i < JoypadFunctions.Length; i++)
|
||||
{
|
||||
lua.RegisterFunction("joypad." + MemoryFunctions[i], this, this.GetType().GetMethod("joypad_" + JoypadFunctions[i]));
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************/
|
||||
/*************function definitions********************/
|
||||
/****************************************************/
|
||||
|
||||
public void DoLuaFile(string File)
|
||||
{
|
||||
|
||||
lua.DoFile(File);
|
||||
}
|
||||
public void print(string s)
|
||||
{
|
||||
|
@ -106,12 +146,24 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
public string movie_mode()
|
||||
{
|
||||
return Global.MovieSession.Movie.Mode.ToString();
|
||||
}
|
||||
|
||||
public string movie_rerecordcount()
|
||||
{
|
||||
return "No";
|
||||
return Global.MovieSession.Movie.Rerecords.ToString();
|
||||
}
|
||||
public void movie_stop()
|
||||
{
|
||||
Global.MovieSession.Movie.StopMovie();
|
||||
}
|
||||
|
||||
public void console_output(object lua_input)
|
||||
{
|
||||
Global.MainForm.LuaConsole1.WriteToOutputWindow(lua_input.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,6 +61,7 @@ namespace BizHawk.MultiClient
|
|||
public ToolBox ToolBox1 = new ToolBox();
|
||||
public TI83KeyPad TI83KeyPad1 = new TI83KeyPad();
|
||||
public TAStudio TAStudio1 = new TAStudio();
|
||||
public LuaConsole LuaConsole1 = new LuaConsole();
|
||||
|
||||
public MainForm(string[] args)
|
||||
{
|
||||
|
@ -1136,6 +1137,7 @@ namespace BizHawk.MultiClient
|
|||
TAStudio1.Restart();
|
||||
Cheats1.Restart();
|
||||
ToolBox1.Restart();
|
||||
LuaConsole1.Restart();
|
||||
|
||||
if (Global.Config.LoadCheatFileByGame)
|
||||
{
|
||||
|
@ -2155,7 +2157,7 @@ namespace BizHawk.MultiClient
|
|||
"Disc Images", "*.cue",
|
||||
"NES", "*.nes;%ARCH%",
|
||||
"Master System", "*.sms;*.gg;*.sg;%ARCH%",
|
||||
"Genesis", "*.gen;*.smd;*.bin;*.cue;%ARCH%",
|
||||
"Genesis", "*.gen;*.smd;*.bin;*.cue;%ARCH%",
|
||||
"PC Engine", "*.pce;*.sgx;*.cue;%ARCH%",
|
||||
"Gameboy", "*.gb;%ARCH%",
|
||||
"TI-83", "*.rom;%ARCH%",
|
||||
|
@ -2190,6 +2192,7 @@ namespace BizHawk.MultiClient
|
|||
TI83KeyPad1.Restart();
|
||||
Cheats1.Restart();
|
||||
ToolBox1.Restart();
|
||||
LuaConsole1.Restart();
|
||||
Text = "BizHawk" + (INTERIM ? " (interim) " : "");
|
||||
HandlePlatformMenus();
|
||||
StateSlots.Clear();
|
||||
|
@ -2462,8 +2465,13 @@ namespace BizHawk.MultiClient
|
|||
|
||||
public void OpenLuaConsole()
|
||||
{
|
||||
LuaConsole l = new LuaConsole();
|
||||
l.Show();
|
||||
if (!LuaConsole1.IsHandleCreated || LuaConsole1.IsDisposed)
|
||||
{
|
||||
LuaConsole1 = new LuaConsole();
|
||||
LuaConsole1.Show();
|
||||
}
|
||||
else
|
||||
LuaConsole1.Focus();
|
||||
}
|
||||
|
||||
public void OpenGameboyDebugger()
|
||||
|
|
|
@ -205,6 +205,18 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
LuaListView.Refresh();
|
||||
UpdateNumberOfScripts();
|
||||
RunLuaScript();
|
||||
}
|
||||
|
||||
private void RunLuaScript()
|
||||
{
|
||||
for (int x = 0; x < luaList.Count; x++)
|
||||
{
|
||||
if (luaList[x].Enabled)
|
||||
{
|
||||
LuaImp.DoLuaFile(luaList[x].Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateNumberOfScripts()
|
||||
|
@ -534,5 +546,11 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
OpenLuaFile();
|
||||
}
|
||||
|
||||
public void WriteToOutputWindow(string message)
|
||||
{
|
||||
OutputBox.Text += message;
|
||||
OutputBox.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue