From bad2bda4f4522db91192927a7de428835870a99b Mon Sep 17 00:00:00 2001 From: scepheo Date: Fri, 10 Oct 2014 11:02:18 +0000 Subject: [PATCH] Added Lua functions to work with the letterboxing of the emulator, and for transforming emulator space points to client space. --- .../Lua/Libraries/EmuLuaLibrary.Client.cs | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs index 9c34491791..5daa423bb8 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs @@ -27,6 +27,50 @@ namespace BizHawk.Client.EmuHawk public override string Name { get { return "client"; } } + [LuaMethodAttributes( + "borderheight", + "Gets the current height in pixels of the border around the emulator's drawing area" + )] + public static int BorderHeight() + { + var point = new System.Drawing.Point(0, 0); + return GlobalWin.DisplayManager.TransformPoint(point).Y; + } + + [LuaMethodAttributes( + "borderwidth", + "Gets the current width in pixels of the border around the emulator's drawing area" + )] + public static int BorderWidth() + { + var point = new System.Drawing.Point(0, 0); + return GlobalWin.DisplayManager.TransformPoint(point).X; + } + + [LuaMethodAttributes( + "bufferheight", + "Gets the current height in pixels of the emulator's drawing area" + )] + public static int BufferHeight() + { + var height = Global.Emulator.VideoProvider.BufferHeight; + var point = new System.Drawing.Point(0, height); + + return GlobalWin.DisplayManager.TransformPoint(point).Y - BorderHeight(); + } + + [LuaMethodAttributes( + "bufferwidth", + "Gets the current width in pixels of the emulator's drawing area" + )] + public static int BufferWidth() + { + var width = Global.Emulator.VideoProvider.BufferWidth; + var point = new System.Drawing.Point(width, 0); + + return GlobalWin.DisplayManager.TransformPoint(point).X - BorderWidth(); + } + [LuaMethodAttributes( "clearautohold", "Clears all autohold keys" @@ -309,6 +353,26 @@ namespace BizHawk.Client.EmuHawk { GlobalWin.MainForm.TogglePause(); } + + [LuaMethodAttributes( + "transformPointX", + "Transforms an x-coordinate in emulator space to an x-coordinate in client space" + )] + public static int TransformPointX(int x) + { + var point = new System.Drawing.Point(x, 0); + return GlobalWin.DisplayManager.TransformPoint(point).X; + } + + [LuaMethodAttributes( + "transformPointY", + "Transforms an y-coordinate in emulator space to an y-coordinate in client space" + )] + public static int TransformPointY(int y) + { + var point = new System.Drawing.Point(0, y); + return GlobalWin.DisplayManager.TransformPoint(point).Y; + } [LuaMethodAttributes( "unpause",