From 0437de604b1df3590b1ee45ba402e82a4e617c2e Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Wed, 1 Apr 2020 09:31:06 +1000 Subject: [PATCH] Revert transformPoint* changes, add transformPoint, delegate all three --- .../Lua/Libraries/EmuLuaLibrary.Client.cs | 40 +++++++++---------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs index ba0f256649..4436210c7b 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs @@ -1,4 +1,5 @@ using System; +using System.Drawing; using System.ComponentModel; using System.Linq; @@ -361,30 +362,25 @@ namespace BizHawk.Client.EmuHawk MainForm.TogglePause(); } - //couldn't make this work.. - //[LuaMethodExample("local inclitra = client.transformPoint( 32, 100 );")] - //[LuaMethod("transformPoint", "Transforms a point in emulator space to a point in client space")] - //public static object TransformPoint(int x, int y) - //{ - // var point = new System.Drawing.Point(x, y); - // return GlobalWin.DisplayManager.TransformPoint(point); - //} - - [LuaMethodExample("local inclitra = client.transformPointX( 16, 100 );")] - [LuaMethod("transformPointX", "Transforms a point in emulator space to an x-coordinate in client space")] - public static int TransformPointX(int x, int y) - { - var point = new System.Drawing.Point(x, y); - return GlobalWin.DisplayManager.TransformPoint(point).X; + [LuaMethodExample("local newPoint = client.transformPoint( 32, 100 );")] + [LuaMethod("transformPoint", "Transforms a point in emulator space to a point in client space")] + public LuaTable TransformPoint(int x, int y) { + var transformed = ClientApi.TransformPoint(new Point(x, y)); + var table = Lua.NewTable(); + table["x"] = transformed.X; + table["y"] = transformed.Y; + return table; } - [LuaMethodExample("local inclitra = client.transformPointY( 16, 100 );")] - [LuaMethod("transformPointY", "Transforms a point in emulator space to a y-coordinate in client space")] - public static int TransformPointY(int x, int y) - { - var point = new System.Drawing.Point(x, y); - return GlobalWin.DisplayManager.TransformPoint(point).Y; - } +#pragma warning disable CS0612 + [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); + + [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); +#pragma warning restore CS0612 [LuaMethodExample("client.unpause( );")] [LuaMethod("unpause", "Unpauses the emulator")]