diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs index afa77b219d..4a6362105a 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs @@ -1248,6 +1248,12 @@ namespace BizHawk.Client.EmuHawk NewScript(); } + private Point GetPromptPoint() + { + Point p = new Point(LuaListView.Location.X + 30, LuaListView.Location.Y + 30); + return PointToScreen(p); + } + private void showRegisteredFunctionsToolStripMenuItem_Click(object sender, EventArgs e) { if (LuaImp.RegisteredFunctions.Any()) @@ -1264,7 +1270,9 @@ namespace BizHawk.Client.EmuHawk if (!alreadyOpen) { - new LuaRegisteredFunctionsList().Show(); + var form = new LuaRegisteredFunctionsList(); + form.StartLocation = GetPromptPoint(); + form.Show(); } } } diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaRegisteredFunctionsList.Designer.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaRegisteredFunctionsList.Designer.cs index 936832d7de..d52452ae15 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/LuaRegisteredFunctionsList.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaRegisteredFunctionsList.Designer.cs @@ -63,6 +63,7 @@ this.FunctionView.View = System.Windows.Forms.View.Details; this.FunctionView.SelectedIndexChanged += new System.EventHandler(this.FunctionView_SelectedIndexChanged); this.FunctionView.DoubleClick += new System.EventHandler(this.FunctionView_DoubleClick); + this.FunctionView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FunctionView_KeyDown); // // FunctionsEvent // @@ -150,7 +151,6 @@ // // LuaRegisteredFunctionsList // - this.AcceptButton = this.OK; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.OK; diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaRegisteredFunctionsList.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaRegisteredFunctionsList.cs index e92d6abf42..d1f5445296 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/LuaRegisteredFunctionsList.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaRegisteredFunctionsList.cs @@ -13,6 +13,7 @@ namespace BizHawk.Client.EmuHawk { public partial class LuaRegisteredFunctionsList : Form { + public Point StartLocation = new Point(0, 0); public LuaRegisteredFunctionsList() { InitializeComponent(); @@ -20,6 +21,10 @@ namespace BizHawk.Client.EmuHawk private void LuaRegisteredFunctionsList_Load(object sender, EventArgs e) { + if (StartLocation.X > 0 && StartLocation.Y > 0) + { + Location = StartLocation; + } PopulateListView(); } @@ -56,20 +61,26 @@ namespace BizHawk.Client.EmuHawk private void CallFunction() { - ListView.SelectedIndexCollection indexes = FunctionView.SelectedIndices; - if (indexes.Count > 0) + ListView.SelectedIndexCollection indices = FunctionView.SelectedIndices; + if (indices.Count > 0) { - GlobalWin.Tools.LuaConsole.LuaImp.RegisteredFunctions[indexes[0]].Call(); + foreach (int index in indices) + { + GlobalWin.Tools.LuaConsole.LuaImp.RegisteredFunctions[index].Call(); + } } } private void RemoveFunctionButton() { - ListView.SelectedIndexCollection indexes = FunctionView.SelectedIndices; - if (indexes.Count > 0) + ListView.SelectedIndexCollection indices = FunctionView.SelectedIndices; + if (indices.Count > 0) { - NamedLuaFunction nlf = GlobalWin.Tools.LuaConsole.LuaImp.RegisteredFunctions[indexes[0]]; - GlobalWin.Tools.LuaConsole.LuaImp.RegisteredFunctions.RemoveFunction(nlf); + foreach (int index in indices) + { + NamedLuaFunction nlf = GlobalWin.Tools.LuaConsole.LuaImp.RegisteredFunctions[index]; + GlobalWin.Tools.LuaConsole.LuaImp.RegisteredFunctions.RemoveFunction(nlf); + } PopulateListView(); } } @@ -97,5 +108,21 @@ namespace BizHawk.Client.EmuHawk RemoveButton.Enabled = indexes.Count > 0; RemoveAllBtn.Enabled = GlobalWin.Tools.LuaConsole.LuaImp.RegisteredFunctions.Any(); } + + private void FunctionView_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Delete && !e.Control && !e.Alt && !e.Shift) //Delete + { + RemoveFunctionButton(); + } + else if (e.KeyCode == Keys.Space && !e.Control && !e.Alt && !e.Shift) //Space + { + CallFunction(); + } + else if (e.KeyCode == Keys.Enter && !e.Control && !e.Alt && !e.Shift) //Enter + { + CallFunction(); + } + } } }