Implement AGE text line spacing

This commit is contained in:
gamer147
2026-07-19 23:32:38 -04:00
parent b8928ec7b8
commit e0aae05f32
11 changed files with 90 additions and 17 deletions

View File

@@ -17,7 +17,7 @@ public class HistoryPresentationOpsTests
history.DefineLayout(1, 640, 160, 80, 430);
history.AppendMetadata(9, 2, AdvTextStyle.Default);
history.AppendText(0, 10, "retained dialogue", new AdvTextStyle(24, 8, false,
0xffffff, 0x606060, 3, 1, 1));
0xffffff, 0x606060, 3, 1, 1, 9));
history.ResetLayout(1);
history.AppendText(0, 11, "next group", AdvTextStyle.Default);
history.SetRecordingEnabled(false);
@@ -29,6 +29,7 @@ public class HistoryPresentationOpsTests
{
(0x198, new[] { I(4), I(65), I(150) }),
(0x7a, new[] { I(4), I(45), I(42) }),
(0x8b, new[] { I(8) }),
(0x1d1, new[] { I(4), I(0), I(0), I(0), I(0) }),
(0x2, Array.Empty<Operand>()),
}, Array.Empty<string>());
@@ -41,8 +42,9 @@ public class HistoryPresentationOpsTests
Assert.Equal((4, 0, "retained dialogue"),
(render.LayoutSlot, render.FirstRecordIndex, render.Text));
Assert.Equal(new AdvTextLayoutSnapshot(4, 600, 150, 65, 150, 45, 42), render.Layout);
Assert.Equal((24, 0xffffffL, 0x606060L),
(render.Style.PrimaryFontSize, render.Style.TextColor, render.Style.EffectColor));
Assert.Equal((24, 0xffffffL, 0x606060L, 8),
(render.Style.PrimaryFontSize, render.Style.TextColor, render.Style.EffectColor,
render.Style.LineSpacing));
}
[Fact]
@@ -97,6 +99,8 @@ public class HistoryPresentationOpsTests
Assert.NotEqual("step-cap", result.Halt);
Assert.Contains(host.HistoryRenders, render => render.Text.Length > 0);
Assert.All(host.HistoryRenders.Where(render => render.Text.Length > 0),
render => Assert.Equal(8, render.Style.LineSpacing));
Assert.Contains(host.PresentedRanges, range => range == (0L, 60000L));
}
}

View File

@@ -26,9 +26,10 @@ public readonly record struct AdvTextStyle(
long EffectColor,
int RenderMode,
int EffectOffsetX,
int EffectOffsetY)
int EffectOffsetY,
int LineSpacing)
{
public static AdvTextStyle Default => new(0, 0, false, 0, 0, 0, 0, 0);
public static AdvTextStyle Default => new(0, 0, false, 0, 0, 0, 0, 0, 6);
}
/// <summary>A stable snapshot of the layout state associated with a retained record.</summary>

View File

@@ -868,7 +868,11 @@ public sealed class VirtualMachine
int flags = (int)Read(a[2]);
if ((flags & 4) == 0 && TextHistory.TryBuildRenderBatch(
(int)Read(a[0]), (int)Read(a[1]), flags, Read(a[3]), Read(a[4]), out var batch))
_host.RenderTextHistory(batch);
_host.RenderTextHistory(batch with
{
// Native History uses the text manager's current leading, not a retained-record field.
Style = batch.Style with { LineSpacing = _advTextStyle.LineSpacing }
});
return pc + 1;
}
case "u0041BB90":
@@ -891,6 +895,9 @@ public sealed class VirtualMachine
_advTextStyle = _advTextStyle with { PrimaryFontSize = (int)Read(a[0]) }; return pc + 1;
case "set-ruby-font-size":
_advTextStyle = _advTextStyle with { RubyFontSize = (int)Read(a[0]) }; return pc + 1;
case "u0041B3D0":
case "set-text-line-spacing":
_advTextStyle = _advTextStyle with { LineSpacing = (int)Read(a[0]) }; return pc + 1;
case "set-font-bold":
_advTextStyle = _advTextStyle with { Bold = Read(a[0]) != 0 }; return pc + 1;
case "set-text-color":