diff --git a/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj b/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj
index fabfc7b9db..74ccb1628a 100644
--- a/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj
+++ b/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj
@@ -499,6 +499,9 @@
+
+ Component
+
Component
@@ -508,6 +511,9 @@
LuaConsole.cs
+
+ Component
+
Form
@@ -622,6 +628,7 @@
LuaBox.cs
+
UserControl
diff --git a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Forms.cs b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Forms.cs
index ff58fa1241..788b87cfa3 100644
--- a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Forms.cs
+++ b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Forms.cs
@@ -20,11 +20,14 @@ namespace BizHawk.Client.EmuHawk
{
"addclick",
"button",
+ "checkbox",
"clearclicks",
"destroy",
"destroyall",
+ "dropdown",
"getproperty",
"gettext",
+ "ischecked",
"label",
"newform",
"openfile",
@@ -127,6 +130,23 @@ namespace BizHawk.Client.EmuHawk
return (int)button.Handle;
}
+ public int forms_checkbox(object form_handle, string caption, object X = null, object Y = null)
+ {
+ LuaWinform form = GetForm(form_handle);
+ if (form == null)
+ {
+ return 0;
+ }
+
+ LuaCheckbox checkbox = new LuaCheckbox();
+ form.Controls.Add(checkbox);
+ SetText(checkbox, caption);
+ SetLocation(checkbox, X, Y);
+
+
+ return (int)checkbox.Handle;
+ }
+
public void forms_clearclicks(object handle)
{
IntPtr ptr = new IntPtr(LuaInt(handle));
@@ -170,6 +190,24 @@ namespace BizHawk.Client.EmuHawk
}
}
+ public int forms_dropdown(object form_handle, LuaTable items, object X = null, object Y = null, object width = null, object height = null)
+ {
+ LuaWinform form = GetForm(form_handle);
+ if (form == null)
+ {
+ return 0;
+ }
+
+ List dropdownItems = items.Values.Cast().ToList();
+ dropdownItems.Sort();
+
+ LuaDropDown dropdown = new LuaDropDown(dropdownItems);
+ form.Controls.Add(dropdown);
+ SetLocation(dropdown, X, Y);
+ SetSize(dropdown, width, height);
+ return (int)dropdown.Handle;
+ }
+
public string forms_getproperty(object handle, object property)
{
try
@@ -218,7 +256,14 @@ namespace BizHawk.Client.EmuHawk
{
if (control.Handle == ptr)
{
- return control.Text;
+ if (control is LuaDropDown)
+ {
+ return (control as LuaDropDown).SelectedItem.ToString();
+ }
+ else
+ {
+ return control.Text;
+ }
}
}
}
@@ -232,6 +277,44 @@ namespace BizHawk.Client.EmuHawk
return String.Empty;
}
+ public bool forms_ischecked(object handle)
+ {
+ try
+ {
+ IntPtr ptr = new IntPtr(LuaInt(handle));
+ foreach (LuaWinform form in _luaForms)
+ {
+ if (form.Handle == ptr)
+ {
+ return false;
+ }
+ else
+ {
+ foreach (Control control in form.Controls)
+ {
+ if (control.Handle == ptr)
+ {
+ if (control is LuaCheckbox)
+ {
+ return (control as LuaCheckbox).Checked;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ ConsoleLuaLibrary.console_output(ex.Message);
+ }
+
+ return false;
+ }
+
public int forms_label(object form_handle, object caption, object X = null, object Y = null, object width = null, object height = null)
{
LuaWinform form = GetForm(form_handle);
diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaCheckbox.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaCheckbox.cs
new file mode 100644
index 0000000000..0323864d5e
--- /dev/null
+++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaCheckbox.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Windows.Forms;
+
+namespace BizHawk.Client.EmuHawk
+{
+ public class LuaCheckbox : CheckBox
+ {
+ private void DoLuaClick(object sender, EventArgs e)
+ {
+ var parent = Parent as LuaWinform;
+ if (parent != null)
+ {
+ parent.DoLuaEvent(Handle);
+ }
+ }
+
+ protected override void OnClick(EventArgs e)
+ {
+ DoLuaClick(this, e);
+ base.OnClick(e);
+ }
+ }
+}
diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaDropDown.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaDropDown.cs
new file mode 100644
index 0000000000..d0842aa701
--- /dev/null
+++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaDropDown.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows.Forms;
+
+namespace BizHawk.Client.EmuHawk
+{
+ public class LuaDropDown : ComboBox
+ {
+ public LuaDropDown(List items)
+ : base()
+ {
+ Items.AddRange(items.Cast