rename LuaMethodAttributes to LuaMethodAttribute so as not to be a bad person

This commit is contained in:
adelikat 2017-07-10 14:02:00 -05:00
parent 0f686a0de1
commit 9581ce6a93
27 changed files with 372 additions and 538 deletions

View File

@ -16,92 +16,92 @@ namespace BizHawk.Client.Common
public override string Name => "bit";
[LuaMethodAttributes("band", "Bitwise AND of 'val' against 'amt'")]
[LuaMethod("band", "Bitwise AND of 'val' against 'amt'")]
public static uint Band(uint val, uint amt)
{
return val & amt;
}
[LuaMethodAttributes("bnot", "Bitwise NOT of 'val' against 'amt'")]
[LuaMethod("bnot", "Bitwise NOT of 'val' against 'amt'")]
public static uint Bnot(uint val)
{
return ~val;
}
[LuaMethodAttributes("bor", "Bitwise OR of 'val' against 'amt'")]
[LuaMethod("bor", "Bitwise OR of 'val' against 'amt'")]
public static uint Bor(uint val, uint amt)
{
return val | amt;
}
[LuaMethodAttributes("bxor", "Bitwise XOR of 'val' against 'amt'")]
[LuaMethod("bxor", "Bitwise XOR of 'val' against 'amt'")]
public static uint Bxor(uint val, uint amt)
{
return val ^ amt;
}
[LuaMethodAttributes("lshift", "Logical shift left of 'val' by 'amt' bits")]
[LuaMethod("lshift", "Logical shift left of 'val' by 'amt' bits")]
public static uint Lshift(uint val, int amt)
{
return val << amt;
}
[LuaMethodAttributes("rol", "Left rotate 'val' by 'amt' bits")]
[LuaMethod("rol", "Left rotate 'val' by 'amt' bits")]
public static uint Rol(uint val, int amt)
{
return (val << amt) | (val >> (32 - amt));
}
[LuaMethodAttributes("ror", "Right rotate 'val' by 'amt' bits")]
[LuaMethod("ror", "Right rotate 'val' by 'amt' bits")]
public static uint Ror(uint val, int amt)
{
return (val >> amt) | (val << (32 - amt));
}
[LuaMethodAttributes("rshift", "Logical shift right of 'val' by 'amt' bits")]
[LuaMethod("rshift", "Logical shift right of 'val' by 'amt' bits")]
public static uint Rshift(uint val, int amt)
{
return (uint)(val >> amt);
}
[LuaMethodAttributes("arshift", "Arithmetic shift right of 'val' by 'amt' bits")]
[LuaMethod("arshift", "Arithmetic shift right of 'val' by 'amt' bits")]
public static int Arshift(int val, int amt)
{
return val >> amt;
}
[LuaMethodAttributes("check", "Returns result of bit 'pos' being set in 'num'")]
[LuaMethod("check", "Returns result of bit 'pos' being set in 'num'")]
public static bool Check(long num, int pos)
{
return (num & (1 << pos)) != 0;
}
[LuaMethodAttributes("set", "Sets the bit 'pos' in 'num'")]
[LuaMethod("set", "Sets the bit 'pos' in 'num'")]
public static uint Set(uint num, int pos)
{
return (uint)(num | (uint)1 << pos);
}
[LuaMethodAttributes("clear", "Clears the bit 'pos' in 'num'")]
[LuaMethod("clear", "Clears the bit 'pos' in 'num'")]
public static long Clear(uint num, int pos)
{
return num & ~(1 << pos);
}
[LuaMethodAttributes("byteswap_16", "Byte swaps 'short', i.e. bit.byteswap_16(0xFF00) would return 0x00FF")]
[LuaMethod("byteswap_16", "Byte swaps 'short', i.e. bit.byteswap_16(0xFF00) would return 0x00FF")]
public static ushort Byteswap16(ushort val)
{
return (ushort)((val & 0xFFU) << 8 | (val & 0xFF00U) >> 8);
}
[LuaMethodAttributes("byteswap_32", "Byte swaps 'dword'")]
[LuaMethod("byteswap_32", "Byte swaps 'dword'")]
public static uint Byteswap32(uint val)
{
return (val & 0x000000FFU) << 24 | (val & 0x0000FF00U) << 8 |
(val & 0x00FF0000U) >> 8 | (val & 0xFF000000U) >> 24;
}
[LuaMethodAttributes("byteswap_64", "Byte swaps 'long'")]
[LuaMethod("byteswap_64", "Byte swaps 'long'")]
public static ulong Byteswap64(ulong val)
{
return (val & 0x00000000000000FFUL) << 56 | (val & 0x000000000000FF00UL) << 40 |

View File

@ -48,25 +48,25 @@ namespace BizHawk.Client.Common
public override string Name => "emu";
[LuaMethodAttributes("displayvsync", "Sets the display vsync property of the emulator")]
[LuaMethod("displayvsync", "Sets the display vsync property of the emulator")]
public static void DisplayVsync(bool enabled)
{
Global.Config.VSync = enabled;
}
[LuaMethodAttributes("frameadvance", "Signals to the emulator to resume emulation. Necessary for any lua script while loop or else the emulator will freeze!")]
[LuaMethod("frameadvance", "Signals to the emulator to resume emulation. Necessary for any lua script while loop or else the emulator will freeze!")]
public void FrameAdvance()
{
FrameAdvanceCallback();
}
[LuaMethodAttributes("framecount", "Returns the current frame count")]
[LuaMethod("framecount", "Returns the current frame count")]
public int FrameCount()
{
return Emulator.Frame;
}
[LuaMethodAttributes("disassemble", "Returns the disassembly object (disasm string and length int) for the given PC address. Uses System Bus domain if no domain name provided")]
[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 = "")
{
try
@ -95,8 +95,7 @@ namespace BizHawk.Client.Common
}
// TODO: what about 64 bit registers?
[LuaMethodAttributes(
"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")]
[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)
{
try
@ -118,8 +117,7 @@ namespace BizHawk.Client.Common
}
}
[LuaMethodAttributes(
"getregisters", "returns the complete set of available flags and registers for a given core")]
[LuaMethod("getregisters", "returns the complete set of available flags and registers for a given core")]
public LuaTable GetRegisters()
{
var table = Lua.NewTable();
@ -144,7 +142,7 @@ namespace BizHawk.Client.Common
return table;
}
[LuaMethodAttributes("setregister", "sets the given register name to the given value")]
[LuaMethod("setregister", "sets the given register name to the given value")]
public void SetRegister(string register, int value)
{
try
@ -162,7 +160,7 @@ namespace BizHawk.Client.Common
}
}
[LuaMethodAttributes("totalexecutedcycles", "gets the total number of executed cpu cycles")]
[LuaMethod("totalexecutedcycles", "gets the total number of executed cpu cycles")]
public int TotalExecutedycles()
{
try
@ -182,13 +180,13 @@ namespace BizHawk.Client.Common
}
}
[LuaMethodAttributes("getsystemid", "Returns the ID string of the current core loaded. Note: No ROM loaded will return the string NULL")]
[LuaMethod("getsystemid", "Returns the ID string of the current core loaded. Note: No ROM loaded will return the string NULL")]
public static string GetSystemId()
{
return Global.Game.System;
}
[LuaMethodAttributes("islagged", "Returns whether or not the current frame is a lag frame")]
[LuaMethod("islagged", "Returns whether or not the current frame is a lag frame")]
public bool IsLagged()
{
if (InputPollableCore != null)
@ -200,7 +198,7 @@ namespace BizHawk.Client.Common
return false;
}
[LuaMethodAttributes("setislagged", "Sets the lag flag for the current frame. If no value is provided, it will default to 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)
{
if (InputPollableCore != null)
@ -213,7 +211,7 @@ namespace BizHawk.Client.Common
}
}
[LuaMethodAttributes("lagcount", "Returns the current lag count")]
[LuaMethod("lagcount", "Returns the current lag count")]
public int LagCount()
{
if (InputPollableCore != null)
@ -225,7 +223,7 @@ namespace BizHawk.Client.Common
return 0;
}
[LuaMethodAttributes("setlagcount", "Sets the current lag count")]
[LuaMethod("setlagcount", "Sets the current lag count")]
public void SetLagCount(int count)
{
if (InputPollableCore != null)
@ -238,19 +236,19 @@ namespace BizHawk.Client.Common
}
}
[LuaMethodAttributes("limitframerate", "sets the limit framerate property of the emulator")]
[LuaMethod("limitframerate", "sets the limit framerate property of the emulator")]
public static void LimitFramerate(bool enabled)
{
Global.Config.ClockThrottle = enabled;
}
[LuaMethodAttributes("minimizeframeskip", "Sets the autominimizeframeskip value of the emulator")]
[LuaMethod("minimizeframeskip", "Sets the autominimizeframeskip value of the emulator")]
public static void MinimizeFrameskip(bool enabled)
{
Global.Config.AutoMinimizeSkipping = enabled;
}
[LuaMethodAttributes("setrenderplanes", "Toggles the drawing of sprites and background planes. Set to false or nil to disable a pane, anything else will draw them")]
[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)
{
if (Emulator is NES)
@ -324,13 +322,13 @@ namespace BizHawk.Client.Common
return true;
}
[LuaMethodAttributes("yield", "allows a script to run while emulation is paused and interact with the gui/main window in realtime ")]
[LuaMethod("yield", "allows a script to run while emulation is paused and interact with the gui/main window in realtime ")]
public void Yield()
{
YieldCallback();
}
[LuaMethodAttributes("getdisplaytype", "returns the display type (PAL vs NTSC) that the emulator is currently running in")]
[LuaMethod("getdisplaytype", "returns the display type (PAL vs NTSC) that the emulator is currently running in")]
public string GetDisplayType()
{
if (RegionableCore != null)
@ -341,7 +339,7 @@ namespace BizHawk.Client.Common
return "";
}
[LuaMethodAttributes("getboardname", "returns (if available) the board name of the loaded ROM")]
[LuaMethod("getboardname", "returns (if available) the board name of the loaded ROM")]
public string GetBoardName()
{
if (BoardInfo != null)

View File

@ -156,8 +156,7 @@ namespace BizHawk.Client.Common
#endregion
[LuaMethodAttributes(
"onframeend", "Calls the given lua function at the end of each frame, after all emulation and drawing has completed. Note: this is the default behavior of lua scripts")]
[LuaMethod("onframeend", "Calls the given lua function at the end of each frame, after all emulation and drawing has completed. Note: this is the default behavior of lua scripts")]
public string OnFrameEnd(LuaFunction luaf, string name = null)
{
var nlf = new NamedLuaFunction(luaf, "OnFrameEnd", LogOutputCallback, CurrentThread, name);
@ -165,8 +164,7 @@ namespace BizHawk.Client.Common
return nlf.Guid.ToString();
}
[LuaMethodAttributes(
"onframestart", "Calls the given lua function at the beginning of each frame before any emulation and drawing occurs")]
[LuaMethod("onframestart", "Calls the given lua function at the beginning of each frame before any emulation and drawing occurs")]
public string OnFrameStart(LuaFunction luaf, string name = null)
{
var nlf = new NamedLuaFunction(luaf, "OnFrameStart", LogOutputCallback, CurrentThread, name);
@ -174,8 +172,7 @@ namespace BizHawk.Client.Common
return nlf.Guid.ToString();
}
[LuaMethodAttributes(
"oninputpoll", "Calls the given lua function after each time the emulator core polls for input")]
[LuaMethod("oninputpoll", "Calls the given lua function after each time the emulator core polls for input")]
public string OnInputPoll(LuaFunction luaf, string name = null)
{
var nlf = new NamedLuaFunction(luaf, "OnInputPoll", LogOutputCallback, CurrentThread, name);
@ -204,8 +201,7 @@ namespace BizHawk.Client.Common
Log($"Error: {Emulator.Attributes().CoreName} does not yet implement input polling callbacks");
}
[LuaMethodAttributes(
"onloadstate", "Fires after a state is loaded. Receives a lua function name, and registers it to the event immediately following a successful savestate event")]
[LuaMethod("onloadstate", "Fires after a state is loaded. Receives a lua function name, and registers it to the event immediately following a successful savestate event")]
public string OnLoadState(LuaFunction luaf, string name = null)
{
var nlf = new NamedLuaFunction(luaf, "OnSavestateLoad", LogOutputCallback, CurrentThread, name);
@ -213,7 +209,7 @@ namespace BizHawk.Client.Common
return nlf.Guid.ToString();
}
[LuaMethodAttributes("onmemoryexecute", "Fires after the given address is executed by the core")]
[LuaMethod("onmemoryexecute", "Fires after the given address is executed by the core")]
public string OnMemoryExecute(LuaFunction luaf, uint address, string name = null)
{
try
@ -244,8 +240,7 @@ namespace BizHawk.Client.Common
return Guid.Empty.ToString();
}
[LuaMethodAttributes(
"onmemoryread", "Fires after the given address is read by the core. If no address is given, it will attach to every memory read")]
[LuaMethod("onmemoryread", "Fires after the given address is read by the core. If no address is given, it will attach to every memory read")]
public string OnMemoryRead(LuaFunction luaf, uint? address = null, string name = null)
{
try
@ -275,8 +270,7 @@ namespace BizHawk.Client.Common
return Guid.Empty.ToString();
}
[LuaMethodAttributes(
"onmemorywrite", "Fires after the given address is written by the core. If no address is given, it will attach to every memory write")]
[LuaMethod("onmemorywrite", "Fires after the given address is written by the core. If no address is given, it will attach to every memory write")]
public string OnMemoryWrite(LuaFunction luaf, uint? address = null, string name = null)
{
try
@ -306,7 +300,7 @@ namespace BizHawk.Client.Common
return Guid.Empty.ToString();
}
[LuaMethodAttributes("onsavestate", "Fires after a state is saved")]
[LuaMethod("onsavestate", "Fires after a state is saved")]
public string OnSaveState(LuaFunction luaf, string name = null)
{
var nlf = new NamedLuaFunction(luaf, "OnSavestateSave", LogOutputCallback, CurrentThread, name);
@ -314,7 +308,7 @@ namespace BizHawk.Client.Common
return nlf.Guid.ToString();
}
[LuaMethodAttributes("onexit", "Fires after the calling script has stopped")]
[LuaMethod("onexit", "Fires after the calling script has stopped")]
public string OnExit(LuaFunction luaf, string name = null)
{
var nlf = new NamedLuaFunction(luaf, "OnExit", LogOutputCallback, CurrentThread, name);
@ -322,8 +316,7 @@ namespace BizHawk.Client.Common
return nlf.Guid.ToString();
}
[LuaMethodAttributes(
"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.")]
[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)
{
foreach (var nlf in _luaFunctions.Where(nlf => nlf.Guid.ToString() == guid.ToString()))
@ -335,8 +328,7 @@ namespace BizHawk.Client.Common
return false;
}
[LuaMethodAttributes(
"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.")]
[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)
{
foreach (var nlf in _luaFunctions.Where(nlf => nlf.Name == name))

View File

@ -18,8 +18,7 @@ namespace BizHawk.Client.Common
public override string Name => "gameinfo";
[LuaMethodAttributes(
"getromname", "returns the path of the currently loaded rom, if a rom is loaded")]
[LuaMethod("getromname", "returns the path of the currently loaded rom, if a rom is loaded")]
public string GetRomName()
{
if (Global.Game != null)
@ -30,8 +29,7 @@ namespace BizHawk.Client.Common
return "";
}
[LuaMethodAttributes(
"getromhash", "returns the hash of the currently loaded rom, if a rom is loaded")]
[LuaMethod("getromhash", "returns the hash of the currently loaded rom, if a rom is loaded")]
public string GetRomHash()
{
if (Global.Game != null)
@ -42,8 +40,7 @@ namespace BizHawk.Client.Common
return "";
}
[LuaMethodAttributes(
"indatabase", "returns whether or not the currently loaded rom is in the game database")]
[LuaMethod("indatabase", "returns whether or not the currently loaded rom is in the game database")]
public bool InDatabase()
{
if (Global.Game != null)
@ -54,8 +51,7 @@ namespace BizHawk.Client.Common
return false;
}
[LuaMethodAttributes(
"getstatus", "returns the game database status of the currently loaded rom. Statuses are for example: GoodDump, BadDump, Hack, Unknown, NotInDatabase")]
[LuaMethod("getstatus", "returns the game database status of the currently loaded rom. Statuses are for example: GoodDump, BadDump, Hack, Unknown, NotInDatabase")]
public string GetStatus()
{
if (Global.Game != null)
@ -66,8 +62,7 @@ namespace BizHawk.Client.Common
return "";
}
[LuaMethodAttributes(
"isstatusbad", "returns the currently loaded rom's game database status is considered 'bad'")]
[LuaMethod("isstatusbad", "returns the currently loaded rom's game database status is considered 'bad'")]
public bool IsStatusBad()
{
if (Global.Game != null)
@ -78,15 +73,13 @@ namespace BizHawk.Client.Common
return true;
}
[LuaMethodAttributes(
"getboardtype", "returns identifying information about the 'mapper' or similar capability used for this game. empty if no such useful distinction can be drawn")]
[LuaMethod("getboardtype", "returns identifying information about the 'mapper' or similar capability used for this game. empty if no such useful distinction can be drawn")]
public string GetBoardType()
{
return BoardInfo?.BoardName ?? "";
}
[LuaMethodAttributes(
"getoptions", "returns the game options for the currently loaded rom. Options vary per platform")]
[LuaMethod("getoptions", "returns the game options for the currently loaded rom. Options vary per platform")]
public LuaTable GetOptions()
{
var options = Lua.NewTable();

View File

@ -37,33 +37,25 @@ namespace BizHawk.Client.Common
Genesis?.PutSettings(settings);
}
[LuaMethodAttributes(
"getlayer_bga",
"Returns whether the bg layer A is displayed")]
[LuaMethod("getlayer_bga", "Returns whether the bg layer A is displayed")]
public bool GetLayerBgA()
{
return GetSettings().DrawBGA;
}
[LuaMethodAttributes(
"getlayer_bgb",
"Returns whether the bg layer B is displayed")]
[LuaMethod("getlayer_bgb", "Returns whether the bg layer B is displayed")]
public bool GetLayerBgB()
{
return GetSettings().DrawBGB;
}
[LuaMethodAttributes(
"getlayer_bgw",
"Returns whether the bg layer W is displayed")]
[LuaMethod("getlayer_bgw", "Returns whether the bg layer W is displayed")]
public bool GetLayerBgW()
{
return GetSettings().DrawBGW;
}
[LuaMethodAttributes(
"setlayer_bga",
"Sets whether the bg layer A is displayed")]
[LuaMethod("setlayer_bga", "Sets whether the bg layer A is displayed")]
public void SetLayerBgA(bool value)
{
var s = GetSettings();
@ -71,9 +63,7 @@ namespace BizHawk.Client.Common
PutSettings(s);
}
[LuaMethodAttributes(
"setlayer_bgb",
"Sets whether the bg layer B is displayed")]
[LuaMethod("setlayer_bgb", "Sets whether the bg layer B is displayed")]
public void SetLayerBgB(bool value)
{
var s = GetSettings();
@ -81,9 +71,7 @@ namespace BizHawk.Client.Common
PutSettings(s);
}
[LuaMethodAttributes(
"setlayer_bgw",
"Sets whether the bg layer W is displayed")]
[LuaMethod("setlayer_bgw", "Sets whether the bg layer W is displayed")]
public void SetLayerBgW(bool value)
{
var s = GetSettings();

View File

@ -13,8 +13,7 @@ namespace BizHawk.Client.Common
public override string Name => "joypad";
[LuaMethodAttributes(
"get", "returns a lua table of the controller buttons pressed. If supplied, it will only return a table of buttons for the given controller")]
[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)
{
var buttons = Lua.NewTable();
@ -51,8 +50,7 @@ namespace BizHawk.Client.Common
}
// TODO: what about float controls?
[LuaMethodAttributes(
"getimmediate", "returns a lua table of any controller buttons currently pressed by the user")]
[LuaMethod("getimmediate", "returns a lua table of any controller buttons currently pressed by the user")]
public LuaTable GetImmediate()
{
var buttons = Lua.NewTable();
@ -64,8 +62,7 @@ namespace BizHawk.Client.Common
return buttons;
}
[LuaMethodAttributes(
"setfrommnemonicstr", "sets the given buttons to their provided values for the current frame, string will be interpretted the same way an entry from a movie input log would be")]
[LuaMethod("setfrommnemonicstr", "sets the given buttons to their provided values for the current frame, string will be interpretted the same way an entry from a movie input log would be")]
public void SetFromMnemonicStr(string inputLogEntry)
{
try
@ -89,8 +86,7 @@ namespace BizHawk.Client.Common
}
}
[LuaMethodAttributes(
"set", "sets the given buttons to their provided values for the current frame")]
[LuaMethod("set", "sets the given buttons to their provided values for the current frame")]
public void Set(LuaTable buttons, int? controller = null)
{
try
@ -154,8 +150,7 @@ namespace BizHawk.Client.Common
}
}
[LuaMethodAttributes(
"setanalog", "sets the given analog controls to their provided values for the current frame. Note that unlike set() there is only the logic of overriding with the given value.")]
[LuaMethod("setanalog", "sets the given analog controls to their provided values for the current frame. Note that unlike set() there is only the logic of overriding with the given value.")]
public void SetAnalog(LuaTable controls, object controller = null)
{
try

View File

@ -37,13 +37,13 @@ namespace BizHawk.Client.Common
#region Unique Library Methods
[LuaMethodAttributes("getname", "returns the name of the domain defined as main memory for the given core")]
[LuaMethod("getname", "returns the name of the domain defined as main memory for the given core")]
public string GetName()
{
return Domain.Name;
}
[LuaMethodAttributes("getcurrentmemorydomainsize", "Returns the number of bytes of the domain defined as main memory")]
[LuaMethod("getcurrentmemorydomainsize", "Returns the number of bytes of the domain defined as main memory")]
public uint GetSize()
{
return (uint)Domain.Size;
@ -53,40 +53,37 @@ namespace BizHawk.Client.Common
#region Common Special and Legacy Methods
[LuaMethodAttributes("readbyte", "gets the value from the given address as an unsigned byte")]
[LuaMethod("readbyte", "gets the value from the given address as an unsigned byte")]
public uint ReadByte(int addr)
{
return ReadUnsignedByte(addr);
}
[LuaMethodAttributes("writebyte", "Writes the given value to the given address as an unsigned byte")]
[LuaMethod("writebyte", "Writes the given value to the given address as an unsigned byte")]
public void WriteByte(int addr, uint value)
{
WriteUnsignedByte(addr, value);
}
[LuaMethodAttributes(
"readbyterange", "Reads the address range that starts from address, and is length long. Returns the result into a table of key value pairs (where the address is the key).")]
[LuaMethod("readbyterange", "Reads the address range that starts from address, and is length long. Returns the result into a table of key value pairs (where the address is the key).")]
public LuaTable ReadByteRange(int addr, int length)
{
return base.ReadByteRange(addr, length);
}
[LuaMethodAttributes("writebyterange", "Writes the given values to the given addresses as unsigned bytes")]
[LuaMethod("writebyterange", "Writes the given values to the given addresses as unsigned bytes")]
public void WriteByteRange(LuaTable memoryblock)
{
base.WriteByteRange(memoryblock);
}
[LuaMethodAttributes(
"readfloat", "Reads the given address as a 32-bit float value from the main memory domain with th e given endian")]
[LuaMethod("readfloat", "Reads the given address as a 32-bit float value from the main memory domain with th e given endian")]
public float ReadFloat(int addr, bool bigendian)
{
return base.ReadFloat(addr, bigendian);
}
[LuaMethodAttributes(
"writefloat", "Writes the given 32-bit float value to the given address and endian")]
[LuaMethod("writefloat", "Writes the given 32-bit float value to the given address and endian")]
public void WriteFloat(int addr, double value, bool bigendian)
{
base.WriteFloat(addr, value, bigendian);
@ -96,25 +93,25 @@ namespace BizHawk.Client.Common
#region 1 Byte
[LuaMethodAttributes("read_s8", "read signed byte")]
[LuaMethod("read_s8", "read signed byte")]
public int ReadS8(int addr)
{
return (sbyte)ReadUnsignedByte(addr);
}
[LuaMethodAttributes("write_s8", "write signed byte")]
[LuaMethod("write_s8", "write signed byte")]
public void WriteS8(int addr, uint value)
{
WriteUnsignedByte(addr, value);
}
[LuaMethodAttributes("read_u8", "read unsigned byte")]
[LuaMethod("read_u8", "read unsigned byte")]
public uint ReadU8(int addr)
{
return ReadUnsignedByte(addr);
}
[LuaMethodAttributes("write_u8", "write unsigned byte")]
[LuaMethod("write_u8", "write unsigned byte")]
public void WriteU8(int addr, uint value)
{
WriteUnsignedByte(addr, value);
@ -124,49 +121,49 @@ namespace BizHawk.Client.Common
#region 2 Byte
[LuaMethodAttributes("read_s16_le", "read signed 2 byte value, little endian")]
[LuaMethod("read_s16_le", "read signed 2 byte value, little endian")]
public int ReadS16Little(int addr)
{
return ReadSignedLittleCore(addr, 2);
}
[LuaMethodAttributes("write_s16_le", "write signed 2 byte value, little endian")]
[LuaMethod("write_s16_le", "write signed 2 byte value, little endian")]
public void WriteS16Little(int addr, int value)
{
WriteSignedLittle(addr, value, 2);
}
[LuaMethodAttributes("read_s16_be", "read signed 2 byte value, big endian")]
[LuaMethod("read_s16_be", "read signed 2 byte value, big endian")]
public int ReadS16Big(int addr)
{
return ReadSignedBig(addr, 2);
}
[LuaMethodAttributes("write_s16_be", "write signed 2 byte value, big endian")]
[LuaMethod("write_s16_be", "write signed 2 byte value, big endian")]
public void WriteS16Big(int addr, int value)
{
WriteSignedBig(addr, value, 2);
}
[LuaMethodAttributes("read_u16_le", "read unsigned 2 byte value, little endian")]
[LuaMethod("read_u16_le", "read unsigned 2 byte value, little endian")]
public uint ReadU16Little(int addr)
{
return ReadSignedLittle(addr, 2);
}
[LuaMethodAttributes("write_u16_le", "write unsigned 2 byte value, little endian")]
[LuaMethod("write_u16_le", "write unsigned 2 byte value, little endian")]
public void WriteU16Little(int addr, uint value)
{
WriteUnsignedLittle(addr, value, 2);
}
[LuaMethodAttributes("read_u16_be", "read unsigned 2 byte value, big endian")]
[LuaMethod("read_u16_be", "read unsigned 2 byte value, big endian")]
public uint ReadU16Big(int addr)
{
return ReadUnsignedBig(addr, 2);
}
[LuaMethodAttributes("write_u16_be", "write unsigned 2 byte value, big endian")]
[LuaMethod("write_u16_be", "write unsigned 2 byte value, big endian")]
public void WriteU16Big(int addr, uint value)
{
WriteUnsignedBig(addr, value, 2);
@ -176,49 +173,49 @@ namespace BizHawk.Client.Common
#region 3 Byte
[LuaMethodAttributes("read_s24_le", "read signed 24 bit value, little endian")]
[LuaMethod("read_s24_le", "read signed 24 bit value, little endian")]
public int ReadS24Little(int addr)
{
return ReadSignedLittleCore(addr, 3);
}
[LuaMethodAttributes("write_s24_le", "write signed 24 bit value, little endian")]
[LuaMethod("write_s24_le", "write signed 24 bit value, little endian")]
public void WriteS24Little(int addr, int value)
{
WriteSignedLittle(addr, value, 3);
}
[LuaMethodAttributes("read_s24_be", "read signed 24 bit value, big endian")]
[LuaMethod("read_s24_be", "read signed 24 bit value, big endian")]
public int ReadS24Big(int addr)
{
return ReadSignedBig(addr, 3);
}
[LuaMethodAttributes("write_s24_be", "write signed 24 bit value, big endian")]
[LuaMethod("write_s24_be", "write signed 24 bit value, big endian")]
public void WriteS24Big(int addr, int value)
{
WriteSignedBig(addr, value, 3);
}
[LuaMethodAttributes("read_u24_le", "read unsigned 24 bit value, little endian")]
[LuaMethod("read_u24_le", "read unsigned 24 bit value, little endian")]
public uint ReadU24Little(int addr)
{
return ReadSignedLittle(addr, 3);
}
[LuaMethodAttributes("write_u24_le", "write unsigned 24 bit value, little endian")]
[LuaMethod("write_u24_le", "write unsigned 24 bit value, little endian")]
public void WriteU24Little(int addr, uint value)
{
WriteUnsignedLittle(addr, value, 3);
}
[LuaMethodAttributes("read_u24_be", "read unsigned 24 bit value, big endian")]
[LuaMethod("read_u24_be", "read unsigned 24 bit value, big endian")]
public uint ReadU24Big(int addr)
{
return ReadUnsignedBig(addr, 3);
}
[LuaMethodAttributes("write_u24_be", "write unsigned 24 bit value, big endian")]
[LuaMethod("write_u24_be", "write unsigned 24 bit value, big endian")]
public void WriteU24Big(int addr, uint value)
{
WriteUnsignedBig(addr, value, 3);
@ -228,49 +225,49 @@ namespace BizHawk.Client.Common
#region 4 Byte
[LuaMethodAttributes("read_s32_le", "read signed 4 byte value, little endian")]
[LuaMethod("read_s32_le", "read signed 4 byte value, little endian")]
public int ReadS32Little(int addr)
{
return ReadSignedLittleCore(addr, 4);
}
[LuaMethodAttributes("write_s32_le", "write signed 4 byte value, little endian")]
[LuaMethod("write_s32_le", "write signed 4 byte value, little endian")]
public void WriteS32Little(int addr, int value)
{
WriteSignedLittle(addr, value, 4);
}
[LuaMethodAttributes("read_s32_be", "read signed 4 byte value, big endian")]
[LuaMethod("read_s32_be", "read signed 4 byte value, big endian")]
public int ReadS32Big(int addr)
{
return ReadSignedBig(addr, 4);
}
[LuaMethodAttributes("write_s32_be", "write signed 4 byte value, big endian")]
[LuaMethod("write_s32_be", "write signed 4 byte value, big endian")]
public void WriteS32Big(int addr, int value)
{
WriteSignedBig(addr, value, 4);
}
[LuaMethodAttributes("read_u32_le", "read unsigned 4 byte value, little endian")]
[LuaMethod("read_u32_le", "read unsigned 4 byte value, little endian")]
public uint ReadU32Little(int addr)
{
return ReadSignedLittle(addr, 4);
}
[LuaMethodAttributes("write_u32_le", "write unsigned 4 byte value, little endian")]
[LuaMethod("write_u32_le", "write unsigned 4 byte value, little endian")]
public void WriteU32Little(int addr, uint value)
{
WriteUnsignedLittle(addr, value, 4);
}
[LuaMethodAttributes("read_u32_be", "read unsigned 4 byte value, big endian")]
[LuaMethod("read_u32_be", "read unsigned 4 byte value, big endian")]
public uint ReadU32Big(int addr)
{
return ReadUnsignedBig(addr, 4);
}
[LuaMethodAttributes("write_u32_be", "write unsigned 4 byte value, big endian")]
[LuaMethod("write_u32_be", "write unsigned 4 byte value, big endian")]
public void WriteU32Big(int addr, uint value)
{
WriteUnsignedBig(addr, value, 4);

View File

@ -48,8 +48,7 @@ namespace BizHawk.Client.Common
#region Unique Library Methods
[LuaMethodAttributes(
"getmemorydomainlist", "Returns a string of the memory domains for the loaded platform core. List will be a single string delimited by line feeds")]
[LuaMethod("getmemorydomainlist", "Returns a string of the memory domains for the loaded platform core. List will be a single string delimited by line feeds")]
public LuaTable GetMemoryDomainList()
{
var table = Lua.NewTable();
@ -64,8 +63,7 @@ namespace BizHawk.Client.Common
return table;
}
[LuaMethodAttributes(
"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")]
[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 = "")
{
if (string.IsNullOrEmpty(name))
@ -76,22 +74,19 @@ namespace BizHawk.Client.Common
return (uint)DomainList[VerifyMemoryDomain(name)].Size;
}
[LuaMethodAttributes(
"getcurrentmemorydomain", "Returns a string name of the current memory domain selected by Lua. The default is Main memory")]
[LuaMethod("getcurrentmemorydomain", "Returns a string name of the current memory domain selected by Lua. The default is Main memory")]
public string GetCurrentMemoryDomain()
{
return Domain.Name;
}
[LuaMethodAttributes(
"getcurrentmemorydomainsize", "Returns the number of bytes of the current memory domain selected by Lua. The default is Main memory")]
[LuaMethod("getcurrentmemorydomainsize", "Returns the number of bytes of the current memory domain selected by Lua. The default is Main memory")]
public uint GetCurrentMemoryDomainSize()
{
return (uint)Domain.Size;
}
[LuaMethodAttributes(
"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")]
[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)
{
try
@ -117,37 +112,37 @@ namespace BizHawk.Client.Common
#region Common Special and Legacy Methods
[LuaMethodAttributes("readbyte", "gets the value from the given address as an unsigned byte")]
[LuaMethod("readbyte", "gets the value from the given address as an unsigned byte")]
public uint ReadByte(int addr, string domain = null)
{
return ReadUnsignedByte(addr, domain);
}
[LuaMethodAttributes("writebyte", "Writes the given value to the given address as an unsigned byte")]
[LuaMethod("writebyte", "Writes the given value to the given address as an unsigned byte")]
public void WriteByte(int addr, uint value, string domain = null)
{
WriteUnsignedByte(addr, value, domain);
}
[LuaMethodAttributes("readbyterange", "Reads the address range that starts from address, and is length long. Returns the result into a table of key value pairs (where the address is the key).")]
[LuaMethod("readbyterange", "Reads the address range that starts from address, and is length long. Returns the result into a table of key value pairs (where the address is the key).")]
public new LuaTable ReadByteRange(int addr, int length, string domain = null)
{
return base.ReadByteRange(addr, length, domain);
}
[LuaMethodAttributes("writebyterange", "Writes the given values to the given addresses as unsigned bytes")]
[LuaMethod("writebyterange", "Writes the given values to the given addresses as unsigned bytes")]
public new void WriteByteRange(LuaTable memoryblock, string domain = null)
{
base.WriteByteRange(memoryblock, domain);
}
[LuaMethodAttributes("readfloat", "Reads the given address as a 32-bit float value from the main memory domain with th e given endian")]
[LuaMethod("readfloat", "Reads the given address as a 32-bit float value from the main memory domain with th e given endian")]
public new float ReadFloat(int addr, bool bigendian, string domain = null)
{
return base.ReadFloat(addr, bigendian, domain);
}
[LuaMethodAttributes("writefloat", "Writes the given 32-bit float value to the given address and endian")]
[LuaMethod("writefloat", "Writes the given 32-bit float value to the given address and endian")]
public new void WriteFloat(int addr, double value, bool bigendian, string domain = null)
{
base.WriteFloat(addr, value, bigendian, domain);
@ -157,25 +152,25 @@ namespace BizHawk.Client.Common
#region 1 Byte
[LuaMethodAttributes("read_s8", "read signed byte")]
[LuaMethod("read_s8", "read signed byte")]
public int ReadS8(int addr, string domain = null)
{
return (sbyte)ReadUnsignedByte(addr, domain);
}
[LuaMethodAttributes("write_s8", "write signed byte")]
[LuaMethod("write_s8", "write signed byte")]
public void WriteS8(int addr, uint value, string domain = null)
{
WriteUnsignedByte(addr, value, domain);
}
[LuaMethodAttributes("read_u8", "read unsigned byte")]
[LuaMethod("read_u8", "read unsigned byte")]
public uint ReadU8(int addr, string domain = null)
{
return ReadUnsignedByte(addr, domain);
}
[LuaMethodAttributes("write_u8", "write unsigned byte")]
[LuaMethod("write_u8", "write unsigned byte")]
public void WriteU8(int addr, uint value, string domain = null)
{
WriteUnsignedByte(addr, value, domain);
@ -185,49 +180,49 @@ namespace BizHawk.Client.Common
#region 2 Byte
[LuaMethodAttributes("read_s16_le", "read signed 2 byte value, little endian")]
[LuaMethod("read_s16_le", "read signed 2 byte value, little endian")]
public int ReadS16Little(int addr, string domain = null)
{
return ReadSignedLittleCore(addr, 2, domain);
}
[LuaMethodAttributes("write_s16_le", "write signed 2 byte value, little endian")]
[LuaMethod("write_s16_le", "write signed 2 byte value, little endian")]
public void WriteS16Little(int addr, int value, string domain = null)
{
WriteSignedLittle(addr, value, 2, domain);
}
[LuaMethodAttributes("read_s16_be", "read signed 2 byte value, big endian")]
[LuaMethod("read_s16_be", "read signed 2 byte value, big endian")]
public int ReadS16Big(int addr, string domain = null)
{
return ReadSignedBig(addr, 2, domain);
}
[LuaMethodAttributes("write_s16_be", "write signed 2 byte value, big endian")]
[LuaMethod("write_s16_be", "write signed 2 byte value, big endian")]
public void WriteS16Big(int addr, int value, string domain = null)
{
WriteSignedBig(addr, value, 2, domain);
}
[LuaMethodAttributes("read_u16_le", "read unsigned 2 byte value, little endian")]
[LuaMethod("read_u16_le", "read unsigned 2 byte value, little endian")]
public uint ReadU16Little(int addr, string domain = null)
{
return ReadUnsignedLittle(addr, 2, domain);
}
[LuaMethodAttributes("write_u16_le", "write unsigned 2 byte value, little endian")]
[LuaMethod("write_u16_le", "write unsigned 2 byte value, little endian")]
public void WriteU16Little(int addr, uint value, string domain = null)
{
WriteUnsignedLittle(addr, value, 2, domain);
}
[LuaMethodAttributes("read_u16_be", "read unsigned 2 byte value, big endian")]
[LuaMethod("read_u16_be", "read unsigned 2 byte value, big endian")]
public uint ReadU16Big(int addr, string domain = null)
{
return ReadUnsignedBig(addr, 2, domain);
}
[LuaMethodAttributes("write_u16_be", "write unsigned 2 byte value, big endian")]
[LuaMethod("write_u16_be", "write unsigned 2 byte value, big endian")]
public void WriteU16Big(int addr, uint value, string domain = null)
{
WriteUnsignedBig(addr, value, 2, domain);
@ -237,49 +232,49 @@ namespace BizHawk.Client.Common
#region 3 Byte
[LuaMethodAttributes("read_s24_le", "read signed 24 bit value, little endian")]
[LuaMethod("read_s24_le", "read signed 24 bit value, little endian")]
public int ReadS24Little(int addr, string domain = null)
{
return ReadSignedLittleCore(addr, 3, domain);
}
[LuaMethodAttributes("write_s24_le", "write signed 24 bit value, little endian")]
[LuaMethod("write_s24_le", "write signed 24 bit value, little endian")]
public void WriteS24Little(int addr, int value, string domain = null)
{
WriteSignedLittle(addr, value, 3, domain);
}
[LuaMethodAttributes("read_s24_be", "read signed 24 bit value, big endian")]
[LuaMethod("read_s24_be", "read signed 24 bit value, big endian")]
public int ReadS24Big(int addr, string domain = null)
{
return ReadSignedBig(addr, 3, domain);
}
[LuaMethodAttributes("write_s24_be", "write signed 24 bit value, big endian")]
[LuaMethod("write_s24_be", "write signed 24 bit value, big endian")]
public void WriteS24Big(int addr, int value, string domain = null)
{
WriteSignedBig(addr, value, 3, domain);
}
[LuaMethodAttributes("read_u24_le", "read unsigned 24 bit value, little endian")]
[LuaMethod("read_u24_le", "read unsigned 24 bit value, little endian")]
public uint ReadU24Little(int addr, string domain = null)
{
return ReadUnsignedLittle(addr, 3, domain);
}
[LuaMethodAttributes("write_u24_le", "write unsigned 24 bit value, little endian")]
[LuaMethod("write_u24_le", "write unsigned 24 bit value, little endian")]
public void WriteU24Little(int addr, uint value, string domain = null)
{
WriteUnsignedLittle(addr, value, 3, domain);
}
[LuaMethodAttributes("read_u24_be", "read unsigned 24 bit value, big endian")]
[LuaMethod("read_u24_be", "read unsigned 24 bit value, big endian")]
public uint ReadU24Big(int addr, string domain = null)
{
return ReadUnsignedBig(addr, 3, domain);
}
[LuaMethodAttributes("write_u24_be", "write unsigned 24 bit value, big endian")]
[LuaMethod("write_u24_be", "write unsigned 24 bit value, big endian")]
public void WriteU24Big(int addr, uint value, string domain = null)
{
WriteUnsignedBig(addr, value, 3, domain);
@ -289,49 +284,49 @@ namespace BizHawk.Client.Common
#region 4 Byte
[LuaMethodAttributes("read_s32_le", "read signed 4 byte value, little endian")]
[LuaMethod("read_s32_le", "read signed 4 byte value, little endian")]
public int ReadS32Little(int addr, string domain = null)
{
return ReadSignedLittleCore(addr, 4, domain);
}
[LuaMethodAttributes("write_s32_le", "write signed 4 byte value, little endian")]
[LuaMethod("write_s32_le", "write signed 4 byte value, little endian")]
public void WriteS32Little(int addr, int value, string domain = null)
{
WriteSignedLittle(addr, value, 4, domain);
}
[LuaMethodAttributes("read_s32_be", "read signed 4 byte value, big endian")]
[LuaMethod("read_s32_be", "read signed 4 byte value, big endian")]
public int ReadS32Big(int addr, string domain = null)
{
return ReadSignedBig(addr, 4, domain);
}
[LuaMethodAttributes("write_s32_be", "write signed 4 byte value, big endian")]
[LuaMethod("write_s32_be", "write signed 4 byte value, big endian")]
public void WriteS32Big(int addr, int value, string domain = null)
{
WriteSignedBig(addr, value, 4, domain);
}
[LuaMethodAttributes("read_u32_le", "read unsigned 4 byte value, little endian")]
[LuaMethod("read_u32_le", "read unsigned 4 byte value, little endian")]
public uint ReadU32Little(int addr, string domain = null)
{
return ReadUnsignedLittle(addr, 4, domain);
}
[LuaMethodAttributes("write_u32_le", "write unsigned 4 byte value, little endian")]
[LuaMethod("write_u32_le", "write unsigned 4 byte value, little endian")]
public void WriteU32Little(int addr, uint value, string domain = null)
{
WriteUnsignedLittle(addr, value, 4, domain);
}
[LuaMethodAttributes("read_u32_be", "read unsigned 4 byte value, big endian")]
[LuaMethod("read_u32_be", "read unsigned 4 byte value, big endian")]
public uint ReadU32Big(int addr, string domain = null)
{
return ReadUnsignedBig(addr, 4, domain);
}
[LuaMethodAttributes("write_u32_be", "write unsigned 4 byte value, big endian")]
[LuaMethod("write_u32_be", "write unsigned 4 byte value, big endian")]
public void WriteU32Big(int addr, uint value, string domain = null)
{
WriteUnsignedBig(addr, value, 4, domain);

View File

@ -23,8 +23,7 @@ namespace BizHawk.Client.Common
private readonly Dictionary<Guid, byte[]> _memorySavestates = new Dictionary<Guid, byte[]>();
[LuaMethodAttributes(
"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")]
[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()
{
var guid = Guid.NewGuid();
@ -35,7 +34,7 @@ namespace BizHawk.Client.Common
return guid.ToString();
}
[LuaMethodAttributes("loadcorestate", "loads an in memory state with the given identifier")]
[LuaMethod("loadcorestate", "loads an in memory state with the given identifier")]
public void LoadCoreStateFromMemory(string identifier)
{
var guid = new Guid(identifier);
@ -56,14 +55,14 @@ namespace BizHawk.Client.Common
}
}
[LuaMethodAttributes("removestate", "removes the savestate with the given identifier from memory")]
[LuaMethod("removestate", "removes the savestate with the given identifier from memory")]
public void DeleteState(string identifier)
{
var guid = new Guid(identifier);
_memorySavestates.Remove(guid);
}
[LuaMethodAttributes("clearstatesfrommemory", "clears all savestates stored in memory")]
[LuaMethod("clearstatesfrommemory", "clears all savestates stored in memory")]
public void ClearInMemoryStates()
{
_memorySavestates.Clear();

View File

@ -14,33 +14,25 @@ namespace BizHawk.Client.Common
public override string Name => "movie";
[LuaMethodAttributes(
"startsfromsavestate",
"Returns whether or not the movie is a savestate-anchored movie")]
[LuaMethod("startsfromsavestate", "Returns whether or not the movie is a savestate-anchored movie")]
public bool StartsFromSavestate()
{
return Global.MovieSession.Movie.IsActive && Global.MovieSession.Movie.StartsFromSavestate;
}
[LuaMethodAttributes(
"startsfromsaveram",
"Returns whether or not the movie is a saveram-anchored movie")]
[LuaMethod("startsfromsaveram", "Returns whether or not the movie is a saveram-anchored movie")]
public bool StartsFromSaveram()
{
return Global.MovieSession.Movie.IsActive && Global.MovieSession.Movie.StartsFromSaveRam;
}
[LuaMethodAttributes(
"filename",
"Returns the file name including path of the currently loaded movie")]
[LuaMethod("filename", "Returns the file name including path of the currently loaded movie")]
public static string Filename()
{
return Global.MovieSession.Movie.Filename;
}
[LuaMethodAttributes(
"getinput",
"Returns a table of buttons pressed on a given frame of the loaded movie")]
[LuaMethod("getinput", "Returns a table of buttons pressed on a given frame of the loaded movie")]
public LuaTable GetInput(int frame)
{
if (!Global.MovieSession.Movie.IsActive)
@ -71,9 +63,7 @@ namespace BizHawk.Client.Common
return input;
}
[LuaMethodAttributes(
"getinputasmnemonic",
"Returns the input of a given frame of the loaded movie in a raw inputlog string")]
[LuaMethod("getinputasmnemonic", "Returns the input of a given frame of the loaded movie in a raw inputlog string")]
public string GetInputAsMnemonic(int frame)
{
if (Global.MovieSession.Movie.IsActive && frame < Global.MovieSession.Movie.InputLogLength)
@ -86,49 +76,37 @@ namespace BizHawk.Client.Common
return "";
}
[LuaMethodAttributes(
"getreadonly",
"Returns true if the movie is in read-only mode, false if in read+write")]
[LuaMethod("getreadonly", "Returns true if the movie is in read-only mode, false if in read+write")]
public static bool GetReadOnly()
{
return Global.MovieSession.ReadOnly;
}
[LuaMethodAttributes(
"getrerecordcount",
"Gets the rerecord count of the current movie.")]
[LuaMethod("getrerecordcount", "Gets the rerecord count of the current movie.")]
public static ulong GetRerecordCount()
{
return Global.MovieSession.Movie.Rerecords;
}
[LuaMethodAttributes(
"getrerecordcounting",
"Returns whether or not the current movie is incrementing rerecords on loadstate")]
[LuaMethod("getrerecordcounting", "Returns whether or not the current movie is incrementing rerecords on loadstate")]
public static bool GetRerecordCounting()
{
return Global.MovieSession.Movie.IsCountingRerecords;
}
[LuaMethodAttributes(
"isloaded",
"Returns true if a movie is loaded in memory (play, record, or finished modes), false if not (inactive mode)")]
[LuaMethod("isloaded", "Returns true if a movie is loaded in memory (play, record, or finished modes), false if not (inactive mode)")]
public static bool IsLoaded()
{
return Global.MovieSession.Movie.IsActive;
}
[LuaMethodAttributes(
"length",
"Returns the total number of frames of the loaded movie")]
[LuaMethod("length", "Returns the total number of frames of the loaded movie")]
public static double Length()
{
return Global.MovieSession.Movie.FrameCount;
}
[LuaMethodAttributes(
"mode",
"Returns the mode of the current movie. Possible modes: \"PLAY\", \"RECORD\", \"FINISHED\", \"INACTIVE\"")]
[LuaMethod("mode", "Returns the mode of the current movie. Possible modes: \"PLAY\", \"RECORD\", \"FINISHED\", \"INACTIVE\"")]
public static string Mode()
{
if (Global.MovieSession.Movie.IsFinished)
@ -149,17 +127,13 @@ namespace BizHawk.Client.Common
return "INACTIVE";
}
[LuaMethodAttributes(
"rerecordcount",
"[Deprecated] Alias of getrerecordcount")]
[LuaMethod("rerecordcount", "[Deprecated] Alias of getrerecordcount")]
public static string RerecordCount()
{
return GetRerecordCount().ToString();
}
[LuaMethodAttributes(
"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.")]
[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 = "")
{
if (!Global.MovieSession.Movie.IsActive)
@ -183,17 +157,13 @@ namespace BizHawk.Client.Common
Global.MovieSession.Movie.Save();
}
[LuaMethodAttributes(
"setreadonly",
"Sets the read-only state to the given value. true for read only, false for read+write")]
[LuaMethod("setreadonly", "Sets the read-only state to the given value. true for read only, false for read+write")]
public static void SetReadOnly(bool readOnly)
{
Global.MovieSession.ReadOnly = readOnly;
}
[LuaMethodAttributes(
"setrerecordcount",
"Sets the rerecord count of the current movie.")]
[LuaMethod("setrerecordcount", "Sets the rerecord count of the current movie.")]
public static void SetRerecordCount(double count)
{
// Lua numbers are always double, integer precision holds up
@ -208,25 +178,19 @@ namespace BizHawk.Client.Common
Global.MovieSession.Movie.Rerecords = (ulong)count;
}
[LuaMethodAttributes(
"setrerecordcounting",
"Sets whether or not the current movie will increment the rerecord counter on loadstate")]
[LuaMethod("setrerecordcounting", "Sets whether or not the current movie will increment the rerecord counter on loadstate")]
public static void SetRerecordCounting(bool counting)
{
Global.MovieSession.Movie.IsCountingRerecords = counting;
}
[LuaMethodAttributes(
"stop",
"Stops the current movie")]
[LuaMethod("stop", "Stops the current movie")]
public static void Stop()
{
Global.MovieSession.Movie.Stop();
}
[LuaMethodAttributes(
"getfps",
"If a movie is loaded, gets the frames per second used by the movie to determine the movie length time")]
[LuaMethod("getfps", "If a movie is loaded, gets the frames per second used by the movie to determine the movie length time")]
public static double GetFps()
{
if (Global.MovieSession.Movie.IsActive)
@ -242,9 +206,7 @@ namespace BizHawk.Client.Common
return 0.0;
}
[LuaMethodAttributes(
"getheader",
"If a movie is active, will return the movie header as a lua table")]
[LuaMethod("getheader", "If a movie is active, will return the movie header as a lua table")]
public LuaTable GetHeader()
{
var luaTable = Lua.NewTable();
@ -259,9 +221,7 @@ namespace BizHawk.Client.Common
return luaTable;
}
[LuaMethodAttributes(
"getcomments",
"If a movie is active, will return the movie comments as a lua table")]
[LuaMethod("getcomments", "If a movie is active, will return the movie comments as a lua table")]
public LuaTable GetComments()
{
var luaTable = Lua.NewTable();
@ -276,9 +236,7 @@ namespace BizHawk.Client.Common
return luaTable;
}
[LuaMethodAttributes(
"getsubtitles",
"If a movie is active, will return the movie subtitles as a lua table")]
[LuaMethod("getsubtitles", "If a movie is active, will return the movie subtitles as a lua table")]
public LuaTable GetSubtitles()
{
var luaTable = Lua.NewTable();

View File

@ -38,8 +38,7 @@ namespace BizHawk.Client.Common
public override string Name => "nes";
[LuaMethodAttributes(
"addgamegenie", "Adds the specified game genie code. If an NES game is not currently loaded or the code is not a valid game genie code, this will have no effect")]
[LuaMethod("addgamegenie", "Adds the specified game genie code. If an NES game is not currently loaded or the code is not a valid game genie code, this will have no effect")]
public void AddGameGenie(string code)
{
if (NESAvailable && HasMemoryDOmains)
@ -60,8 +59,7 @@ namespace BizHawk.Client.Common
}
}
[LuaMethodAttributes(
"getallowmorethaneightsprites", "Gets the NES setting 'Allow more than 8 sprites per scanline' value")]
[LuaMethod("getallowmorethaneightsprites", "Gets the NES setting 'Allow more than 8 sprites per scanline' value")]
public bool GetAllowMoreThanEightSprites()
{
if (Quicknes != null)
@ -77,8 +75,7 @@ namespace BizHawk.Client.Common
throw new InvalidOperationException();
}
[LuaMethodAttributes(
"getbottomscanline", "Gets the current value for the bottom scanline value")]
[LuaMethod("getbottomscanline", "Gets the current value for the bottom scanline value")]
public int GetBottomScanline(bool pal = false)
{
if (Quicknes != null)
@ -96,8 +93,7 @@ namespace BizHawk.Client.Common
throw new InvalidOperationException();
}
[LuaMethodAttributes(
"getclipleftandright", "Gets the current value for the Clip Left and Right sides option")]
[LuaMethod("getclipleftandright", "Gets the current value for the Clip Left and Right sides option")]
public bool GetClipLeftAndRight()
{
if (Quicknes != null)
@ -113,8 +109,7 @@ namespace BizHawk.Client.Common
throw new InvalidOperationException();
}
[LuaMethodAttributes(
"getdispbackground", "Indicates whether or not the bg layer is being displayed")]
[LuaMethod("getdispbackground", "Indicates whether or not the bg layer is being displayed")]
public bool GetDisplayBackground()
{
if (Quicknes != null)
@ -130,8 +125,7 @@ namespace BizHawk.Client.Common
throw new InvalidOperationException();
}
[LuaMethodAttributes(
"getdispsprites", "Indicates whether or not sprites are being displayed")]
[LuaMethod("getdispsprites", "Indicates whether or not sprites are being displayed")]
public bool GetDisplaySprites()
{
if (Quicknes != null)
@ -147,8 +141,7 @@ namespace BizHawk.Client.Common
throw new InvalidOperationException();
}
[LuaMethodAttributes(
"gettopscanline", "Gets the current value for the top scanline value")]
[LuaMethod("gettopscanline", "Gets the current value for the top scanline value")]
public int GetTopScanline(bool pal = false)
{
if (Quicknes != null)
@ -166,8 +159,7 @@ namespace BizHawk.Client.Common
throw new InvalidOperationException();
}
[LuaMethodAttributes(
"removegamegenie", "Removes the specified game genie code. If an NES game is not currently loaded or the code is not a valid game genie code, this will have no effect")]
[LuaMethod("removegamegenie", "Removes the specified game genie code. If an NES game is not currently loaded or the code is not a valid game genie code, this will have no effect")]
public void RemoveGameGenie(string code)
{
if (NESAvailable)
@ -178,8 +170,7 @@ namespace BizHawk.Client.Common
}
}
[LuaMethodAttributes(
"setallowmorethaneightsprites", "Sets the NES setting 'Allow more than 8 sprites per scanline'")]
[LuaMethod("setallowmorethaneightsprites", "Sets the NES setting 'Allow more than 8 sprites per scanline'")]
public void SetAllowMoreThanEightSprites(bool allow)
{
if (Neshawk != null)
@ -196,8 +187,7 @@ namespace BizHawk.Client.Common
}
}
[LuaMethodAttributes(
"setclipleftandright", "Sets the Clip Left and Right sides option")]
[LuaMethod("setclipleftandright", "Sets the Clip Left and Right sides option")]
public void SetClipLeftAndRight(bool leftandright)
{
if (Neshawk != null)
@ -214,8 +204,7 @@ namespace BizHawk.Client.Common
}
}
[LuaMethodAttributes(
"setdispbackground", "Sets whether or not the background layer will be displayed")]
[LuaMethod("setdispbackground", "Sets whether or not the background layer will be displayed")]
public void SetDisplayBackground(bool show)
{
if (Neshawk != null)
@ -226,8 +215,7 @@ namespace BizHawk.Client.Common
}
}
[LuaMethodAttributes(
"setdispsprites", "Sets whether or not sprites will be displayed")]
[LuaMethod("setdispsprites", "Sets whether or not sprites will be displayed")]
public void SetDisplaySprites(bool show)
{
if (Neshawk != null)
@ -244,8 +232,7 @@ namespace BizHawk.Client.Common
}
}
[LuaMethodAttributes(
"setscanlines", "sets the top and bottom scanlines to be drawn (same values as in the graphics options dialog). Top must be in the range of 0 to 127, bottom must be between 128 and 239. Not supported in the Quick Nes core")]
[LuaMethod("setscanlines", "sets the top and bottom scanlines to be drawn (same values as in the graphics options dialog). Top must be in the range of 0 to 127, bottom must be between 128 and 239. Not supported in the Quick Nes core")]
public void SetScanlines(int top, int bottom, bool pal = false)
{
if (Neshawk != null)

View File

@ -35,55 +35,55 @@ namespace BizHawk.Client.Common
Snes?.PutSettings(settings);
}
[LuaMethodAttributes("getlayer_bg_1", "Returns whether the bg 1 layer is displayed")]
[LuaMethod("getlayer_bg_1", "Returns whether the bg 1 layer is displayed")]
public bool GetLayerBg1()
{
return GetSettings().ShowBG1_1;
}
[LuaMethodAttributes("getlayer_bg_2", "Returns whether the bg 2 layer is displayed")]
[LuaMethod("getlayer_bg_2", "Returns whether the bg 2 layer is displayed")]
public bool GetLayerBg2()
{
return GetSettings().ShowBG2_1;
}
[LuaMethodAttributes("getlayer_bg_3", "Returns whether the bg 3 layer is displayed")]
[LuaMethod("getlayer_bg_3", "Returns whether the bg 3 layer is displayed")]
public bool GetLayerBg3()
{
return GetSettings().ShowBG3_1;
}
[LuaMethodAttributes("getlayer_bg_4", "Returns whether the bg 4 layer is displayed")]
[LuaMethod("getlayer_bg_4", "Returns whether the bg 4 layer is displayed")]
public bool GetLayerBg4()
{
return GetSettings().ShowBG4_1;
}
[LuaMethodAttributes("getlayer_obj_1", "Returns whether the obj 1 layer is displayed")]
[LuaMethod("getlayer_obj_1", "Returns whether the obj 1 layer is displayed")]
public bool GetLayerObj1()
{
return GetSettings().ShowOBJ_0;
}
[LuaMethodAttributes("getlayer_obj_2", "Returns whether the obj 2 layer is displayed")]
[LuaMethod("getlayer_obj_2", "Returns whether the obj 2 layer is displayed")]
public bool GetLayerObj2()
{
return GetSettings().ShowOBJ_1;
}
[LuaMethodAttributes("getlayer_obj_3", "Returns whether the obj 3 layer is displayed")]
[LuaMethod("getlayer_obj_3", "Returns whether the obj 3 layer is displayed")]
public bool GetLayerObj3()
{
return GetSettings().ShowOBJ_2;
}
[LuaMethodAttributes("getlayer_obj_4", "Returns whether the obj 4 layer is displayed")]
[LuaMethod("getlayer_obj_4", "Returns whether the obj 4 layer is displayed")]
public bool GetLayerObj4()
{
return GetSettings().ShowOBJ_3;
}
[LuaMethodAttributes("setlayer_bg_1", "Sets whether the bg 1 layer is displayed")]
[LuaMethod("setlayer_bg_1", "Sets whether the bg 1 layer is displayed")]
public void SetLayerBg1(bool value)
{
var s = GetSettings();
@ -91,7 +91,7 @@ namespace BizHawk.Client.Common
PutSettings(s);
}
[LuaMethodAttributes("setlayer_bg_2", "Sets whether the bg 2 layer is displayed")]
[LuaMethod("setlayer_bg_2", "Sets whether the bg 2 layer is displayed")]
public void SetLayerBg2(bool value)
{
var s = GetSettings();
@ -99,7 +99,7 @@ namespace BizHawk.Client.Common
PutSettings(s);
}
[LuaMethodAttributes("setlayer_bg_3", "Sets whether the bg 3 layer is displayed")]
[LuaMethod("setlayer_bg_3", "Sets whether the bg 3 layer is displayed")]
public void SetLayerBg3(bool value)
{
var s = GetSettings();
@ -107,7 +107,7 @@ namespace BizHawk.Client.Common
PutSettings(s);
}
[LuaMethodAttributes("setlayer_bg_4", "Sets whether the bg 4 layer is displayed")]
[LuaMethod("setlayer_bg_4", "Sets whether the bg 4 layer is displayed")]
public void SetLayerBg4(bool value)
{
var s = GetSettings();
@ -115,7 +115,7 @@ namespace BizHawk.Client.Common
PutSettings(s);
}
[LuaMethodAttributes("setlayer_obj_1", "Sets whether the obj 1 layer is displayed")]
[LuaMethod("setlayer_obj_1", "Sets whether the obj 1 layer is displayed")]
public void SetLayerObj1(bool value)
{
var s = GetSettings();
@ -123,7 +123,7 @@ namespace BizHawk.Client.Common
PutSettings(s);
}
[LuaMethodAttributes("setlayer_obj_2", "Sets whether the obj 2 layer is displayed")]
[LuaMethod("setlayer_obj_2", "Sets whether the obj 2 layer is displayed")]
public void SetLayerObj2(bool value)
{
var s = GetSettings();
@ -131,7 +131,7 @@ namespace BizHawk.Client.Common
PutSettings(s);
}
[LuaMethodAttributes("setlayer_obj_3", "Sets whether the obj 3 layer is displayed")]
[LuaMethod("setlayer_obj_3", "Sets whether the obj 3 layer is displayed")]
public void SetLayerObj3(bool value)
{
var s = GetSettings();
@ -139,7 +139,7 @@ namespace BizHawk.Client.Common
PutSettings(s);
}
[LuaMethodAttributes("setlayer_obj_4", "Sets whether the obj 4 layer is displayed")]
[LuaMethod("setlayer_obj_4", "Sets whether the obj 4 layer is displayed")]
public void SetLayerObj4(bool value)
{
var s = GetSettings();

View File

@ -21,7 +21,7 @@ namespace BizHawk.Client.Common
SQLiteConnection m_dbConnection;
string connectionString;
[LuaMethodAttributes("createdatabase","Creates a SQLite Database. Name should end with .db")]
[LuaMethod("createdatabase","Creates a SQLite Database. Name should end with .db")]
public string CreateDatabase(string name)
{
try
@ -37,7 +37,7 @@ namespace BizHawk.Client.Common
}
[LuaMethodAttributes("opendatabase", "Opens a SQLite database. Name should end with .db")]
[LuaMethod("opendatabase", "Opens a SQLite database. Name should end with .db")]
public string OpenDatabase(string name)
{
try
@ -60,7 +60,7 @@ namespace BizHawk.Client.Common
}
}
[LuaMethodAttributes("writecommand", "Runs a SQLite write command which includes CREATE,INSERT, UPDATE. " +
[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="")
{
@ -90,7 +90,7 @@ namespace BizHawk.Client.Common
}
}
[LuaMethodAttributes("readcommand", "Run a SQLite read command which includes Select. Returns all rows into a LuaTable." +
[LuaMethod("readcommand", "Run a SQLite read command which includes Select. Returns all rows into a LuaTable." +
"Ex: select * from rewards")]
public dynamic ReadCommand(string query="")
{

View File

@ -17,8 +17,7 @@ namespace BizHawk.Client.Common
public StringLuaLibrary(Lua lua, Action<string> logOutputCallback)
: base(lua, logOutputCallback) { }
[LuaMethodAttributes(
"hex", "Converts the number to a string representation of the hexadecimal value of the given number")]
[LuaMethod("hex", "Converts the number to a string representation of the hexadecimal value of the given number")]
public static string Hex(long num)
{
var hex = $"{num:X}";
@ -30,8 +29,7 @@ namespace BizHawk.Client.Common
return hex;
}
[LuaMethodAttributes(
"binary", "Converts the number to a string representation of the binary value of the given number")]
[LuaMethod("binary", "Converts the number to a string representation of the binary value of the given number")]
public static string Binary(long num)
{
var binary = Convert.ToString(num, 2);
@ -39,8 +37,7 @@ namespace BizHawk.Client.Common
return binary;
}
[LuaMethodAttributes(
"octal", "Converts the number to a string representation of the octal value of the given number")]
[LuaMethod("octal", "Converts the number to a string representation of the octal value of the given number")]
public static string Octal(long num)
{
var octal = Convert.ToString(num, 8);
@ -52,8 +49,7 @@ namespace BizHawk.Client.Common
return octal;
}
[LuaMethodAttributes(
"trim", "returns a string that trims whitespace on the left and right ends of the string")]
[LuaMethod("trim", "returns a string that trims whitespace on the left and right ends of the string")]
public static string Trim(string str)
{
if (string.IsNullOrEmpty(str))
@ -64,8 +60,7 @@ namespace BizHawk.Client.Common
return str.Trim();
}
[LuaMethodAttributes(
"replace", "Returns a string that replaces all occurances of str2 in str1 with the value of replace")]
[LuaMethod("replace", "Returns a string that replaces all occurances of str2 in str1 with the value of replace")]
public static string Replace(string str, string str2, string replace)
{
if (string.IsNullOrEmpty(str))
@ -76,7 +71,7 @@ namespace BizHawk.Client.Common
return str.Replace(str2, replace);
}
[LuaMethodAttributes("toupper", "Returns an uppercase version of the given string")]
[LuaMethod("toupper", "Returns an uppercase version of the given string")]
public static string ToUpper(string str)
{
if (string.IsNullOrEmpty(str))
@ -87,7 +82,7 @@ namespace BizHawk.Client.Common
return str.ToUpper();
}
[LuaMethodAttributes("tolower", "Returns an lowercase version of the given string")]
[LuaMethod("tolower", "Returns an lowercase version of the given string")]
public static string ToLower(string str)
{
if (string.IsNullOrEmpty(str))
@ -98,8 +93,7 @@ namespace BizHawk.Client.Common
return str.ToLower();
}
[LuaMethodAttributes(
"substring", "Returns a string that represents a substring of str starting at position for the specified length")]
[LuaMethod("substring", "Returns a string that represents a substring of str starting at position for the specified length")]
public static string SubString(string str, int position, int length)
{
if (string.IsNullOrEmpty(str))
@ -110,8 +104,7 @@ namespace BizHawk.Client.Common
return str.Substring(position, length);
}
[LuaMethodAttributes(
"remove", "Returns a string that represents str with the given position and count removed")]
[LuaMethod("remove", "Returns a string that represents str with the given position and count removed")]
public static string Remove(string str, int position, int count)
{
if (string.IsNullOrEmpty(str))
@ -122,7 +115,7 @@ namespace BizHawk.Client.Common
return str.Remove(position, count);
}
[LuaMethodAttributes("contains", "Returns whether or not str contains str2")]
[LuaMethod("contains", "Returns whether or not str contains str2")]
public static bool Contains(string str, string str2)
{
if (string.IsNullOrEmpty(str))
@ -133,7 +126,7 @@ namespace BizHawk.Client.Common
return str.Contains(str2);
}
[LuaMethodAttributes("startswith", "Returns whether str starts with str2")]
[LuaMethod("startswith", "Returns whether str starts with str2")]
public static bool StartsWith(string str, string str2)
{
if (string.IsNullOrEmpty(str))
@ -144,7 +137,7 @@ namespace BizHawk.Client.Common
return str.StartsWith(str2);
}
[LuaMethodAttributes("endswith", "Returns whether str ends wth str2")]
[LuaMethod("endswith", "Returns whether str ends wth str2")]
public static bool EndsWith(string str, string str2)
{
if (string.IsNullOrEmpty(str))
@ -155,8 +148,7 @@ namespace BizHawk.Client.Common
return str.EndsWith(str2);
}
[LuaMethodAttributes(
"split", "Splits str based on separator into a LuaTable. Separator must be one character!. Same functionality as .NET string.Split() using the RemoveEmptyEntries option")]
[LuaMethod("split", "Splits str based on separator into a LuaTable. Separator must be one character!. Same functionality as .NET string.Split() using the RemoveEmptyEntries option")]
public LuaTable Split(string str, string separator)
{
var table = Lua.NewTable();

View File

@ -18,17 +18,13 @@ namespace BizHawk.Client.EmuHawk
public override string Name => "userdata";
[LuaMethodAttributes(
"set",
"adds or updates the data with the given key with the given value")]
[LuaMethod("set", "adds or updates the data with the given key with the given value")]
public void Set(string name, object value)
{
Global.UserBag[name] = value;
}
[LuaMethodAttributes(
"get",
"gets the data with the given key, if the key does not exist it will return nil")]
[LuaMethod("get", "gets the data with the given key, if the key does not exist it will return nil")]
public object Get(string key)
{
if (Global.UserBag.ContainsKey(key))
@ -39,25 +35,19 @@ namespace BizHawk.Client.EmuHawk
return null;
}
[LuaMethodAttributes(
"clear",
"clears all user data")]
[LuaMethod("clear", "clears all user data")]
public void Clear()
{
Global.UserBag.Clear();
}
[LuaMethodAttributes(
"remove",
"remove the data with the given key. Returns true if the element is successfully found and removed; otherwise, false.")]
[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)
{
return Global.UserBag.Remove(key);
}
[LuaMethodAttributes(
"containskey",
"returns whether or not there is an entry for the given key")]
[LuaMethod("containskey", "returns whether or not there is an entry for the given key")]
public bool ContainsKey(string key)
{
return Global.UserBag.ContainsKey(key);

View File

@ -3,9 +3,9 @@
namespace BizHawk.Client.Common
{
[AttributeUsage(AttributeTargets.Method)]
public class LuaMethodAttributes : Attribute
public class LuaMethodAttribute : Attribute
{
public LuaMethodAttributes(string name, string description)
public LuaMethodAttribute(string name, string description)
{
Name = name;
Description = description;
@ -16,9 +16,9 @@ namespace BizHawk.Client.Common
}
[AttributeUsage(AttributeTargets.Class)]
public class LuaLibraryAttributes : Attribute
public class LuaLibraryAttribute : Attribute
{
public LuaLibraryAttributes(bool released)
public LuaLibraryAttribute(bool released)
{
Released = released;
}

View File

@ -161,13 +161,13 @@ __Types and notation__
public class LibraryFunction
{
private readonly LuaMethodAttributes _luaAttributes;
private readonly LuaMethodAttribute _luaAttributes;
private readonly MethodInfo _method;
public LibraryFunction(string library, string libraryDescription, MethodInfo method)
{
_luaAttributes = method.GetCustomAttributes(typeof(LuaMethodAttributes), false)
.First() as LuaMethodAttributes;
_luaAttributes = method.GetCustomAttributes(typeof(LuaMethodAttribute), false)
.First() as LuaMethodAttribute;
_method = method;
Library = library;

View File

@ -96,7 +96,7 @@ namespace BizHawk.Client.Common
{
Lua.NewTable(Name);
var luaAttr = typeof(LuaMethodAttributes);
var luaAttr = typeof(LuaMethodAttribute);
var methods = GetType()
.GetMethods()
@ -104,7 +104,7 @@ namespace BizHawk.Client.Common
foreach (var method in methods)
{
var luaMethodAttr = (LuaMethodAttributes)method.GetCustomAttributes(luaAttr, false).First();
var luaMethodAttr = (LuaMethodAttribute)method.GetCustomAttributes(luaAttr, false).First();
var luaName = Name + "." + luaMethodAttr.Name;
Lua.RegisterFunction(luaName, this, method);

View File

@ -36,67 +36,63 @@ namespace BizHawk.Client.EmuHawk
public override string Name => "client";
[LuaMethodAttributes("exit", "Closes the emulator")]
[LuaMethod("exit", "Closes the emulator")]
public void CloseEmulator()
{
GlobalWin.MainForm.CloseEmulator();
}
[LuaMethodAttributes("exitCode", "Closes the emulator and returns the provided code")]
[LuaMethod("exitCode", "Closes the emulator and returns the provided code")]
public void CloseEmulatorWithCode(int exitCode)
{
GlobalWin.MainForm.CloseEmulator(exitCode);
}
[LuaMethodAttributes(
"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.")]
[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 System.Drawing.Point(0, 0);
return GlobalWin.DisplayManager.TransformPoint(point).Y;
}
[LuaMethodAttributes(
"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.")]
[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 System.Drawing.Point(0, 0);
return GlobalWin.DisplayManager.TransformPoint(point).X;
}
[LuaMethodAttributes(
"bufferheight", "Gets the visible height of the emu display surface (the core video output). This excludes the gameExtraPadding you've set.")]
[LuaMethod("bufferheight", "Gets the visible height of the emu display surface (the core video output). This excludes the gameExtraPadding you've set.")]
public int BufferHeight()
{
return VideoProvider.BufferHeight;
}
[LuaMethodAttributes(
"bufferwidth", "Gets the visible width of the emu display surface (the core video output). This excludes the gameExtraPadding you've set.")]
[LuaMethod("bufferwidth", "Gets the visible width of the emu display surface (the core video output). This excludes the gameExtraPadding you've set.")]
public int BufferWidth()
{
return VideoProvider.BufferWidth;
}
[LuaMethodAttributes("clearautohold", "Clears all autohold keys")]
[LuaMethod("clearautohold", "Clears all autohold keys")]
public void ClearAutohold()
{
GlobalWin.MainForm.ClearHolds();
}
[LuaMethodAttributes("closerom", "Closes the loaded Rom")]
[LuaMethod("closerom", "Closes the loaded Rom")]
public static void CloseRom()
{
GlobalWin.MainForm.CloseRom();
}
[LuaMethodAttributes("enablerewind", "Sets whether or not the rewind feature is enabled")]
[LuaMethod("enablerewind", "Sets whether or not the rewind feature is enabled")]
public void EnableRewind(bool enabled)
{
GlobalWin.MainForm.EnableRewind(enabled);
}
[LuaMethodAttributes("frameskip", "Sets the frame skip value of the client UI")]
[LuaMethod("frameskip", "Sets the frame skip value of the client UI")]
public void FrameSkip(int numFrames)
{
if (numFrames > 0)
@ -110,111 +106,111 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes("gettargetscanlineintensity", "Gets the current scanline intensity setting, used for the scanline display filter")]
[LuaMethod("gettargetscanlineintensity", "Gets the current scanline intensity setting, used for the scanline display filter")]
public static int GetTargetScanlineIntensity()
{
return Global.Config.TargetScanlineFilterIntensity;
}
[LuaMethodAttributes("getwindowsize", "Gets the main window's size Possible values are 1, 2, 3, 4, 5, and 10")]
[LuaMethod("getwindowsize", "Gets the main window's size Possible values are 1, 2, 3, 4, 5, and 10")]
public int GetWindowSize()
{
return Global.Config.TargetZoomFactors[Emulator.SystemId];
}
[LuaMethodAttributes("SetGameExtraPadding", "Sets the extra padding added to the 'emu' surface so that you can draw HUD elements in predictable placements")]
[LuaMethod("SetGameExtraPadding", "Sets the extra padding added to the 'emu' surface so that you can draw HUD elements in predictable placements")]
public static void SetGameExtraPadding(int left, int top, int right, int bottom)
{
GlobalWin.DisplayManager.GameExtraPadding = new System.Windows.Forms.Padding(left, top, right, bottom);
GlobalWin.MainForm.FrameBufferResized();
}
[LuaMethodAttributes("SetSoundOn", "Sets the state of the Sound On toggle")]
[LuaMethod("SetSoundOn", "Sets the state of the Sound On toggle")]
public static void SetSoundOn(bool enable)
{
Global.Config.SoundEnabled = enable;
}
[LuaMethodAttributes("GetSoundOn", "Gets the state of the Sound On toggle")]
[LuaMethod("GetSoundOn", "Gets the state of the Sound On toggle")]
public static bool GetSoundOn()
{
return Global.Config.SoundEnabled;
}
[LuaMethodAttributes("SetClientExtraPadding", "Sets the extra padding added to the 'native' surface so that you can draw HUD elements in predictable placements")]
[LuaMethod("SetClientExtraPadding", "Sets the extra padding added to the 'native' surface so that you can draw HUD elements in predictable placements")]
public static void SetClientExtraPadding(int left, int top, int right, int bottom)
{
GlobalWin.DisplayManager.ClientExtraPadding = new System.Windows.Forms.Padding(left, top, right, bottom);
GlobalWin.MainForm.FrameBufferResized();
}
[LuaMethodAttributes("ispaused", "Returns true if emulator is paused, otherwise, false")]
[LuaMethod("ispaused", "Returns true if emulator is paused, otherwise, false")]
public static bool IsPaused()
{
return GlobalWin.MainForm.EmulatorPaused;
}
[LuaMethodAttributes("opencheats", "opens the Cheats dialog")]
[LuaMethod("opencheats", "opens the Cheats dialog")]
public static void OpenCheats()
{
GlobalWin.Tools.Load<Cheats>();
}
[LuaMethodAttributes("openhexeditor", "opens the Hex Editor dialog")]
[LuaMethod("openhexeditor", "opens the Hex Editor dialog")]
public static void OpenHexEditor()
{
GlobalWin.Tools.Load<HexEditor>();
}
[LuaMethodAttributes("openramwatch", "opens the RAM Watch dialog")]
[LuaMethod("openramwatch", "opens the RAM Watch dialog")]
public static void OpenRamWatch()
{
GlobalWin.Tools.LoadRamWatch(loadDialog: true);
}
[LuaMethodAttributes("openramsearch", "opens the RAM Search dialog")]
[LuaMethod("openramsearch", "opens the RAM Search dialog")]
public static void OpenRamSearch()
{
GlobalWin.Tools.Load<RamSearch>();
}
[LuaMethodAttributes("openrom", "opens the Open ROM dialog")]
[LuaMethod("openrom", "opens the Open ROM dialog")]
public static void OpenRom(string path)
{
GlobalWin.MainForm.LoadRom(path, new MainForm.LoadRomArgs { OpenAdvanced = new OpenAdvanced_OpenRom() });
}
[LuaMethodAttributes("opentasstudio", "opens the TAStudio dialog")]
[LuaMethod("opentasstudio", "opens the TAStudio dialog")]
public static void OpenTasStudio()
{
GlobalWin.Tools.Load<TAStudio>();
}
[LuaMethodAttributes("opentoolbox", "opens the Toolbox Dialog")]
[LuaMethod("opentoolbox", "opens the Toolbox Dialog")]
public static void OpenToolBox()
{
GlobalWin.Tools.Load<ToolBox>();
}
[LuaMethodAttributes("opentracelogger", "opens the tracelogger if it is available for the given core")]
[LuaMethod("opentracelogger", "opens the tracelogger if it is available for the given core")]
public static void OpenTraceLogger()
{
GlobalWin.Tools.Load<TraceLogger>();
}
[LuaMethodAttributes("pause", "Pauses the emulator")]
[LuaMethod("pause", "Pauses the emulator")]
public static void Pause()
{
GlobalWin.MainForm.PauseEmulator();
}
[LuaMethodAttributes("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")]
[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 static void PauseAv()
{
GlobalWin.MainForm.PauseAvi = true;
}
[LuaMethodAttributes("reboot_core", "Reboots the currently loaded core")]
[LuaMethod("reboot_core", "Reboots the currently loaded core")]
public static void RebootCore()
{
((LuaConsole)GlobalWin.Tools.Get<LuaConsole>()).LuaImp.IsRebootingCore = true;
@ -222,13 +218,13 @@ namespace BizHawk.Client.EmuHawk
((LuaConsole)GlobalWin.Tools.Get<LuaConsole>()).LuaImp.IsRebootingCore = false;
}
[LuaMethodAttributes("screenheight", "Gets the current height in pixels of the emulator's drawing area")]
[LuaMethod("screenheight", "Gets the current height in pixels of the emulator's drawing area")]
public static int ScreenHeight()
{
return GlobalWin.MainForm.PresentationPanel.NativeSize.Height;
}
[LuaMethodAttributes("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")]
[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 static void Screenshot(string path = null)
{
if (path == null)
@ -241,31 +237,31 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes("screenshottoclipboard", "Performs the same function as EmuHawk's Screenshot To Clipboard menu item")]
[LuaMethod("screenshottoclipboard", "Performs the same function as EmuHawk's Screenshot To Clipboard menu item")]
public static void ScreenshotToClipboard()
{
GlobalWin.MainForm.TakeScreenshotToClipboard();
}
[LuaMethodAttributes("settargetscanlineintensity", "Sets the current scanline intensity setting, used for the scanline display filter")]
[LuaMethod("settargetscanlineintensity", "Sets the current scanline intensity setting, used for the scanline display filter")]
public static void SetTargetScanlineIntensity(int val)
{
Global.Config.TargetScanlineFilterIntensity = val;
}
[LuaMethodAttributes("setscreenshotosd", "Sets the screenshot Capture OSD property of the client")]
[LuaMethod("setscreenshotosd", "Sets the screenshot Capture OSD property of the client")]
public static void SetScreenshotOSD(bool value)
{
Global.Config.Screenshot_CaptureOSD = value;
}
[LuaMethodAttributes("screenwidth", "Gets the current width in pixels of the emulator's drawing area")]
[LuaMethod("screenwidth", "Gets the current width in pixels of the emulator's drawing area")]
public static int ScreenWidth()
{
return GlobalWin.MainForm.PresentationPanel.NativeSize.Width;
}
[LuaMethodAttributes("setwindowsize", "Sets the main window's size to the give value. Accepted values are 1, 2, 3, 4, 5, and 10")]
[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)
{
if (size == 1 || size == 2 || size == 3 || size == 4 || size == 5 || size == 10)
@ -280,7 +276,7 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes("speedmode", "Sets the speed of the emulator (in terms of percent)")]
[LuaMethod("speedmode", "Sets the speed of the emulator (in terms of percent)")]
public void SpeedMode(int percent)
{
if (percent > 0 && percent < 6400)
@ -293,51 +289,51 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes("togglepause", "Toggles the current pause state")]
[LuaMethod("togglepause", "Toggles the current pause state")]
public static void TogglePause()
{
GlobalWin.MainForm.TogglePause();
}
[LuaMethodAttributes("transformPointX", "Transforms an x-coordinate in emulator space to an x-coordinate in client space")]
[LuaMethod("transformPointX", "Transforms an x-coordinate in emulator space to an x-coordinate in client space")]
public static int TransformPointX(int x)
{
var point = new System.Drawing.Point(x, 0);
return GlobalWin.DisplayManager.TransformPoint(point).X;
}
[LuaMethodAttributes("transformPointY", "Transforms an y-coordinate in emulator space to an y-coordinate in client space")]
[LuaMethod("transformPointY", "Transforms an y-coordinate in emulator space to an y-coordinate in client space")]
public static int TransformPointY(int y)
{
var point = new System.Drawing.Point(0, y);
return GlobalWin.DisplayManager.TransformPoint(point).Y;
}
[LuaMethodAttributes("unpause", "Unpauses the emulator")]
[LuaMethod("unpause", "Unpauses the emulator")]
public static void Unpause()
{
GlobalWin.MainForm.UnpauseEmulator();
}
[LuaMethodAttributes("unpause_av", "If currently capturing Audio/Video this resumes capturing")]
[LuaMethod("unpause_av", "If currently capturing Audio/Video this resumes capturing")]
public static void UnpauseAv()
{
GlobalWin.MainForm.PauseAvi = false;
}
[LuaMethodAttributes("xpos", "Returns the x value of the screen position where the client currently sits")]
[LuaMethod("xpos", "Returns the x value of the screen position where the client currently sits")]
public static int Xpos()
{
return GlobalWin.MainForm.DesktopLocation.X;
}
[LuaMethodAttributes("ypos", "Returns the y value of the screen position where the client currently sits")]
[LuaMethod("ypos", "Returns the y value of the screen position where the client currently sits")]
public static int Ypos()
{
return GlobalWin.MainForm.DesktopLocation.Y;
}
[LuaMethodAttributes("getavailabletools", "Returns a list of the tools currently open")]
[LuaMethod("getavailabletools", "Returns a list of the tools currently open")]
public LuaTable GetAvailableTools()
{
var t = Lua.NewTable();
@ -350,8 +346,7 @@ namespace BizHawk.Client.EmuHawk
return t;
}
[LuaMethodAttributes(
"gettool", "Returns an object that represents a tool of the given name (not case sensitive). If the tool is not open, it will be loaded if available. Use gettools to get a list of names")]
[LuaMethod("gettool", "Returns an object that represents a tool of the given name (not case sensitive). If the tool is not open, it will be loaded if available. Use gettools to get a list of names")]
public LuaTable GetTool(string name)
{
var toolType = ReflectionUtil.GetTypeByName(name)
@ -373,8 +368,7 @@ namespace BizHawk.Client.EmuHawk
return null;
}
[LuaMethodAttributes(
"createinstance", "returns a default instance of the given type of object if it exists (not case sensitive). Note: This will only work on objects which have a parameterless constructor. If no suitable type is found, or the type does not have a parameterless constructor, then nil is returned")]
[LuaMethod("createinstance", "returns a default instance of the given type of object if it exists (not case sensitive). Note: This will only work on objects which have a parameterless constructor. If no suitable type is found, or the type does not have a parameterless constructor, then nil is returned")]
public LuaTable CreateInstance(string name)
{
var possibleTypes = ReflectionUtil.GetTypeByName(name);
@ -388,13 +382,13 @@ namespace BizHawk.Client.EmuHawk
return null;
}
[LuaMethodAttributes("displaymessages", "sets whether or not on screen messages will display")]
[LuaMethod("displaymessages", "sets whether or not on screen messages will display")]
public void DisplayMessages(bool value)
{
Global.Config.DisplayMessages = value;
}
[LuaMethodAttributes("saveram", "flushes save ram to disk")]
[LuaMethod("saveram", "flushes save ram to disk")]
public void SaveRam()
{
GlobalWin.MainForm.FlushSaveRAM();

View File

@ -18,7 +18,7 @@ namespace BizHawk.Client.EmuHawk
public override string Name => "console";
[LuaMethodAttributes("clear", "clears the output box of the Lua Console window")]
[LuaMethod("clear", "clears the output box of the Lua Console window")]
public static void Clear()
{
if (GlobalWin.Tools.Has<LuaConsole>())
@ -27,7 +27,7 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes("getluafunctionslist", "returns a list of implemented functions")]
[LuaMethod("getluafunctionslist", "returns a list of implemented functions")]
public static string GetLuaFunctionsList()
{
var list = new StringBuilder();
@ -39,7 +39,7 @@ namespace BizHawk.Client.EmuHawk
return list.ToString();
}
[LuaMethodAttributes("log", "Outputs the given object to the output box on the Lua Console dialog. Note: Can accept a LuaTable")]
[LuaMethod("log", "Outputs the given object to the output box on the Lua Console dialog. Note: Can accept a LuaTable")]
public static void Log(params object[] outputs)
{
if (GlobalWin.Tools.Has<LuaConsole>())
@ -57,7 +57,7 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes("writeline", "Outputs the given object to the output box on the Lua Console dialog. Note: Can accept a LuaTable")]
[LuaMethod("writeline", "Outputs the given object to the output box on the Lua Console dialog. Note: Can accept a LuaTable")]
public static void WriteLine(params object[] outputs)
{
if (GlobalWin.Tools.Has<LuaConsole>())
@ -66,7 +66,7 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes("write", "Outputs the given object to the output box on the Lua Console dialog. Note: Can accept a LuaTable")]
[LuaMethod("write", "Outputs the given object to the output box on the Lua Console dialog. Note: Can accept a LuaTable")]
public static void Write(params object[] outputs)
{
LogWithSeparator("", "", outputs);

View File

@ -61,7 +61,7 @@ namespace BizHawk.Client.EmuHawk
#endregion
[LuaMethodAttributes("addclick", "adds the given lua function as a click event to the given control")]
[LuaMethod("addclick", "adds the given lua function as a click event to the given control")]
public void AddClick(int handle, LuaFunction clickEvent)
{
var ptr = new IntPtr(handle);
@ -77,8 +77,7 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes(
"button", "Creates a button control on the given form. The caption property will be the text value on the button. clickEvent is the name of a Lua function that will be invoked when the button is clicked. x, and y are the optional location parameters for the position of the button within the given form. The function returns the handle of the created button. Width and Height are optional, if not specified they will be a default size")]
[LuaMethod("button", "Creates a button control on the given form. The caption property will be the text value on the button. clickEvent is the name of a Lua function that will be invoked when the button is clicked. x, and y are the optional location parameters for the position of the button within the given form. The function returns the handle of the created button. Width and Height are optional, if not specified they will be a default size")]
public int Button(
int formHandle,
string caption,
@ -112,8 +111,7 @@ namespace BizHawk.Client.EmuHawk
return (int)button.Handle;
}
[LuaMethodAttributes(
"checkbox", "Creates a checkbox control on the given form. The caption property will be the text of the checkbox. x and y are the optional location parameters for the position of the checkbox within the form")]
[LuaMethod("checkbox", "Creates a checkbox control on the given form. The caption property will be the text of the checkbox. x and y are the optional location parameters for the position of the checkbox within the form")]
public int Checkbox(int formHandle, string caption, int? x = null, int? y = null)
{
var form = GetForm(formHandle);
@ -134,7 +132,7 @@ namespace BizHawk.Client.EmuHawk
return (int)checkbox.Handle;
}
[LuaMethodAttributes("clearclicks", "Removes all click events from the given widget at the specified handle")]
[LuaMethod("clearclicks", "Removes all click events from the given widget at the specified handle")]
public void ClearClicks(int handle)
{
var ptr = new IntPtr(handle);
@ -154,7 +152,7 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes("destroy", "Closes and removes a Lua created form with the specified handle. If a dialog was found and removed true is returned, else false")]
[LuaMethod("destroy", "Closes and removes a Lua created form with the specified handle. If a dialog was found and removed true is returned, else false")]
public bool Destroy(int handle)
{
var ptr = new IntPtr(handle);
@ -171,7 +169,7 @@ namespace BizHawk.Client.EmuHawk
return false;
}
[LuaMethodAttributes("destroyall", "Closes and removes all Lua created dialogs")]
[LuaMethod("destroyall", "Closes and removes all Lua created dialogs")]
public void DestroyAll()
{
for (var i = _luaForms.Count - 1; i >= 0; i--)
@ -180,8 +178,7 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes(
"dropdown", "Creates a dropdown (with a ComboBoxStyle of DropDownList) control on the given form. Dropdown items are passed via a lua table. Only the values will be pulled for the dropdown items, the keys are irrelevant. Items will be sorted alphabetically. x and y are the optional location parameters, and width and height are the optional size parameters.")]
[LuaMethod("dropdown", "Creates a dropdown (with a ComboBoxStyle of DropDownList) control on the given form. Dropdown items are passed via a lua table. Only the values will be pulled for the dropdown items, the keys are irrelevant. Items will be sorted alphabetically. x and y are the optional location parameters, and width and height are the optional size parameters.")]
public int Dropdown(
int formHandle,
LuaTable items,
@ -215,7 +212,7 @@ namespace BizHawk.Client.EmuHawk
return (int)dropdown.Handle;
}
[LuaMethodAttributes("getproperty", "returns a string representation of the value of a property of the widget at the given handle")]
[LuaMethod("getproperty", "returns a string representation of the value of a property of the widget at the given handle")]
public string GetProperty(int handle, string property)
{
try
@ -245,7 +242,7 @@ namespace BizHawk.Client.EmuHawk
return "";
}
[LuaMethodAttributes("gettext", "Returns the text property of a given form or control")]
[LuaMethod("gettext", "Returns the text property of a given form or control")]
public string GetText(int handle)
{
try
@ -280,7 +277,7 @@ namespace BizHawk.Client.EmuHawk
return "";
}
[LuaMethodAttributes("ischecked", "Returns the given checkbox's checked property")]
[LuaMethod("ischecked", "Returns the given checkbox's checked property")]
public bool IsChecked(int handle)
{
var ptr = new IntPtr(handle);
@ -308,8 +305,7 @@ namespace BizHawk.Client.EmuHawk
return false;
}
[LuaMethodAttributes(
"label", "Creates a label control on the given form. The caption property is the text of the label. x, and y are the optional location parameters for the position of the label within the given form. The function returns the handle of the created label. Width and Height are optional, if not specified they will be a default size.")]
[LuaMethod("label", "Creates a label control on the given form. The caption property is the text of the label. x, and y are the optional location parameters for the position of the label within the given form. The function returns the handle of the created label. Width and Height are optional, if not specified they will be a default size.")]
public int Label(
int formHandle,
string caption,
@ -347,8 +343,7 @@ namespace BizHawk.Client.EmuHawk
return (int)label.Handle;
}
[LuaMethodAttributes(
"newform", "creates a new default dialog, if both width and height are specified it will create a dialog of the specified size. If title is specified it will be the caption of the dialog, else the dialog caption will be 'Lua Dialog'. The function will return an int representing the handle of the dialog created.")]
[LuaMethod("newform", "creates a new default dialog, if both width and height are specified it will create a dialog of the specified size. If title is specified it will be the caption of the dialog, else the dialog caption will be 'Lua Dialog'. The function will return an int representing the handle of the dialog created.")]
public int NewForm(int? width = null, int? height = null, string title = null, LuaFunction onClose = null)
{
var form = new LuaWinform(CurrentThread);
@ -382,8 +377,7 @@ namespace BizHawk.Client.EmuHawk
return (int)form.Handle;
}
[LuaMethodAttributes(
"openfile", "Creates a standard openfile dialog with optional parameters for the filename, directory, and filter. The return value is the directory that the user picked. If they chose to cancel, it will return an empty string")]
[LuaMethod("openfile", "Creates a standard openfile dialog with optional parameters for the filename, directory, and filter. The return value is the directory that the user picked. If they chose to cancel, it will return an empty string")]
public string OpenFile(string fileName = null, string initialDirectory = null, string filter = "All files (*.*)|*.*")
{
// filterext format ex: "Image Files(*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF|All files (*.*)|*.*"
@ -412,7 +406,7 @@ namespace BizHawk.Client.EmuHawk
return "";
}
[LuaMethodAttributes("setdropdownitems", "Sets the items for a given dropdown box")]
[LuaMethod("setdropdownitems", "Sets the items for a given dropdown box")]
public void SetDropdownItems(int handle, LuaTable items)
{
try
@ -447,7 +441,7 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes("setlocation", "Sets the location of a control or form by passing in the handle of the created object")]
[LuaMethod("setlocation", "Sets the location of a control or form by passing in the handle of the created object")]
public void SetLocation(int handle, int x, int y)
{
var ptr = new IntPtr(handle);
@ -470,7 +464,7 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes("setproperty", "Attempts to set the given property of the widget with the given value. Note: not all properties will be able to be represented for the control to accept")]
[LuaMethod("setproperty", "Attempts to set the given property of the widget with the given value. Note: not all properties will be able to be represented for the control to accept")]
public void SetProperty(int handle, string property, object value)
{
var ptr = new IntPtr(handle);
@ -525,13 +519,13 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes("createcolor", "Creates a color object useful with setproperty")]
[LuaMethod("createcolor", "Creates a color object useful with setproperty")]
public Color CreateColor(int r, int g, int b, int a)
{
return Color.FromArgb(a, r, g, b);
}
[LuaMethodAttributes("setsize", "TODO")]
[LuaMethod("setsize", "TODO")]
public void SetSize(int handle, int width, int height)
{
var ptr = new IntPtr(handle);
@ -554,7 +548,7 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes("settext", "Sets the text property of a control or form by passing in the handle of the created object")]
[LuaMethod("settext", "Sets the text property of a control or form by passing in the handle of the created object")]
public void Settext(int handle, string caption)
{
var ptr = new IntPtr(handle);
@ -577,8 +571,7 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes(
"textbox", "Creates a textbox control on the given form. The caption property will be the initial value of the textbox (default is empty). Width and Height are option, if not specified they will be a default size of 100, 20. Type is an optional property to restrict the textbox input. The available options are HEX, SIGNED, and UNSIGNED. Passing it null or any other value will set it to no restriction. x, and y are the optional location parameters for the position of the textbox within the given form. The function returns the handle of the created textbox. If true, the multiline will enable the standard winform multi-line property. If true, the fixedWidth options will create a fixed width font. Scrollbars is an optional property to specify which scrollbars to display. The available options are Vertical, Horizontal, Both, and None. Scrollbars are only shown on a multiline textbox")]
[LuaMethod("textbox", "Creates a textbox control on the given form. The caption property will be the initial value of the textbox (default is empty). Width and Height are option, if not specified they will be a default size of 100, 20. Type is an optional property to restrict the textbox input. The available options are HEX, SIGNED, and UNSIGNED. Passing it null or any other value will set it to no restriction. x, and y are the optional location parameters for the position of the textbox within the given form. The function returns the handle of the created textbox. If true, the multiline will enable the standard winform multi-line property. If true, the fixedWidth options will create a fixed width font. Scrollbars is an optional property to specify which scrollbars to display. The available options are Vertical, Horizontal, Both, and None. Scrollbars are only shown on a multiline textbox")]
public int Textbox(
int formHandle,
string caption = null,

View File

@ -45,8 +45,7 @@ namespace BizHawk.Client.EmuHawk
public bool SurfaceIsNull => _luaSurface == null;
[LuaMethodAttributes(
"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)")]
[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)
{
try
@ -60,7 +59,7 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes("DrawFinish", "Finishes drawing to the current lua surface and causes it to get displayed.")]
[LuaMethod("DrawFinish", "Finishes drawing to the current lua surface and causes it to get displayed.")]
public void DrawFinish()
{
if (_luaSurface != null)
@ -127,45 +126,44 @@ namespace BizHawk.Client.EmuHawk
#endregion
[LuaMethodAttributes("addmessage", "Adds a message to the OSD's message area")]
[LuaMethod("addmessage", "Adds a message to the OSD's message area")]
public void AddMessage(string message)
{
GlobalWin.OSD.AddMessage(message);
}
[LuaMethodAttributes("clearGraphics", "clears all lua drawn graphics from the screen")]
[LuaMethod("clearGraphics", "clears all lua drawn graphics from the screen")]
public void ClearGraphics()
{
_luaSurface.Clear();
DrawFinish();
}
[LuaMethodAttributes("cleartext", "clears all text created by gui.text()")]
[LuaMethod("cleartext", "clears all text created by gui.text()")]
public static void ClearText()
{
GlobalWin.OSD.ClearGUIText();
}
[LuaMethodAttributes("defaultForeground", "Sets the default foreground color to use in drawing methods, white by default")]
[LuaMethod("defaultForeground", "Sets the default foreground color to use in drawing methods, white by default")]
public void SetDefaultForegroundColor(Color color)
{
_defaultForeground = color;
}
[LuaMethodAttributes("defaultBackground", "Sets the default background color to use in drawing methods, transparent by default")]
[LuaMethod("defaultBackground", "Sets the default background color to use in drawing methods, transparent by default")]
public void SetDefaultBackgroundColor(Color color)
{
_defaultBackground = color;
}
[LuaMethodAttributes("defaultTextBackground", "Sets the default backgroiund color to use in text drawing methods, half-transparent black by default")]
[LuaMethod("defaultTextBackground", "Sets the default backgroiund color to use in text drawing methods, half-transparent black by default")]
public void SetDefaultTextBackground(Color color)
{
_defaultTextBackground = color;
}
[LuaMethodAttributes(
"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")]
[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 SetDefaultTextBackground(string fontfamily)
{
switch (fontfamily)
@ -184,7 +182,7 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes("drawBezier", "Draws a Bezier curve using the table of coordinates provided in the given color")]
[LuaMethod("drawBezier", "Draws a Bezier curve using the table of coordinates provided in the given color")]
public void DrawBezier(LuaTable points, Color color)
{
using (var g = GetGraphics())
@ -213,8 +211,7 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes(
"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")]
[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, Color? line = null, Color? background = null)
{
using (var g = GetGraphics())
@ -257,8 +254,7 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes(
"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")]
[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, Color? line = null, Color? background = null)
{
using (var g = GetGraphics())
@ -282,8 +278,7 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes(
"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")]
[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)
{
using (var g = GetGraphics())
@ -309,8 +304,7 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes(
"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")]
[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)
{
if (!File.Exists(path))
@ -339,8 +333,7 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes(
"clearImageCache", "clears the image cache that is built up by using gui.drawImage, also releases the file handle for cached images")]
[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()
{
foreach (var image in _imageCache)
@ -351,8 +344,7 @@ namespace BizHawk.Client.EmuHawk
_imageCache.Clear();
}
[LuaMethodAttributes(
"drawImageRegion", "draws a given region of an image file from the given path at the given coordinate, and optionally with the given size")]
[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)
{
if (!File.Exists(path))
@ -380,8 +372,7 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes(
"drawLine", "Draws a line from the first coordinate pair to the 2nd. Color is optional (if not specified it will be drawn black)")]
[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, Color? color = null)
{
using (var g = GetGraphics())
@ -390,14 +381,14 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes("drawAxis", "Draws an axis of the specified size at the coordinate pair.)")]
[LuaMethod("drawAxis", "Draws an axis of the specified size at the coordinate pair.)")]
public void DrawAxis(int x, int y, int size, Color? color = null)
{
DrawLine(x + size, y, x - size, y, color);
DrawLine(x, y + size, x, y - size, color);
}
[LuaMethodAttributes("drawPie", "draws a Pie shape at the given coordinates and the given width and height")]
[LuaMethod("drawPie", "draws a Pie shape at the given coordinates and the given width and height")]
public void DrawPie(
int x,
int y,
@ -421,8 +412,7 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes(
"drawPixel", "Draws a single pixel at the given coordinates in the given color. Color is optional (if not specified it will be drawn black)")]
[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, Color? color = null)
{
using (var g = GetGraphics())
@ -438,8 +428,7 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes(
"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")]
[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, Color? line = null, Color? background = null)
{
using (var g = GetGraphics())
@ -468,8 +457,7 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes(
"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")]
[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, Color? line = null, Color? background = null)
{
using (var g = GetGraphics())
@ -483,7 +471,7 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes("drawString", "Alias of gui.drawText()")]
[LuaMethod("drawString", "Alias of gui.drawText()")]
public void DrawString(
int x,
int y,
@ -499,8 +487,7 @@ namespace BizHawk.Client.EmuHawk
DrawText(x, y, message, forecolor, backcolor, fontsize, fontfamily, fontstyle, horizalign, vertalign);
}
[LuaMethodAttributes(
"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.")]
[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.")]
public void DrawText(
int x,
int y,
@ -595,9 +582,7 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes(
"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 emulaors they've been taken from. If no font family is specified, it uses \"gens\" font, unless that's overridden via gui.defaultPixelFont()")]
[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 emulaors 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,
@ -651,8 +636,7 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes(
"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")]
[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,
@ -693,7 +677,7 @@ namespace BizHawk.Client.EmuHawk
GlobalWin.OSD.AddGUIText(message, x, y, Color.Black, forecolor ?? Color.White, a);
}
[LuaMethodAttributes("createcanvas", "Creates a canvas of the given size.")]
[LuaMethod("createcanvas", "Creates a canvas of the given size.")]
public LuaTable Text(int width, int height)
{
var canvas = new LuaCanvas(width, height);

View File

@ -17,8 +17,7 @@ namespace BizHawk.Client.EmuHawk
public override string Name => "input";
[LuaMethodAttributes(
"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.")]
[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()
{
var buttons = Lua.NewTable();
@ -30,8 +29,7 @@ namespace BizHawk.Client.EmuHawk
return buttons;
}
[LuaMethodAttributes(
"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.")]
[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()
{
var buttons = Lua.NewTable();

View File

@ -17,7 +17,7 @@ namespace BizHawk.Client.EmuHawk
public override string Name => "savestate";
[LuaMethodAttributes("load", "Loads a savestate with the given path")]
[LuaMethod("load", "Loads a savestate with the given path")]
public void Load(string path)
{
if (!File.Exists(path))
@ -30,7 +30,7 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes("loadslot", "Loads the savestate at the given slot number (must be an integer between 0 and 9)")]
[LuaMethod("loadslot", "Loads the savestate at the given slot number (must be an integer between 0 and 9)")]
public void LoadSlot(int slotNum)
{
if (slotNum >= 0 && slotNum <= 9)
@ -39,13 +39,13 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes("save", "Saves a state at the given path")]
[LuaMethod("save", "Saves a state at the given path")]
public void Save(string path)
{
GlobalWin.MainForm.SaveState(path, path, true);
}
[LuaMethodAttributes("saveslot", "Saves a state at the given save slot (must be an integer between 0 and 9)")]
[LuaMethod("saveslot", "Saves a state at the given save slot (must be an integer between 0 and 9)")]
public void SaveSlot(int slotNum)
{
if (slotNum >= 0 && slotNum <= 9)

View File

@ -8,7 +8,7 @@ using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk
{
[Description("A library for manipulating the Tastudio dialog of the EmuHawk client")]
[LuaLibraryAttributes(released: true)]
[LuaLibrary(released: true)]
public sealed class TastudioLuaLibrary : LuaLibraryBase
{
public TastudioLuaLibrary(Lua lua)
@ -21,19 +21,19 @@ namespace BizHawk.Client.EmuHawk
private TAStudio Tastudio => GlobalWin.Tools.Get<TAStudio>() as TAStudio;
[LuaMethodAttributes("engaged", "returns whether or not tastudio is currently engaged (active)")]
[LuaMethod("engaged", "returns whether or not tastudio is currently engaged (active)")]
public bool Engaged()
{
return GlobalWin.Tools.Has<TAStudio>(); // TODO: eventually tastudio should have an engaged flag
}
[LuaMethodAttributes("getrecording", "returns whether or not TAStudio is in recording mode")]
[LuaMethod("getrecording", "returns whether or not TAStudio is in recording mode")]
public bool GetRecording()
{
return Tastudio.TasPlaybackBox.RecordingMode;
}
[LuaMethodAttributes("setrecording", "sets the recording mode on/off depending on the parameter")]
[LuaMethod("setrecording", "sets the recording mode on/off depending on the parameter")]
public void SetRecording(bool val)
{
if (Tastudio.TasPlaybackBox.RecordingMode != val)
@ -42,13 +42,13 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes("togglerecording", "toggles tastudio recording mode on/off depending on its current state")]
[LuaMethod("togglerecording", "toggles tastudio recording mode on/off depending on its current state")]
public void SetRecording()
{
Tastudio.ToggleReadOnly();
}
[LuaMethodAttributes("setbranchtext", "adds the given message to the existing branch, or to the branch that will be created next if branch index is not specified")]
[LuaMethod("setbranchtext", "adds the given message to the existing branch, or to the branch that will be created next if branch index is not specified")]
public void SetBranchText(string text, int? index = null)
{
if (index != null)
@ -61,7 +61,7 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes("getmarker", "returns the marker text at the given frame, or an empty string if there is no marker for the given frame")]
[LuaMethod("getmarker", "returns the marker text at the given frame, or an empty string if there is no marker for the given frame")]
public string GetMarker(int frame)
{
if (Engaged())
@ -76,7 +76,7 @@ namespace BizHawk.Client.EmuHawk
return "";
}
[LuaMethodAttributes("removemarker", "if there is a marker for the given frame, it will be removed")]
[LuaMethod("removemarker", "if there is a marker for the given frame, it will be removed")]
public void RemoveMarker(int frame)
{
if (Engaged())
@ -90,7 +90,7 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes("setmarker", "Adds or sets a marker at the given frame, with an optional message")]
[LuaMethod("setmarker", "Adds or sets a marker at the given frame, with an optional message")]
public void SetMarker(int frame, string message = null)
{
if (Engaged())
@ -108,7 +108,7 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes("islag", "Returns whether or not the given frame was a lag frame, null if unknown")]
[LuaMethod("islag", "Returns whether or not the given frame was a lag frame, null if unknown")]
public bool? IsLag(int frame)
{
if (Engaged())
@ -122,7 +122,7 @@ namespace BizHawk.Client.EmuHawk
return null;
}
[LuaMethodAttributes("setlag", "Sets the lag information for the given frame, if the frame does not exist in the lag log, it will be added. If the value is null, the lag information for that frame will be removed")]
[LuaMethod("setlag", "Sets the lag information for the given frame, if the frame does not exist in the lag log, it will be added. If the value is null, the lag information for that frame will be removed")]
public void SetLag(int frame, bool? value)
{
if (Engaged())
@ -131,7 +131,7 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes("hasstate", "Returns whether or not the given frame has a savestate associated with it")]
[LuaMethod("hasstate", "Returns whether or not the given frame has a savestate associated with it")]
public bool HasState(int frame)
{
if (Engaged())
@ -145,7 +145,7 @@ namespace BizHawk.Client.EmuHawk
return false;
}
[LuaMethodAttributes("setplayback", "Seeks the given frame (a number) or marker (a string)")]
[LuaMethod("setplayback", "Seeks the given frame (a number) or marker (a string)")]
public void SetPlayback(object frame)
{
if (Engaged())
@ -173,8 +173,7 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes(
"onqueryitembg", "called during the background draw event of the tastudio listview. luaf must be a function that takes 2 params: index, column. The first is the integer row index of the listview, and the 2nd is the string column name. luaf should return a value that can be parsed into a .NET Color object (string color name, or integer value)")]
[LuaMethod("onqueryitembg", "called during the background draw event of the tastudio listview. luaf must be a function that takes 2 params: index, column. The first is the integer row index of the listview, and the 2nd is the string column name. luaf should return a value that can be parsed into a .NET Color object (string color name, or integer value)")]
public void OnQueryItemBg(LuaFunction luaf)
{
if (Engaged())
@ -194,8 +193,7 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes(
"onqueryitemtext", "called during the text draw event of the tastudio listview. luaf must be a function that takes 2 params: index, column. The first is the integer row index of the listview, and the 2nd is the string column name. luaf should return a value that can be parsed into a .NET Color object (string color name, or integer value)")]
[LuaMethod("onqueryitemtext", "called during the text draw event of the tastudio listview. luaf must be a function that takes 2 params: index, column. The first is the integer row index of the listview, and the 2nd is the string column name. luaf should return a value that can be parsed into a .NET Color object (string color name, or integer value)")]
public void OnQueryItemText(LuaFunction luaf)
{
if (Engaged())
@ -209,8 +207,7 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes(
"onqueryitemicon", "called during the icon draw event of the tastudio listview. luaf must be a function that takes 2 params: index, column. The first is the integer row index of the listview, and the 2nd is the string column name. luaf should return a value that can be parsed into a .NET Color object (string color name, or integer value)")]
[LuaMethod("onqueryitemicon", "called during the icon draw event of the tastudio listview. luaf must be a function that takes 2 params: index, column. The first is the integer row index of the listview, and the 2nd is the string column name. luaf should return a value that can be parsed into a .NET Color object (string color name, or integer value)")]
public void OnQueryItemIcon(LuaFunction luaf)
{
if (Engaged())
@ -230,7 +227,7 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes("ongreenzoneinvalidated", "called whenever the greenzone is invalidated and returns the first frame that was invalidated")]
[LuaMethod("ongreenzoneinvalidated", "called whenever the greenzone is invalidated and returns the first frame that was invalidated")]
public void OnGreenzoneInvalidated(LuaFunction luaf)
{
if (Engaged())
@ -242,7 +239,7 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes("getselection", "gets the currently selected frames")]
[LuaMethod("getselection", "gets the currently selected frames")]
public LuaTable GetSelection()
{
LuaTable table = Lua.NewTable();
@ -260,7 +257,7 @@ namespace BizHawk.Client.EmuHawk
return table;
}
[LuaMethodAttributes("insertframes", "inserts the given number of blank frames at the given insertion frame")]
[LuaMethod("insertframes", "inserts the given number of blank frames at the given insertion frame")]
public void InsertNumFrames(int insertionFrame, int numberOfFrames)
{
if (Engaged())
@ -276,7 +273,7 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes("deleteframes", "deletes the given number of blank frames beginning at the given frame")]
[LuaMethod("deleteframes", "deletes the given number of blank frames beginning at the given frame")]
public void DeleteFrames(int beginningFrame, int numberOfFrames)
{
if (Engaged())

View File

@ -47,10 +47,10 @@ namespace BizHawk.Client.EmuHawk
foreach (var lib in libs)
{
bool addLibrary = true;
var attributes = lib.GetCustomAttributes(typeof(LuaLibraryAttributes), false);
var attributes = lib.GetCustomAttributes(typeof(LuaLibraryAttribute), false);
if (attributes.Any())
{
addLibrary = VersionInfo.DeveloperBuild || (attributes.First() as LuaLibraryAttributes).Released;
addLibrary = VersionInfo.DeveloperBuild || (attributes.First() as LuaLibraryAttribute).Released;
}
if (addLibrary)
@ -73,7 +73,7 @@ namespace BizHawk.Client.EmuHawk
var methods = luaCanvas
.GetMethods()
.Where(m => m.GetCustomAttributes(typeof(LuaMethodAttributes), false).Any());
.Where(m => m.GetCustomAttributes(typeof(LuaMethodAttribute), false).Any());
foreach (var method in methods)
{

View File

@ -59,37 +59,37 @@ namespace BizHawk.Client.EmuHawk
_graphics = Graphics.FromImage(pictureBox.Image);
}
[LuaMethodAttributes("SetTitle", "Sets the canvas window title")]
[LuaMethod("SetTitle", "Sets the canvas window title")]
public void SetTitle(string title)
{
Text = title;
}
[LuaMethodAttributes("Clear", "Clears the canvas")]
[LuaMethod("Clear", "Clears the canvas")]
public void Clear(Color color)
{
_graphics.Clear(color);
}
[LuaMethodAttributes("Refresh", "Redraws the canvas")]
[LuaMethod("Refresh", "Redraws the canvas")]
public new void Refresh()
{
pictureBox.Refresh();
}
[LuaMethodAttributes("defaultForeground", "Sets the default foreground color to use in drawing methods, white by default")]
[LuaMethod("defaultForeground", "Sets the default foreground color to use in drawing methods, white by default")]
public void SetDefaultForegroundColor(Color color)
{
_defaultForeground = color;
}
[LuaMethodAttributes("defaultBackground", "Sets the default background color to use in drawing methods, transparent by default")]
[LuaMethod("defaultBackground", "Sets the default background color to use in drawing methods, transparent by default")]
public void SetDefaultBackgroundColor(Color color)
{
_defaultBackground = color;
}
[LuaMethodAttributes("drawBezier", "Draws a Bezier curve using the table of coordinates provided in the given color")]
[LuaMethod("drawBezier", "Draws a Bezier curve using the table of coordinates provided in the given color")]
public void DrawBezier(LuaTable points, Color color)
{
try
@ -116,8 +116,7 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes(
"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")]
[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, Color? line = null, Color? background = null)
{
try
@ -157,8 +156,7 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes(
"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")]
[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, Color? line = null, Color? background = null)
{
try
@ -179,8 +177,7 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes(
"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")]
[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)
{
try
@ -204,8 +201,7 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes(
"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")]
[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)
{
if (!File.Exists(path))
@ -231,8 +227,7 @@ namespace BizHawk.Client.EmuHawk
_graphics.DrawImage(img, x, y, width ?? img.Width, height ?? img.Height);
}
[LuaMethodAttributes(
"clearImageCache", "clears the image cache that is built up by using gui.drawImage, also releases the file handle for cached images")]
[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()
{
foreach (var image in _imageCache)
@ -243,8 +238,7 @@ namespace BizHawk.Client.EmuHawk
_imageCache.Clear();
}
[LuaMethodAttributes(
"drawImageRegion", "draws a given region of an image file from the given path at the given coordinate, and optionally with the given size")]
[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)
{
if (!File.Exists(path))
@ -269,31 +263,27 @@ namespace BizHawk.Client.EmuHawk
_graphics.DrawImage(img, destRect, source_x, source_y, source_width, source_height, GraphicsUnit.Pixel);
}
[LuaMethodAttributes(
"drawLine", "Draws a line from the first coordinate pair to the 2nd. Color is optional (if not specified it will be drawn black)")]
[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, Color? color = null)
{
_graphics.DrawLine(GetPen(color ?? _defaultForeground), x1, y1, x2, y2);
}
[LuaMethodAttributes("drawAxis", "Draws an axis of the specified size at the coordinate pair.)")]
[LuaMethod("drawAxis", "Draws an axis of the specified size at the coordinate pair.)")]
public void DrawAxis(int x, int y, int size, Color? color = null)
{
DrawLine(x + size, y, x - size, y, color);
DrawLine(x, y + size, x, y - size, color);
}
[LuaMethodAttributes(
"drawArc",
"draws a Arc shape at the given coordinates and the given width and height"
)]
[LuaMethod("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, Color? line = null)
{
var pen = new Pen(line.HasValue ? line.Value : Color.Black);
_graphics.DrawArc(pen, x, y, width, height, startangle, sweepangle);
}
[LuaMethodAttributes("drawPie", "draws a Pie shape at the given coordinates and the given width and height")]
[LuaMethod("drawPie", "draws a Pie shape at the given coordinates and the given width and height")]
public void DrawPie(
int x,
int y,
@ -314,8 +304,7 @@ namespace BizHawk.Client.EmuHawk
_graphics.DrawPie(GetPen(line ?? _defaultForeground), x + 1, y + 1, width - 1, height - 1, startangle, sweepangle);
}
[LuaMethodAttributes(
"drawPixel", "Draws a single pixel at the given coordinates in the given color. Color is optional (if not specified it will be drawn black)")]
[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, Color? color = null)
{
try
@ -329,8 +318,7 @@ namespace BizHawk.Client.EmuHawk
}
}
[LuaMethodAttributes(
"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")]
[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, Color? line = null, Color? background = null)
{
try
@ -358,9 +346,7 @@ namespace BizHawk.Client.EmuHawk
}
[LuaMethodAttributes(
"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")]
[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, Color? outline = null, Color? fill = null)
{
if (fill.HasValue)
@ -373,9 +359,7 @@ namespace BizHawk.Client.EmuHawk
_graphics.DrawRectangle(pen, x, y, width, height);
}
[LuaMethodAttributes(
"DrawText",
"Draws the given message 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.")]
[LuaMethod("DrawText", "Draws the given message 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.")]
public void DrawText(int x, int y, string message, Color? color = null, int? fontsize = null, string fontfamily = null, string fontstyle = null)
{
var family = FontFamily.GenericMonospace;