From 7797689c53f2de6a19913a1bd783e50d0ea173aa Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Wed, 1 Apr 2020 09:49:27 +1000 Subject: [PATCH] Add LuaDeprecatedMethodAttribute and apply to client.transformPointX/Y --- BizHawk.Client.Common/lua/LuaAttributes.cs | 3 +++ BizHawk.Client.Common/lua/LuaDocumentation.cs | 5 ++++- .../tools/Lua/Libraries/EmuLuaLibrary.Client.cs | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/BizHawk.Client.Common/lua/LuaAttributes.cs b/BizHawk.Client.Common/lua/LuaAttributes.cs index 0f9300a62c..dc3ba7affd 100644 --- a/BizHawk.Client.Common/lua/LuaAttributes.cs +++ b/BizHawk.Client.Common/lua/LuaAttributes.cs @@ -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 { diff --git a/BizHawk.Client.Common/lua/LuaDocumentation.cs b/BizHawk.Client.Common/lua/LuaDocumentation.cs index 59ee62163d..473c0c2bfc 100644 --- a/BizHawk.Client.Common/lua/LuaDocumentation.cs +++ b/BizHawk.Client.Common/lua/LuaDocumentation.cs @@ -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(false); _method = method; + IsDeprecated = method.GetCustomAttribute(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; diff --git a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs index 4436210c7b..d6f4dec6f5 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs @@ -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);