luaimplementation: input.getmouse(): button fields are now bools. position fields are now in emulated screen coordinates. no, it doesn't quite work right for some cases of window sizing... so don't do that!
This commit is contained in:
parent
79f5a344e1
commit
e8a54aaeed
|
@ -2530,13 +2530,14 @@ namespace BizHawk.MultiClient
|
||||||
public LuaTable input_getmouse()
|
public LuaTable input_getmouse()
|
||||||
{
|
{
|
||||||
LuaTable buttons = lua.NewTable();
|
LuaTable buttons = lua.NewTable();
|
||||||
buttons["X"] = Control.MousePosition.X;
|
Point p = Global.RenderPanel.ScreenToScreen(Control.MousePosition);
|
||||||
buttons["Y"] = Control.MousePosition.Y;
|
buttons["X"] = p.X;
|
||||||
buttons[MouseButtons.Left.ToString()] = Control.MouseButtons & MouseButtons.Left;
|
buttons["Y"] = p.Y;
|
||||||
buttons[MouseButtons.Middle.ToString()] = Control.MouseButtons & MouseButtons.Middle;
|
buttons[MouseButtons.Left.ToString()] = (Control.MouseButtons & MouseButtons.Left) != 0;
|
||||||
buttons[MouseButtons.Right.ToString()] = Control.MouseButtons & MouseButtons.Right;
|
buttons[MouseButtons.Middle.ToString()] = (Control.MouseButtons & MouseButtons.Middle) != 0;
|
||||||
buttons[MouseButtons.XButton1.ToString()] = Control.MouseButtons & MouseButtons.XButton1;
|
buttons[MouseButtons.Right.ToString()] = (Control.MouseButtons & MouseButtons.Right) != 0;
|
||||||
buttons[MouseButtons.XButton2.ToString()] = Control.MouseButtons & MouseButtons.XButton2;
|
buttons[MouseButtons.XButton1.ToString()] = (Control.MouseButtons & MouseButtons.XButton1) != 0;
|
||||||
|
buttons[MouseButtons.XButton2.ToString()] = (Control.MouseButtons & MouseButtons.XButton2) != 0;
|
||||||
return buttons;
|
return buttons;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -133,6 +133,12 @@ namespace BizHawk.MultiClient
|
||||||
void Present();
|
void Present();
|
||||||
bool Resized { get; set; }
|
bool Resized { get; set; }
|
||||||
Size NativeSize { get; }
|
Size NativeSize { get; }
|
||||||
|
/// <summary>
|
||||||
|
/// convert coordinates
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="p">desktop coordinates</param>
|
||||||
|
/// <returns>ivideoprovider coordinates</returns>
|
||||||
|
Point ScreenToScreen(Point p);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SysdrawingRenderPanel : IRenderer, IBlitter
|
public class SysdrawingRenderPanel : IRenderer, IBlitter
|
||||||
|
@ -148,7 +154,7 @@ namespace BizHawk.MultiClient
|
||||||
{
|
{
|
||||||
backingControl.ReleaseCallback = RetainedViewportPanelDisposeCallback;
|
backingControl.ReleaseCallback = RetainedViewportPanelDisposeCallback;
|
||||||
|
|
||||||
lock(this)
|
lock (this)
|
||||||
tempBuffer = surfaceSet.AllocateSurface(backingControl.Width, backingControl.Height, false);
|
tempBuffer = surfaceSet.AllocateSurface(backingControl.Width, backingControl.Height, false);
|
||||||
|
|
||||||
RenderInternal(surface, false);
|
RenderInternal(surface, false);
|
||||||
|
@ -176,7 +182,7 @@ namespace BizHawk.MultiClient
|
||||||
void IBlitter.Open()
|
void IBlitter.Open()
|
||||||
{
|
{
|
||||||
g = Graphics.FromImage(tempBuffer.PeekBitmap());
|
g = Graphics.FromImage(tempBuffer.PeekBitmap());
|
||||||
ClipBounds = new Rectangle(0, 0, NativeSize.Width, NativeSize.Height);
|
ClipBounds = new Rectangle(0, 0, NativeSize.Width, NativeSize.Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IBlitter.Close()
|
void IBlitter.Close()
|
||||||
|
@ -227,6 +233,10 @@ namespace BizHawk.MultiClient
|
||||||
else
|
else
|
||||||
g.DrawImage(surface.PeekBitmap(), 0, 0, backingControl.Width, backingControl.Height);
|
g.DrawImage(surface.PeekBitmap(), 0, 0, backingControl.Width, backingControl.Height);
|
||||||
}
|
}
|
||||||
|
if (!transparent)
|
||||||
|
{
|
||||||
|
lastsize = new Size(surface.Width, surface.Height);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FastRenderAndPresent(DisplaySurface surface)
|
public void FastRenderAndPresent(DisplaySurface surface)
|
||||||
|
@ -252,6 +262,15 @@ namespace BizHawk.MultiClient
|
||||||
AlertFont = new sysdrawingfont("Courier", 14, FontStyle.Bold, GraphicsUnit.Pixel);
|
AlertFont = new sysdrawingfont("Courier", 14, FontStyle.Bold, GraphicsUnit.Pixel);
|
||||||
}
|
}
|
||||||
RetainedViewportPanel backingControl;
|
RetainedViewportPanel backingControl;
|
||||||
|
|
||||||
|
Size lastsize = new Size(256, 192);
|
||||||
|
public Point ScreenToScreen(Point p)
|
||||||
|
{
|
||||||
|
p = backingControl.PointToClient(p);
|
||||||
|
Point ret = new Point(p.X * lastsize.Width / backingControl.Width,
|
||||||
|
p.Y * lastsize.Height / backingControl.Height);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IBlitter
|
public interface IBlitter
|
||||||
|
@ -561,6 +580,14 @@ namespace BizHawk.MultiClient
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Point ScreenToScreen(Point p)
|
||||||
|
{
|
||||||
|
p = backingControl.PointToClient(p);
|
||||||
|
Point ret = new Point(p.X * Texture.ImageWidth / backingControl.Width,
|
||||||
|
p.Y * Texture.ImageHeight / backingControl.Height);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue