Let a project choose how its game link is zoomed (#279)
The page of a released game always drew the camera at Auto, the
largest whole step that fits. A camera of 300x180 in a window of
1280x800 stands at step 4 and leaves a border left and right. The
issue asks for Fit next to it. Answered there: a setting of its own
rather than the scale of the Game tab, and no switch for the player.
- The project has a field gameLinkZoom, 'auto' or 'fit'. A document
without it reads as 'auto', so nothing changes for a project that
is there already. No format bump.
- Project settings has a row "Link zoom" with a menu of Auto and
Fit. It is an undo step of its own, SetGameLinkZoomCommand.
- GameScreen hands the field to cameraView where it passed a fixed
'auto'.
- gameScale, the scale of the Game tab, is not touched and does not
reach the link.
- The released copy is frozen, so the change reaches the link only
with "Update release".
Decided here:
- The row is called "Link zoom", not "Game link zoom" as proposed.
The longer label is wider than the label column of the dialog and
pushed its button 12 px out of line with the others.
- The undo step keeps the name "Game link zoom", which is what the
tooltip of the undo button shows.
- A note under the row says "The released game at the largest whole
step that fits, or filling the window."
Tests:
- Gate on melektaus-atx: 211 files, 3227 tests (3219 + 8), exit 0
- e2e 60 on melektaus-atx: 19 checks, all pass
- e2e 35,46,59,60: 74 checks, all pass
- No full run and no smokes. The sum of 1671 (1668 + 3) is reckoned,
1668 is what CI counted for 9e869df.
- Eight unit tests: the default, saving and loading, values that
are not a choice, undo, gameScale left alone, the factor of Fit
for a window larger and smaller than the camera, and the rule
behind Apply.
- Three e2e checks in block 60i of module 60, with the real mouse:
Auto to Fit in the dialog, update the release, open the link
without a session and measure scale, frame and pixels. Fit reads
4.267 where Auto reads 4.
- Nine unit counter-probes and three browser counter-probes all fail
their tests.
- Not checked in the browser: Fit in a window smaller than the
camera, which has a unit test, and Fit under a display scale above
100 %. Nothing was looked at after the build.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9e869df063
commit
c88f57cf0a
13 files changed
+272
-15
No files matched your search
@@ -77,8 +77,8 @@ function game(id) {
|
||||
|
||||
/**
|
||||
* Releasing a project (#266): published from the main menu, played from the link without a
|
||||
* session – only the game, zoomed to Auto, on the page colour, with a fullscreen button in the
|
||||
* corner (#267) – updated under the same link, and taken down.
|
||||
* session – only the game, zoomed to Auto or, once the project says so, to Fit (#279), on the page
|
||||
* colour, with a fullscreen button in the corner (#267) – updated under the same link, and taken down.
|
||||
*
|
||||
* Works on a throwaway project of its own, like step 50. The last thing it does is delete that
|
||||
* project and open the fixture again.
|
||||
@@ -303,6 +303,80 @@ export async function release(t) {
|
||||
);
|
||||
check('the play page threw nothing', exceptions().length === 0, exceptions().join(' | '));
|
||||
|
||||
// 60i (#279). Project settings switch the link from Auto to Fit, with the mouse and as one undo
|
||||
// step; once the release is updated, the same link fills the window at a scale between the steps.
|
||||
await t.signIn();
|
||||
await cdp.send('Page.navigate', { url: `${baseUrl}?project=${made.id}` });
|
||||
await sleep(4000);
|
||||
await waitUntil(`window.__gm?.state?.project?.id === ${JSON.stringify(made.id)}`, {
|
||||
timeout: 15000,
|
||||
label: 'the throwaway project is open for its settings',
|
||||
});
|
||||
const undoBefore = await json('__gm.state.commands.undoStack.length');
|
||||
await clickToolbar('menu');
|
||||
await clickText('Project settings…');
|
||||
await settle();
|
||||
const shown = (await json('__gm.projectSettings()')).gameLinkZoom;
|
||||
const zoomAt = await json('__gm.projectSettingsGameLinkZoomAt()');
|
||||
await click(zoomAt.x, zoomAt.y);
|
||||
await clickLast('Fit');
|
||||
await settle();
|
||||
const chosen = (await json('__gm.projectSettings()')).gameLinkZoom;
|
||||
await shot('60-release-link-zoom');
|
||||
await clickLast('Apply');
|
||||
await settle();
|
||||
const stored279 = await json('__gm.state.project.gameLinkZoom');
|
||||
const undoAfter = await json('__gm.state.commands.undoStack.length');
|
||||
check(
|
||||
'the Project settings show the link zoom as Auto and take Fit from the menu, as one undo step',
|
||||
shown === 'auto' && chosen === 'fit' && stored279 === 'fit' && undoAfter === undoBefore + 1,
|
||||
JSON.stringify({ shown, chosen, stored: stored279, undoBefore, undoAfter }),
|
||||
);
|
||||
await saved();
|
||||
const changed = await openRelease();
|
||||
await clickLast('Update release');
|
||||
await waitUntil('__gm.release()?.state.endsWith("as saved")', { label: 'the release carries the zoom' });
|
||||
await clickLast('Cancel');
|
||||
const releasedZoom = (await (await send('GET', `releases/${token}`, undefined, false)).json()).project
|
||||
.gameLinkZoom;
|
||||
await openLink(after.link);
|
||||
await waitUntil('__gameMakerPlay.screen().caption === "Click to play"', {
|
||||
timeout: 15000,
|
||||
label: 'the fitted game offers to start',
|
||||
});
|
||||
await click(size.w / 2, size.h / 2);
|
||||
await waitUntil('__gameMakerPlay.running()', { label: 'the fitted game runs' });
|
||||
await sleep(300);
|
||||
const fitted = await player('screen()');
|
||||
const fit = Math.min(size.w / CAMERA.width, size.h / CAMERA.height);
|
||||
const near = (a, b) => Math.abs(a - b) < 0.01;
|
||||
const fittedCentre = {
|
||||
x: fitted.frame.x + fitted.frame.w / 2,
|
||||
y: fitted.frame.y + fitted.frame.h / 2,
|
||||
};
|
||||
const fittedPixels = {
|
||||
centre: await player(`pixelAt(${fittedCentre.x}, ${fittedCentre.y})`),
|
||||
beside: await player(`pixelAt(${fittedCentre.x - 40 * fitted.scale}, ${fittedCentre.y})`),
|
||||
};
|
||||
check(
|
||||
'with Fit the link fills the window, at a scale between the steps',
|
||||
changed.state.endsWith('the project has changed since') &&
|
||||
releasedZoom === 'fit' &&
|
||||
!STEPS.includes(fit) &&
|
||||
fit > auto &&
|
||||
near(fitted.scale, fit) &&
|
||||
near(fitted.frame.w, CAMERA.width * fit) &&
|
||||
near(fitted.frame.h, CAMERA.height * fit) &&
|
||||
(near(fitted.frame.w, size.w) || near(fitted.frame.h, size.h)) &&
|
||||
fittedPixels.centre === RED &&
|
||||
fittedPixels.beside === BACKGROUND,
|
||||
JSON.stringify({ size, auto, fit, fitted, fittedPixels, releasedZoom, changed: changed.state }),
|
||||
);
|
||||
await shot('60-release-fit');
|
||||
await press('s');
|
||||
await sleep(400);
|
||||
check('the fitted play page threw nothing', exceptions().length === 0, exceptions().join(' | '));
|
||||
|
||||
// 60f. Take down asks, then the link is dead – for the API and for the page.
|
||||
await t.signIn();
|
||||
await cdp.send('Page.navigate', { url: `${baseUrl}?project=${made.id}` });
|
||||
|
||||
Reference in new issue
Block a user