Lua - new Register method on some more libraries
This commit is contained in:
parent
583be2516c
commit
bce8320b85
|
@ -20,75 +20,131 @@ namespace BizHawk.Client.Common
|
||||||
"startswith",
|
"startswith",
|
||||||
"substring",
|
"substring",
|
||||||
"contains",
|
"contains",
|
||||||
"endswith",
|
"endswith"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static string string_hex(object num)
|
|
||||||
|
[LuaMethodAttributes(
|
||||||
|
"hex",
|
||||||
|
"TODO"
|
||||||
|
)]
|
||||||
|
public static string Hex(object num)
|
||||||
{
|
{
|
||||||
string hex = String.Format("{0:X}", LuaLong(num));
|
var hex = String.Format("{0:X}", LuaLong(num));
|
||||||
if (hex.Length == 1) hex = "0" + hex;
|
if (hex.Length == 1)
|
||||||
|
{
|
||||||
|
hex = "0" + hex;
|
||||||
|
}
|
||||||
|
|
||||||
return hex;
|
return hex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string string_binary(object num)
|
[LuaMethodAttributes(
|
||||||
|
"binary",
|
||||||
|
"TODO"
|
||||||
|
)]
|
||||||
|
public static string Binary(object num)
|
||||||
{
|
{
|
||||||
string binary = Convert.ToString( LuaLong(num), 2);
|
var binary = Convert.ToString(LuaLong(num), 2);
|
||||||
binary = binary.TrimStart('0');
|
binary = binary.TrimStart('0');
|
||||||
return binary;
|
return binary;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string string_octal(object num)
|
[LuaMethodAttributes(
|
||||||
|
"octal",
|
||||||
|
"TODO"
|
||||||
|
)]
|
||||||
|
public static string Octal(object num)
|
||||||
{
|
{
|
||||||
string octal = Convert.ToString(LuaLong(num),8);
|
var octal = Convert.ToString(LuaLong(num), 8);
|
||||||
if (octal.Length == 1) octal = "0" + octal;
|
if (octal.Length == 1)
|
||||||
|
{
|
||||||
|
octal = "0" + octal;
|
||||||
|
}
|
||||||
|
|
||||||
return octal;
|
return octal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string string_trim(string str)
|
[LuaMethodAttributes(
|
||||||
|
"trim",
|
||||||
|
"TODO"
|
||||||
|
)]
|
||||||
|
public static string Trim(string str)
|
||||||
{
|
{
|
||||||
return str.Trim();
|
return str.Trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string string_replace(string str, string str2, string replace)
|
[LuaMethodAttributes(
|
||||||
|
"replace",
|
||||||
|
"TODO"
|
||||||
|
)]
|
||||||
|
public static string Replace(string str, string str2, string replace)
|
||||||
{
|
{
|
||||||
return str.Replace(str2, replace);
|
return str.Replace(str2, replace);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string string_toupper(string str)
|
[LuaMethodAttributes(
|
||||||
|
"toupper",
|
||||||
|
"TODO"
|
||||||
|
)]
|
||||||
|
public static string ToUpper(string str)
|
||||||
{
|
{
|
||||||
return str.ToUpper();
|
return str.ToUpper();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string string_tolower(string str)
|
[LuaMethodAttributes(
|
||||||
|
"tolower",
|
||||||
|
"TODO"
|
||||||
|
)]
|
||||||
|
public static string ToLower(string str)
|
||||||
{
|
{
|
||||||
return str.ToLower();
|
return str.ToLower();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string string_substring(string str, object position, object length)
|
[LuaMethodAttributes(
|
||||||
|
"substring",
|
||||||
|
"TODO"
|
||||||
|
)]
|
||||||
|
public static string SubString(string str, object position, object length)
|
||||||
{
|
{
|
||||||
return str.Substring((int)position, (int)length);
|
return str.Substring((int)position, (int)length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string string_remove(string str, object position, object count)
|
[LuaMethodAttributes(
|
||||||
|
"remove",
|
||||||
|
"TODO"
|
||||||
|
)]
|
||||||
|
public static string Remove(string str, object position, object count)
|
||||||
{
|
{
|
||||||
return str.Remove((int) position,(int) (count));
|
return str.Remove((int)position, (int)count);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool string_contains(string str, string str2)
|
[LuaMethodAttributes(
|
||||||
|
"contains",
|
||||||
|
"TODO"
|
||||||
|
)]
|
||||||
|
public static bool Contains(string str, string str2)
|
||||||
{
|
{
|
||||||
return str.Contains(str2);
|
return str.Contains(str2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool string_startswith(string str, string str2)
|
[LuaMethodAttributes(
|
||||||
|
"startswith",
|
||||||
|
"TODO"
|
||||||
|
)]
|
||||||
|
public static bool StartsWith(string str, string str2)
|
||||||
{
|
{
|
||||||
return str.StartsWith(str2);
|
return str.StartsWith(str2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool string_endswith(string str, string str2)
|
[LuaMethodAttributes(
|
||||||
|
"endswith",
|
||||||
|
"TODO"
|
||||||
|
)]
|
||||||
|
public static bool EndsWith(string str, string str2)
|
||||||
{
|
{
|
||||||
return str.EndsWith(str2);
|
return str.EndsWith(str2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
using LuaInterface;
|
|
||||||
using BizHawk.Client.Common;
|
using BizHawk.Client.Common;
|
||||||
|
using LuaInterface;
|
||||||
|
|
||||||
namespace BizHawk.Client.EmuHawk
|
namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
|
@ -28,17 +28,26 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private readonly Lua _lua;
|
private readonly Lua _lua;
|
||||||
|
|
||||||
public LuaTable input_get()
|
[LuaMethodAttributes(
|
||||||
|
"get",
|
||||||
|
"TODO"
|
||||||
|
)]
|
||||||
|
public LuaTable Get()
|
||||||
{
|
{
|
||||||
var buttons = _lua.NewTable();
|
var buttons = _lua.NewTable();
|
||||||
foreach (var kvp in Global.ControllerInputCoalescer.BoolButtons().Where(kvp => kvp.Value))
|
foreach (var kvp in Global.ControllerInputCoalescer.BoolButtons().Where(kvp => kvp.Value))
|
||||||
{
|
{
|
||||||
buttons[kvp.Key] = true;
|
buttons[kvp.Key] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return buttons;
|
return buttons;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LuaTable input_getmouse()
|
[LuaMethodAttributes(
|
||||||
|
"getmouse",
|
||||||
|
"TODO"
|
||||||
|
)]
|
||||||
|
public LuaTable GetMouse()
|
||||||
{
|
{
|
||||||
var buttons = _lua.NewTable();
|
var buttons = _lua.NewTable();
|
||||||
var p = GlobalWin.RenderPanel.ScreenToScreen(Control.MousePosition);
|
var p = GlobalWin.RenderPanel.ScreenToScreen(Control.MousePosition);
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using LuaInterface;
|
|
||||||
using BizHawk.Client.Common;
|
using BizHawk.Client.Common;
|
||||||
|
|
||||||
namespace BizHawk.Client.EmuHawk
|
namespace BizHawk.Client.EmuHawk
|
||||||
|
@ -16,45 +15,54 @@ namespace BizHawk.Client.EmuHawk
|
||||||
"load",
|
"load",
|
||||||
"loadslot",
|
"loadslot",
|
||||||
"save",
|
"save",
|
||||||
"saveslot",
|
"saveslot"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void savestate_load(object lua_input)
|
[LuaMethodAttributes(
|
||||||
|
"load",
|
||||||
|
"TODO"
|
||||||
|
)]
|
||||||
|
public void Load(string path)
|
||||||
{
|
{
|
||||||
if (lua_input is string)
|
GlobalWin.MainForm.LoadState(path, Path.GetFileName(path), true);
|
||||||
{
|
|
||||||
GlobalWin.MainForm.LoadState(lua_input.ToString(), Path.GetFileName(lua_input.ToString()), true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void savestate_loadslot(object lua_input)
|
[LuaMethodAttributes(
|
||||||
|
"loadslot",
|
||||||
|
"TODO"
|
||||||
|
)]
|
||||||
|
public void LoadSlot(object slotNum)
|
||||||
{
|
{
|
||||||
int slot = LuaInt(lua_input);
|
var slot = LuaInt(slotNum);
|
||||||
|
|
||||||
if (slot >= 0 && slot <= 9)
|
if (slot >= 0 && slot <= 9)
|
||||||
{
|
{
|
||||||
GlobalWin.MainForm.LoadQuickSave("QuickSave" + slot.ToString(), true);
|
GlobalWin.MainForm.LoadQuickSave("QuickSave" + slot, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void savestate_save(object lua_input)
|
[LuaMethodAttributes(
|
||||||
|
"save",
|
||||||
|
"TODO"
|
||||||
|
)]
|
||||||
|
public void Save(string path)
|
||||||
{
|
{
|
||||||
if (lua_input is string)
|
|
||||||
{
|
|
||||||
string path = lua_input.ToString();
|
|
||||||
GlobalWin.MainForm.SaveState(path, path, true);
|
GlobalWin.MainForm.SaveState(path, path, true);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void savestate_saveslot(object lua_input)
|
[LuaMethodAttributes(
|
||||||
|
"saveslot",
|
||||||
|
"TODO"
|
||||||
|
)]
|
||||||
|
public void SaveSlot(object slotNum)
|
||||||
{
|
{
|
||||||
int slot = LuaInt(lua_input);
|
var slot = LuaInt(slotNum);
|
||||||
|
|
||||||
if (slot >= 0 && slot <= 9)
|
if (slot >= 0 && slot <= 9)
|
||||||
{
|
{
|
||||||
GlobalWin.MainForm.SaveQuickSave("QuickSave" + slot.ToString());
|
GlobalWin.MainForm.SaveQuickSave("QuickSave" + slot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,15 +93,15 @@ namespace BizHawk.Client.EmuHawk
|
||||||
_eventLibrary.LuaRegisterNew(lua, Docs);
|
_eventLibrary.LuaRegisterNew(lua, Docs);
|
||||||
_formsLibrary.LuaRegister(lua, Docs);
|
_formsLibrary.LuaRegister(lua, Docs);
|
||||||
_guiLibrary.LuaRegister(lua, Docs);
|
_guiLibrary.LuaRegister(lua, Docs);
|
||||||
new InputLuaLibrary(_lua).LuaRegister(lua, Docs);
|
new InputLuaLibrary(_lua).LuaRegisterNew(lua, Docs);
|
||||||
new JoypadLuaLibrary(_lua).LuaRegisterNew(lua, Docs);
|
new JoypadLuaLibrary(_lua).LuaRegisterNew(lua, Docs);
|
||||||
new MemoryLuaLibrary().LuaRegisterNew(lua, Docs);
|
new MemoryLuaLibrary().LuaRegisterNew(lua, Docs);
|
||||||
new MainMemoryLuaLibrary(_lua).LuaRegisterNew(lua, Docs);
|
new MainMemoryLuaLibrary(_lua).LuaRegisterNew(lua, Docs);
|
||||||
new MovieLuaLibrary(_lua).LuaRegisterNew(lua, Docs);
|
new MovieLuaLibrary(_lua).LuaRegisterNew(lua, Docs);
|
||||||
new NESLuaLibrary().LuaRegisterNew(lua, Docs);
|
new NESLuaLibrary().LuaRegisterNew(lua, Docs);
|
||||||
new SavestateLuaLibrary().LuaRegister(lua, Docs);
|
new SavestateLuaLibrary().LuaRegisterNew(lua, Docs);
|
||||||
new SNESLuaLibrary().LuaRegisterNew(lua, Docs);
|
new SNESLuaLibrary().LuaRegisterNew(lua, Docs);
|
||||||
new StringLuaLibrary().LuaRegister(lua, Docs);
|
new StringLuaLibrary().LuaRegisterNew(lua, Docs);
|
||||||
|
|
||||||
Docs.Sort();
|
Docs.Sort();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue