Fix incremental menu animation presentation
This commit is contained in:
@@ -33,6 +33,7 @@ internal class RecordingHost : IHost
|
||||
public readonly List<bool> WaitIndicatorEnabledChanges = new();
|
||||
public readonly List<int> PublishedAdvTextLayouts = new();
|
||||
public readonly List<long> SleptDurations = new();
|
||||
public readonly List<long> TimedCallbackWaitDurations = new();
|
||||
public readonly List<(long Resource, int Channel)> SfxLoads = new();
|
||||
public readonly List<long> Voices = new();
|
||||
public readonly List<(long Id, int PlaybackVariant)> VoiceRequests = new();
|
||||
@@ -148,6 +149,11 @@ internal class RecordingHost : IHost
|
||||
public void SetCursorResource(long resourceId) => CursorResources.Add(resourceId);
|
||||
public void ClearCursorResource() => CursorClearCount++;
|
||||
public virtual void Sleep(long duration) => SleptDurations.Add(duration);
|
||||
public virtual void WaitForTimedCallbackDeadline(long duration)
|
||||
{
|
||||
TimedCallbackWaitDurations.Add(duration);
|
||||
Sleep(duration);
|
||||
}
|
||||
public virtual void FrameYield() { }
|
||||
public void ResetSceneContext() => SceneContextResets++;
|
||||
public bool IsMessageSkipActive => MessageSkip;
|
||||
|
||||
@@ -22,6 +22,21 @@ public class TimedCallbackOpsTests
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class NonPresentingClockHost : RecordingHost
|
||||
{
|
||||
private long _now;
|
||||
public override long InputClockMilliseconds => _now;
|
||||
|
||||
public override void Sleep(long duration)
|
||||
=> throw new InvalidOperationException("Timed callback pacing used presentation-capable sleep.");
|
||||
|
||||
public override void WaitForTimedCallbackDeadline(long duration)
|
||||
{
|
||||
TimedCallbackWaitDurations.Add(duration);
|
||||
_now += duration;
|
||||
}
|
||||
}
|
||||
|
||||
private static Script BuildTwoEventSequence()
|
||||
=> ScriptAssembler.Assemble(Table, "TIMED_CALLBACKS",
|
||||
new List<(int, Operand[])>
|
||||
@@ -48,6 +63,7 @@ public class TimedCallbackOpsTests
|
||||
Assert.Equal(2, vm.Globals[0x100]);
|
||||
Assert.Equal(0, vm.Globals.GetValueOrDefault(0x101));
|
||||
Assert.Equal(new long[] { 10, 10 }, host.SleptDurations);
|
||||
Assert.Equal(new long[] { 10, 10 }, host.TimedCallbackWaitDurations);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -62,5 +78,19 @@ public class TimedCallbackOpsTests
|
||||
Assert.Equal(1, vm.Globals[0x100]);
|
||||
Assert.Equal(1, vm.Globals[0x101]);
|
||||
Assert.Equal(new long[] { 10 }, host.SleptDurations);
|
||||
Assert.Equal(new long[] { 10 }, host.TimedCallbackWaitDurations);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SequencePacingDoesNotUsePresentationCapableScriptSleep()
|
||||
{
|
||||
var host = new NonPresentingClockHost();
|
||||
var vm = new VirtualMachine(BuildTwoEventSequence(), Table, host);
|
||||
|
||||
vm.Run();
|
||||
|
||||
Assert.Equal("exit", vm.HaltReason);
|
||||
Assert.Equal(new long[] { 10, 10 }, host.TimedCallbackWaitDurations);
|
||||
Assert.Empty(host.SleptDurations);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user