Fix menu cursor auto-move

This commit is contained in:
gamer147
2026-08-16 11:07:09 -04:00
parent d4d9def8f4
commit eef1225b56
11 changed files with 75 additions and 10 deletions

View File

@@ -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;

View File

@@ -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);