Correct ADV Hide Window restore behavior

This commit is contained in:
gamer147
2026-07-18 22:23:06 -04:00
parent ad022ace51
commit 66b13315f2
13 changed files with 177 additions and 35 deletions

View File

@@ -41,6 +41,7 @@ public sealed class GodotAdvHost : IHost
private AudioPayload? _queuedSkippedVoice;
private int _activeWaitLayout;
private long _waitIndicatorStartedMs;
private volatile bool _advPagePresentationSuspended;
private GfxState? _foregroundGfx;
public volatile bool IsWaiting;
public volatile bool IsTransitionWaiting;
@@ -131,7 +132,7 @@ public sealed class GodotAdvHost : IHost
public AdvWaitIndicatorSnapshot? SnapshotAdvWaitIndicator()
{
if (!IsWaiting) return null;
if (!IsWaiting || _advPagePresentationSuspended) return null;
AdvWaitIndicatorConfig config;
long resourceId;
lock (_textLock)
@@ -250,6 +251,14 @@ public sealed class GodotAdvHost : IHost
public void WakeInputCallbackService() => _inputCallbackSignal.Set();
public bool IsAdvPagePresentationSuspended => _advPagePresentationSuspended;
public void SetAdvPagePresentationSuspended(bool suspended)
{
_advPagePresentationSuspended = suspended;
_timeline?.State(suspended ? "adv-page-suspended" : "adv-page-restored", new());
}
public void InputCallbackCompleted(GfxState gfx)
=> Interlocked.Exchange(ref _presentRequested, 1);

View File

@@ -350,15 +350,23 @@ public partial class Main : Godot.Control
&& (mb.ButtonIndex == MouseButton.Left || mb.ButtonIndex == MouseButton.Right))
{
var p = ToNativeScreen(mb.Position);
bool advPageSuspended = _host.IsAdvPagePresentationSuspended;
_vm.UpdatePointer(p.X, p.Y);
int nativeButtonBit = mb.ButtonIndex == MouseButton.Left ? 0x1 : 0x2;
_vm.UpdateMouseButtonState(nativeButtonBit, mb.Pressed);
// AGE exposes the physical left button twice: raw mask 0x1 for the timed mouse callback,
// and the configured primary action (default input callback index 4). During HIDEWIN the
// activation click's release arms the script; the next completed left click restores it.
if (mb.ButtonIndex == MouseButton.Left && advPageSuspended)
_vm.QueueInputCallback(mb.Pressed ? 4 : 10);
if (mb.ButtonIndex == MouseButton.Left && mb.Pressed && _vm.TryActivatePointer(p.X, p.Y))
{
GetViewport().SetInputAsHandled();
return;
}
if (mb.ButtonIndex == MouseButton.Left && mb.Pressed) _host.SignalInput();
// A left click owned by the yielded page must return through HIDEWIN's callback/coroutine
// path. Releasing the enclosing ADV wait here would also advance the restored dialogue page.
if (mb.ButtonIndex == MouseButton.Left && mb.Pressed && !advPageSuspended) _host.SignalInput();
return;
}
UpdateAgeInputCallback(e, "ui_down", 0);
@@ -515,6 +523,8 @@ public partial class Main : Godot.Control
private void UpdateAdvTextPresentation()
{
_text.Visible = !_host.IsAdvPagePresentationSuspended;
if (!_text.Visible) return;
var t = _host.SnapshotAdvText();
_text.Position = new Vector2(t.X, 430 + t.Y);
_text.Size = new Vector2(System.Math.Max(1, 720 - t.X), System.Math.Max(1, 147 - t.Y));