Fix menu cursor auto-move
This commit is contained in:
@@ -482,6 +482,13 @@ public sealed partial class GodotAdvHost
|
||||
_timeline?.Event("cursor-clear", new());
|
||||
}
|
||||
|
||||
public void WarpCursor(int virtualX, int virtualY)
|
||||
{
|
||||
// Script execution is on the VM thread; Godot input/display APIs belong to the main thread.
|
||||
_main.CallDeferred("WarpAgeCursor", virtualX, virtualY);
|
||||
_timeline?.Event("cursor-warp", new() { ["x"] = virtualX, ["y"] = virtualY });
|
||||
}
|
||||
|
||||
public void WaitForForegroundTransition(GfxState gfx)
|
||||
{
|
||||
_foregroundTransitionWaitBypassed = false;
|
||||
|
||||
@@ -256,6 +256,17 @@ public partial class Main
|
||||
(int)System.Math.Floor(position.Y * _screenHeight / size.Y));
|
||||
}
|
||||
|
||||
public void WarpAgeCursor(int virtualX, int virtualY)
|
||||
{
|
||||
// Viewport.WarpMouse expects viewport coordinates. This is the inverse of ToNativeScreen and
|
||||
// lets Godot account for the platform window origin before moving the desktop pointer.
|
||||
Vector2 size = GetViewport().GetVisibleRect().Size;
|
||||
if (size.X <= 0 || size.Y <= 0 || _screenWidth <= 0 || _screenHeight <= 0) return;
|
||||
GetViewport().WarpMouse(new Vector2(
|
||||
virtualX * size.X / _screenWidth,
|
||||
virtualY * size.Y / _screenHeight));
|
||||
}
|
||||
|
||||
public void SetAgeCursor(byte[] rgba, int width, int height, int hotspotX, int hotspotY)
|
||||
{
|
||||
var image = Image.CreateFromData(width, height, false, Image.Format.Rgba8, rgba);
|
||||
|
||||
Reference in New Issue
Block a user