Delegate more of ClientLuaLibrary to ApiHawk
This commit is contained in:
parent
a74d657a2a
commit
ff4662efe8
|
@ -1,16 +1,15 @@
|
|||
using System;
|
||||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
using BizHawk.Client.Common.cheats;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
using NLua;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Client.Common;
|
||||
using System.Threading;
|
||||
using System.Diagnostics;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Client.Common.cheats;
|
||||
|
||||
// ReSharper disable StringLiteralTypo
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
@ -37,33 +36,19 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
[LuaMethodExample("client.exit( );")]
|
||||
[LuaMethod("exit", "Closes the emulator")]
|
||||
public void CloseEmulator()
|
||||
{
|
||||
MainForm.CloseEmulator();
|
||||
}
|
||||
public void CloseEmulator() => APIs.EmuClient.CloseEmulator();
|
||||
|
||||
[LuaMethodExample("client.exitCode( 0 );")]
|
||||
[LuaMethod("exitCode", "Closes the emulator and returns the provided code")]
|
||||
public void CloseEmulatorWithCode(int exitCode)
|
||||
{
|
||||
MainForm.CloseEmulator(exitCode);
|
||||
}
|
||||
public void CloseEmulatorWithCode(int exitCode) => APIs.EmuClient.CloseEmulatorWithCode(exitCode);
|
||||
|
||||
[LuaMethodExample("local inclibor = client.borderheight( );")]
|
||||
[LuaMethod("borderheight", "Gets the current height in pixels of the letter/pillarbox area (top side only) around the emu display surface, excluding the gameExtraPadding you've set. This function (the whole lot of them) should be renamed or refactored since the padding areas have got more complex.")]
|
||||
public static int BorderHeight()
|
||||
{
|
||||
var point = new Point(0, 0);
|
||||
return GlobalWin.DisplayManager.TransformPoint(point).Y;
|
||||
}
|
||||
public int BorderHeight() => APIs.EmuClient.BorderHeight();
|
||||
|
||||
[LuaMethodExample("local inclibor = client.borderwidth( );")]
|
||||
[LuaMethod("borderwidth", "Gets the current width in pixels of the letter/pillarbox area (left side only) around the emu display surface, excluding the gameExtraPadding you've set. This function (the whole lot of them) should be renamed or refactored since the padding areas have got more complex.")]
|
||||
public static int BorderWidth()
|
||||
{
|
||||
var point = new Point(0, 0);
|
||||
return GlobalWin.DisplayManager.TransformPoint(point).X;
|
||||
}
|
||||
public int BorderWidth() => APIs.EmuClient.BorderWidth();
|
||||
|
||||
[LuaMethodExample("local inclibuf = client.bufferheight( );")]
|
||||
[LuaMethod("bufferheight", "Gets the visible height of the emu display surface (the core video output). This excludes the gameExtraPadding you've set.")]
|
||||
|
@ -81,29 +66,21 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
[LuaMethodExample("client.clearautohold( );")]
|
||||
[LuaMethod("clearautohold", "Clears all autohold keys")]
|
||||
public void ClearAutohold()
|
||||
{
|
||||
MainForm.ClearHolds();
|
||||
}
|
||||
public void ClearAutohold() => APIs.EmuClient.ClearAutohold();
|
||||
|
||||
[LuaMethodExample("client.closerom( );")]
|
||||
[LuaMethod("closerom", "Closes the loaded Rom")]
|
||||
public void CloseRom()
|
||||
{
|
||||
MainForm.CloseRom();
|
||||
}
|
||||
public void CloseRom() => APIs.EmuClient.CloseRom();
|
||||
|
||||
[LuaMethodExample("client.enablerewind( true );")]
|
||||
[LuaMethod("enablerewind", "Sets whether or not the rewind feature is enabled")]
|
||||
public void EnableRewind(bool enabled)
|
||||
{
|
||||
MainForm.EnableRewind(enabled);
|
||||
}
|
||||
public void EnableRewind(bool enabled) => APIs.EmuClient.EnableRewind(enabled);
|
||||
|
||||
[LuaMethodExample("client.frameskip( 8 );")]
|
||||
[LuaMethod("frameskip", "Sets the frame skip value of the client UI (use 0 to disable)")]
|
||||
public void FrameSkip(int numFrames)
|
||||
{
|
||||
//TODO delegate to APIs.EmuClient (impl uses `> 0` instead of `>= 0`)
|
||||
if (numFrames >= 0)
|
||||
{
|
||||
GlobalWin.Config.FrameSkip = numFrames;
|
||||
|
@ -115,21 +92,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use with <see cref="SeekFrame(int)"/> for CamHack.
|
||||
/// Refer to <see cref="MainForm.InvisibleEmulation"/> for the workflow details.
|
||||
/// </summary>
|
||||
[LuaMethodExample("client.invisibleemulation( true );")]
|
||||
[LuaMethod("invisibleemulation", "Disables and enables emulator updates")]
|
||||
public void InvisibleEmulation(bool invisible)
|
||||
{
|
||||
MainForm.InvisibleEmulation = invisible;
|
||||
}
|
||||
public void InvisibleEmulation(bool invisible) => APIs.EmuClient.InvisibleEmulation(invisible);
|
||||
|
||||
/// <summary>
|
||||
/// Use with <see cref="InvisibleEmulation(bool)"/> for CamHack.
|
||||
/// Refer to <see cref="MainForm.InvisibleEmulation"/> for the workflow details.
|
||||
/// </summary>
|
||||
[LuaMethodExample("client.seekframe( 100 );")]
|
||||
[LuaMethod("seekframe", "Makes the emulator seek to the frame specified")]
|
||||
public void SeekFrame(int frame)
|
||||
|
@ -153,62 +119,43 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
[LuaMethodExample("local incliget = client.gettargetscanlineintensity( );")]
|
||||
[LuaMethod("gettargetscanlineintensity", "Gets the current scanline intensity setting, used for the scanline display filter")]
|
||||
public static int GetTargetScanlineIntensity()
|
||||
{
|
||||
return GlobalWin.Config.TargetScanlineFilterIntensity;
|
||||
}
|
||||
public int GetTargetScanlineIntensity() => APIs.EmuClient.GetTargetScanlineIntensity();
|
||||
|
||||
[LuaMethodExample("local incliget = client.getwindowsize( );")]
|
||||
[LuaMethod("getwindowsize", "Gets the main window's size Possible values are 1, 2, 3, 4, 5, and 10")]
|
||||
public int GetWindowSize()
|
||||
{
|
||||
//TODO delegate to APIs.EmuClient (impl's copy of Emulator is weird)
|
||||
return GlobalWin.Config.TargetZoomFactors[Emulator.SystemId];
|
||||
}
|
||||
|
||||
[LuaMethodExample("client.SetGameExtraPadding( 5, 10, 15, 20 );")]
|
||||
[LuaMethod("SetGameExtraPadding", "Sets the extra padding added to the 'emu' surface so that you can draw HUD elements in predictable placements")]
|
||||
public void SetGameExtraPadding(int left, int top, int right, int bottom)
|
||||
{
|
||||
GlobalWin.DisplayManager.GameExtraPadding = new System.Windows.Forms.Padding(left, top, right, bottom);
|
||||
MainForm.FrameBufferResized();
|
||||
}
|
||||
public void SetGameExtraPadding(int left, int top, int right, int bottom) => APIs.EmuClient.SetGameExtraPadding(left, top, right, bottom);
|
||||
|
||||
[LuaMethodExample("client.SetSoundOn( true );")]
|
||||
[LuaMethod("SetSoundOn", "Sets the state of the Sound On toggle")]
|
||||
public static void SetSoundOn(bool enable) => ClientApi.SetSoundOn(enable);
|
||||
public void SetSoundOn(bool enable) => APIs.EmuClient.SetSoundOn(enable);
|
||||
|
||||
[LuaMethodExample("if ( client.GetSoundOn( ) ) then\r\n\tconsole.log( \"Gets the state of the Sound On toggle\" );\r\nend;")]
|
||||
[LuaMethod("GetSoundOn", "Gets the state of the Sound On toggle")]
|
||||
public static bool GetSoundOn() => ClientApi.GetSoundOn();
|
||||
public bool GetSoundOn() => APIs.EmuClient.GetSoundOn();
|
||||
|
||||
[LuaMethodExample("client.SetClientExtraPadding( 5, 10, 15, 20 );")]
|
||||
[LuaMethod("SetClientExtraPadding", "Sets the extra padding added to the 'native' surface so that you can draw HUD elements in predictable placements")]
|
||||
public void SetClientExtraPadding(int left, int top, int right, int bottom)
|
||||
{
|
||||
GlobalWin.DisplayManager.ClientExtraPadding = new System.Windows.Forms.Padding(left, top, right, bottom);
|
||||
MainForm.FrameBufferResized();
|
||||
}
|
||||
public void SetClientExtraPadding(int left, int top, int right, int bottom) => APIs.EmuClient.SetClientExtraPadding(left, top, right, bottom);
|
||||
|
||||
[LuaMethodExample("if ( client.ispaused( ) ) then\r\n\tconsole.log( \"Returns true if emulator is paused, otherwise, false\" );\r\nend;")]
|
||||
[LuaMethod("ispaused", "Returns true if emulator is paused, otherwise, false")]
|
||||
public bool IsPaused()
|
||||
{
|
||||
return MainForm.EmulatorPaused;
|
||||
}
|
||||
public bool IsPaused() => APIs.EmuClient.IsPaused();
|
||||
|
||||
[LuaMethodExample("if ( client.client.isturbo( ) ) then\r\n\tconsole.log( \"Returns true if emulator is in turbo mode, otherwise, false\" );\r\nend;")]
|
||||
[LuaMethod("isturbo", "Returns true if emulator is in turbo mode, otherwise, false")]
|
||||
public bool IsTurbo()
|
||||
{
|
||||
return MainForm.IsTurboing;
|
||||
}
|
||||
public bool IsTurbo() => APIs.EmuClient.IsTurbo();
|
||||
|
||||
[LuaMethodExample("if ( client.isseeking( ) ) then\r\n\tconsole.log( \"Returns true if emulator is seeking, otherwise, false\" );\r\nend;")]
|
||||
[LuaMethod("isseeking", "Returns true if emulator is seeking, otherwise, false")]
|
||||
public bool IsSeeking()
|
||||
{
|
||||
return MainForm.IsSeeking;
|
||||
}
|
||||
public bool IsSeeking() => APIs.EmuClient.IsSeeking();
|
||||
|
||||
[LuaMethodExample("client.opencheats( );")]
|
||||
[LuaMethod("opencheats", "opens the Cheats dialog")]
|
||||
|
@ -228,11 +175,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
[LuaMethodExample("client.openrom( \"C:\\\" );")]
|
||||
[LuaMethod("openrom", "opens the Open ROM dialog")]
|
||||
public void OpenRom(string path)
|
||||
{
|
||||
var ioa = OpenAdvancedSerializer.ParseWithLegacy(path);
|
||||
MainForm.LoadRom(path, new LoadRomArgs { OpenAdvanced = ioa });
|
||||
}
|
||||
public void OpenRom(string path) => APIs.EmuClient.OpenRom(path);
|
||||
|
||||
[LuaMethodExample("client.opentasstudio( );")]
|
||||
[LuaMethod("opentasstudio", "opens the TAStudio dialog")]
|
||||
|
@ -248,80 +191,50 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
[LuaMethodExample("client.pause( );")]
|
||||
[LuaMethod("pause", "Pauses the emulator")]
|
||||
public void Pause()
|
||||
{
|
||||
MainForm.PauseEmulator();
|
||||
}
|
||||
public void Pause() => APIs.EmuClient.Pause();
|
||||
|
||||
[LuaMethodExample("client.pause_av( );")]
|
||||
[LuaMethod("pause_av", "If currently capturing Audio/Video, this will suspend the record. Frames will not be captured into the AV until client.unpause_av() is called")]
|
||||
public void PauseAv()
|
||||
{
|
||||
MainForm.PauseAvi = true;
|
||||
}
|
||||
public void PauseAv() => APIs.EmuClient.PauseAv();
|
||||
|
||||
[LuaMethodExample("client.reboot_core( );")]
|
||||
[LuaMethod("reboot_core", "Reboots the currently loaded core")]
|
||||
public void RebootCore()
|
||||
{
|
||||
((LuaConsole)GlobalWin.Tools.Get<LuaConsole>()).LuaImp.IsRebootingCore = true;
|
||||
MainForm.RebootCore();
|
||||
APIs.EmuClient.RebootCore();
|
||||
((LuaConsole)GlobalWin.Tools.Get<LuaConsole>()).LuaImp.IsRebootingCore = false;
|
||||
}
|
||||
|
||||
[LuaMethodExample("local incliscr = client.screenheight( );")]
|
||||
[LuaMethod("screenheight", "Gets the current height in pixels of the emulator's drawing area")]
|
||||
public int ScreenHeight()
|
||||
{
|
||||
return MainForm.PresentationPanel.NativeSize.Height;
|
||||
}
|
||||
public int ScreenHeight() => APIs.EmuClient.ScreenHeight();
|
||||
|
||||
[LuaMethodExample("client.screenshot( \"C:\\\" );")]
|
||||
[LuaMethod("screenshot", "if a parameter is passed it will function as the Screenshot As menu item of EmuHawk, else it will function as the Screenshot menu item")]
|
||||
public void Screenshot(string path = null)
|
||||
{
|
||||
if (path == null)
|
||||
{
|
||||
MainForm.TakeScreenshot();
|
||||
}
|
||||
else
|
||||
{
|
||||
MainForm.TakeScreenshot(path);
|
||||
}
|
||||
}
|
||||
public void Screenshot(string path = null) => APIs.EmuClient.Screenshot(path);
|
||||
|
||||
[LuaMethodExample("client.screenshottoclipboard( );")]
|
||||
[LuaMethod("screenshottoclipboard", "Performs the same function as EmuHawk's Screenshot To Clipboard menu item")]
|
||||
public void ScreenshotToClipboard()
|
||||
{
|
||||
MainForm.TakeScreenshotToClipboard();
|
||||
}
|
||||
public void ScreenshotToClipboard() => APIs.EmuClient.ScreenshotToClipboard();
|
||||
|
||||
[LuaMethodExample("client.settargetscanlineintensity( -1000 );")]
|
||||
[LuaMethod("settargetscanlineintensity", "Sets the current scanline intensity setting, used for the scanline display filter")]
|
||||
public static void SetTargetScanlineIntensity(int val)
|
||||
{
|
||||
GlobalWin.Config.TargetScanlineFilterIntensity = val;
|
||||
}
|
||||
public void SetTargetScanlineIntensity(int val) => APIs.EmuClient.SetTargetScanlineIntensity(val);
|
||||
|
||||
[LuaMethodExample("client.setscreenshotosd( true );")]
|
||||
[LuaMethod("setscreenshotosd", "Sets the screenshot Capture OSD property of the client")]
|
||||
public static void SetScreenshotOSD(bool value)
|
||||
{
|
||||
GlobalWin.Config.ScreenshotCaptureOsd = value;
|
||||
}
|
||||
public void SetScreenshotOSD(bool value) => APIs.EmuClient.SetScreenshotOSD(value);
|
||||
|
||||
[LuaMethodExample("local incliscr = client.screenwidth( );")]
|
||||
[LuaMethod("screenwidth", "Gets the current width in pixels of the emulator's drawing area")]
|
||||
public int ScreenWidth()
|
||||
{
|
||||
return MainForm.PresentationPanel.NativeSize.Width;
|
||||
}
|
||||
public int ScreenWidth() => APIs.EmuClient.ScreenWidth();
|
||||
|
||||
[LuaMethodExample("client.setwindowsize( 100 );")]
|
||||
[LuaMethod("setwindowsize", "Sets the main window's size to the give value. Accepted values are 1, 2, 3, 4, 5, and 10")]
|
||||
public void SetWindowSize(int size)
|
||||
{
|
||||
//TODO delegate to APIs.EmuClient (impl's copy of Emulator is weird)
|
||||
if (size == 1 || size == 2 || size == 3 || size == 4 || size == 5 || size == 10)
|
||||
{
|
||||
GlobalWin.Config.TargetZoomFactors[Emulator.SystemId] = size;
|
||||
|
@ -336,17 +249,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
[LuaMethodExample("client.speedmode( 75 );")]
|
||||
[LuaMethod("speedmode", "Sets the speed of the emulator (in terms of percent)")]
|
||||
public void SpeedMode(int percent)
|
||||
{
|
||||
if (percent.StrictlyBoundedBy(0.RangeTo(6400)))
|
||||
{
|
||||
MainForm.ClickSpeedItem(percent);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log("Invalid speed value");
|
||||
}
|
||||
}
|
||||
public void SpeedMode(int percent) => APIs.EmuClient.SpeedMode(percent);
|
||||
|
||||
[LuaMethodExample("local curSpeed = client.getconfig().SpeedPercent")]
|
||||
[LuaMethod("getconfig", "gets the current config settings object")]
|
||||
|
@ -357,15 +260,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
[LuaMethodExample("client.togglepause( );")]
|
||||
[LuaMethod("togglepause", "Toggles the current pause state")]
|
||||
public void TogglePause()
|
||||
{
|
||||
MainForm.TogglePause();
|
||||
}
|
||||
public void TogglePause() => APIs.EmuClient.TogglePause();
|
||||
|
||||
[LuaMethodExample("local newY = client.transform_point( 32, 100 ).y;")]
|
||||
[LuaMethod("transformPoint", "Transforms a point (x, y) in emulator space to a point in client space")]
|
||||
public LuaTable TransformPoint(int x, int y) {
|
||||
var transformed = ClientApi.TransformPoint(new Point(x, y));
|
||||
var transformed = APIs.EmuClient.TransformPoint(new Point(x, y));
|
||||
var table = Lua.NewTable();
|
||||
table["x"] = transformed.X;
|
||||
table["y"] = transformed.Y;
|
||||
|
@ -374,31 +274,19 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
[LuaMethodExample("client.unpause( );")]
|
||||
[LuaMethod("unpause", "Unpauses the emulator")]
|
||||
public void Unpause()
|
||||
{
|
||||
MainForm.UnpauseEmulator();
|
||||
}
|
||||
public void Unpause() => APIs.EmuClient.Unpause();
|
||||
|
||||
[LuaMethodExample("client.unpause_av( );")]
|
||||
[LuaMethod("unpause_av", "If currently capturing Audio/Video this resumes capturing")]
|
||||
public void UnpauseAv()
|
||||
{
|
||||
MainForm.PauseAvi = false;
|
||||
}
|
||||
public void UnpauseAv() => APIs.EmuClient.UnpauseAv();
|
||||
|
||||
[LuaMethodExample("local inclixpo = client.xpos( );")]
|
||||
[LuaMethod("xpos", "Returns the x value of the screen position where the client currently sits")]
|
||||
public int Xpos()
|
||||
{
|
||||
return MainForm.DesktopLocation.X;
|
||||
}
|
||||
public int Xpos() => APIs.EmuClient.Xpos();
|
||||
|
||||
[LuaMethodExample("local incliypo = client.ypos( );")]
|
||||
[LuaMethod("ypos", "Returns the y value of the screen position where the client currently sits")]
|
||||
public int Ypos()
|
||||
{
|
||||
return MainForm.DesktopLocation.Y;
|
||||
}
|
||||
public int Ypos() => APIs.EmuClient.Ypos();
|
||||
|
||||
[LuaMethodExample("local incbhver = client.getversion( );")]
|
||||
[LuaMethod("getversion", "Returns the current stable BizHawk version")]
|
||||
|
@ -429,17 +317,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
[LuaMethodExample("client.displaymessages( true );")]
|
||||
[LuaMethod("displaymessages", "sets whether or not on screen messages will display")]
|
||||
public void DisplayMessages(bool value)
|
||||
{
|
||||
GlobalWin.Config.DisplayMessages = value;
|
||||
}
|
||||
public void DisplayMessages(bool value) => APIs.EmuClient.DisplayMessages(value);
|
||||
|
||||
[LuaMethodExample("client.saveram( );")]
|
||||
[LuaMethod("saveram", "flushes save ram to disk")]
|
||||
public void SaveRam()
|
||||
{
|
||||
MainForm.FlushSaveRAM();
|
||||
}
|
||||
public void SaveRam() => APIs.EmuClient.SaveRam();
|
||||
|
||||
[LuaMethodExample("client.sleep( 50 );")]
|
||||
[LuaMethod("sleep", "sleeps for n milliseconds")]
|
||||
|
|
Loading…
Reference in New Issue