diff --git a/BizHawk.MultiClient/LuaImplementation.cs b/BizHawk.MultiClient/LuaImplementation.cs index 1ae325ceb8..a78242066e 100644 --- a/BizHawk.MultiClient/LuaImplementation.cs +++ b/BizHawk.MultiClient/LuaImplementation.cs @@ -11,11 +11,12 @@ namespace BizHawk.MultiClient class LuaImplementation { Lua lua = new Lua(); - LuaWindow Caller; + LuaConsole Caller; + public static string[] MemoryFunctions = new string[] { "readbyte", "writebyte"}; - public LuaImplementation(LuaWindow passed) + public LuaImplementation(LuaConsole passed) { Caller = passed.get(); lua.RegisterFunction("print",this, this.GetType().GetMethod("print")); @@ -24,8 +25,8 @@ namespace BizHawk.MultiClient { lua.RegisterFunction("memory." + MemoryFunctions[i], this, this.GetType().GetMethod(MemoryFunctions[i])); } - } + public void DoLuaFile(string File) { lua.DoFile(File); diff --git a/BizHawk.MultiClient/tools/LuaConsole.Designer.cs b/BizHawk.MultiClient/tools/LuaConsole.Designer.cs index d58469a5c9..501dfb48a5 100644 --- a/BizHawk.MultiClient/tools/LuaConsole.Designer.cs +++ b/BizHawk.MultiClient/tools/LuaConsole.Designer.cs @@ -53,7 +53,7 @@ this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.saveWindowPositionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.restoreWindowSizeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.richTextBox1 = new System.Windows.Forms.RichTextBox(); + this.OutputBox = new System.Windows.Forms.RichTextBox(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.NumberOfScripts = new System.Windows.Forms.Label(); this.insertSeparatorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -250,18 +250,18 @@ this.restoreWindowSizeToolStripMenuItem.Text = "Restore Window Size"; this.restoreWindowSizeToolStripMenuItem.Click += new System.EventHandler(this.restoreWindowSizeToolStripMenuItem_Click); // - // richTextBox1 + // OutputBox // - this.richTextBox1.Location = new System.Drawing.Point(6, 19); - this.richTextBox1.Name = "richTextBox1"; - this.richTextBox1.ReadOnly = true; - this.richTextBox1.Size = new System.Drawing.Size(246, 253); - this.richTextBox1.TabIndex = 2; - this.richTextBox1.Text = ""; + this.OutputBox.Location = new System.Drawing.Point(6, 19); + this.OutputBox.Name = "OutputBox"; + this.OutputBox.ReadOnly = true; + this.OutputBox.Size = new System.Drawing.Size(246, 253); + this.OutputBox.TabIndex = 2; + this.OutputBox.Text = ""; // // groupBox1 // - this.groupBox1.Controls.Add(this.richTextBox1); + this.groupBox1.Controls.Add(this.OutputBox); this.groupBox1.Location = new System.Drawing.Point(311, 51); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(258, 278); @@ -363,7 +363,7 @@ private System.Windows.Forms.ToolStripMenuItem moveUpToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem moveDownToolStripMenuItem; public System.Windows.Forms.ColumnHeader Script; - private System.Windows.Forms.RichTextBox richTextBox1; + private System.Windows.Forms.RichTextBox OutputBox; private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.ToolStripMenuItem newToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem removeToolStripMenuItem; diff --git a/BizHawk.MultiClient/tools/LuaConsole.cs b/BizHawk.MultiClient/tools/LuaConsole.cs index 1728bc2774..517290946e 100644 --- a/BizHawk.MultiClient/tools/LuaConsole.cs +++ b/BizHawk.MultiClient/tools/LuaConsole.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; +using LuaInterface; namespace BizHawk.MultiClient { @@ -18,6 +19,7 @@ namespace BizHawk.MultiClient int defaultHeight; List luaList = new List(); + LuaImplementation LuaImp; string lastLuaFile = ""; private List GetLuaFileList() @@ -29,9 +31,20 @@ namespace BizHawk.MultiClient return l; } + public LuaConsole get() + { + return this; + } + + public void AddText(string s) + { + OutputBox.Text += s; + } + public LuaConsole() { InitializeComponent(); + LuaImp = new LuaImplementation(this); Closing += (o, e) => SaveConfigSettings(); LuaListView.QueryItemText += new QueryItemTextHandler(LuaListView_QueryItemText); LuaListView.QueryItemBkColor += new QueryItemBkColorHandler(LuaListView_QueryItemBkColor); @@ -114,13 +127,20 @@ namespace BizHawk.MultiClient return file; } + private void LoadLuaFile(string path) + { + LuaFiles l = new LuaFiles("", path, true); + luaList.Add(l); + + LuaImp.DoLuaFile(path); + } private void OpenLuaFile() { var file = GetFileFromUser(); if (file != null) { - //LoadLuaFile(file.FullName, false); + LoadLuaFile(file.FullName); //DisplayLuaList(); } } diff --git a/BizHawk.MultiClient/tools/LuaWindow.cs b/BizHawk.MultiClient/tools/LuaWindow.cs index 86a5f9c921..d7761855a4 100644 --- a/BizHawk.MultiClient/tools/LuaWindow.cs +++ b/BizHawk.MultiClient/tools/LuaWindow.cs @@ -17,12 +17,12 @@ namespace BizHawk.MultiClient.tools int defaultWidth; //For saving the default size of the dialog, so the user can restore if desired int defaultHeight; - LuaImplementation LuaImp; + //LuaImplementation LuaImp; public LuaWindow() { InitializeComponent(); - LuaImp = new LuaImplementation(this); + //LuaImp = new LuaImplementation(this); Closing += (o, e) => SaveConfigSettings(); } public LuaWindow get()