Dock last-turn recap beside the board with pinned controls
This commit is contained in:
parent
781ec693c9
commit
1217836c20
8 changed files with 538 additions and 64 deletions
|
|
@ -1011,3 +1011,36 @@ The packed-engine civilization suite passes 226 tests, including both Inspiratio
|
|||
copies and privacy/cancel/allow coverage. Both copies pass the browser smoke at
|
||||
all three widths; battle-dice smoke also passes. The pre-existing combat smoke
|
||||
still expects `Battle · C1` instead of `Battle · Round 1`; it remains unchanged.
|
||||
|
||||
# Viewer 0.1.206 / engine unchanged (0.4.138)
|
||||
|
||||
“Since your last turn” is a compact 350px left dock inside the board layout on
|
||||
wide desktop screens and short landscape screens. The action heading, battle
|
||||
recap and event explanations share a bounded content scroller; Back, Next,
|
||||
Play/Pause/Replay, autoplay preference and Skip/Back to game stay visible outside
|
||||
it. Each new action resets the content to its heading without remounting the
|
||||
transport controls. Narrow screens retain the bottom recap above the toolbar.
|
||||
Full-game replay keeps its existing root event overlay and never gets the recap
|
||||
dock. Chat/Journal no longer reserve bottom-recap space when the dock is active.
|
||||
|
||||
Publish only the viewer with `npm run publish:bgs` (first with `--dry-run`),
|
||||
preserving engine 0.4.138's exact package URL and all unrelated metadata, including
|
||||
the exact game-length labels/order and Standard default. No game rules, saved
|
||||
data, live game moves or smaller-city experiment are included.
|
||||
|
||||
The new `node web-client/scripts/recap-layout-smoke.mjs` uses repository battle
|
||||
fixtures with the real engine and built viewer. It covers eight viewport sizes,
|
||||
English and French, overflowing event rules, stable controls and scroll reset,
|
||||
all recap transport actions, and recap/full-replay isolation across resizes.
|
||||
For a read-only local preview, add `--serve --port 8673`; `?stress` adds overflow,
|
||||
`?locale=fr` selects French and `?theme=light` selects the light theme.
|
||||
|
||||
Verified 1,031 frontend tests, 17 locale catalogs and four extraction tests,
|
||||
Svelte checks (zero errors/warnings), the rebuilt WASM bridge and production
|
||||
build, all eight recap smoke sizes, battle-dice smoke, and engine protocol checks.
|
||||
Rust 1.94.1 build/format/Clippy and all 465 native workspace tests pass (one
|
||||
existing ignored test); Clippy retains existing warnings. The legacy combat
|
||||
smoke still expects `Battle · C1` rather than `Battle · Round 1`, and the legacy
|
||||
playback smoke still expects the board toolbar to be hidden. Both failures were
|
||||
reproduced against the hash-verified published 0.1.205 viewer and engine 0.4.138;
|
||||
neither assertion was changed or suppressed.
|
||||
|
|
|
|||
4
web-client/package-lock.json
generated
4
web-client/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "@boardgamers/clash-web-client",
|
||||
"version": "0.1.205",
|
||||
"version": "0.1.206",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@boardgamers/clash-web-client",
|
||||
"version": "0.1.205",
|
||||
"version": "0.1.206",
|
||||
"dependencies": {
|
||||
"@boardgamers/protocol": "0.9.0",
|
||||
"lucide-svelte": "^0.577.0",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@boardgamers/clash-web-client",
|
||||
"version": "0.1.205",
|
||||
"version": "0.1.206",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
|
|
|||
377
web-client/scripts/recap-layout-smoke.mjs
Normal file
377
web-client/scripts/recap-layout-smoke.mjs
Normal file
|
|
@ -0,0 +1,377 @@
|
|||
import assert from 'node:assert/strict';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { createServer } from 'node:http';
|
||||
import { createRequire } from 'node:module';
|
||||
import { pathToFileURL } from 'node:url';
|
||||
import { chromium } from 'playwright';
|
||||
|
||||
const engine = createRequire(import.meta.url)('../.engine/server.js');
|
||||
const dist = new URL('../dist/', import.meta.url);
|
||||
|
||||
// Only repository test positions are used. Execute the recorded battle with the
|
||||
// actual engine, then group its payment/tactics responses into one public action.
|
||||
// The synthetic preceding end-turn boundary makes this a returning-player recap.
|
||||
export async function createFixture(stress = false) {
|
||||
const load = async (name) =>
|
||||
JSON.parse(
|
||||
await readFile(new URL(`../../server/tests/test_games/combat/${name}.json`, import.meta.url), 'utf8'),
|
||||
);
|
||||
const initial = await load('combat_all_modifiers');
|
||||
const npcs = JSON.parse(await engine.init(2, [], {}, 'recap-layout-smoke', {})).players.slice(2);
|
||||
for (const npc of npcs)
|
||||
if (!initial.players.some((p) => p.civilization === npc.civilization)) {
|
||||
initial.players.push({ ...npc, id: initial.players.length });
|
||||
}
|
||||
const outcome = await load('combat_all_modifiers.outcome5');
|
||||
const actions = outcome.log.flatMap((a) =>
|
||||
a.rounds.flatMap((r) => r.turns.flatMap((t) => t.actions ?? [])),
|
||||
);
|
||||
let raw = JSON.stringify(initial);
|
||||
for (const action of actions) raw = engine.tryMove(raw, JSON.stringify(action.action), action.player);
|
||||
const battleCursor = JSON.parse(raw).board_history.frames.at(-1).cursor;
|
||||
raw = engine.tryMove(raw, JSON.stringify({ Movement: 'Stop' }), 0);
|
||||
raw = engine.tryMove(raw, JSON.stringify({ Playing: 'EndTurn' }), 0);
|
||||
const game = JSON.parse(engine.stripSecret(raw, 1));
|
||||
const frames = game.board_history.frames;
|
||||
const before = { ...frames[0], actor: 1, ended_turn: true, title: 'End turn' };
|
||||
const battle = { ...frames.find((f) => f.cursor === battleCursor), actor: 0, title: 'Battle' };
|
||||
const end = frames.at(-1);
|
||||
game.board_history = { id: `recap-layout-${stress ? 'stress' : 'battle'}`, frames: [before, battle, end] };
|
||||
if (stress) {
|
||||
// Deliberately overfull public notices exercise the content scroller, without
|
||||
// DOM injection or production/controller test hooks. Rules are real catalog data.
|
||||
const catalog = JSON.parse(engine.webView(raw, 1)).eventCatalog;
|
||||
const unique = [...new Map(catalog.map((e) => [e.name, e])).values()]
|
||||
.sort((a, b) => b.rules.join('').length - a.rules.join('').length)
|
||||
.slice(0, 12);
|
||||
const publicActions = game.log.flatMap((a) =>
|
||||
a.rounds.flatMap((r) => r.turns.flatMap((t) => t.actions ?? [])),
|
||||
);
|
||||
publicActions[battleCursor - 1].items.push(
|
||||
...unique.map((event) => ({
|
||||
player: 0,
|
||||
Text: `triggers the event ${event.name}`,
|
||||
origin: { Incident: event.id },
|
||||
})),
|
||||
);
|
||||
}
|
||||
return { raw: JSON.stringify(game), seat: 1, battleCursor, endCursor: end.cursor, stress };
|
||||
}
|
||||
|
||||
export async function startPreview(port = 0) {
|
||||
const fixtures = { battle: await createFixture(), stress: await createFixture(true) };
|
||||
const server = createServer(async (req, res) => {
|
||||
try {
|
||||
const url = new URL(req.url, 'http://localhost');
|
||||
if (url.pathname === '/fixture.json') {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
return res.end(JSON.stringify(fixtures[url.searchParams.has('stress') ? 'stress' : 'battle']));
|
||||
}
|
||||
if (url.pathname === '/') {
|
||||
res.setHeader('Content-Type', 'text/html; charset=utf-8');
|
||||
return res.end(`<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Recap layout · synthetic battle preview</title></head><body><div id="app"></div><script src="/viewer.js"></script><script>
|
||||
(async () => {
|
||||
const params = new URLSearchParams(location.search);
|
||||
const fixture = await (await fetch('/fixture.json' + (params.has('stress') ? '?stress' : ''))).json();
|
||||
for (const key of Object.keys(localStorage)) if (key.startsWith('clash:board-seen:')) localStorage.removeItem(key);
|
||||
window.sent = []; window.replayInfo = []; window.fixture = fixture;
|
||||
window.host = clash3d.launch('#app');
|
||||
let prefs = { sound: false, replayAutoplay: false, locale: params.get('locale') || 'en' };
|
||||
host.on('move', (move) => sent.push(move));
|
||||
host.on('replay:info', (info) => replayInfo.push(info));
|
||||
host.on('update:preference', ({name, value}) => { prefs = {...prefs, [name]: value}; host.emit('preferences', prefs); });
|
||||
host.emit('player', { index: fixture.seat });
|
||||
host.emit('theme', { dark: params.get('theme') !== 'light' });
|
||||
host.emit('preferences', prefs); host.emit('state', fixture.raw);
|
||||
// Land on the recorded dice, not an empty start frame. Real controls remain live.
|
||||
if (!params.has('start')) {
|
||||
const timer = setInterval(() => {
|
||||
const next = document.querySelector('.playback-next');
|
||||
if (next && !next.disabled) { clearInterval(timer); next.click(); window.previewReady = true; }
|
||||
}, 40);
|
||||
setTimeout(() => clearInterval(timer), 20000);
|
||||
} else window.previewReady = true;
|
||||
})();
|
||||
</script></body></html>`);
|
||||
}
|
||||
const asset = new URL('.' + url.pathname, dist);
|
||||
if (!asset.href.startsWith(dist.href)) return res.writeHead(404).end();
|
||||
const types = {
|
||||
wasm: 'application/wasm',
|
||||
js: 'text/javascript',
|
||||
json: 'application/json',
|
||||
woff2: 'font/woff2',
|
||||
svg: 'image/svg+xml',
|
||||
};
|
||||
res.setHeader('Content-Type', types[url.pathname.split('.').at(-1)] ?? 'application/octet-stream');
|
||||
res.end(await readFile(asset));
|
||||
} catch (error) {
|
||||
res.writeHead(404).end(String(error));
|
||||
}
|
||||
});
|
||||
await new Promise((resolve) => server.listen(port, '127.0.0.1', resolve));
|
||||
return { server, url: `http://localhost:${server.address().port}/` };
|
||||
}
|
||||
|
||||
async function assertLayout(page, width, height, stress = false) {
|
||||
const metrics = await page.locator('.playback-bar').evaluate((bar) => {
|
||||
const rect = (el) => {
|
||||
const b = el.getBoundingClientRect();
|
||||
return { x: b.x, y: b.y, width: b.width, height: b.height, right: b.right, bottom: b.bottom };
|
||||
};
|
||||
const scroller = bar.querySelector('.playback-content');
|
||||
return {
|
||||
bar: rect(bar),
|
||||
board: rect(document.querySelector('main.play-layout')),
|
||||
scrollWidth: bar.scrollWidth,
|
||||
clientWidth: bar.clientWidth,
|
||||
documentWidth: document.documentElement.scrollWidth,
|
||||
controls: [
|
||||
...bar.querySelectorAll('.playback-transport button, .playback-exit, .playback-preference'),
|
||||
].map((el) => ({
|
||||
...rect(el),
|
||||
label: el.textContent,
|
||||
inScroller: !!scroller?.contains(el),
|
||||
})),
|
||||
scroller: scroller && {
|
||||
...rect(scroller),
|
||||
overflow: getComputedStyle(scroller).overflowY,
|
||||
scrollHeight: scroller.scrollHeight,
|
||||
clientHeight: scroller.clientHeight,
|
||||
},
|
||||
centerCovered: !!document.elementFromPoint(innerWidth / 2, innerHeight / 2)?.closest('.playback-bar'),
|
||||
};
|
||||
});
|
||||
const b = metrics.bar;
|
||||
assert(
|
||||
b.x >= 0 && b.right <= width + 1 && b.y >= 0 && b.bottom <= height + 1,
|
||||
`panel is in viewport: ${JSON.stringify(metrics)}`,
|
||||
);
|
||||
assert(metrics.scrollWidth <= metrics.clientWidth + 1, 'no horizontal panel overflow');
|
||||
assert(metrics.documentWidth <= width, 'no horizontal document overflow');
|
||||
if (width >= 1100 || (width >= 760 && height <= 550)) {
|
||||
assert(b.x <= 30, `desktop panel stays at left, not center: x=${b.x}`);
|
||||
assert(b.width <= 380, `compact desktop width: ${b.width}`);
|
||||
assert(b.right < width / 2, 'desktop map center remains outside the dock');
|
||||
assert(!metrics.centerCovered, 'desktop map center is not covered');
|
||||
assert(
|
||||
b.y >= metrics.board.y && b.y <= metrics.board.y + 30,
|
||||
`dock starts near board area: y=${b.y}, board=${metrics.board.y}`,
|
||||
);
|
||||
} else {
|
||||
assert(
|
||||
b.bottom >= height - 150 && b.y >= 0,
|
||||
`mobile retains bottom panel above reserved toolbar: bottom=${b.bottom}`,
|
||||
);
|
||||
}
|
||||
assert(metrics.controls.length >= 5, 'Back, Next, Play/Replay, preference and Skip/Back to game exist');
|
||||
for (const control of metrics.controls) {
|
||||
assert(
|
||||
control.x >= b.x - 1 &&
|
||||
control.right <= b.right + 1 &&
|
||||
control.y >= b.y - 1 &&
|
||||
control.bottom <= b.bottom + 1,
|
||||
`control fits inside visible panel: ${JSON.stringify(control)}`,
|
||||
);
|
||||
assert(!control.inScroller, `control remains outside scrolling content: ${control.label}`);
|
||||
}
|
||||
if (stress) {
|
||||
assert(metrics.scroller, 'recap has dedicated content scroller');
|
||||
assert(['auto', 'scroll'].includes(metrics.scroller.overflow), 'overflow content can scroll');
|
||||
assert(
|
||||
metrics.scroller.scrollHeight > metrics.scroller.clientHeight + 20,
|
||||
'stress fixture actually overflows content',
|
||||
);
|
||||
const positions = metrics.controls.map(({ x, y }) => ({ x, y }));
|
||||
await page.locator('.playback-content').evaluate((el) => {
|
||||
el.scrollTop = el.scrollHeight;
|
||||
});
|
||||
assert(await page.locator('.playback-content').evaluate((el) => el.scrollTop > 0), 'content scrolls');
|
||||
const after = await page.locator('.playback-bar').evaluate((bar) =>
|
||||
[...bar.querySelectorAll('.playback-transport button, .playback-exit, .playback-preference')].map(
|
||||
(el) => {
|
||||
const r = el.getBoundingClientRect();
|
||||
return { x: r.x, y: r.y };
|
||||
},
|
||||
),
|
||||
);
|
||||
assert.deepEqual(after, positions, 'scrolling content does not move any controls');
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
async function smoke() {
|
||||
const fixtureOnly = process.argv.includes('--fixture-only');
|
||||
const { server, url } = await startPreview();
|
||||
const browser = await chromium.launch({
|
||||
headless: true,
|
||||
args: ['--use-gl=angle', '--use-angle=swiftshader'],
|
||||
});
|
||||
const sizes = fixtureOnly
|
||||
? [[1400, 850]]
|
||||
: [
|
||||
[1400, 850],
|
||||
[1920, 1080],
|
||||
[1100, 650],
|
||||
[1366, 520],
|
||||
[1099, 650],
|
||||
[844, 390],
|
||||
[390, 844],
|
||||
[320, 640],
|
||||
];
|
||||
try {
|
||||
for (const [width, height] of sizes) {
|
||||
if (process.env.SMOKE_WIDTH && width !== Number(process.env.SMOKE_WIDTH)) continue;
|
||||
const page = await browser.newPage({ viewport: { width, height } });
|
||||
const errors = [];
|
||||
page.on('pageerror', (error) => errors.push(error.message));
|
||||
await page.goto(url);
|
||||
await page.waitForFunction(
|
||||
() => window.previewReady && document.querySelectorAll('.playback-bar .battle-die').length > 0,
|
||||
);
|
||||
const bar = page.locator('.playback-bar');
|
||||
const battle = bar.locator('.battle-recap');
|
||||
const next = bar.locator('.playback-next');
|
||||
const back = bar.locator('.playback-transport button').first();
|
||||
const play = bar.locator('.playback-transport button').nth(2);
|
||||
assert((await battle.locator('.battle-die').count()) >= 6, 'recorded dice render in recap');
|
||||
assert((await battle.locator('.battle-die svg').count()) >= 6, 'recorded dice retain unit faces');
|
||||
if (!fixtureOnly) await assertLayout(page, width, height);
|
||||
await page.waitForTimeout(1250); // Capture completed recorded dice, not their entrance animation.
|
||||
await page.screenshot({ path: `/tmp/clash-recap-dock-${width}x${height}.png` });
|
||||
await back.click();
|
||||
await battle.waitFor({ state: 'hidden' });
|
||||
assert(await back.isDisabled(), 'Back reaches the recorded start');
|
||||
await next.click();
|
||||
await battle.waitFor();
|
||||
await play.click();
|
||||
assert.match(await play.getAttribute('aria-label'), /Pause/, 'Play starts the recap');
|
||||
await play.click();
|
||||
assert.match(await play.getAttribute('aria-label'), /Play/, 'Pause stops the recap');
|
||||
await battle.locator('button').click();
|
||||
await battle.waitFor({ state: 'hidden' });
|
||||
await back.click();
|
||||
await next.click();
|
||||
await battle.waitFor();
|
||||
if (width === 1400) {
|
||||
await play.click();
|
||||
await page.waitForFunction(() => document.querySelector('.playback-next')?.disabled, null, {
|
||||
timeout: 15000,
|
||||
});
|
||||
} else await next.click();
|
||||
assert(await next.isDisabled(), 'manual Next/autoplay reaches bounded end');
|
||||
await play.click();
|
||||
assert(await back.isDisabled(), 'Replay returns to start');
|
||||
await bar.locator('.playback-exit').click();
|
||||
await bar.waitFor({ state: 'hidden' });
|
||||
await page.locator('.last-turn-button').click();
|
||||
await bar.waitFor();
|
||||
await next.click();
|
||||
await battle.waitFor();
|
||||
if (!fixtureOnly) await assertLayout(page, width, height);
|
||||
// Native host full replay must not inherit the recap dock or controls.
|
||||
await page.evaluate(() => {
|
||||
host.emit('replay:start');
|
||||
host.emit('replay:to', fixture.battleCursor);
|
||||
});
|
||||
await bar.waitFor({ state: 'hidden' });
|
||||
await page.locator('.battle-recap').waitFor();
|
||||
await page.waitForFunction(() => replayInfo.at(-1)?.current === fixture.battleCursor);
|
||||
assert.equal(
|
||||
await page.locator('.playback-bar').count(),
|
||||
0,
|
||||
'full replay does not render recap controls',
|
||||
);
|
||||
await page.setViewportSize({ width: width >= 1100 ? 390 : 1400, height: 850 });
|
||||
assert.equal(
|
||||
await page.locator('.playback-bar').count(),
|
||||
0,
|
||||
'resizing full replay does not create recap dock',
|
||||
);
|
||||
await page.evaluate(() => host.emit('replay:end'));
|
||||
await page.setViewportSize({ width, height });
|
||||
await page.goto(url + '?stress&locale=fr');
|
||||
await page.waitForFunction(
|
||||
() => window.previewReady && document.querySelectorAll('.replay-event-explanations').length > 0,
|
||||
);
|
||||
await page.locator('.playback-bar .battle-recap').waitFor();
|
||||
await page.waitForFunction(() =>
|
||||
document.querySelector('.playback-exit')?.textContent.includes('Passer'),
|
||||
);
|
||||
assert(
|
||||
(await bar.locator('.replay-event-explanations').innerText()).length > 500,
|
||||
'many real event rules populate overflow fixture',
|
||||
);
|
||||
if (!fixtureOnly) await assertLayout(page, width, height, true);
|
||||
await page.screenshot({ path: `/tmp/clash-recap-dock-stress-fr-${width}x${height}.png` });
|
||||
// Resize the same recap across the breakpoint, then return without resetting it.
|
||||
if (!fixtureOnly) {
|
||||
const other = width >= 1100 ? { width: 390, height: 844 } : { width: 1400, height: 850 };
|
||||
await page.setViewportSize(other);
|
||||
await assertLayout(page, other.width, other.height, true);
|
||||
await page.setViewportSize({ width, height });
|
||||
await assertLayout(page, width, height, true);
|
||||
await page.evaluate(() => {
|
||||
window.transportNode = document.querySelector('.playback-controls');
|
||||
});
|
||||
await back.click();
|
||||
assert.equal(
|
||||
await bar.locator('.playback-content').evaluate((el) => el.scrollTop),
|
||||
0,
|
||||
'Back resets scroll to the action heading',
|
||||
);
|
||||
await next.click();
|
||||
await battle.waitFor();
|
||||
assert.equal(
|
||||
await bar.locator('.playback-content').evaluate((el) => el.scrollTop),
|
||||
0,
|
||||
'Next resets scroll to the action heading',
|
||||
);
|
||||
assert(
|
||||
await page.evaluate(() => transportNode === document.querySelector('.playback-controls')),
|
||||
'transport controls remain mounted while content changes',
|
||||
);
|
||||
}
|
||||
await bar.locator('.playback-exit').click();
|
||||
await bar.waitFor({ state: 'hidden' });
|
||||
// Full replay event explanations remain root overlays, not board-relative
|
||||
// recap content, including after crossing the responsive breakpoint.
|
||||
await page.evaluate(() => {
|
||||
host.emit('replay:start');
|
||||
host.emit('replay:to', fixture.battleCursor);
|
||||
});
|
||||
const eventOverlay = page.locator('.card-reveal:has(.event-explanation)');
|
||||
await eventOverlay.waitFor();
|
||||
assert.equal(await bar.count(), 0, 'full replay events do not create recap controls');
|
||||
assert(
|
||||
await eventOverlay.evaluate((el) => !el.closest('main.play-layout')),
|
||||
'full replay event overlay stays outside the board layout',
|
||||
);
|
||||
await page.setViewportSize({ width: width >= 1100 ? 390 : 1400, height: 850 });
|
||||
assert(await eventOverlay.isVisible(), 'full replay event overlay survives resizing');
|
||||
assert.equal(await bar.count(), 0, 'resizing event replay does not create recap dock');
|
||||
await page.evaluate(() => host.emit('replay:end'));
|
||||
await eventOverlay.waitFor({ state: 'hidden' });
|
||||
assert.deepEqual(await page.evaluate(() => sent), [], 'recap never submits a game move');
|
||||
assert.deepEqual(errors, [], 'no browser exceptions');
|
||||
console.log(
|
||||
`${width}x${height}: ${fixtureOnly ? 'fixture' : 'dock/bottom layout'}, battle dice/dismiss, Back/Next/Play/Pause/Replay/Skip, recap/full-replay resize isolation, FR event overflow verified.`,
|
||||
);
|
||||
await page.close();
|
||||
}
|
||||
} finally {
|
||||
await browser.close();
|
||||
await new Promise((resolve) => server.close(resolve));
|
||||
}
|
||||
}
|
||||
|
||||
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
||||
if (process.argv.includes('--serve')) {
|
||||
const portIndex = process.argv.indexOf('--port');
|
||||
const { url } = await startPreview(portIndex >= 0 ? Number(process.argv[portIndex + 1]) : 8673);
|
||||
console.log(`Recap layout preview ready: ${url}`);
|
||||
console.log(
|
||||
'Synthetic repository battle; real Back/Next/Play/Skip. Add ?stress for overflow or ?locale=fr for French.',
|
||||
);
|
||||
} else await smoke();
|
||||
}
|
||||
|
|
@ -1951,6 +1951,7 @@
|
|||
>
|
||||
<BattlePlayback {controller} />
|
||||
</div>{/if}
|
||||
{#if $session.playback && $session.playback.range !== 'all'}<PlaybackPanel {controller} />{/if}
|
||||
</main>
|
||||
{#if wonderReference}<WonderReferenceDialog
|
||||
card={wonderReference}
|
||||
|
|
@ -1975,7 +1976,7 @@
|
|||
{#if $session.cardsOpen && $session.seat !== undefined}<ActionCardsDialog {controller} />{/if}
|
||||
{#if !$session.playback && !$session.eventNotices?.length}<CardReveal {controller} />{/if}
|
||||
{#if $session.mode !== 'research'}<EventReveal {controller}/>{/if}
|
||||
<PlaybackPanel {controller} />
|
||||
{#if $session.playback?.range === 'all'}<PlaybackPanel {controller} />{/if}
|
||||
<PublicEffects {controller} />
|
||||
{#if effectsOpen}<ActiveEffectsDialog
|
||||
effects={$session.view?.activeEffects ?? []}
|
||||
|
|
|
|||
|
|
@ -37,64 +37,75 @@
|
|||
|
||||
{#if playback && recap}
|
||||
<section class="playback-bar floating-panel" aria-label="Board replay">
|
||||
{#if playback.events?.length}<div class="replay-event-explanations" aria-label="Event explanation">
|
||||
{#each playback.events as notice}<EventExplanation {notice}/>{/each}
|
||||
</div>{/if}
|
||||
{#if $session.battles?.length}<BattlePlayback {controller} />{/if}
|
||||
<div class="playback-description" aria-live="polite">
|
||||
<strong
|
||||
><History size={16} />Since your last turn
|
||||
{#if playback.end > playback.start}<span class="playback-progress"
|
||||
>{atStart ? 'Start' : `Action ${progress} of ${count}`}</span
|
||||
>{/if}
|
||||
</strong>
|
||||
<small
|
||||
>{#if atStart}Use Next to step through, or Play to watch.{:else}<ResourceText
|
||||
text={details.caption}
|
||||
compactResources
|
||||
/>{/if}</small
|
||||
>
|
||||
</div>
|
||||
{#if playback.end > playback.start}<div class="playback-transport">
|
||||
<button aria-label="Previous action" disabled={atStart} onclick={() => controller.stepPlayback(-1)}
|
||||
><ChevronLeft size={16} />Back</button
|
||||
>
|
||||
<button
|
||||
class="playback-next"
|
||||
aria-label="Next action"
|
||||
disabled={atEnd}
|
||||
onclick={() => controller.stepPlayback(1)}>Next<ChevronRight size={16} /></button
|
||||
>
|
||||
{#if atEnd}
|
||||
<button aria-label="Replay these actions" onclick={() => controller.restartPlayback()}
|
||||
><RotateCcw size={16} />Replay</button
|
||||
{#key playback.index}
|
||||
<div class="playback-content">
|
||||
<div class="playback-description" aria-live="polite">
|
||||
<strong
|
||||
><History size={16} />Since your last turn
|
||||
{#if playback.end > playback.start}<span class="playback-progress"
|
||||
>{atStart ? 'Start' : `Action ${progress} of ${count}`}</span
|
||||
>{/if}
|
||||
</strong>
|
||||
<small
|
||||
>{#if atStart}Use Next to step through, or Play to watch.{:else}<ResourceText
|
||||
text={details.caption}
|
||||
compactResources
|
||||
/>{/if}</small
|
||||
>
|
||||
</div>
|
||||
{#if $session.battles?.length}<BattlePlayback {controller} />{/if}
|
||||
{#if playback.events?.length}<div class="replay-event-explanations" aria-label="Event explanation">
|
||||
{#each playback.events as notice}<EventExplanation {notice} />{/each}
|
||||
</div>{/if}
|
||||
</div>
|
||||
{/key}
|
||||
<div class="playback-controls">
|
||||
{#if playback.end > playback.start}<div class="playback-transport">
|
||||
<button aria-label="Previous action" disabled={atStart} onclick={() => controller.stepPlayback(-1)}
|
||||
><ChevronLeft size={16} />Back</button
|
||||
>
|
||||
{:else}
|
||||
<button
|
||||
aria-label={playback.playing ? 'Pause replay' : 'Play replay'}
|
||||
onclick={() => controller.togglePlayback()}
|
||||
>{#if playback.playing}<Pause size={16} />Pause{:else}<Play size={16} />Play{/if}</button
|
||||
class="playback-next"
|
||||
aria-label="Next action"
|
||||
disabled={atEnd}
|
||||
onclick={() => controller.stepPlayback(1)}>Next<ChevronRight size={16} /></button
|
||||
>
|
||||
{/if}
|
||||
</div>{/if}
|
||||
<label class="playback-preference" title="Remember this preference for future opponent recaps">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={$session.replayAutoplay}
|
||||
onchange={(event) => controller.setReplayAutoplay(event.currentTarget.checked)}
|
||||
/>Autoplay on return
|
||||
</label>
|
||||
<button class="playback-exit" onclick={() => controller.endPlayback()}>
|
||||
{atEnd ? 'Back to game' : 'Skip'}<X size={15} />
|
||||
</button>
|
||||
{#if atEnd}
|
||||
<button aria-label="Replay these actions" onclick={() => controller.restartPlayback()}
|
||||
><RotateCcw size={16} />Replay</button
|
||||
>
|
||||
{:else}
|
||||
<button
|
||||
aria-label={playback.playing ? 'Pause replay' : 'Play replay'}
|
||||
onclick={() => controller.togglePlayback()}
|
||||
>{#if playback.playing}<Pause size={16} />Pause{:else}<Play size={16} />Play{/if}</button
|
||||
>
|
||||
{/if}
|
||||
</div>{/if}
|
||||
<label class="playback-preference" title="Remember this preference for future opponent recaps">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={$session.replayAutoplay}
|
||||
onchange={(event) => controller.setReplayAutoplay(event.currentTarget.checked)}
|
||||
/>Autoplay on return
|
||||
</label>
|
||||
<button class="playback-exit" onclick={() => controller.endPlayback()}>
|
||||
{atEnd ? 'Back to game' : 'Skip'}<X size={15} />
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
{/if}
|
||||
|
||||
{#if playback && !recap && playback.events?.length}
|
||||
<aside class="card-reveal" aria-label="Replay event explanation">
|
||||
{#each playback.events as notice}<EventExplanation {notice}/>{/each}
|
||||
{#each playback.events as notice}<EventExplanation {notice} />{/each}
|
||||
</aside>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.replay-event-explanations { grid-column: 1 / -1; width:100%; max-height:35vh; overflow:auto; border-bottom:1px solid var(--line); padding-bottom:.6rem; }
|
||||
.replay-event-explanations {
|
||||
min-width: 0;
|
||||
border-top: 1px solid var(--line);
|
||||
padding-top: 10px;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -161,10 +161,9 @@
|
|||
z-index: 70;
|
||||
padding: 10px 12px;
|
||||
}
|
||||
.playback-bar > .battle-recap {
|
||||
grid-column: 1 / -1;
|
||||
border-bottom: 1px solid var(--line);
|
||||
padding-bottom: 9px;
|
||||
.playback-content > .battle-recap {
|
||||
border-top: 1px solid var(--line);
|
||||
padding-top: 10px;
|
||||
}
|
||||
.battle-recap {
|
||||
min-width: 0;
|
||||
|
|
|
|||
|
|
@ -5421,14 +5421,31 @@ small {
|
|||
z-index: 80;
|
||||
bottom: 126px;
|
||||
left: 50%;
|
||||
right: auto;
|
||||
transform: translateX(-50%);
|
||||
width: 720px;
|
||||
max-width: calc(100% - 24px);
|
||||
max-height: calc(100% - 138px);
|
||||
padding: 12px 14px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
.playback-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
overscroll-behavior: contain;
|
||||
}
|
||||
.playback-controls {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto auto;
|
||||
align-items: center;
|
||||
gap: 10px 16px;
|
||||
gap: 8px 12px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.playback-description {
|
||||
grid-column: 1 / -1;
|
||||
|
|
@ -5439,8 +5456,9 @@ small {
|
|||
}
|
||||
.playback-description strong {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 7px;
|
||||
gap: 5px 7px;
|
||||
font-size: 14px;
|
||||
}
|
||||
.playback-description small {
|
||||
|
|
@ -5458,11 +5476,12 @@ small {
|
|||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
min-width: 0;
|
||||
font-size: 11px;
|
||||
color: var(--muted);
|
||||
white-space: nowrap;
|
||||
}
|
||||
.playback-preference input {
|
||||
flex-shrink: 0;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
|
|
@ -5493,6 +5512,35 @@ small {
|
|||
padding: 7px 12px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
/* Keep recaps beside the board, not across the action. A landscape phone also
|
||||
benefits from the side layout when there is little vertical space. */
|
||||
@media (min-width: 1100px), (min-width: 760px) and (max-height: 550px) {
|
||||
.playback-bar {
|
||||
top: 20px;
|
||||
bottom: auto;
|
||||
left: 20px;
|
||||
transform: none;
|
||||
width: 350px;
|
||||
max-height: calc(100% - 40px);
|
||||
}
|
||||
.playback-controls {
|
||||
grid-template-columns: minmax(0, 1fr) auto;
|
||||
}
|
||||
.playback-transport {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
.playback-transport > button {
|
||||
flex: 1;
|
||||
padding-inline: 6px;
|
||||
}
|
||||
.playback-exit {
|
||||
justify-self: end;
|
||||
}
|
||||
.playback-progress {
|
||||
flex-basis: 100%;
|
||||
margin-left: 23px;
|
||||
}
|
||||
}
|
||||
.public-effect {
|
||||
position: absolute;
|
||||
z-index: 85;
|
||||
|
|
@ -5567,12 +5615,15 @@ small {
|
|||
}
|
||||
@media (max-width: 600px) {
|
||||
.playback-bar {
|
||||
grid-template-columns: 1fr auto;
|
||||
gap: 8px;
|
||||
bottom: 120px;
|
||||
max-height: calc(100% - 132px);
|
||||
width: calc(100% - 24px);
|
||||
padding: 10px 12px;
|
||||
}
|
||||
.playback-controls {
|
||||
grid-template-columns: 1fr auto;
|
||||
}
|
||||
.playback-exit {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
|
@ -6247,9 +6298,11 @@ small {
|
|||
font: bold 12px/1 sans-serif;
|
||||
}
|
||||
|
||||
.game-shell.playing-back:not(.full-replay) .activity.floating-panel {
|
||||
bottom: 260px;
|
||||
height: min(470px, calc(100% - 280px));
|
||||
@media (max-width: 1099px) and (min-height: 551px), (max-width: 759px) {
|
||||
.game-shell.playing-back:not(.full-replay) .activity.floating-panel {
|
||||
bottom: 260px;
|
||||
height: min(470px, calc(100% - 280px));
|
||||
}
|
||||
}
|
||||
@media (max-width: 600px) {
|
||||
.game-shell.playing-back:not(.full-replay) .activity.floating-panel {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue