Add LuaDeprecatedMethodAttribute and apply to client.transformPointX/Y

This commit is contained in:
YoshiRulz 2020-04-01 09:49:27 +10:00
parent 0437de604b
commit 7797689c53
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
3 changed files with 9 additions and 1 deletions

View File

@ -2,6 +2,9 @@
namespace BizHawk.Client.Common
{
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)]
public sealed class LuaDeprecatedMethodAttribute : Attribute {}
[AttributeUsage(AttributeTargets.Method)]
public sealed class LuaMethodAttribute : Attribute
{

View File

@ -40,7 +40,7 @@ __Types and notation__
** A standard Lua table
");
foreach (var library in this.Select(lf => new { Name = lf.Library, Description = lf.LibraryDescription }).Distinct())
foreach (var library in this.Where(lf => !lf.IsDeprecated).Select(lf => new { Name = lf.Library, Description = lf.LibraryDescription }).Distinct())
{
sb
.AppendFormat("%%TAB {0}%%", library.Name)
@ -166,6 +166,7 @@ __Types and notation__
_luaExampleAttribute = method.GetCustomAttribute<LuaMethodExampleAttribute>(false);
_method = method;
IsDeprecated = method.GetCustomAttribute<LuaDeprecatedMethodAttribute>(false) != null;
Library = library;
LibraryDescription = libraryDescription;
}
@ -173,6 +174,8 @@ __Types and notation__
public string Library { get; }
public string LibraryDescription { get; }
public readonly bool IsDeprecated;
public MethodInfo Method => _method;
public string Name => _luaAttributes.Name;

View File

@ -373,10 +373,12 @@ namespace BizHawk.Client.EmuHawk
}
#pragma warning disable CS0612
[LuaDeprecatedMethod]
[LuaMethodExample("local inclitra = client.transformPointX( 16 );")]
[LuaMethod("transformPointX", "Transforms an x-coordinate in emulator space to an x-coordinate in client space")]
public static int TransformPointX(int x) => ClientApi.TransformPointX(x);
[LuaDeprecatedMethod]
[LuaMethodExample("local inclitra = client.transformPointY( 32 );")]
[LuaMethod("transformPointY", "Transforms an y-coordinate in emulator space to an y-coordinate in client space")]
public static int TransformPointY(int y) => ClientApi.TransformPointY(y);