Use consistent whitespace/wrapping in Lua libs

This commit is contained in:
YoshiRulz 2022-02-03 22:57:14 +10:00
parent e621b878b8
commit 5012ba0f09
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
21 changed files with 555 additions and 217 deletions

View File

@ -33,19 +33,23 @@ namespace BizHawk.Client.Common
[LuaMethodExample("client.exit( );")]
[LuaMethod("exit", "Closes the emulator")]
public void CloseEmulator() => APIs.EmuClient.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) => APIs.EmuClient.CloseEmulator(exitCode);
public void CloseEmulatorWithCode(int exitCode)
=> APIs.EmuClient.CloseEmulator(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 int BorderHeight() => APIs.EmuClient.BorderHeight();
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 int BorderWidth() => APIs.EmuClient.BorderWidth();
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.")]
@ -63,26 +67,32 @@ namespace BizHawk.Client.Common
[LuaMethodExample("client.clearautohold( );")]
[LuaMethod("clearautohold", "Clears all autohold keys")]
public void ClearAutohold() => APIs.EmuClient.ClearAutohold();
public void ClearAutohold()
=> APIs.EmuClient.ClearAutohold();
[LuaMethodExample("client.closerom( );")]
[LuaMethod("closerom", "Closes the loaded Rom")]
public void CloseRom() => APIs.EmuClient.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) => APIs.EmuClient.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) => APIs.EmuClient.FrameSkip(numFrames);
public void FrameSkip(int numFrames)
=> APIs.EmuClient.FrameSkip(numFrames);
[LuaMethod("get_lua_engine", "returns the name of the Lua engine currently in use")]
public string GetLuaEngine() => _luaLibsImpl.EngineName;
public string GetLuaEngine()
=> _luaLibsImpl.EngineName;
[LuaMethodExample("client.invisibleemulation( true );")]
[LuaMethod("invisibleemulation", "Disables and enables emulator updates")]
public void InvisibleEmulation(bool invisible) => APIs.EmuClient.InvisibleEmulation(invisible);
public void InvisibleEmulation(bool invisible)
=> APIs.EmuClient.InvisibleEmulation(invisible);
[LuaMethodExample("client.seekframe( 100 );")]
[LuaMethod("seekframe", "Makes the emulator seek to the frame specified")]
@ -114,59 +124,73 @@ namespace BizHawk.Client.Common
[LuaMethodExample("local sounds_terrible = client.get_approx_framerate() < 55;")]
[LuaMethod("get_approx_framerate", "Gets the (host) framerate, approximated from frame durations.")]
public int GetApproxFramerate() => APIs.EmuClient.GetApproxFramerate();
public int GetApproxFramerate()
=> APIs.EmuClient.GetApproxFramerate();
[LuaMethodExample("local incliget = client.gettargetscanlineintensity( );")]
[LuaMethod("gettargetscanlineintensity", "Gets the current scanline intensity setting, used for the scanline display filter")]
public int GetTargetScanlineIntensity() => APIs.EmuClient.GetTargetScanlineIntensity();
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() => APIs.EmuClient.GetWindowSize();
public int GetWindowSize()
=> APIs.EmuClient.GetWindowSize();
[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) => APIs.EmuClient.SetGameExtraPadding(left, top, right, bottom);
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 void SetSoundOn(bool enable) => APIs.EmuClient.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 bool GetSoundOn() => APIs.EmuClient.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) => APIs.EmuClient.SetClientExtraPadding(left, top, right, bottom);
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() => APIs.EmuClient.IsPaused();
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() => APIs.EmuClient.IsTurbo();
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() => APIs.EmuClient.IsSeeking();
public bool IsSeeking()
=> APIs.EmuClient.IsSeeking();
[LuaMethodExample("client.opencheats( );")]
[LuaMethod("opencheats", "opens the Cheats dialog")]
public void OpenCheats() => APIs.Tool.OpenCheats();
public void OpenCheats()
=> APIs.Tool.OpenCheats();
[LuaMethodExample("client.openhexeditor( );")]
[LuaMethod("openhexeditor", "opens the Hex Editor dialog")]
public void OpenHexEditor() => APIs.Tool.OpenHexEditor();
public void OpenHexEditor()
=> APIs.Tool.OpenHexEditor();
[LuaMethodExample("client.openramwatch( );")]
[LuaMethod("openramwatch", "opens the RAM Watch dialog")]
public void OpenRamWatch() => APIs.Tool.OpenRamWatch();
public void OpenRamWatch()
=> APIs.Tool.OpenRamWatch();
[LuaMethodExample("client.openramsearch( );")]
[LuaMethod("openramsearch", "opens the RAM Search dialog")]
public void OpenRamSearch() => APIs.Tool.OpenRamSearch();
public void OpenRamSearch()
=> APIs.Tool.OpenRamSearch();
[LuaMethodExample("client.openrom( \"C:\\\" );")]
[LuaMethod("openrom", "opens the Open ROM dialog")]
@ -179,23 +203,28 @@ namespace BizHawk.Client.Common
[LuaMethodExample("client.opentasstudio( );")]
[LuaMethod("opentasstudio", "opens the TAStudio dialog")]
public void OpenTasStudio() => APIs.Tool.OpenTasStudio();
public void OpenTasStudio()
=> APIs.Tool.OpenTasStudio();
[LuaMethodExample("client.opentoolbox( );")]
[LuaMethod("opentoolbox", "opens the Toolbox Dialog")]
public void OpenToolBox() => APIs.Tool.OpenToolBox();
public void OpenToolBox()
=> APIs.Tool.OpenToolBox();
[LuaMethodExample("client.opentracelogger( );")]
[LuaMethod("opentracelogger", "opens the tracelogger if it is available for the given core")]
public void OpenTraceLogger() => APIs.Tool.OpenTraceLogger();
public void OpenTraceLogger()
=> APIs.Tool.OpenTraceLogger();
[LuaMethodExample("client.pause( );")]
[LuaMethod("pause", "Pauses the emulator")]
public void Pause() => APIs.EmuClient.Pause();
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() => APIs.EmuClient.PauseAv();
public void PauseAv()
=> APIs.EmuClient.PauseAv();
[LuaMethodExample("client.reboot_core( );")]
[LuaMethod("reboot_core", "Reboots the currently loaded core")]
@ -208,43 +237,53 @@ namespace BizHawk.Client.Common
[LuaMethodExample("local incliscr = client.screenheight( );")]
[LuaMethod("screenheight", "Gets the current height in pixels of the emulator's drawing area")]
public int ScreenHeight() => APIs.EmuClient.ScreenHeight();
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) => APIs.EmuClient.Screenshot(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() => APIs.EmuClient.ScreenshotToClipboard();
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 void SetTargetScanlineIntensity(int val) => APIs.EmuClient.SetTargetScanlineIntensity(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 void SetScreenshotOSD(bool value) => APIs.EmuClient.SetScreenshotOSD(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() => APIs.EmuClient.ScreenWidth();
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) => APIs.EmuClient.SetWindowSize(size);
public void SetWindowSize(int size)
=> APIs.EmuClient.SetWindowSize(size);
[LuaMethodExample("client.speedmode( 75 );")]
[LuaMethod("speedmode", "Sets the speed of the emulator (in terms of percent)")]
public void SpeedMode(int percent) => APIs.EmuClient.SpeedMode(percent);
public void SpeedMode(int percent)
=> APIs.EmuClient.SpeedMode(percent);
[LuaMethodExample("local curSpeed = client.getconfig().SpeedPercent")]
[LuaMethod("getconfig", "gets the current config settings object")]
public object GetConfig() => ((EmulationApi) APIs.Emulation).ForbiddenConfigReference;
public object GetConfig()
=> ((EmulationApi) APIs.Emulation).ForbiddenConfigReference;
[LuaMethodExample("client.togglepause( );")]
[LuaMethod("togglepause", "Toggles the current pause state")]
public void TogglePause() => APIs.EmuClient.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")]
@ -258,19 +297,23 @@ namespace BizHawk.Client.Common
[LuaMethodExample("client.unpause( );")]
[LuaMethod("unpause", "Unpauses the emulator")]
public void Unpause() => APIs.EmuClient.Unpause();
public void Unpause()
=> APIs.EmuClient.Unpause();
[LuaMethodExample("client.unpause_av( );")]
[LuaMethod("unpause_av", "If currently capturing Audio/Video this resumes capturing")]
public void UnpauseAv() => APIs.EmuClient.UnpauseAv();
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() => APIs.EmuClient.Xpos();
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() => APIs.EmuClient.Ypos();
public int Ypos()
=> APIs.EmuClient.Ypos();
[LuaMethodExample("local incbhver = client.getversion( );")]
[LuaMethod("getversion", "Returns the current stable BizHawk version")]
@ -302,11 +345,13 @@ namespace BizHawk.Client.Common
[LuaMethodExample("client.displaymessages( true );")]
[LuaMethod("displaymessages", "sets whether or not on screen messages will display")]
public void DisplayMessages(bool value) => APIs.EmuClient.DisplayMessages(value);
public void DisplayMessages(bool value)
=> APIs.EmuClient.DisplayMessages(value);
[LuaMethodExample("client.saveram( );")]
[LuaMethod("saveram", "flushes save ram to disk")]
public void SaveRam() => APIs.EmuClient.SaveRam();
public void SaveRam()
=> APIs.EmuClient.SaveRam();
[LuaMethodExample("client.sleep( 50 );")]
[LuaMethod("sleep", "sleeps for n milliseconds")]

View File

@ -31,7 +31,8 @@ namespace BizHawk.Client.Common
}
[LuaMethod("socketServerIsConnected", "socketServerIsConnected")]
public bool SocketServerIsConnected() => APIs.Comm.Sockets.Connected;
public bool SocketServerIsConnected()
=> APIs.Comm.Sockets.Connected;
[LuaMethod("socketServerScreenShot", "sends a screenshot to the Socket server")]
public string SocketServerScreenShot()
@ -153,26 +154,31 @@ namespace BizHawk.Client.Common
{
return APIs.Comm.MMF.WriteToFile(mmf_filename, outputString);
}
[LuaMethod("mmfWriteBytes", "Write bytes to a memory mapped file")]
public int MmfWriteBytes(string mmf_filename, LuaTable byteArray)
{
return APIs.Comm.MMF.WriteToFile(mmf_filename, _th.EnumerateValues<double>(byteArray).Select(d => (byte)d).ToArray());
}
[LuaMethod("mmfCopyFromMemory", "Copy a section of the memory to a memory mapped file")]
public int MmfCopyFromMemory(string mmf_filename, long addr, int length, string domain)
{
return APIs.Comm.MMF.WriteToFile(mmf_filename, APIs.Memory.ReadByteRange(addr, length, domain).ToArray());
}
[LuaMethod("mmfCopyToMemory", "Copy a memory mapped file to a section of the memory")]
public void MmfCopyToMemory(string mmf_filename, long addr, int length, string domain)
{
APIs.Memory.WriteByteRange(addr, new List<byte>(APIs.Comm.MMF.ReadBytesFromFile(mmf_filename, length)), domain);
}
[LuaMethod("mmfRead", "Reads a string from a memory mapped file")]
public string MmfRead(string mmf_filename, int expectedSize)
{
return APIs.Comm.MMF.ReadFromFile(mmf_filename, expectedSize);
}
[LuaMethod("mmfReadBytes", "Reads bytes from a memory mapped file")]
public LuaTable MmfReadBytes(string mmf_filename, int expectedSize)
=> _th.ListToTable(APIs.Comm.MMF.ReadBytesFromFile(mmf_filename, expectedSize), indexFrom: 0);
@ -281,15 +287,17 @@ namespace BizHawk.Client.Common
[LuaMethod("ws_receive", "Receive a message from a certain websocket id and a maximum number of bytes to read")]
[LuaMethodExample("local ws = comm.ws_receive(ws_id, str_len);")]
public string WebSocketReceive(string guid, int bufferCap) => _websockets.TryGetValue(Guid.Parse(guid), out var wrapper)
? wrapper.Receive(bufferCap)
: null;
public string WebSocketReceive(string guid, int bufferCap)
=> _websockets.TryGetValue(Guid.Parse(guid), out var wrapper)
? wrapper.Receive(bufferCap)
: null;
[LuaMethod("ws_get_status", "Get a websocket's status")]
[LuaMethodExample("local ws_status = comm.ws_get_status(ws_id);")]
public int? WebSocketGetStatus(string guid) => _websockets.TryGetValue(Guid.Parse(guid), out var wrapper)
? (int) wrapper.State
: (int?) null;
public int? WebSocketGetStatus(string guid)
=> _websockets.TryGetValue(Guid.Parse(guid), out var wrapper)
? (int) wrapper.State
: (int?) null;
[LuaMethod("ws_close", "Close a websocket connection with a close status")]
[LuaMethodExample("local ws_status = comm.ws_close(ws_id, close_status);")]

View File

@ -20,7 +20,8 @@ namespace BizHawk.Client.Common
[LuaMethodExample("emu.displayvsync( true );")]
[LuaMethod("displayvsync", "Sets the display vsync property of the emulator")]
public void DisplayVsync(bool enabled) => APIs.Emulation.DisplayVsync(enabled);
public void DisplayVsync(bool enabled)
=> APIs.Emulation.DisplayVsync(enabled);
[LuaMethodExample("emu.frameadvance( );")]
[LuaMethod("frameadvance", "Signals to the emulator to resume emulation. Necessary for any lua script while loop or else the emulator will freeze!")]
@ -31,60 +32,74 @@ namespace BizHawk.Client.Common
[LuaMethodExample("local inemufra = emu.framecount( );")]
[LuaMethod("framecount", "Returns the current frame count")]
public int FrameCount() => APIs.Emulation.FrameCount();
public int FrameCount()
=> APIs.Emulation.FrameCount();
[LuaMethodExample("local obemudis = emu.disassemble( 0x8000 );")]
[LuaMethod("disassemble", "Returns the disassembly object (disasm string and length int) for the given PC address. Uses System Bus domain if no domain name provided")]
public object Disassemble(uint pc, string name = "") => APIs.Emulation.Disassemble(pc, name);
public object Disassemble(uint pc, string name = "")
=> APIs.Emulation.Disassemble(pc, name);
// TODO: what about 64 bit registers?
[LuaMethodExample("local inemuget = emu.getregister( emu.getregisters( )[ 0 ] );")]
[LuaMethod("getregister", "returns the value of a cpu register or flag specified by name. For a complete list of possible registers or flags for a given core, use getregisters")]
public int GetRegister(string name) => (int?) APIs.Emulation.GetRegister(name) ?? 0;
public int GetRegister(string name)
=> (int?) APIs.Emulation.GetRegister(name) ?? 0;
[LuaMethodExample("local nlemuget = emu.getregisters( );")]
[LuaMethod("getregisters", "returns the complete set of available flags and registers for a given core")]
public LuaTable GetRegisters() => _th.DictToTable(APIs.Emulation.GetRegisters());
public LuaTable GetRegisters()
=> _th.DictToTable(APIs.Emulation.GetRegisters());
[LuaMethodExample("emu.setregister( emu.getregisters( )[ 0 ], -1000 );")]
[LuaMethod("setregister", "sets the given register name to the given value")]
public void SetRegister(string register, int value) => APIs.Emulation.SetRegister(register, value);
public void SetRegister(string register, int value)
=> APIs.Emulation.SetRegister(register, value);
[LuaMethodExample("local inemutot = emu.totalexecutedcycles( );")]
[LuaMethod("totalexecutedcycles", "gets the total number of executed cpu cycles")]
public long TotalExecutedycles() => APIs.Emulation.TotalExecutedCycles();
public long TotalExecutedycles()
=> APIs.Emulation.TotalExecutedCycles();
[LuaMethodExample("local stemuget = emu.getsystemid( );")]
[LuaMethod("getsystemid", "Returns the ID string of the current core loaded. Note: No ROM loaded will return the string NULL")]
public string GetSystemId() => APIs.Emulation.GetSystemId();
public string GetSystemId()
=> APIs.Emulation.GetSystemId();
[LuaMethodExample("if ( emu.islagged( ) ) then\r\n\tconsole.log( \"Returns whether or not the current frame is a lag frame\" );\r\nend;")]
[LuaMethod("islagged", "Returns whether or not the current frame is a lag frame")]
public bool IsLagged() => APIs.Emulation.IsLagged();
public bool IsLagged()
=> APIs.Emulation.IsLagged();
[LuaMethodExample("emu.setislagged( true );")]
[LuaMethod("setislagged", "Sets the lag flag for the current frame. If no value is provided, it will default to true")]
public void SetIsLagged(bool value = true) => APIs.Emulation.SetIsLagged(value);
public void SetIsLagged(bool value = true)
=> APIs.Emulation.SetIsLagged(value);
[LuaMethodExample("local inemulag = emu.lagcount( );")]
[LuaMethod("lagcount", "Returns the current lag count")]
public int LagCount() => APIs.Emulation.LagCount();
public int LagCount()
=> APIs.Emulation.LagCount();
[LuaMethodExample("emu.setlagcount( 50 );")]
[LuaMethod("setlagcount", "Sets the current lag count")]
public void SetLagCount(int count) => APIs.Emulation.SetLagCount(count);
public void SetLagCount(int count)
=> APIs.Emulation.SetLagCount(count);
[LuaMethodExample("emu.limitframerate( true );")]
[LuaMethod("limitframerate", "sets the limit framerate property of the emulator")]
public void LimitFramerate(bool enabled) => APIs.Emulation.LimitFramerate(enabled);
public void LimitFramerate(bool enabled)
=> APIs.Emulation.LimitFramerate(enabled);
[LuaMethodExample("emu.minimizeframeskip( true );")]
[LuaMethod("minimizeframeskip", "Sets the autominimizeframeskip value of the emulator")]
public void MinimizeFrameskip(bool enabled) => APIs.Emulation.MinimizeFrameskip(enabled);
public void MinimizeFrameskip(bool enabled)
=> APIs.Emulation.MinimizeFrameskip(enabled);
[LuaMethodExample("emu.setrenderplanes( true, false );")]
[LuaMethod("setrenderplanes", "Toggles the drawing of sprites and background planes. Set to false or nil to disable a pane, anything else will draw them")]
public void SetRenderPlanes(params bool[] luaParam) => APIs.Emulation.SetRenderPlanes(luaParam);
public void SetRenderPlanes(params bool[] luaParam)
=> APIs.Emulation.SetRenderPlanes(luaParam);
[LuaMethodExample("emu.yield( );")]
[LuaMethod("yield", "allows a script to run while emulation is paused and interact with the gui/main window in realtime ")]
@ -95,11 +110,13 @@ namespace BizHawk.Client.Common
[LuaMethodExample("local stemuget = emu.getdisplaytype();")]
[LuaMethod("getdisplaytype", "returns the display type (PAL vs NTSC) that the emulator is currently running in")]
public string GetDisplayType() => APIs.Emulation.GetDisplayType();
public string GetDisplayType()
=> APIs.Emulation.GetDisplayType();
[LuaMethodExample("local stemuget = emu.getboardname();")]
[LuaMethod("getboardname", "returns (if available) the board name of the loaded ROM")]
public string GetBoardName() => APIs.Emulation.GetBoardName();
public string GetBoardName()
=> APIs.Emulation.GetBoardName();
[LuaDeprecatedMethod]
[LuaMethod("getluacore", "returns the name of the Lua core currently in use")]

View File

@ -17,45 +17,55 @@ namespace BizHawk.Client.Common
public override string Name => "gui";
private DisplaySurfaceID UseOrFallback(string surfaceName) => DisplaySurfaceIDParser.Parse(surfaceName) ?? _rememberedSurfaceID;
private DisplaySurfaceID UseOrFallback(string surfaceName)
=> DisplaySurfaceIDParser.Parse(surfaceName) ?? _rememberedSurfaceID;
#pragma warning disable CS0612
[LuaDeprecatedMethod]
[LuaMethod("DrawNew", "Changes drawing target to the specified lua surface name. This may clobber any previous drawing to this surface (pass false if you don't want it to)")]
public void DrawNew(string name, bool? clear = true) => APIs.Gui.DrawNew(name, clear ?? true);
public void DrawNew(string name, bool? clear = true)
=> APIs.Gui.DrawNew(name, clear ?? true);
[LuaDeprecatedMethod]
[LuaMethod("DrawFinish", "Finishes drawing to the current lua surface and causes it to get displayed.")]
public void DrawFinish() => APIs.Gui.DrawFinish();
public void DrawFinish()
=> APIs.Gui.DrawFinish();
#pragma warning restore CS0612
[LuaMethodExample("gui.addmessage( \"Some message\" );")]
[LuaMethod("addmessage", "Adds a message to the OSD's message area")]
public void AddMessage(string message) => APIs.Gui.AddMessage(message);
public void AddMessage(string message)
=> APIs.Gui.AddMessage(message);
[LuaMethodExample("gui.clearGraphics( );")]
[LuaMethod("clearGraphics", "clears all lua drawn graphics from the screen")]
public void ClearGraphics(string surfaceName = null) => APIs.Gui.ClearGraphics(surfaceID: UseOrFallback(surfaceName));
public void ClearGraphics(string surfaceName = null)
=> APIs.Gui.ClearGraphics(surfaceID: UseOrFallback(surfaceName));
[LuaMethodExample("gui.cleartext( );")]
[LuaMethod("cleartext", "clears all text created by gui.text()")]
public void ClearText() => APIs.Gui.ClearText();
public void ClearText()
=> APIs.Gui.ClearText();
[LuaMethodExample("gui.defaultForeground( 0x000000FF );")]
[LuaMethod("defaultForeground", "Sets the default foreground color to use in drawing methods, white by default")]
public void SetDefaultForegroundColor([LuaColorParam] object color) => APIs.Gui.SetDefaultForegroundColor(_th.ParseColor(color));
public void SetDefaultForegroundColor([LuaColorParam] object color)
=> APIs.Gui.SetDefaultForegroundColor(_th.ParseColor(color));
[LuaMethodExample("gui.defaultBackground( 0xFFFFFFFF );")]
[LuaMethod("defaultBackground", "Sets the default background color to use in drawing methods, transparent by default")]
public void SetDefaultBackgroundColor([LuaColorParam] object color) => APIs.Gui.SetDefaultBackgroundColor(_th.ParseColor(color));
public void SetDefaultBackgroundColor([LuaColorParam] object color)
=> APIs.Gui.SetDefaultBackgroundColor(_th.ParseColor(color));
[LuaMethodExample("gui.defaultTextBackground( 0x000000FF );")]
[LuaMethod("defaultTextBackground", "Sets the default background color to use in text drawing methods, half-transparent black by default")]
public void SetDefaultTextBackground([LuaColorParam] object color) => APIs.Gui.SetDefaultTextBackground(_th.ParseColor(color));
public void SetDefaultTextBackground([LuaColorParam] object color)
=> APIs.Gui.SetDefaultTextBackground(_th.ParseColor(color));
[LuaMethodExample("gui.defaultPixelFont( \"Arial Narrow\");")]
[LuaMethod("defaultPixelFont", "Sets the default font to use in gui.pixelText(). Two font families are available, \"fceux\" and \"gens\" (or \"0\" and \"1\" respectively), \"gens\" is used by default")]
public void SetDefaultPixelFont(string fontfamily) => APIs.Gui.SetDefaultPixelFont(fontfamily);
public void SetDefaultPixelFont(string fontfamily)
=> APIs.Gui.SetDefaultPixelFont(fontfamily);
[LuaMethodExample("gui.drawBezier( { { 5, 10 }, { 10, 10 }, { 10, 20 }, { 5, 20 } }, 0x000000FF );")]
[LuaMethod("drawBezier", "Draws a Bezier curve using the table of coordinates provided in the given color")]
@ -85,47 +95,109 @@ namespace BizHawk.Client.Common
[LuaMethodExample("gui.drawBox( 16, 32, 162, 322, 0x007F00FF, 0x7F7F7FFF );")]
[LuaMethod("drawBox", "Draws a rectangle on screen from x1/y1 to x2/y2. Same as drawRectangle except it receives two points intead of a point and width/height")]
public void DrawBox(int x, int y, int x2, int y2, [LuaColorParam] object line = null, [LuaColorParam] object background = null, string surfaceName = null) => APIs.Gui.DrawBox(x, y, x2, y2, _th.SafeParseColor(line), _th.SafeParseColor(background), surfaceID: UseOrFallback(surfaceName));
public void DrawBox(
int x,
int y,
int x2,
int y2,
[LuaColorParam] object line = null,
[LuaColorParam] object background = null,
string surfaceName = null)
=> APIs.Gui.DrawBox(x, y, x2, y2, _th.SafeParseColor(line), _th.SafeParseColor(background), surfaceID: UseOrFallback(surfaceName));
[LuaMethodExample("gui.drawEllipse( 16, 32, 77, 99, 0x007F00FF, 0x7F7F7FFF );")]
[LuaMethod("drawEllipse", "Draws an ellipse at the given coordinates and the given width and height. Line is the color of the ellipse. Background is the optional fill color")]
public void DrawEllipse(int x, int y, int width, int height, [LuaColorParam] object line = null, [LuaColorParam] object background = null, string surfaceName = null) => APIs.Gui.DrawEllipse(x, y, width, height, _th.SafeParseColor(line), _th.SafeParseColor(background), surfaceID: UseOrFallback(surfaceName));
public void DrawEllipse(
int x,
int y,
int width,
int height,
[LuaColorParam] object line = null,
[LuaColorParam] object background = null,
string surfaceName = null)
=> APIs.Gui.DrawEllipse(x, y, width, height, _th.SafeParseColor(line), _th.SafeParseColor(background), surfaceID: UseOrFallback(surfaceName));
[LuaMethodExample("gui.drawIcon( \"C:\\sample.ico\", 16, 32, 18, 24 );")]
[LuaMethod("drawIcon", "draws an Icon (.ico) file from the given path at the given coordinate. width and height are optional. If specified, it will resize the image accordingly")]
public void DrawIcon(string path, int x, int y, int? width = null, int? height = null, string surfaceName = null) => APIs.Gui.DrawIcon(path, x, y, width, height, surfaceID: UseOrFallback(surfaceName));
public void DrawIcon(string path, int x, int y, int? width = null, int? height = null, string surfaceName = null)
=> APIs.Gui.DrawIcon(path, x, y, width, height, surfaceID: UseOrFallback(surfaceName));
[LuaMethodExample("gui.drawImage( \"C:\\sample.bmp\", 16, 32, 18, 24, false );")]
[LuaMethod("drawImage", "draws an image file from the given path at the given coordinate. width and height are optional. If specified, it will resize the image accordingly")]
public void DrawImage(string path, int x, int y, int? width = null, int? height = null, bool cache = true, string surfaceName = null) => APIs.Gui.DrawImage(path, x, y, width, height, cache, surfaceID: UseOrFallback(surfaceName));
public void DrawImage(
string path,
int x,
int y,
int? width = null,
int? height = null,
bool cache = true,
string surfaceName = null)
=> APIs.Gui.DrawImage(path, x, y, width, height, cache, surfaceID: UseOrFallback(surfaceName));
[LuaMethodExample("gui.clearImageCache( );")]
[LuaMethod("clearImageCache", "clears the image cache that is built up by using gui.drawImage, also releases the file handle for cached images")]
public void ClearImageCache() => APIs.Gui.ClearImageCache();
public void ClearImageCache()
=> APIs.Gui.ClearImageCache();
[LuaMethodExample("gui.drawImageRegion( \"C:\\sample.png\", 11, 22, 33, 44, 21, 43, 34, 45 );")]
[LuaMethod("drawImageRegion", "draws a given region of an image file from the given path at the given coordinate, and optionally with the given size")]
public void DrawImageRegion(string path, int source_x, int source_y, int source_width, int source_height, int dest_x, int dest_y, int? dest_width = null, int? dest_height = null, string surfaceName = null) => APIs.Gui.DrawImageRegion(path, source_x, source_y, source_width, source_height, dest_x, dest_y, dest_width, dest_height, surfaceID: UseOrFallback(surfaceName));
public void DrawImageRegion(
string path,
int source_x,
int source_y,
int source_width,
int source_height,
int dest_x,
int dest_y,
int? dest_width = null,
int? dest_height = null,
string surfaceName = null)
=> APIs.Gui.DrawImageRegion(path, source_x, source_y, source_width, source_height, dest_x, dest_y, dest_width, dest_height, surfaceID: UseOrFallback(surfaceName));
[LuaMethodExample("gui.drawLine( 161, 321, 162, 322, 0xFFFFFFFF );")]
[LuaMethod("drawLine", "Draws a line from the first coordinate pair to the 2nd. Color is optional (if not specified it will be drawn black)")]
public void DrawLine(int x1, int y1, int x2, int y2, [LuaColorParam] object color = null, string surfaceName = null) => APIs.Gui.DrawLine(x1, y1, x2, y2, _th.SafeParseColor(color), surfaceID: UseOrFallback(surfaceName));
public void DrawLine(
int x1,
int y1,
int x2,
int y2,
[LuaColorParam] object color = null,
string surfaceName = null)
=> APIs.Gui.DrawLine(x1, y1, x2, y2, _th.SafeParseColor(color), surfaceID: UseOrFallback(surfaceName));
[LuaMethodExample("gui.drawAxis( 16, 32, 15, 0xFFFFFFFF );")]
[LuaMethod("drawAxis", "Draws an axis of the specified size at the coordinate pair.)")]
public void DrawAxis(int x, int y, int size, [LuaColorParam] object color = null, string surfaceName = null) => APIs.Gui.DrawAxis(x, y, size, _th.SafeParseColor(color), surfaceID: UseOrFallback(surfaceName));
public void DrawAxis(int x, int y, int size, [LuaColorParam] object color = null, string surfaceName = null)
=> APIs.Gui.DrawAxis(x, y, size, _th.SafeParseColor(color), surfaceID: UseOrFallback(surfaceName));
[LuaMethodExample("gui.drawPie( 16, 32, 77, 99, 180, 90, 0x007F00FF, 0x7F7F7FFF );")]
[LuaMethod("drawPie", "draws a Pie shape at the given coordinates and the given width and height")]
public void DrawPie(int x, int y, int width, int height, int startangle, int sweepangle, [LuaColorParam] object line = null, [LuaColorParam] object background = null, string surfaceName = null) => APIs.Gui.DrawPie(x, y, width, height, startangle, sweepangle, _th.SafeParseColor(line), _th.SafeParseColor(background), surfaceID: UseOrFallback(surfaceName));
public void DrawPie(
int x,
int y,
int width,
int height,
int startangle,
int sweepangle,
[LuaColorParam] object line = null,
[LuaColorParam] object background = null,
string surfaceName = null)
=> APIs.Gui.DrawPie(x, y, width, height, startangle, sweepangle, _th.SafeParseColor(line), _th.SafeParseColor(background), surfaceID: UseOrFallback(surfaceName));
[LuaMethodExample("gui.drawPixel( 16, 32, 0xFFFFFFFF );")]
[LuaMethod("drawPixel", "Draws a single pixel at the given coordinates in the given color. Color is optional (if not specified it will be drawn black)")]
public void DrawPixel(int x, int y, [LuaColorParam] object color = null, string surfaceName = null) => APIs.Gui.DrawPixel(x, y, _th.SafeParseColor(color), surfaceID: UseOrFallback(surfaceName));
public void DrawPixel(int x, int y, [LuaColorParam] object color = null, string surfaceName = null)
=> APIs.Gui.DrawPixel(x, y, _th.SafeParseColor(color), surfaceID: UseOrFallback(surfaceName));
[LuaMethodExample("gui.drawPolygon( { { 5, 10 }, { 10, 10 }, { 10, 20 }, { 5, 20 } }, 10, 30, 0x007F00FF, 0x7F7F7FFF );")]
[LuaMethod("drawPolygon", "Draws a polygon using the table of coordinates specified in points. This should be a table of tables(each of size 2). If x or y is passed, the polygon will be translated by the passed coordinate pair. Line is the color of the polygon. Background is the optional fill color")]
public void DrawPolygon(LuaTable points, int? offsetX = null, int? offsetY = null, [LuaColorParam] object line = null, [LuaColorParam] object background = null, string surfaceName = null)
public void DrawPolygon(
LuaTable points,
int? offsetX = null,
int? offsetY = null,
[LuaColorParam] object line = null,
[LuaColorParam] object background = null,
string surfaceName = null)
{
var pointsList = _th.EnumerateValues<LuaTable>(points)
.Select(table => _th.EnumerateValues<double>(table).ToList()).ToList();
@ -148,7 +220,15 @@ namespace BizHawk.Client.Common
[LuaMethodExample("gui.drawRectangle( 16, 32, 77, 99, 0x007F00FF, 0x7F7F7FFF );")]
[LuaMethod("drawRectangle", "Draws a rectangle at the given coordinate and the given width and height. Line is the color of the box. Background is the optional fill color")]
public void DrawRectangle(int x, int y, int width, int height, [LuaColorParam] object line = null, [LuaColorParam] object background = null, string surfaceName = null) => APIs.Gui.DrawRectangle(x, y, width, height, _th.SafeParseColor(line), _th.SafeParseColor(background), surfaceID: UseOrFallback(surfaceName));
public void DrawRectangle(
int x,
int y,
int width,
int height,
[LuaColorParam] object line = null,
[LuaColorParam] object background = null,
string surfaceName = null)
=> APIs.Gui.DrawRectangle(x, y, width, height, _th.SafeParseColor(line), _th.SafeParseColor(background), surfaceID: UseOrFallback(surfaceName));
[LuaMethodExample("gui.drawString( 16, 32, \"Some message\", 0x7F0000FF, 0x00007FFF, 8, \"Arial Narrow\", \"bold\", \"center\", \"middle\" );")]
[LuaMethod("drawString", "Alias of gui.drawText()")]
@ -170,19 +250,41 @@ namespace BizHawk.Client.Common
[LuaMethodExample("gui.drawText( 16, 32, \"Some message\", 0x7F0000FF, 0x00007FFF, 8, \"Arial Narrow\", \"bold\", \"center\", \"middle\" );")]
[LuaMethod("drawText", "Draws the given message in the emulator screen space (like all draw functions) at the given x,y coordinates and the given color. The default color is white. A fontfamily can be specified and is monospace generic if none is specified (font family options are the same as the .NET FontFamily class). The fontsize default is 12. The default font style is regular. Font style options are regular, bold, italic, strikethrough, underline. Horizontal alignment options are left (default), center, or right. Vertical alignment options are bottom (default), middle, or top. Alignment options specify which ends of the text will be drawn at the x and y coordinates. For pixel-perfect font look, make sure to disable aspect ratio correction.")]
public void DrawText(int x, int y, string message, [LuaColorParam] object forecolor = null, [LuaColorParam] object backcolor = null, int? fontsize = null, string fontfamily = null, string fontstyle = null, string horizalign = null, string vertalign = null, string surfaceName = null) => APIs.Gui.DrawString(x, y, message, _th.SafeParseColor(forecolor), _th.SafeParseColor(backcolor), fontsize, fontfamily, fontstyle, horizalign, vertalign, surfaceID: UseOrFallback(surfaceName));
public void DrawText(
int x,
int y,
string message,
[LuaColorParam] object forecolor = null,
[LuaColorParam] object backcolor = null,
int? fontsize = null,
string fontfamily = null,
string fontstyle = null,
string horizalign = null,
string vertalign = null,
string surfaceName = null)
=> APIs.Gui.DrawString(x, y, message, _th.SafeParseColor(forecolor), _th.SafeParseColor(backcolor), fontsize, fontfamily, fontstyle, horizalign, vertalign, surfaceID: UseOrFallback(surfaceName));
[LuaMethodExample("gui.pixelText( 16, 32, \"Some message\", 0x7F0000FF, 0x00007FFF, \"Arial Narrow\" );")]
[LuaMethod("pixelText", "Draws the given message in the emulator screen space (like all draw functions) at the given x,y coordinates and the given color. The default color is white. Two font families are available, \"fceux\" and \"gens\" (or \"0\" and \"1\" respectively), both are monospace and have the same size as in the emulators they've been taken from. If no font family is specified, it uses \"gens\" font, unless that's overridden via gui.defaultPixelFont()")]
public void DrawText(int x, int y, string message, [LuaColorParam] object forecolor = null, [LuaColorParam] object backcolor = null, string fontfamily = null, string surfaceName = null) => APIs.Gui.DrawText(x, y, message, _th.SafeParseColor(forecolor), _th.SafeParseColor(backcolor) ?? APIs.Gui.GetDefaultTextBackground().Value, fontfamily, surfaceID: UseOrFallback(surfaceName));
public void DrawText(
int x,
int y,
string message,
[LuaColorParam] object forecolor = null,
[LuaColorParam] object backcolor = null,
string fontfamily = null,
string surfaceName = null)
=> APIs.Gui.DrawText(x, y, message, _th.SafeParseColor(forecolor), _th.SafeParseColor(backcolor) ?? APIs.Gui.GetDefaultTextBackground().Value, fontfamily, surfaceID: UseOrFallback(surfaceName));
[LuaMethodExample("gui.text( 16, 32, \"Some message\", 0x7F0000FF, \"bottomleft\" );")]
[LuaMethod("text", "Displays the given text on the screen at the given coordinates. Optional Foreground color. The optional anchor flag anchors the text to one of the four corners. Anchor flag parameters: topleft, topright, bottomleft, bottomright")]
public void Text(int x, int y, string message, [LuaColorParam] object forecolor = null, string anchor = null) => APIs.Gui.Text(x, y, message, _th.SafeParseColor(forecolor), anchor);
public void Text(int x, int y, string message, [LuaColorParam] object forecolor = null, string anchor = null)
=> APIs.Gui.Text(x, y, message, _th.SafeParseColor(forecolor), anchor);
[LuaMethodExample("local nlguicre = gui.createcanvas( 77, 99, 2, 48 );")]
[LuaMethod("createcanvas", "Creates a canvas of the given size and, if specified, the given coordinates.")]
public LuaTable Text(int width, int height, int? x = null, int? y = null) => CreateLuaCanvasCallback(width, height, x, y);
public LuaTable Text(int width, int height, int? x = null, int? y = null)
=> CreateLuaCanvasCallback(width, height, x, y);
[LuaMethodExample("gui.use_surface( \"client\" );")]
[LuaMethod("use_surface", "Stores the name of a surface to draw on, so you don't need to pass it to every draw function. The default is \"emucore\", and the other valid value is \"client\".")]
@ -196,6 +298,7 @@ namespace BizHawk.Client.Common
_rememberedSurfaceID = DisplaySurfaceIDParser.Parse(surfaceName).Value;
}
public void Dispose() => APIs.Gui.Dispose();
public void Dispose()
=> APIs.Gui.Dispose();
}
}

View File

@ -13,10 +13,12 @@ namespace BizHawk.Client.Common
[LuaMethodExample("local nlinpget = input.get( );")]
[LuaMethod("get", "Returns a lua table of all the buttons the user is currently pressing on their keyboard and gamepads\nAll buttons that are pressed have their key values set to true; all others remain nil.")]
public LuaTable Get() => _th.DictToTable(APIs.Input.Get());
public LuaTable Get()
=> _th.DictToTable(APIs.Input.Get());
[LuaMethodExample("local nlinpget = input.getmouse( );")]
[LuaMethod("getmouse", "Returns a lua table of the mouse X/Y coordinates and button states. Table keys are X, Y, Left, Middle, Right, XButton1, XButton2, Wheel.")]
public LuaTable GetMouse() => _th.DictToTable(APIs.Input.GetMouse());
public LuaTable GetMouse()
=> _th.DictToTable(APIs.Input.GetMouse());
}
}

View File

@ -15,19 +15,23 @@ namespace BizHawk.Client.Common
[LuaMethodExample("local nljoyget = joypad.get( 1 );")]
[LuaMethod("get", "returns a lua table of the controller buttons pressed. If supplied, it will only return a table of buttons for the given controller")]
public LuaTable Get(int? controller = null) => _th.DictToTable(APIs.Joypad.Get(controller));
public LuaTable Get(int? controller = null)
=> _th.DictToTable(APIs.Joypad.Get(controller));
[LuaMethodExample("local nljoyget = joypad.getwithmovie( 1 );")]
[LuaMethod("getwithmovie", "returns a lua table of the controller buttons pressed, including ones pressed by the current movie. If supplied, it will only return a table of buttons for the given controller")]
public LuaTable GetWithMovie(int? controller = null) => _th.DictToTable(APIs.Joypad.GetWithMovie(controller));
public LuaTable GetWithMovie(int? controller = null)
=> _th.DictToTable(APIs.Joypad.GetWithMovie(controller));
[LuaMethodExample("local nljoyget = joypad.getimmediate( );")]
[LuaMethod("getimmediate", "returns a lua table of any controller buttons currently pressed by the user")]
public LuaTable GetImmediate(int? controller = null) => _th.DictToTable(APIs.Joypad.GetImmediate(controller));
public LuaTable GetImmediate(int? controller = null)
=> _th.DictToTable(APIs.Joypad.GetImmediate(controller));
[LuaMethodExample("joypad.setfrommnemonicstr( \"| 0, 0, 0, 100,...R..B....|\" );")]
[LuaMethod("setfrommnemonicstr", "sets the given buttons to their provided values for the current frame, string will be interpreted the same way an entry from a movie input log would be")]
public void SetFromMnemonicStr(string inputLogEntry) => APIs.Joypad.SetFromMnemonicStr(inputLogEntry);
public void SetFromMnemonicStr(string inputLogEntry)
=> APIs.Joypad.SetFromMnemonicStr(inputLogEntry);
[LuaMethodExample("joypad.set( { [\"Left\"] = true, [ \"A\" ] = true, [ \"B\" ] = true } );")]
[LuaMethod("set", "sets the given buttons to their provided values for the current frame")]

View File

@ -22,31 +22,38 @@ namespace BizHawk.Client.Common
[LuaMethodExample("local uimemget = memory.getmemorydomainsize( mainmemory.getname( ) );")]
[LuaMethod("getmemorydomainsize", "Returns the number of bytes of the specified memory domain. If no domain is specified, or the specified domain doesn't exist, returns the current domain size")]
public uint GetMemoryDomainSize(string name = "") => APIs.Memory.GetMemoryDomainSize(name);
public uint GetMemoryDomainSize(string name = "")
=> APIs.Memory.GetMemoryDomainSize(name);
[LuaMethodExample("local stmemget = memory.getcurrentmemorydomain( );")]
[LuaMethod("getcurrentmemorydomain", "Returns a string name of the current memory domain selected by Lua. The default is Main memory")]
public string GetCurrentMemoryDomain() => APIs.Memory.GetCurrentMemoryDomain();
public string GetCurrentMemoryDomain()
=> APIs.Memory.GetCurrentMemoryDomain();
[LuaMethodExample("local uimemget = memory.getcurrentmemorydomainsize( );")]
[LuaMethod("getcurrentmemorydomainsize", "Returns the number of bytes of the current memory domain selected by Lua. The default is Main memory")]
public uint GetCurrentMemoryDomainSize() => APIs.Memory.GetCurrentMemoryDomainSize();
public uint GetCurrentMemoryDomainSize()
=> APIs.Memory.GetCurrentMemoryDomainSize();
[LuaMethodExample("if ( memory.usememorydomain( mainmemory.getname( ) ) ) then\r\n\tconsole.log( \"Attempts to set the current memory domain to the given domain. If the name does not match a valid memory domain, the function returns false, else it returns true\" );\r\nend;")]
[LuaMethod("usememorydomain", "Attempts to set the current memory domain to the given domain. If the name does not match a valid memory domain, the function returns false, else it returns true")]
public bool UseMemoryDomain(string domain) => APIs.Memory.UseMemoryDomain(domain);
public bool UseMemoryDomain(string domain)
=> APIs.Memory.UseMemoryDomain(domain);
[LuaMethodExample("local stmemhas = memory.hash_region( 0x100, 50, mainmemory.getname( ) );")]
[LuaMethod("hash_region", "Returns a hash as a string of a region of memory, starting from addr, through count bytes. If the domain is unspecified, it uses the current region.")]
public string HashRegion(long addr, int count, string domain = null) => APIs.Memory.HashRegion(addr, count, domain);
public string HashRegion(long addr, int count, string domain = null)
=> APIs.Memory.HashRegion(addr, count, domain);
[LuaMethodExample("local uimemrea = memory.readbyte( 0x100, mainmemory.getname( ) );")]
[LuaMethod("readbyte", "gets the value from the given address as an unsigned byte")]
public uint ReadByte(long addr, string domain = null) => APIs.Memory.ReadByte(addr, domain);
public uint ReadByte(long addr, string domain = null)
=> APIs.Memory.ReadByte(addr, domain);
[LuaMethodExample("memory.writebyte( 0x100, 1000, mainmemory.getname( ) );")]
[LuaMethod("writebyte", "Writes the given value to the given address as an unsigned byte")]
public void WriteByte(long addr, uint value, string domain = null) => APIs.Memory.WriteByte(addr, value, domain);
public void WriteByte(long addr, uint value, string domain = null)
=> APIs.Memory.WriteByte(addr, value, domain);
[LuaDeprecatedMethod]
[LuaMethod("readbyterange", "Reads the address range that starts from address, and is length long. Returns a zero-indexed table containing the read values (an array of bytes.)")]
@ -126,19 +133,23 @@ namespace BizHawk.Client.Common
[LuaMethodExample("local inmemrea = memory.read_s8( 0x100, mainmemory.getname( ) );")]
[LuaMethod("read_s8", "read signed byte")]
public int ReadS8(long addr, string domain = null) => APIs.Memory.ReadS8(addr, domain);
public int ReadS8(long addr, string domain = null)
=> APIs.Memory.ReadS8(addr, domain);
[LuaMethodExample("memory.write_s8( 0x100, 1000, mainmemory.getname( ) );")]
[LuaMethod("write_s8", "write signed byte")]
public void WriteS8(long addr, uint value, string domain = null) => APIs.Memory.WriteS8(addr, unchecked((int) value), domain);
public void WriteS8(long addr, uint value, string domain = null)
=> APIs.Memory.WriteS8(addr, unchecked((int) value), domain);
[LuaMethodExample("local uimemrea = memory.read_u8( 0x100, mainmemory.getname( ) );")]
[LuaMethod("read_u8", "read unsigned byte")]
public uint ReadU8(long addr, string domain = null) => APIs.Memory.ReadU8(addr, domain);
public uint ReadU8(long addr, string domain = null)
=> APIs.Memory.ReadU8(addr, domain);
[LuaMethodExample("memory.write_u8( 0x100, 1000, mainmemory.getname( ) );")]
[LuaMethod("write_u8", "write unsigned byte")]
public void WriteU8(long addr, uint value, string domain = null) => APIs.Memory.WriteU8(addr, value, domain);
public void WriteU8(long addr, uint value, string domain = null)
=> APIs.Memory.WriteU8(addr, value, domain);
[LuaMethodExample("local inmemrea = memory.read_s16_le( 0x100, mainmemory.getname( ) );")]
[LuaMethod("read_s16_le", "read signed 2 byte value, little endian")]

View File

@ -13,18 +13,22 @@ namespace BizHawk.Client.Common
[LuaMethodExample("local mmsvstsvcst = memorysavestate.savecorestate( );")]
[LuaMethod("savecorestate", "creates a core savestate and stores it in memory. Note: a core savestate is only the raw data from the core, and not extras such as movie input logs, or framebuffers. Returns a unique identifer for the savestate")]
public string SaveCoreStateToMemory() => APIs.MemorySaveState.SaveCoreStateToMemory();
public string SaveCoreStateToMemory()
=> APIs.MemorySaveState.SaveCoreStateToMemory();
[LuaMethodExample("memorysavestate.loadcorestate( \"3fcf120f-0778-43fd-b2c5-460fb7d34184\" );")]
[LuaMethod("loadcorestate", "loads an in memory state with the given identifier")]
public void LoadCoreStateFromMemory(string identifier) => APIs.MemorySaveState.LoadCoreStateFromMemory(identifier);
public void LoadCoreStateFromMemory(string identifier)
=> APIs.MemorySaveState.LoadCoreStateFromMemory(identifier);
[LuaMethodExample("memorysavestate.removestate( \"3fcf120f-0778-43fd-b2c5-460fb7d34184\" );")]
[LuaMethod("removestate", "removes the savestate with the given identifier from memory")]
public void DeleteState(string identifier) => APIs.MemorySaveState.DeleteState(identifier);
public void DeleteState(string identifier)
=> APIs.MemorySaveState.DeleteState(identifier);
[LuaMethodExample("memorysavestate.clearstatesfrommemory( );")]
[LuaMethod("clearstatesfrommemory", "clears all savestates stored in memory")]
public void ClearInMemoryStates() => APIs.MemorySaveState.ClearInMemoryStates();
public void ClearInMemoryStates()
=> APIs.MemorySaveState.ClearInMemoryStates();
}
}

View File

@ -14,75 +14,93 @@ namespace BizHawk.Client.Common
[LuaMethodExample("if ( movie.startsfromsavestate( ) ) then\r\n\tconsole.log( \"Returns whether or not the movie is a savestate-anchored movie\" );\r\nend;")]
[LuaMethod("startsfromsavestate", "Returns whether or not the movie is a savestate-anchored movie")]
public bool StartsFromSavestate() => APIs.Movie.StartsFromSavestate();
public bool StartsFromSavestate()
=> APIs.Movie.StartsFromSavestate();
[LuaMethodExample("if ( movie.startsfromsaveram( ) ) then\r\n\tconsole.log( \"Returns whether or not the movie is a saveram-anchored movie\" );\r\nend;")]
[LuaMethod("startsfromsaveram", "Returns whether or not the movie is a saveram-anchored movie")]
public bool StartsFromSaveram() => APIs.Movie.StartsFromSaveram();
public bool StartsFromSaveram()
=> APIs.Movie.StartsFromSaveram();
[LuaMethodExample("local stmovfil = movie.filename( );")]
[LuaMethod("filename", "Returns the file name including path of the currently loaded movie")]
public string Filename() => APIs.Movie.Filename();
public string Filename()
=> APIs.Movie.Filename();
[LuaMethodExample("local nlmovget = movie.getinput( 500 );")]
[LuaMethod("getinput", "Returns a table of buttons pressed on a given frame of the loaded movie")]
public LuaTable GetInput(int frame, int? controller = null) => _th.DictToTable(APIs.Movie.GetInput(frame, controller));
public LuaTable GetInput(int frame, int? controller = null)
=> _th.DictToTable(APIs.Movie.GetInput(frame, controller));
[LuaMethodExample("local stmovget = movie.getinputasmnemonic( 500 );")]
[LuaMethod("getinputasmnemonic", "Returns the input of a given frame of the loaded movie in a raw inputlog string")]
public string GetInputAsMnemonic(int frame) => APIs.Movie.GetInputAsMnemonic(frame);
public string GetInputAsMnemonic(int frame)
=> APIs.Movie.GetInputAsMnemonic(frame);
[LuaMethodExample("if ( movie.getreadonly( ) ) then\r\n\tconsole.log( \"Returns true if the movie is in read-only mode, false if in read+write\" );\r\nend;")]
[LuaMethod("getreadonly", "Returns true if the movie is in read-only mode, false if in read+write")]
public bool GetReadOnly() => APIs.Movie.GetReadOnly();
public bool GetReadOnly()
=> APIs.Movie.GetReadOnly();
[LuaMethodExample("local ulmovget = movie.getrerecordcount();")]
[LuaMethod("getrerecordcount", "Gets the rerecord count of the current movie.")]
public ulong GetRerecordCount() => APIs.Movie.GetRerecordCount();
public ulong GetRerecordCount()
=> APIs.Movie.GetRerecordCount();
[LuaMethodExample("if ( movie.getrerecordcounting( ) ) then\r\n\tconsole.log( \"Returns whether or not the current movie is incrementing rerecords on loadstate\" );\r\nend;")]
[LuaMethod("getrerecordcounting", "Returns whether or not the current movie is incrementing rerecords on loadstate")]
public bool GetRerecordCounting() => APIs.Movie.GetRerecordCounting();
public bool GetRerecordCounting()
=> APIs.Movie.GetRerecordCounting();
[LuaMethodExample("if ( movie.isloaded( ) ) then\r\n\tconsole.log( \"Returns true if a movie is loaded in memory ( play, record, or finished modes ), false if not ( inactive mode )\" );\r\nend;")]
[LuaMethod("isloaded", "Returns true if a movie is loaded in memory (play, record, or finished modes), false if not (inactive mode)")]
public bool IsLoaded() => APIs.Movie.IsLoaded();
public bool IsLoaded()
=> APIs.Movie.IsLoaded();
[LuaMethodExample("local domovlen = movie.length( );")]
[LuaMethod("length", "Returns the total number of frames of the loaded movie")]
public double Length() => APIs.Movie.Length();
public double Length()
=> APIs.Movie.Length();
[LuaMethodExample("local stmovmod = movie.mode( );")]
[LuaMethod("mode", "Returns the mode of the current movie. Possible modes: \"PLAY\", \"RECORD\", \"FINISHED\", \"INACTIVE\"")]
public string Mode() => APIs.Movie.Mode();
public string Mode()
=> APIs.Movie.Mode();
[LuaMethodExample("movie.save( \"C:\\moviename.ext\" );")]
[LuaMethod("save", "Saves the current movie to the disc. If the filename is provided (no extension or path needed), the movie is saved under the specified name to the current movie directory. The filename may contain a subdirectory, it will be created if it doesn't exist. Existing files won't get overwritten.")]
public void Save(string filename = "") => APIs.Movie.Save(filename);
public void Save(string filename = "")
=> APIs.Movie.Save(filename);
[LuaMethodExample("movie.setreadonly( false );")]
[LuaMethod("setreadonly", "Sets the read-only state to the given value. true for read only, false for read+write")]
public void SetReadOnly(bool readOnly) => APIs.Movie.SetReadOnly(readOnly);
public void SetReadOnly(bool readOnly)
=> APIs.Movie.SetReadOnly(readOnly);
[LuaMethodExample("movie.setrerecordcount( 20.0 );")]
[LuaMethod("setrerecordcount", "Sets the rerecord count of the current movie.")]
public void SetRerecordCount(double count) => APIs.Movie.SetRerecordCount((ulong) count.AsInteger());
public void SetRerecordCount(double count)
=> APIs.Movie.SetRerecordCount((ulong) count.AsInteger());
[LuaMethodExample("movie.setrerecordcounting( true );")]
[LuaMethod("setrerecordcounting", "Sets whether or not the current movie will increment the rerecord counter on loadstate")]
public void SetRerecordCounting(bool counting) => APIs.Movie.SetRerecordCounting(counting);
public void SetRerecordCounting(bool counting)
=> APIs.Movie.SetRerecordCounting(counting);
[LuaMethodExample("movie.stop( );")]
[LuaMethod("stop", "Stops the current movie")]
public void Stop() => APIs.Movie.Stop();
public void Stop()
=> APIs.Movie.Stop();
[LuaMethodExample("local domovget = movie.getfps( );")]
[LuaMethod("getfps", "If a movie is loaded, gets the frames per second used by the movie to determine the movie length time")]
public double GetFps() => APIs.Movie.GetFps();
public double GetFps()
=> APIs.Movie.GetFps();
[LuaMethodExample("local nlmovget = movie.getheader( );")]
[LuaMethod("getheader", "If a movie is active, will return the movie header as a lua table")]
public LuaTable GetHeader() => _th.DictToTable(APIs.Movie.GetHeader());
public LuaTable GetHeader()
=> _th.DictToTable(APIs.Movie.GetHeader());
[LuaMethodExample("local nlmovget = movie.getcomments( );")]
[LuaMethod("getcomments", "If a movie is active, will return the movie comments as a lua table")]

View File

@ -15,16 +15,19 @@ namespace BizHawk.Client.Common
[LuaMethodExample("local stSQLcre = SQL.createdatabase( \"eg_db\" );")]
[LuaMethod("createdatabase", "Creates a SQLite Database. Name should end with .db")]
public string CreateDatabase(string name) => APIs.SQLite.CreateDatabase(name);
public string CreateDatabase(string name)
=> APIs.SQLite.CreateDatabase(name);
[LuaMethodExample("local stSQLope = SQL.opendatabase( \"eg_db\" );")]
[LuaMethod("opendatabase", "Opens a SQLite database. Name should end with .db")]
public string OpenDatabase(string name) => APIs.SQLite.OpenDatabase(name);
public string OpenDatabase(string name)
=> APIs.SQLite.OpenDatabase(name);
[LuaMethodExample("local stSQLwri = SQL.writecommand( \"CREATE TABLE eg_tab ( eg_tab_id integer PRIMARY KEY, eg_tab_row_name text NOT NULL ); INSERT INTO eg_tab ( eg_tab_id, eg_tab_row_name ) VALUES ( 1, 'Example table row' );\" );")]
[LuaMethod("writecommand", "Runs a SQLite write command which includes CREATE,INSERT, UPDATE. " +
"Ex: create TABLE rewards (ID integer PRIMARY KEY, action VARCHAR(20)) ")]
public string WriteCommand(string query = "") => APIs.SQLite.WriteCommand(query);
public string WriteCommand(string query = "")
=> APIs.SQLite.WriteCommand(query);
[LuaMethodExample("local obSQLrea = SQL.readcommand( \"SELECT * FROM eg_tab WHERE eg_tab_id = 1;\" );")]
[LuaMethod("readcommand", "Run a SQLite read command which includes Select. Returns all rows into a LuaTable." +

View File

@ -33,10 +33,12 @@ namespace BizHawk.Client.Common
[LuaMethodExample("savestate.save( \"C:\\state.bin\" );")]
[LuaMethod("save", "Saves a state at the given path. If EmuHawk is deferring quicksaves, to TAStudio for example, that form will do what it likes (and the path is ignored).")]
public void Save(string path, bool suppressOSD = false) => APIs.SaveState.Save(path, suppressOSD);
public void Save(string path, bool suppressOSD = false)
=> APIs.SaveState.Save(path, suppressOSD);
[LuaMethodExample("savestate.saveslot( 7 );")]
[LuaMethod("saveslot", "Saves a state at the given save slot (must be an integer between 0 and 9). If EmuHawk is deferring quicksaves, to TAStudio for example, that form will do what it likes with the slot number.")]
public void SaveSlot(int slotNum, bool suppressOSD = false) => APIs.SaveState.SaveSlot(slotNum, suppressOSD);
public void SaveSlot(int slotNum, bool suppressOSD = false)
=> APIs.SaveState.SaveSlot(slotNum, suppressOSD);
}
}

View File

@ -14,22 +14,27 @@ namespace BizHawk.Client.Common
[LuaMethodExample("userdata.set(\"Unique key\", \"Current key data\");")]
[LuaMethod("set", "adds or updates the data with the given key with the given value")]
public void Set(string name, object value) => APIs.UserData.Set(name, value);
public void Set(string name, object value)
=> APIs.UserData.Set(name, value);
[LuaMethodExample("local obuseget = userdata.get( \"Unique key\" );")]
[LuaMethod("get", "gets the data with the given key, if the key does not exist it will return nil")]
public object Get(string key) => APIs.UserData.Get(key);
public object Get(string key)
=> APIs.UserData.Get(key);
[LuaMethodExample("userdata.clear( );")]
[LuaMethod("clear", "clears all user data")]
public void Clear() => APIs.UserData.Clear();
public void Clear()
=> APIs.UserData.Clear();
[LuaMethodExample("if ( userdata.remove( \"Unique key\" ) ) then\r\n\tconsole.log( \"remove the data with the given key.Returns true if the element is successfully found and removed; otherwise, false.\" );\r\nend;")]
[LuaMethod("remove", "remove the data with the given key. Returns true if the element is successfully found and removed; otherwise, false.")]
public bool Remove(string key) => APIs.UserData.Remove(key);
public bool Remove(string key)
=> APIs.UserData.Remove(key);
[LuaMethodExample("if ( userdata.containskey( \"Unique key\" ) ) then\r\n\tconsole.log( \"returns whether or not there is an entry for the given key\" );\r\nend;")]
[LuaMethod("containskey", "returns whether or not there is an entry for the given key")]
public bool ContainsKey(string key) => APIs.UserData.ContainsKey(key);
public bool ContainsKey(string key)
=> APIs.UserData.ContainsKey(key);
}
}

View File

@ -244,11 +244,13 @@ namespace BizHawk.Client.Common
[LuaMethodExample("if ( event.unregisterbyid( \"4d1810b7 - 0d28 - 4acb - 9d8b - d87721641551\" ) ) then\r\n\tconsole.log( \"Removes the registered function that matches the guid.If a function is found and remove the function will return true.If unable to find a match, the function will return false.\" );\r\nend;")]
[LuaMethod("unregisterbyid", "Removes the registered function that matches the guid. If a function is found and remove the function will return true. If unable to find a match, the function will return false.")]
public bool UnregisterById(string guid) => _luaLibsImpl.RemoveNamedFunctionMatching(nlf => nlf.Guid.ToString() == guid);
public bool UnregisterById(string guid)
=> _luaLibsImpl.RemoveNamedFunctionMatching(nlf => nlf.Guid.ToString() == guid);
[LuaMethodExample("if ( event.unregisterbyname( \"Function name\" ) ) then\r\n\tconsole.log( \"Removes the first registered function that matches Name.If a function is found and remove the function will return true.If unable to find a match, the function will return false.\" );\r\nend;")]
[LuaMethod("unregisterbyname", "Removes the first registered function that matches Name. If a function is found and remove the function will return true. If unable to find a match, the function will return false.")]
public bool UnregisterByName(string name) => _luaLibsImpl.RemoveNamedFunctionMatching(nlf => nlf.Name == name);
public bool UnregisterByName(string name)
=> _luaLibsImpl.RemoveNamedFunctionMatching(nlf => nlf.Name == name);
[LuaMethodExample("local scopes = event.availableScopes();")]
[LuaMethod("availableScopes", "Lists the available scopes that can be passed into memory events")]

View File

@ -23,15 +23,18 @@ namespace BizHawk.Client.Common
[LuaMethodExample("if ( genesis.getlayer_bga( ) ) then\r\n\tconsole.log( \"Returns whether the bg layer A is displayed\" );\r\nend;")]
[LuaMethod("getlayer_bga", "Returns whether the bg layer A is displayed")]
public bool GetLayerBgA() => Settings.DrawBGA;
public bool GetLayerBgA()
=> Settings.DrawBGA;
[LuaMethodExample("if ( genesis.getlayer_bgb( ) ) then\r\n\tconsole.log( \"Returns whether the bg layer B is displayed\" );\r\nend;")]
[LuaMethod("getlayer_bgb", "Returns whether the bg layer B is displayed")]
public bool GetLayerBgB() => Settings.DrawBGB;
public bool GetLayerBgB()
=> Settings.DrawBGB;
[LuaMethodExample("if ( genesis.getlayer_bgw( ) ) then\r\n\tconsole.log( \"Returns whether the bg layer W is displayed\" );\r\nend;")]
[LuaMethod("getlayer_bgw", "Returns whether the bg layer W is displayed")]
public bool GetLayerBgW() => Settings.DrawBGW;
public bool GetLayerBgW()
=> Settings.DrawBGW;
[LuaMethodExample("genesis.setlayer_bga( true );")]
[LuaMethod("setlayer_bga", "Sets whether the bg layer A is displayed")]

View File

@ -27,7 +27,8 @@ namespace BizHawk.Client.Common
[LuaMethodExample("local stmaiget = mainmemory.getname( );")]
[LuaMethod("getname", "returns the name of the domain defined as main memory for the given core")]
public string GetName() => MainMemName;
public string GetName()
=> MainMemName;
[LuaMethodExample("local uimaiget = mainmemory.getcurrentmemorydomainsize( );")]
[LuaMethod("getcurrentmemorydomainsize", "Returns the number of bytes of the domain defined as main memory")]
@ -38,11 +39,13 @@ namespace BizHawk.Client.Common
[LuaMethodExample("local uimairea = mainmemory.readbyte( 0x100 );")]
[LuaMethod("readbyte", "gets the value from the given address as an unsigned byte")]
public uint ReadByte(long addr) => APIs.Memory.ReadByte(addr, MainMemName);
public uint ReadByte(long addr)
=> APIs.Memory.ReadByte(addr, MainMemName);
[LuaMethodExample("mainmemory.writebyte( 0x100, 1000 );")]
[LuaMethod("writebyte", "Writes the given value to the given address as an unsigned byte")]
public void WriteByte(long addr, uint value) => APIs.Memory.WriteByte(addr, value, MainMemName);
public void WriteByte(long addr, uint value)
=> APIs.Memory.WriteByte(addr, value, MainMemName);
[LuaDeprecatedMethod]
[LuaMethod("readbyterange", "Reads the address range that starts from address, and is length long. Returns a zero-indexed table containing the read values (an array of bytes.)")]
@ -122,19 +125,23 @@ namespace BizHawk.Client.Common
[LuaMethodExample("local inmairea = mainmemory.read_s8( 0x100 );")]
[LuaMethod("read_s8", "read signed byte")]
public int ReadS8(long addr) => APIs.Memory.ReadS8(addr, MainMemName);
public int ReadS8(long addr)
=> APIs.Memory.ReadS8(addr, MainMemName);
[LuaMethodExample("mainmemory.write_s8( 0x100, 1000 );")]
[LuaMethod("write_s8", "write signed byte")]
public void WriteS8(long addr, uint value) => APIs.Memory.WriteS8(addr, unchecked((int) value), MainMemName);
public void WriteS8(long addr, uint value)
=> APIs.Memory.WriteS8(addr, unchecked((int) value), MainMemName);
[LuaMethodExample("local uimairea = mainmemory.read_u8( 0x100 );")]
[LuaMethod("read_u8", "read unsigned byte")]
public uint ReadU8(long addr) => APIs.Memory.ReadU8(addr, MainMemName);
public uint ReadU8(long addr)
=> APIs.Memory.ReadU8(addr, MainMemName);
[LuaMethodExample("mainmemory.write_u8( 0x100, 1000 );")]
[LuaMethod("write_u8", "write unsigned byte")]
public void WriteU8(long addr, uint value) => APIs.Memory.WriteU8(addr, value, MainMemName);
public void WriteU8(long addr, uint value)
=> APIs.Memory.WriteU8(addr, value, MainMemName);
[LuaMethodExample("local inmairea = mainmemory.read_s16_le( 0x100 );")]
[LuaMethod("read_s16_le", "read signed 2 byte value, little endian")]

View File

@ -23,23 +23,28 @@ namespace BizHawk.Client.Common
[LuaMethodExample("if ( nds.getscreenlayout( ) ) then\r\n\tconsole.log( \"Returns which screen layout is active\" );\r\nend;")]
[LuaMethod("getscreenlayout", "Returns which screen layout is active")]
public string GetScreenLayout() => Settings.ScreenLayout.ToString();
public string GetScreenLayout()
=> Settings.ScreenLayout.ToString();
[LuaMethodExample("if ( nds.getscreeninvert( ) ) then\r\n\tconsole.log( \"Returns whether screens are inverted\" );\r\nend;")]
[LuaMethod("getscreeninvert", "Returns whether screens are inverted")]
public bool GetScreenInvert() => Settings.ScreenInvert;
public bool GetScreenInvert()
=> Settings.ScreenInvert;
[LuaMethodExample("if ( nds.getscreenrotation( ) ) then\r\n\tconsole.log( \"Returns how screens are rotated\" );\r\nend;")]
[LuaMethod("getscreenrotation", "Returns how screens are rotated")]
public string GetScreenRotation() => Settings.ScreenRotation.ToString();
public string GetScreenRotation()
=> Settings.ScreenRotation.ToString();
[LuaMethodExample("if ( nds.getscreengap( ) ) then\r\n\tconsole.log( \"Returns the gap between the screens\" );\r\nend;")]
[LuaMethod("getscreengap", "Returns the gap between the screens")]
public int GetScreenGap() => Settings.ScreenGap;
public int GetScreenGap()
=> Settings.ScreenGap;
[LuaMethodExample("if ( nds.getaccurateaudiobitrate( ) ) then\r\n\tconsole.log( \"Returns whether the audio bitrate is set to accurate mode\" );\r\nend;")]
[LuaMethod("getaccurateaudiobitrate", "Returns whether the audio bitrate is in accurate mode")]
public bool GetAccurateAudioBitrate() => Settings.AccurateAudioBitrate;
public bool GetAccurateAudioBitrate()
=> Settings.AccurateAudioBitrate;
[LuaMethodExample("nds.setscreenlayout( \"Vertical\" );")]
[LuaMethod("setscreenlayout", "Sets which screen layout is active")]

View File

@ -33,62 +33,68 @@ namespace BizHawk.Client.Common
/// <exception cref="InvalidOperationException">loaded core is not NESHawk or QuickNes</exception>
[LuaMethodExample("if ( nes.getallowmorethaneightsprites( ) ) then\r\n\tconsole.log( \"Gets the NES setting 'Allow more than 8 sprites per scanline' value\" );\r\nend;")]
[LuaMethod("getallowmorethaneightsprites", "Gets the NES setting 'Allow more than 8 sprites per scanline' value")]
public bool GetAllowMoreThanEightSprites() => Settings switch
{
NES.NESSettings nhs => nhs.AllowMoreThanEightSprites,
QuickNES.QuickNESSettings qns => qns.NumSprites != 8,
_ => throw new InvalidOperationException()
};
public bool GetAllowMoreThanEightSprites()
=> Settings switch
{
NES.NESSettings nhs => nhs.AllowMoreThanEightSprites,
QuickNES.QuickNESSettings qns => qns.NumSprites != 8,
_ => throw new InvalidOperationException()
};
/// <exception cref="InvalidOperationException">loaded core is not NESHawk or QuickNes</exception>
[LuaMethodExample("local innesget = nes.getbottomscanline( false );")]
[LuaMethod("getbottomscanline", "Gets the current value for the bottom scanline value")]
public int GetBottomScanline(bool pal = false) => Settings switch
{
NES.NESSettings nhs => pal ? nhs.PAL_BottomLine : nhs.NTSC_BottomLine,
QuickNES.QuickNESSettings qns => qns.ClipTopAndBottom ? 231 : 239,
_ => throw new InvalidOperationException()
};
public int GetBottomScanline(bool pal = false)
=> Settings switch
{
NES.NESSettings nhs => pal ? nhs.PAL_BottomLine : nhs.NTSC_BottomLine,
QuickNES.QuickNESSettings qns => qns.ClipTopAndBottom ? 231 : 239,
_ => throw new InvalidOperationException()
};
/// <exception cref="InvalidOperationException">loaded core is not NESHawk or QuickNes</exception>
[LuaMethodExample("if ( nes.getclipleftandright( ) ) then\r\n\tconsole.log( \"Gets the current value for the Clip Left and Right sides option\" );\r\nend;")]
[LuaMethod("getclipleftandright", "Gets the current value for the Clip Left and Right sides option")]
public bool GetClipLeftAndRight() => Settings switch
{
NES.NESSettings nhs => nhs.ClipLeftAndRight,
QuickNES.QuickNESSettings qns => qns.ClipLeftAndRight,
_ => throw new InvalidOperationException()
};
public bool GetClipLeftAndRight()
=> Settings switch
{
NES.NESSettings nhs => nhs.ClipLeftAndRight,
QuickNES.QuickNESSettings qns => qns.ClipLeftAndRight,
_ => throw new InvalidOperationException()
};
/// <exception cref="InvalidOperationException">loaded core is not NESHawk or QuickNes</exception>
[LuaMethodExample("if ( nes.getdispbackground( ) ) then\r\n\tconsole.log( \"Indicates whether or not the bg layer is being displayed\" );\r\nend;")]
[LuaMethod("getdispbackground", "Indicates whether or not the bg layer is being displayed")]
public bool GetDisplayBackground() => Settings switch
{
NES.NESSettings nhs => nhs.DispBackground,
QuickNES.QuickNESSettings => true,
_ => throw new InvalidOperationException()
};
public bool GetDisplayBackground()
=> Settings switch
{
NES.NESSettings nhs => nhs.DispBackground,
QuickNES.QuickNESSettings => true,
_ => throw new InvalidOperationException()
};
/// <exception cref="InvalidOperationException">loaded core is not NESHawk or QuickNes</exception>
[LuaMethodExample("if ( nes.getdispsprites( ) ) then\r\n\tconsole.log( \"Indicates whether or not sprites are being displayed\" );\r\nend;")]
[LuaMethod("getdispsprites", "Indicates whether or not sprites are being displayed")]
public bool GetDisplaySprites() => Settings switch
{
NES.NESSettings nhs => nhs.DispSprites,
QuickNES.QuickNESSettings qns => qns.NumSprites > 0,
_ => throw new InvalidOperationException()
};
public bool GetDisplaySprites()
=> Settings switch
{
NES.NESSettings nhs => nhs.DispSprites,
QuickNES.QuickNESSettings qns => qns.NumSprites > 0,
_ => throw new InvalidOperationException()
};
/// <exception cref="InvalidOperationException">loaded core is not NESHawk or QuickNes</exception>
[LuaMethodExample("local innesget = nes.gettopscanline(false);")]
[LuaMethod("gettopscanline", "Gets the current value for the top scanline value")]
public int GetTopScanline(bool pal = false) => Settings switch
{
NES.NESSettings nhs => pal ? nhs.PAL_TopLine : nhs.NTSC_TopLine,
QuickNES.QuickNESSettings qns => qns.ClipTopAndBottom ? 8 : 0,
_ => throw new InvalidOperationException()
};
public int GetTopScanline(bool pal = false)
=> Settings switch
{
NES.NESSettings nhs => pal ? nhs.PAL_TopLine : nhs.NTSC_TopLine,
QuickNES.QuickNESSettings qns => qns.ClipTopAndBottom ? 8 : 0,
_ => throw new InvalidOperationException()
};
/// <exception cref="InvalidOperationException">loaded core is not NESHawk or QuickNes</exception>
[LuaMethodExample("nes.setallowmorethaneightsprites( true );")]

View File

@ -124,8 +124,9 @@ namespace BizHawk.Client.Common
[LuaMethodExample("local nlbizspl = bizstring.split( \"Some, string\", \", \" );")]
[LuaMethod("split", "Splits str into a Lua-style array using the given separator (consecutive separators in str will NOT create empty entries in the array). If the separator is not a string exactly one char long, ',' will be used.")]
public LuaTable Split(string str, string separator) => string.IsNullOrEmpty(str)
? _th.CreateTable()
: _th.ListToTable(str.Split(new[] { separator?.Length == 1 ? separator[0] : ',' }, StringSplitOptions.RemoveEmptyEntries));
public LuaTable Split(string str, string separator)
=> string.IsNullOrEmpty(str)
? _th.CreateTable()
: _th.ListToTable(str.Split(new[] { separator?.Length == 1 ? separator[0] : ',' }, StringSplitOptions.RemoveEmptyEntries));
}
}

View File

@ -613,7 +613,14 @@ namespace BizHawk.Client.EmuHawk
[LuaMethod(
"drawBox",
"Draws a rectangle on screen from x1/y1 to x2/y2. Same as drawRectangle except it receives two points intead of a point and width/height")]
public void DrawBox(int componentHandle, int x, int y, int x2, int y2, [LuaColorParam] object line = null, [LuaColorParam] object background = null)
public void DrawBox(
int componentHandle,
int x,
int y,
int x2,
int y2,
[LuaColorParam] object line = null,
[LuaColorParam] object background = null)
{
try
{
@ -644,7 +651,14 @@ namespace BizHawk.Client.EmuHawk
[LuaMethod(
"drawEllipse",
"Draws an ellipse at the given coordinates and the given width and height. Line is the color of the ellipse. Background is the optional fill color")]
public void DrawEllipse(int componentHandle, int x, int y, int width, int height, [LuaColorParam] object line = null, [LuaColorParam] object background = null)
public void DrawEllipse(
int componentHandle,
int x,
int y,
int width,
int height,
[LuaColorParam] object line = null,
[LuaColorParam] object background = null)
{
try
{
@ -709,7 +723,14 @@ namespace BizHawk.Client.EmuHawk
[LuaMethod(
"drawImage",
"draws an image file from the given path at the given coordinate. width and height are optional. If specified, it will resize the image accordingly")]
public void DrawImage(int componentHandle, string path, int x, int y, int? width = null, int? height = null, bool cache = true)
public void DrawImage(
int componentHandle,
string path,
int x,
int y,
int? width = null,
int? height = null,
bool cache = true)
{
if (!File.Exists(path))
{
@ -772,7 +793,17 @@ namespace BizHawk.Client.EmuHawk
[LuaMethod(
"drawImageRegion",
"draws a given region of an image file from the given path at the given coordinate, and optionally with the given size")]
public void DrawImageRegion(int componentHandle, string path, int source_x, int source_y, int source_width, int source_height, int dest_x, int dest_y, int? dest_width = null, int? dest_height = null)
public void DrawImageRegion(
int componentHandle,
string path,
int source_x,
int source_y,
int source_width,
int source_height,
int dest_x,
int dest_y,
int? dest_width = null,
int? dest_height = null)
{
if (!File.Exists(path))
{
@ -867,7 +898,15 @@ namespace BizHawk.Client.EmuHawk
"drawArc",
"draws a Arc shape at the given coordinates and the given width and height"
)]
public void DrawArc(int componentHandle, int x, int y, int width, int height, int startangle, int sweepangle, [LuaColorParam] object line = null)
public void DrawArc(
int componentHandle,
int x,
int y,
int width,
int height,
int startangle,
int sweepangle,
[LuaColorParam] object line = null)
{
try
{
@ -967,7 +1006,13 @@ namespace BizHawk.Client.EmuHawk
[LuaMethod(
"drawPolygon",
"Draws a polygon using the table of coordinates specified in points. This should be a table of tables(each of size 2). If x or y is passed, the polygon will be translated by the passed coordinate pair. Line is the color of the polygon. Background is the optional fill color")]
public void DrawPolygon(int componentHandle, LuaTable points, int? x = null, int? y = null, [LuaColorParam] object line = null, [LuaColorParam] object background = null)
public void DrawPolygon(
int componentHandle,
LuaTable points,
int? x = null,
int? y = null,
[LuaColorParam] object line = null,
[LuaColorParam] object background = null)
{
try
{
@ -999,7 +1044,14 @@ namespace BizHawk.Client.EmuHawk
[LuaMethod(
"drawRectangle",
"Draws a rectangle at the given coordinate and the given width and height. Line is the color of the box. Background is the optional fill color")]
public void DrawRectangle(int componentHandle, int x, int y, int width, int height, [LuaColorParam] object line = null, [LuaColorParam] object background = null)
public void DrawRectangle(
int componentHandle,
int x,
int y,
int width,
int height,
[LuaColorParam] object line = null,
[LuaColorParam] object background = null)
{
try
{

View File

@ -165,9 +165,10 @@ namespace BizHawk.Client.EmuHawk
[LuaMethodExample("local nltasget = tastudio.getselection( );")]
[LuaMethod("getselection", "gets the currently selected frames")]
public LuaTable GetSelection() => Engaged()
? _th.EnumerateToLuaTable(Tastudio.GetSelection(), indexFrom: 0)
: _th.CreateTable();
public LuaTable GetSelection()
=> Engaged()
? _th.EnumerateToLuaTable(Tastudio.GetSelection(), indexFrom: 0)
: _th.CreateTable();
[LuaMethodExample("")]
[LuaMethod("submitinputchange", "")]

View File

@ -174,7 +174,13 @@ namespace BizHawk.Client.EmuHawk
[LuaMethod(
"DrawBox",
"Draws a rectangle on screen from x1/y1 to x2/y2. Same as drawRectangle except it receives two points intead of a point and width/height")]
public void DrawBox(int x, int y, int x2, int y2, [LuaColorParam] object line = null, [LuaColorParam] object background = null)
public void DrawBox(
int x,
int y,
int x2,
int y2,
[LuaColorParam] object line = null,
[LuaColorParam] object background = null)
{
try
{
@ -191,7 +197,13 @@ namespace BizHawk.Client.EmuHawk
[LuaMethod(
"DrawEllipse",
"Draws an ellipse at the given coordinates and the given width and height. Line is the color of the ellipse. Background is the optional fill color")]
public void DrawEllipse(int x, int y, int width, int height, [LuaColorParam] object line = null, [LuaColorParam] object background = null)
public void DrawEllipse(
int x,
int y,
int width,
int height,
[LuaColorParam] object line = null,
[LuaColorParam] object background = null)
{
try
{
@ -251,7 +263,16 @@ namespace BizHawk.Client.EmuHawk
[LuaMethod(
"DrawImageRegion",
"draws a given region of an image file from the given path at the given coordinate, and optionally with the given size")]
public void DrawImageRegion(string path, int sourceX, int sourceY, int sourceWidth, int sourceHeight, int destX, int destY, int? destWidth = null, int? destHeight = null)
public void DrawImageRegion(
string path,
int sourceX,
int sourceY,
int sourceWidth,
int sourceHeight,
int destX,
int destY,
int? destWidth = null,
int? destHeight = null)
{
if (!File.Exists(path))
{
@ -288,7 +309,14 @@ namespace BizHawk.Client.EmuHawk
"DrawArc",
"draws a Arc shape at the given coordinates and the given width and height"
)]
public void DrawArc(int x, int y, int width, int height, int startAngle, int sweepAngle, [LuaColorParam] object line = null)
public void DrawArc(
int x,
int y,
int width,
int height,
int startAngle,
int sweepAngle,
[LuaColorParam] object line = null)
{
luaPictureBox.DrawArc(x, y, width, height, startAngle, sweepAngle, _th.SafeParseColor(line));
}
@ -333,7 +361,12 @@ namespace BizHawk.Client.EmuHawk
[LuaMethod(
"DrawPolygon",
"Draws a polygon using the table of coordinates specified in points. This should be a table of tables(each of size 2). Line is the color of the polygon. Background is the optional fill color")]
public void DrawPolygon(LuaTable points, int? x = null, int? y = null, [LuaColorParam] object line = null, [LuaColorParam] object background = null)
public void DrawPolygon(
LuaTable points,
int? x = null,
int? y = null,
[LuaColorParam] object line = null,
[LuaColorParam] object background = null)
{
try
{
@ -351,7 +384,13 @@ namespace BizHawk.Client.EmuHawk
[LuaMethod(
"DrawRectangle",
"Draws a rectangle at the given coordinate and the given width and height. Line is the color of the box. Background is the optional fill color")]
public void DrawRectangle(int x, int y, int width, int height, [LuaColorParam] object line = null, [LuaColorParam] object background = null)
public void DrawRectangle(
int x,
int y,
int width,
int height,
[LuaColorParam] object line = null,
[LuaColorParam] object background = null)
{
luaPictureBox.DrawRectangle(x, y, width, height, _th.SafeParseColor(line), _th.SafeParseColor(background));
}