From 064bdbb9a7c0af7284e7ea38ff53e5b15944b11c Mon Sep 17 00:00:00 2001 From: "andres.delikat" Date: Sat, 28 Jan 2012 22:44:48 +0000 Subject: [PATCH] Lua - start gui.text() but currently outputs to console window instead of on screen --- BizHawk.MultiClient/LuaImplementation.cs | 36 ++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/BizHawk.MultiClient/LuaImplementation.cs b/BizHawk.MultiClient/LuaImplementation.cs index a63d3c2ed5..4c09d782bd 100644 --- a/BizHawk.MultiClient/LuaImplementation.cs +++ b/BizHawk.MultiClient/LuaImplementation.cs @@ -47,6 +47,13 @@ namespace BizHawk.MultiClient LuaLibraryList += "console." + ConsoleFunctions[i] + "\n"; } + lua.NewTable("gui"); + for (int i = 0; i < GuiFunctions.Length; i++) + { + lua.RegisterFunction("gui." + GuiFunctions[i], this, this.GetType().GetMethod("gui_" + GuiFunctions[i])); + LuaLibraryList += "gui." + GuiFunctions[i] + "\n"; + } + lua.NewTable("emu"); for (int i = 0; i < EmuFunctions.Length; i++) { @@ -134,6 +141,11 @@ namespace BizHawk.MultiClient "getluafunctionslist" }; + public static string[] GuiFunctions = new string[] + { + "text" + }; + public static string[] EmuFunctions = new string[] { "frameadvance", @@ -236,6 +248,30 @@ namespace BizHawk.MultiClient return LuaLibraryList; } + //---------------------------------------------------- + //Gui library + //---------------------------------------------------- + public void gui_text(object luaX, object luaY, object lua_input) + { + int x = 0; + int y = 0; + + try //adelikat: This crap might not be necessary, need to test for a more elegant solution + { + x = int.Parse(luaX.ToString()); + y = int.Parse(luaY.ToString()); + } + catch + { + return; + } + + if (y.GetType() != typeof(int)) + return; + + Global.MainForm.LuaConsole1.WriteToOutputWindow(lua_input.ToString()); + } + //---------------------------------------------------- //Emu library //----------------------------------------------------