straighten out lua APIs for coordinate transforming
This commit is contained in:
parent
667a218c58
commit
377e4498d7
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Drawing;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
@ -663,26 +664,14 @@ namespace BizHawk.Client.ApiHawk
|
|||
InvokeMainFormMethod("TogglePause");
|
||||
}
|
||||
|
||||
public static int TransformPointX(int x)
|
||||
public static Point TransformPoint(Point point)
|
||||
{
|
||||
var point = new System.Drawing.Point(x, 0);
|
||||
Type t = ClientAssembly.GetType("BizHawk.Client.EmuHawk.GlobalWin");
|
||||
FieldInfo f = t.GetField("DisplayManager");
|
||||
object displayManager = f.GetValue(null);
|
||||
MethodInfo m = t.GetMethod("TransFormPoint");
|
||||
point = (System.Drawing.Point)m.Invoke(displayManager, new object[] { point });
|
||||
return point.X;
|
||||
}
|
||||
|
||||
public static int TransformPointY(int y)
|
||||
{
|
||||
var point = new System.Drawing.Point(0, y);
|
||||
Type t = ClientAssembly.GetType("BizHawk.Client.EmuHawk.GlobalWin");
|
||||
FieldInfo f = t.GetField("DisplayManager");
|
||||
object displayManager = f.GetValue(null);
|
||||
MethodInfo m = t.GetMethod("TransFormPoint");
|
||||
point = (System.Drawing.Point)m.Invoke(displayManager, new object[] { point });
|
||||
return point.Y;
|
||||
return point;
|
||||
}
|
||||
|
||||
public static void Unpause()
|
||||
|
|
|
@ -334,7 +334,11 @@ namespace BizHawk.Client.EmuHawk.Filters
|
|||
public override Vector2 UntransformPoint(string channel, Vector2 point)
|
||||
{
|
||||
point = Transform(matBotInvert, point);
|
||||
|
||||
//hack to accomodate input tracking system's float-point sense (based on the core's videobuffer height)
|
||||
//actually, this is needed for a reason similar to the "TouchScreenStart" that I removed.
|
||||
//So, something like that needs readding if we're to get rid of this hack.
|
||||
//(should redo it as a mouse coordinate offset or something.. but the key is to pipe it to the point where this is needed.. that is where MainForm does DisplayManager.UntransformPoint()
|
||||
point.Y *= 2;
|
||||
|
||||
//in case we're in this layout, we get confused, so fix it
|
||||
|
@ -351,8 +355,8 @@ namespace BizHawk.Client.EmuHawk.Filters
|
|||
|
||||
public override Vector2 TransformPoint(string channel, Vector2 point)
|
||||
{
|
||||
//NOT TESTED, probably needs adjustment
|
||||
return Transform(matBot, point);
|
||||
point = Transform(matBot, point);
|
||||
return point;
|
||||
}
|
||||
|
||||
public override void Run()
|
||||
|
|
|
@ -361,19 +361,28 @@ namespace BizHawk.Client.EmuHawk
|
|||
MainForm.TogglePause();
|
||||
}
|
||||
|
||||
[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)
|
||||
//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, 0);
|
||||
var point = new System.Drawing.Point(x, y);
|
||||
return GlobalWin.DisplayManager.TransformPoint(point).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)
|
||||
[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(0, y);
|
||||
var point = new System.Drawing.Point(x, y);
|
||||
return GlobalWin.DisplayManager.TransformPoint(point).Y;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue