Fix ADV config opacity and text lifetime
This commit is contained in:
@@ -226,11 +226,36 @@ public class AdvTextOpsTests
|
||||
Assert.Equal((53, 10, 495, 60), CursorAndBounds(history.GetLayoutSnapshot(8)));
|
||||
history.ResetLayout(9);
|
||||
Assert.Equal((10, 10, 250, 368), CursorAndBounds(history.GetLayoutSnapshot(9)));
|
||||
Assert.Equal(new[] { 1 }, history.LayoutsCoveredByTextObjectErase(0xd6d8, 0x1f4));
|
||||
Assert.Equal(new[] { 7 }, history.LayoutsCoveredByTextObjectErase(0x7d0, 0x1f4));
|
||||
|
||||
static (int X, int Y, int Right, int Bottom) CursorAndBounds(AdvTextLayoutSnapshot layout)
|
||||
=> (layout.CursorX, layout.CursorY, layout.Right, layout.Bottom);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FullNativeGlyphRangeEraseClearsDetachedLayoutPresentation()
|
||||
{
|
||||
var table = OpcodeTableJson.Load(Paths.OpcodesJson);
|
||||
static Operand I(long value) => new(0, value);
|
||||
var script = ScriptAssembler.Assemble(table, "ADV_GLYPH_ERASE",
|
||||
new List<(int, Operand[])>
|
||||
{
|
||||
(0x70, new[] { I(1), I(800), I(160), I(0), I(430) }),
|
||||
(0x213, new[] { I(1), I(0xd6d8), I(0x1f4) }),
|
||||
(0x1f7, new[] { I(0xd6d8), I(1) }), // partial erase cannot clear collapsed text
|
||||
(0x1f7, new[] { I(0xd6d8), I(0x1f4) }), // SC0000 transition teardown
|
||||
(0x2, Array.Empty<Operand>()),
|
||||
}, Array.Empty<string>());
|
||||
var host = new RecordingHost();
|
||||
var vm = new VirtualMachine(script, table, host);
|
||||
|
||||
vm.Run();
|
||||
|
||||
Assert.Equal(new[] { 1 }, host.ClearedTextLayouts);
|
||||
Assert.Null(vm.Gfx.TryGet(1)); // 0x213 configures the ADV layout, not retained gfx handle 1
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WaitIndicatorConfigurationReachesHost()
|
||||
{
|
||||
|
||||
@@ -69,6 +69,25 @@ public class HistoryPresentationOpsTests
|
||||
Assert.Equal((0L, 60000L), Assert.Single(host.PresentedRanges));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MessageWindowAlphaSetterImmediatelyFeedsThePairedGetter()
|
||||
{
|
||||
var script = ScriptAssembler.Assemble(Table, "MESSAGE_WINDOW_ALPHA",
|
||||
new List<(int, Operand[])>
|
||||
{
|
||||
(0x141, new[] { I(7) }),
|
||||
(0x131, new[] { G(0x100) }),
|
||||
(0x2, Array.Empty<Operand>()),
|
||||
}, Array.Empty<string>());
|
||||
var host = new RecordingHost();
|
||||
var vm = new VirtualMachine(script, Table, host);
|
||||
|
||||
vm.Run();
|
||||
|
||||
Assert.Equal(7, host.MessageWindowAlphaSetting);
|
||||
Assert.Equal(7, vm.Globals[0x100]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ResetLayoutClearsItsPreviouslyBoundHostPresentation()
|
||||
{
|
||||
|
||||
@@ -101,6 +101,35 @@ public class RenderObjectBlendTests
|
||||
Assert.Equal(255, g.SnapshotVisibleObjects().Single(x => x.Handle == idle).Alpha);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AdvCallbackRebuild_PostBindStaticAlphaControlsBackingOpacity()
|
||||
{
|
||||
const long backing = 0xd2f0;
|
||||
var g = new GfxState();
|
||||
g.SetSurface(0x11, resId: 0x1234, colorKey: -1);
|
||||
|
||||
// CALLBACK_SETTING erases the old ADV family, recreates the backing from SO001, then applies
|
||||
// (16-MesWinAlpha)<<4 through static mode-0 op 0x203.
|
||||
g.EraseRange(backing, 7);
|
||||
g.BindDraw(backing, 0x11, 0, 0, 800, 227, 0, 373);
|
||||
g.SetStaticObjectColorResolved(backing, mode: 0, alpha: 0x80, rgb: 0x000000);
|
||||
|
||||
var rebuilt = g.SnapshotVisibleObjects().Single();
|
||||
Assert.Equal(0x80, rebuilt.Alpha);
|
||||
Assert.Equal(0x000000, rebuilt.Tint);
|
||||
Assert.True(rebuilt.MultiplyTint);
|
||||
|
||||
// A later draw-texture bind starts a new presentation lifetime and clears the post-bind latch.
|
||||
g.BindDraw(backing, 0x11, 0, 0, 800, 227, 0, 373);
|
||||
Assert.Equal(255, g.SnapshotVisibleObjects().Single().Alpha);
|
||||
|
||||
// Opening CONFIG again repeats the erase/rebuild sequence and must accept the next setting too.
|
||||
g.EraseRange(backing, 7);
|
||||
g.BindDraw(backing, 0x11, 0, 0, 800, 227, 0, 373);
|
||||
g.SetStaticObjectColorResolved(backing, mode: 0, alpha: 0x20, rgb: 0x000000);
|
||||
Assert.Equal(0x20, g.SnapshotVisibleObjects().Single().Alpha);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TransitionCleanup_Mode2ToMode0PreservedWhite_RemainsIdentity()
|
||||
{
|
||||
|
||||
@@ -99,6 +99,7 @@ internal class RecordingHost : IHost
|
||||
ActiveHistoryRenders.Clear();
|
||||
}
|
||||
public int MessageWindowAlphaSetting { get; set; }
|
||||
public void SetMessageWindowAlphaSetting(int value) => MessageWindowAlphaSetting = value;
|
||||
public void FillSurfaceRect(SurfaceRectFill fill) => SurfaceFills.Add(fill);
|
||||
public void CopySurfaceRect(SurfaceRectCopy copy) => SurfaceCopies.Add(copy);
|
||||
public void PresentObjectRange(GfxState gfx, long firstHandle, long count)
|
||||
|
||||
Reference in New Issue
Block a user