fix: handle MIST movie timer actions and verify skipping
This commit is contained in:
1 parent
11f87df712
commit
11d769f466
3 files changed
+25
-2
No files matched your search
@@ -2046,7 +2046,12 @@ export class ScreenManager {
|
||||
Image: shape("image"),
|
||||
AlphaMask: shape("alphamask"),
|
||||
};
|
||||
out.If = (condition: any, yes: any = null, no: any = null) => (truthy(condition) ? yes : no);
|
||||
out.If = (...a: any[]) => {
|
||||
const kw = kwOf(a), args = a.filter((value) => !value?.__kw);
|
||||
const condition = args.length ? args[0] : kw.expression;
|
||||
return truthy(condition) ? (args.length > 1 ? args[1] : kw.true ?? null)
|
||||
: (args.length > 2 ? args[2] : kw.false ?? null);
|
||||
};
|
||||
out.GetTooltip = () => this.tooltip;
|
||||
out.StaticValue = (value: number, range = 1) => new BarValue(() => value, () => range);
|
||||
out.AnimatedValue = out.StaticValue;
|
||||
|
||||
@@ -19,12 +19,14 @@ test("MIST's actual movie Skip survives a queued redraw and returns before its t
|
||||
engine.newStore();
|
||||
Object.assign(engine.store, { movielength: 63, movieplaying: "images/animations/movies/Intro_Movie.webm" });
|
||||
const completed = engine.exec({ op: "call_screen", name: "custommoviescreen", args: [], kw: {} });
|
||||
await until(() => root.querySelector(".pg-sadd")?.dataset.seen);
|
||||
const button = [...root.querySelectorAll(".pg-sbtn")].find((element) => element.textContent === "Skip");
|
||||
assert.ok(button);
|
||||
assert.equal(button.classList.contains("pg-sdisabled"), false);
|
||||
engine.screens.refresh();
|
||||
window.dispatchEvent(new window.Event("pointerdown"));
|
||||
await until(() => engine.store.movielength < 63);
|
||||
const remaining = engine.store.movielength;
|
||||
await until(() => engine.store.movielength < remaining);
|
||||
assert.equal(button.isConnected, true);
|
||||
window.dispatchEvent(new window.Event("pointerup"));
|
||||
click(button);
|
||||
|
||||
@@ -55,6 +55,22 @@ const buttons = (root) => [...root.querySelectorAll(".pg-sbtn")];
|
||||
const click = (el) => el.onclick({ stopPropagation() {}, preventDefault() {} });
|
||||
const settle = () => wait(15);
|
||||
|
||||
test("If accepts named true/false actions used by MIST's movie timer", () => {
|
||||
const { manager, store } = setup();
|
||||
try {
|
||||
const { If, SetVariable } = manager.builtins();
|
||||
const yes = SetVariable("branch", "yes"), no = SetVariable("branch", "no");
|
||||
manager.run(If(true, { __kw: { true: yes, false: no } }), null);
|
||||
assert.equal(store.branch, "yes");
|
||||
manager.run(If(false, { __kw: { true: yes, false: no } }), null);
|
||||
assert.equal(store.branch, "no");
|
||||
assert.equal(If(true, yes, no), yes);
|
||||
assert.equal(If(false, yes, no), no);
|
||||
assert.equal(If(true, null, { __kw: { false: no } }), null);
|
||||
assert.equal(If({ __kw: { expression: false, true: yes, false: no } }), no);
|
||||
} finally { manager.destroy(); }
|
||||
});
|
||||
|
||||
test("a screen renders its widgets, conditions, loops and interpolated text", () => {
|
||||
const { manager } = setup();
|
||||
manager.show("hud", [2]);
|
||||
|
||||
Reference in new issue
Block a user