port some lua libraries to client.common

This commit is contained in:
adelikat 2013-11-01 14:51:51 +00:00
parent c7fbcbca40
commit a8079f5170
7 changed files with 47 additions and 43 deletions

View File

@ -102,6 +102,10 @@
<Compile Include="helpers\InputValidate.cs" /> <Compile Include="helpers\InputValidate.cs" />
<Compile Include="KeyTurbo.cs" /> <Compile Include="KeyTurbo.cs" />
<Compile Include="lua\EmuLuaLibrary.Bit.cs" /> <Compile Include="lua\EmuLuaLibrary.Bit.cs" />
<Compile Include="lua\EmuLuaLibrary.Emu.cs" />
<Compile Include="lua\EmuLuaLibrary.Events.cs" />
<Compile Include="lua\EmuLuaLibrary.MainMemory.cs" />
<Compile Include="lua\EmuLuaLibrary.Memory.cs" />
<Compile Include="lua\LuaDocumentation.cs" /> <Compile Include="lua\LuaDocumentation.cs" />
<Compile Include="lua\LuaFile.cs" /> <Compile Include="lua\LuaFile.cs" />
<Compile Include="lua\LuaFunctionList.cs" /> <Compile Include="lua\LuaFunctionList.cs" />

View File

@ -1,9 +1,9 @@
using System; using System;
using LuaInterface; using LuaInterface;
using BizHawk.Client.Common;
using BizHawk.Emulation.Consoles.Nintendo; using BizHawk.Emulation.Consoles.Nintendo;
namespace BizHawk.MultiClient namespace BizHawk.Client.Common
{ {
public partial class EmulatorLuaLibrary : LuaLibraryBase public partial class EmulatorLuaLibrary : LuaLibraryBase
{ {
@ -75,7 +75,6 @@ namespace BizHawk.MultiClient
{ {
Global.Config.VSyncThrottle = true; Global.Config.VSyncThrottle = true;
} }
GlobalWinF.MainForm.VsyncMessage();
} }
} }
@ -117,7 +116,6 @@ namespace BizHawk.MultiClient
{ {
Global.Config.ClockThrottle = true; Global.Config.ClockThrottle = true;
} }
GlobalWinF.MainForm.LimitFrameRateMessage();
} }
} }
@ -134,7 +132,6 @@ namespace BizHawk.MultiClient
{ {
Global.Config.AutoMinimizeSkipping = true; Global.Config.AutoMinimizeSkipping = true;
} }
GlobalWinF.MainForm.MinimizeFrameskipMessage();
} }
} }

View File

@ -2,12 +2,17 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using LuaInterface; using LuaInterface;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient namespace BizHawk.Client.Common
{ {
public class EventLuaLibrary : LuaLibraryBase public class EventLuaLibrary : LuaLibraryBase
{ {
public EventLuaLibrary(Action<string> logOutputCallback)
: base()
{
LogOutputCallback = logOutputCallback;
}
public override string Name { get { return "event"; } } public override string Name { get { return "event"; } }
public override string[] Functions public override string[] Functions
{ {
@ -28,6 +33,8 @@ namespace BizHawk.MultiClient
} }
} }
public Action<string> LogOutputCallback = null;
#region Events Library Helpers #region Events Library Helpers
private readonly LuaFunctionList lua_functions = new LuaFunctionList(); private readonly LuaFunctionList lua_functions = new LuaFunctionList();
@ -48,9 +55,10 @@ namespace BizHawk.MultiClient
} }
catch (SystemException e) catch (SystemException e)
{ {
GlobalWinF.MainForm.LuaConsole1.WriteToOutputWindow( LogOutputCallback(
"error running function attached by lua function savestate.registersave" + "error running function attached by lua function event.onsavestate" +
"\nError message: " + e.Message); "\nError message: " +
e.Message);
} }
} }
} }
@ -69,9 +77,10 @@ namespace BizHawk.MultiClient
} }
catch (SystemException e) catch (SystemException e)
{ {
GlobalWinF.MainForm.LuaConsole1.WriteToOutputWindow( LogOutputCallback(
"error running function attached by lua function savestate.registerload" + "error running function attached by lua function event.onloadstate" +
"\nError message: " + e.Message); "\nError message: " +
e.Message);
} }
} }
} }
@ -90,9 +99,10 @@ namespace BizHawk.MultiClient
} }
catch (SystemException e) catch (SystemException e)
{ {
GlobalWinF.MainForm.LuaConsole1.WriteToOutputWindow( LogOutputCallback(
"error running function attached by lua function emu.registerbefore" + "error running function attached by lua function event.onframestart" +
"\nError message: " + e.Message); "\nError message: " +
e.Message);
} }
} }
} }
@ -111,9 +121,10 @@ namespace BizHawk.MultiClient
} }
catch (SystemException e) catch (SystemException e)
{ {
GlobalWinF.MainForm.LuaConsole1.WriteToOutputWindow( LogOutputCallback(
"error running function attached by lua function emu.registerafter" + "error running function attached by lua function event.onframeend" +
"\nError message: " + e.Message); "\nError message: " +
e.Message);
} }
} }
} }
@ -146,9 +157,10 @@ namespace BizHawk.MultiClient
} }
catch (SystemException e) catch (SystemException e)
{ {
GlobalWinF.MainForm.LuaConsole1.WriteToOutputWindow( LogOutputCallback(
"error running function attached by lua function emu.on_snoop" + "error running function attached by lua function event.oninputpoll" +
"\nError message: " + e.Message); "\nError message: "
+ e.Message);
} }
}; };
} }
@ -189,12 +201,12 @@ namespace BizHawk.MultiClient
} }
catch (SystemException e) catch (SystemException e)
{ {
GlobalWinF.MainForm.LuaConsole1.WriteToOutputWindow( LogOutputCallback(
"error running function attached by lua function event.onmemoryread" + "error running function attached by lua function event.onmemoryread" +
"\nError message: " + e.Message); "\nError message: " +
e.Message);
} }
}); });
} }
else else
{ {
@ -226,9 +238,10 @@ namespace BizHawk.MultiClient
} }
catch (SystemException e) catch (SystemException e)
{ {
GlobalWinF.MainForm.LuaConsole1.WriteToOutputWindow( LogOutputCallback(
"error running function attached by lua function event.onmemoryread" + "error running function attached by lua function event.onmemoryread" +
"\nError message: " + e.Message); "\nError message: " +
e.Message);
} }
}); });
} }
@ -247,7 +260,6 @@ namespace BizHawk.MultiClient
public bool event_unregisterbyid(object guid) public bool event_unregisterbyid(object guid)
{ {
//Iterating every possible event type is not very scalable
foreach (NamedLuaFunction nlf in lua_functions) foreach (NamedLuaFunction nlf in lua_functions)
{ {
if (nlf.GUID.ToString() == guid.ToString()) if (nlf.GUID.ToString() == guid.ToString())
@ -262,7 +274,6 @@ namespace BizHawk.MultiClient
public bool event_unregisterbyname(object name) public bool event_unregisterbyname(object name)
{ {
//Horribly redundant to the function above!
foreach (NamedLuaFunction nlf in lua_functions) foreach (NamedLuaFunction nlf in lua_functions)
{ {
if (nlf.Name == name.ToString()) if (nlf.Name == name.ToString())

View File

@ -1,8 +1,8 @@
using System; using System;
using LuaInterface;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient using LuaInterface;
namespace BizHawk.Client.Common
{ {
//TODO: this needs a major refactor, as well as MemoryLuaLibrary, and this shoudl inherit memorylua library and extend it //TODO: this needs a major refactor, as well as MemoryLuaLibrary, and this shoudl inherit memorylua library and extend it
public class MainMemoryLuaLibrary : LuaLibraryBase public class MainMemoryLuaLibrary : LuaLibraryBase

View File

@ -1,8 +1,7 @@
using System; using System;
using System.Linq; using System.Linq;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient namespace BizHawk.Client.Common
{ {
public class MemoryLuaLibrary : LuaLibraryBase public class MemoryLuaLibrary : LuaLibraryBase
{ {

View File

@ -446,14 +446,10 @@
<Compile Include="tools\Lua\Libraries\EmuLuaLibrary.Client.cs" /> <Compile Include="tools\Lua\Libraries\EmuLuaLibrary.Client.cs" />
<Compile Include="tools\Lua\Libraries\EmuLuaLibrary.Console.cs" /> <Compile Include="tools\Lua\Libraries\EmuLuaLibrary.Console.cs" />
<Compile Include="tools\Lua\Libraries\EmuLuaLibrary.cs" /> <Compile Include="tools\Lua\Libraries\EmuLuaLibrary.cs" />
<Compile Include="tools\Lua\Libraries\EmuLuaLibrary.Emu.cs" />
<Compile Include="tools\Lua\Libraries\EmuLuaLibrary.Events.cs" />
<Compile Include="tools\Lua\Libraries\EmuLuaLibrary.Forms.cs" /> <Compile Include="tools\Lua\Libraries\EmuLuaLibrary.Forms.cs" />
<Compile Include="tools\Lua\Libraries\EmuLuaLibrary.Gui.cs" /> <Compile Include="tools\Lua\Libraries\EmuLuaLibrary.Gui.cs" />
<Compile Include="tools\Lua\Libraries\EmuLuaLibrary.Input.cs" /> <Compile Include="tools\Lua\Libraries\EmuLuaLibrary.Input.cs" />
<Compile Include="tools\Lua\Libraries\EmuLuaLibrary.Joypad.cs" /> <Compile Include="tools\Lua\Libraries\EmuLuaLibrary.Joypad.cs" />
<Compile Include="tools\Lua\Libraries\EmuLuaLibrary.MainMemory.cs" />
<Compile Include="tools\Lua\Libraries\EmuLuaLibrary.Memory.cs" />
<Compile Include="tools\Lua\Libraries\EmuLuaLibrary.Movie.cs" /> <Compile Include="tools\Lua\Libraries\EmuLuaLibrary.Movie.cs" />
<Compile Include="tools\Lua\Libraries\EmuLuaLibrary.NES.cs" /> <Compile Include="tools\Lua\Libraries\EmuLuaLibrary.NES.cs" />
<Compile Include="tools\Lua\Libraries\EmuLuaLibrary.Savestate.cs" /> <Compile Include="tools\Lua\Libraries\EmuLuaLibrary.Savestate.cs" />

View File

@ -12,7 +12,7 @@ namespace BizHawk.MultiClient
private readonly LuaConsole _caller; private readonly LuaConsole _caller;
private Lua currThread; private Lua currThread;
private FormsLuaLibrary _formsLibrary = new FormsLuaLibrary(); private FormsLuaLibrary _formsLibrary = new FormsLuaLibrary();
private EventLuaLibrary _eventLibrary = new EventLuaLibrary(); private EventLuaLibrary _eventLibrary = new EventLuaLibrary(ConsoleLuaLibrary.console_log);
private GuiLuaLibrary _guiLibrary = new GuiLuaLibrary(); private GuiLuaLibrary _guiLibrary = new GuiLuaLibrary();
public LuaDocumentation Docs = new LuaDocumentation(); public LuaDocumentation Docs = new LuaDocumentation();
@ -22,10 +22,7 @@ namespace BizHawk.MultiClient
public GuiLuaLibrary GuiLibrary public GuiLuaLibrary GuiLibrary
{ {
get get { return _guiLibrary; }
{
return _guiLibrary;
}
} }
public void WindowClosed(IntPtr handle) public void WindowClosed(IntPtr handle)