2012-07-10 19:04:35 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using LuaInterface;
|
2015-07-02 00:17:15 +00:00
|
|
|
|
using BizHawk.Client.EmuHawk.tools.Lua;
|
2012-07-10 19:04:35 +00:00
|
|
|
|
|
2013-11-03 03:54:37 +00:00
|
|
|
|
namespace BizHawk.Client.EmuHawk
|
2012-07-10 19:04:35 +00:00
|
|
|
|
{
|
|
|
|
|
public partial class LuaWinform : Form
|
|
|
|
|
{
|
2013-11-17 15:55:13 +00:00
|
|
|
|
public List<LuaEvent> ControlEvents = new List<LuaEvent>();
|
2012-07-10 19:04:35 +00:00
|
|
|
|
|
2015-07-01 02:35:59 +00:00
|
|
|
|
private string CurrentDirectory = Environment.CurrentDirectory;
|
|
|
|
|
|
2012-07-10 19:04:35 +00:00
|
|
|
|
public LuaWinform()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2014-05-22 01:03:18 +00:00
|
|
|
|
StartPosition = FormStartPosition.CenterParent;
|
2012-07-10 19:04:35 +00:00
|
|
|
|
Closing += (o, e) => CloseThis();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LuaWinform_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void CloseThis()
|
|
|
|
|
{
|
2013-11-03 16:07:58 +00:00
|
|
|
|
GlobalWin.Tools.LuaConsole.LuaImp.WindowClosed(Handle);
|
2012-07-10 19:04:35 +00:00
|
|
|
|
}
|
2012-07-10 20:23:19 +00:00
|
|
|
|
|
|
|
|
|
public void DoLuaEvent(IntPtr handle)
|
|
|
|
|
{
|
2015-07-02 00:17:15 +00:00
|
|
|
|
LuaSandbox.Sandbox(() =>
|
2012-07-10 20:23:19 +00:00
|
|
|
|
{
|
2015-07-02 00:17:15 +00:00
|
|
|
|
Environment.CurrentDirectory = CurrentDirectory;
|
|
|
|
|
foreach (LuaEvent l_event in ControlEvents)
|
2012-07-10 20:23:19 +00:00
|
|
|
|
{
|
2015-07-02 00:17:15 +00:00
|
|
|
|
if (l_event.Control == handle)
|
|
|
|
|
{
|
|
|
|
|
l_event.Event.Call();
|
|
|
|
|
}
|
2012-07-10 20:23:19 +00:00
|
|
|
|
}
|
2015-07-02 00:17:15 +00:00
|
|
|
|
});
|
2012-07-10 20:23:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-17 15:55:13 +00:00
|
|
|
|
public class LuaEvent
|
2012-07-10 20:23:19 +00:00
|
|
|
|
{
|
|
|
|
|
public LuaFunction Event;
|
|
|
|
|
public IntPtr Control;
|
|
|
|
|
|
2013-11-17 15:55:13 +00:00
|
|
|
|
public LuaEvent() { }
|
|
|
|
|
public LuaEvent(IntPtr handle, LuaFunction lfunction)
|
2012-07-10 20:23:19 +00:00
|
|
|
|
{
|
|
|
|
|
Event = lfunction;
|
|
|
|
|
Control = handle;
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-07-10 19:04:35 +00:00
|
|
|
|
}
|
|
|
|
|
}
|