Add a LuaLibraryAttributes attribute to lua libraries with a Released property, only register libraries that are released except in Developer Builds, set tastudio library Released flag to false
This commit is contained in:
parent
489d69d20c
commit
538c4632af
|
@ -4,13 +4,23 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
public class LuaMethodAttributes : Attribute
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
|
||||
public LuaMethodAttributes(string name, string description)
|
||||
{
|
||||
Name = name;
|
||||
Description = description;
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
}
|
||||
|
||||
public class LuaLibraryAttributes : Attribute
|
||||
{
|
||||
public LuaLibraryAttributes(bool released)
|
||||
{
|
||||
Released = released;
|
||||
}
|
||||
|
||||
public bool Released { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ using LuaInterface;
|
|||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
[Description("A library for manipulating the Tastudio dialog of the EmuHawk client")]
|
||||
[LuaLibraryAttributes(released: false)]
|
||||
public sealed class TastudioLuaLibrary : LuaLibraryBase
|
||||
{
|
||||
public TastudioLuaLibrary(Lua lua)
|
||||
|
|
|
@ -49,6 +49,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
Docs.Clear();
|
||||
_caller = passed.Get();
|
||||
|
||||
|
||||
var tt = typeof(TastudioLuaLibrary);
|
||||
var mm = typeof(MainMemoryLuaLibrary);
|
||||
|
||||
var tatt = tt.GetCustomAttributes(typeof(LuaLibraryAttributes), false);
|
||||
var matt = mm.GetCustomAttributes(typeof(LuaLibraryAttributes), false);
|
||||
|
||||
// Register lua libraries
|
||||
var libs = Assembly
|
||||
.Load("BizHawk.Client.Common")
|
||||
|
@ -67,9 +74,19 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
foreach (var lib in libs)
|
||||
{
|
||||
var instance = (LuaLibraryBase)Activator.CreateInstance(lib, _lua);
|
||||
instance.LuaRegister(lib, Docs);
|
||||
Libraries.Add(lib, instance);
|
||||
bool addLibrary = true;
|
||||
var attributes = lib.GetCustomAttributes(typeof(LuaLibraryAttributes), false);
|
||||
if (attributes.Any())
|
||||
{
|
||||
addLibrary = VersionInfo.DeveloperBuild || (attributes.First() as LuaLibraryAttributes).Released;
|
||||
}
|
||||
|
||||
if (addLibrary)
|
||||
{
|
||||
var instance = (LuaLibraryBase)Activator.CreateInstance(lib, _lua);
|
||||
instance.LuaRegister(lib, Docs);
|
||||
Libraries.Add(lib, instance);
|
||||
}
|
||||
}
|
||||
|
||||
_lua.RegisterFunction("print", this, GetType().GetMethod("Print"));
|
||||
|
|
Loading…
Reference in New Issue