Clear ADV History presentation on exit

This commit is contained in:
gamer147
2026-07-19 11:32:36 -04:00
parent c30cf6cb08
commit 538e87d368
7 changed files with 46 additions and 3 deletions

View File

@@ -167,6 +167,8 @@ public class HistoryInteractionOpsTests
Assert.True(host.SawRenderedText);
Assert.True(host.HistoryReturned);
Assert.Equal(1, host.Waits); // the enclosing ADV page was never released or re-entered
Assert.Equal(1, host.HistoryPresentationEnds);
Assert.Empty(host.ActiveHistoryRenders);
var historyButtons = host.FirstHistoryFrame
.Where(render => render.Handle >= 0xd2fa && render.Handle <= 0xd300)

View File

@@ -18,6 +18,8 @@ internal class RecordingHost : IHost
public readonly List<(int Slot, int X, int Y)> TextCursors = new();
public readonly List<(int Surface, int X, int Y, string Text)> SurfaceStrings = new();
public readonly List<AdvTextHistoryRenderBatch> HistoryRenders = new();
public readonly Dictionary<int, AdvTextHistoryRenderBatch> ActiveHistoryRenders = new();
public int HistoryPresentationEnds;
public readonly List<int> ClearedTextLayouts = new();
public readonly List<SurfaceRectFill> SurfaceFills = new();
public readonly List<(long First, long Count)> PresentedRanges = new();
@@ -38,8 +40,21 @@ internal class RecordingHost : IHost
=> SurfaceStrings.Add((surfaceSlot, x, y, text));
public void DrawStringToSurface(int surfaceSlot, int x, int y, string text, AdvTextStyle style)
=> SurfaceStrings.Add((surfaceSlot, x, y, text));
public void ClearRenderedAdvTextLayout(int layoutSlot) => ClearedTextLayouts.Add(layoutSlot);
public void RenderTextHistory(AdvTextHistoryRenderBatch batch) => HistoryRenders.Add(batch);
public void ClearRenderedAdvTextLayout(int layoutSlot)
{
ClearedTextLayouts.Add(layoutSlot);
ActiveHistoryRenders.Remove(layoutSlot);
}
public void RenderTextHistory(AdvTextHistoryRenderBatch batch)
{
HistoryRenders.Add(batch);
ActiveHistoryRenders[batch.LayoutSlot] = batch;
}
public void EndTextHistoryPresentation()
{
HistoryPresentationEnds++;
ActiveHistoryRenders.Clear();
}
public int MessageWindowAlphaSetting { get; set; }
public void FillSurfaceRect(SurfaceRectFill fill) => SurfaceFills.Add(fill);
public void PresentObjectRange(GfxState gfx, long firstHandle, long count)

View File

@@ -24,6 +24,9 @@ public interface IHost
=> DrawStringToSurface(surfaceSlot, x, y, text);
void ClearRenderedAdvTextLayout(int layoutSlot) { }
void RenderTextHistory(AdvTextHistoryRenderBatch batch) { }
// History render batches are transient bindings, unlike the retained backlog itself. HISTORY.BIN's
// recording re-enable at exit ends that presentation and drops every bound target layout.
void EndTextHistoryPresentation() { }
int MessageWindowAlphaSetting => 0;
void FillSurfaceRect(SurfaceRectFill fill) { }
void PresentObjectRange(GfxState gfx, long firstHandle, long count) { }

View File

@@ -772,7 +772,12 @@ public sealed class VirtualMachine
case "reset-message-voice-state": // 0x1bc resets native per-message voice/queued-voice state
_autoVoicePending = false; return pc + 1;
case "set-text-history-recording": // 0x1bb: HISTORY.BIN suppresses recording its own UI
if (Read(a[0]) is 0 or 1) TextHistory.SetRecordingEnabled(Read(a[0]) == 1);
if (Read(a[0]) is 0 or 1)
{
bool enabled = Read(a[0]) == 1;
TextHistory.SetRecordingEnabled(enabled);
if (enabled) _host.EndTextHistoryPresentation();
}
return pc + 1;
case "append-text-history-metadata": // 0x1d2: typed value attached to the current group
TextHistory.AppendMetadata(Read(a[0]), Read(a[1]), _advTextStyle); return pc + 1;