Let a project choose how its game link is zoomed (#279)
game-maker / gate (push) Successful in 2m52s
game-maker / suite (push) Successful in 14m31s

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:
adminandClaude Opus 5.5 committed 2026-10-02 13:53:10 +02:00
1 parent 9e869df063
commit c88f57cf0a
13 files changed
+272 -15

No files matched your search

+64 -2
View File
@@ -4,11 +4,12 @@
* saved but never lands on the undo stack.
*/
import { describe, expect, it } from 'vitest';
import { SetPlayFromCommand } from '../../src/core/commands/projectCommands';
import { gameScaleOf, playFromOf } from '../../src/core/model/playSettings';
import { SetGameLinkZoomCommand, SetPlayFromCommand } from '../../src/core/commands/projectCommands';
import { gameLinkZoomOf, gameScaleOf, playFromOf } from '../../src/core/model/playSettings';
import { createEmptyProject } from '../../src/core/model/Project';
import { deserializeProject, serializeProject } from '../../src/core/store/serialize';
import { EditorState } from '../../src/editor/state';
import { cameraView } from '../../src/viewport/view';
function loaded() {
const state = new EditorState();
@@ -74,3 +75,64 @@ describe('play settings in the project', () => {
expect(state.saveStatus).toBe('dirty');
});
});
describe('the zoom of the game link (#279)', () => {
it('is Auto in a new project and in one written before there was a choice', () => {
expect(createEmptyProject('p', 'P').gameLinkZoom).toBe('auto');
expect(deserializeProject({ id: 'p', name: 'P', assets: [] }).gameLinkZoom).toBe('auto');
});
it('survives a save and a load, apart from the scale of the game view', () => {
const project = { ...createEmptyProject('p', 'P'), gameLinkZoom: 'fit' as const, gameScale: 2 };
const back = deserializeProject(serializeProject(project));
expect([back.gameLinkZoom, back.gameScale]).toEqual(['fit', 2]);
});
it('reads untrusted JSON as Auto unless it is one of the two choices', () => {
expect(gameLinkZoomOf({ gameLinkZoom: 'fit' })).toBe('fit');
expect(gameLinkZoomOf({ gameLinkZoom: 'auto' })).toBe('auto');
expect(gameLinkZoomOf({ gameLinkZoom: 2 })).toBe('auto');
expect(gameLinkZoomOf({ gameLinkZoom: 'Fit' })).toBe('auto');
expect(gameLinkZoomOf({ gameScale: 'fit' })).toBe('auto');
expect(gameLinkZoomOf(null)).toBe('auto');
});
it('is one undo step', () => {
const state = loaded();
state.execute(new SetGameLinkZoomCommand('fit'));
expect(state.project.gameLinkZoom).toBe('fit');
expect(state.saveStatus).toBe('dirty');
state.undo();
expect(state.project.gameLinkZoom).toBe('auto');
state.redo();
expect(state.project.gameLinkZoom).toBe('fit');
});
it('leaves the scale of the game view alone', () => {
const state = loaded();
state.setGameScale(3);
state.execute(new SetGameLinkZoomCommand('fit'));
expect(state.gameScale).toBe(3);
});
it('fills the window at Fit where Auto stops at the step below', () => {
const camera = { x: 0, y: 0, props: { width: 300, height: 180, zoom: 1 } };
const auto = cameraView(camera, 1000, 700, 'auto');
const fit = cameraView(camera, 1000, 700, 'fit');
expect(auto.scale).toBe(3);
expect(auto.rect).toEqual({ x: 50, y: 80, w: 900, h: 540 });
expect(fit.scale).toBeCloseTo(10 / 3, 9);
expect(fit.rect.x).toBeCloseTo(0, 9);
expect(fit.rect.w).toBeCloseTo(1000, 9);
expect(fit.rect.h).toBeCloseTo(600, 9);
expect(fit.rect.y).toBeCloseTo(50, 9);
});
it('shrinks the picture at Fit in a window smaller than the camera', () => {
const camera = { x: 0, y: 0, props: { width: 300, height: 180, zoom: 1 } };
const fit = cameraView(camera, 200, 400, 'fit');
expect(fit.scale).toBeCloseTo(2 / 3, 9);
expect(fit.rect.w).toBeCloseTo(200, 9);
expect(fit.rect.h).toBeCloseTo(120, 9);
});
});
+6
View File
@@ -9,6 +9,7 @@ const before: ProjectSettings = {
name: 'Demo project',
playFrom: 'start',
whilePlaying: 'balanced',
gameLinkZoom: 'auto',
collisionLayers: ['Default', 'Enemies'],
symbolScale: 1,
};
@@ -63,4 +64,9 @@ describe('project settings', () => {
expect(settingsChanges(before, { ...before, whilePlaying: 'live' }).whilePlaying).toBe('live');
expect(settingsChanges(before, { ...before, whilePlaying: 'balanced' }).whilePlaying).toBeUndefined();
});
it('writes the zoom of the game link only when it changed (#279)', () => {
expect(settingsChanges(before, { ...before, gameLinkZoom: 'fit' }).gameLinkZoom).toBe('fit');
expect(settingsChanges(before, { ...before, gameLinkZoom: 'auto' }).gameLinkZoom).toBeUndefined();
});
});