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

+59 -4
View File
@@ -1,7 +1,13 @@
import { layerFallback, MAX_COLLISION_LAYERS } from '../core/model/collisionLayers';
import { clampSymbolScale, SYMBOL_SCALE_MAX, SYMBOL_SCALE_MIN } from '../core/model/symbolScale';
import { Button, HStack, Label, Menu, NumberField, TextField, Theme, VStack } from '../ui';
import { type PlayFrom, WHILE_PLAYING, type WhilePlaying } from '../core/model/playSettings';
import {
GAME_LINK_ZOOMS,
type GameLinkZoom,
type PlayFrom,
WHILE_PLAYING,
type WhilePlaying,
} from '../core/model/playSettings';
import { FormDialog } from './FormDialog';
/** What the dialog hands back when Apply is pressed. */
@@ -9,6 +15,7 @@ export interface ProjectSettings {
name: string;
playFrom: PlayFrom;
whilePlaying: WhilePlaying;
gameLinkZoom: GameLinkZoom;
collisionLayers: string[];
symbolScale: number;
}
@@ -29,6 +36,7 @@ export function settingsChanges(
symbolScale?: number;
playFrom?: PlayFrom;
whilePlaying?: WhilePlaying;
gameLinkZoom?: GameLinkZoom;
} {
const name = after.name.trim() || before.name;
const symbolScale = clampSymbolScale(after.symbolScale);
@@ -40,6 +48,7 @@ export function settingsChanges(
...(symbolScale === before.symbolScale ? {} : { symbolScale }),
...(after.playFrom === before.playFrom ? {} : { playFrom: after.playFrom }),
...(after.whilePlaying === before.whilePlaying ? {} : { whilePlaying: after.whilePlaying }),
...(after.gameLinkZoom === before.gameLinkZoom ? {} : { gameLinkZoom: after.gameLinkZoom }),
};
}
@@ -54,9 +63,14 @@ const WHILE_PLAYING_LABEL: Record<WhilePlaying, string> = {
minimal: 'Minimal',
};
const GAME_LINK_ZOOM_LABEL: Record<GameLinkZoom, string> = {
auto: 'Auto',
fit: 'Fit',
};
/**
* Everything about the project that is not an asset (#183): its name, which scene Play starts and
* how closely the panels follow it (#265), the
* how closely the panels follow it (#265), the zoom of the game link (#279), the
* size of the scene view's symbol icons, and the collision layers (#152). The top bar carries icons
* only, so this is the one place they are edited.
*
@@ -68,11 +82,13 @@ export class ProjectSettingsDialog extends FormDialog {
private projectName: string;
private playFrom: PlayFrom;
private whilePlaying: WhilePlaying;
private gameLinkZoom: GameLinkZoom;
private layers: string[];
private symbolScale: number;
private readonly nameField: TextField;
private readonly playFromButton: Button;
private readonly whilePlayingButton: Button;
private readonly gameLinkZoomButton: Button;
private readonly symbolScaleField: NumberField;
private readonly rows = new VStack({ gap: Theme.gap });
private readonly addButton: Button;
@@ -82,6 +98,7 @@ export class ProjectSettingsDialog extends FormDialog {
this.projectName = settings.name;
this.playFrom = settings.playFrom;
this.whilePlaying = settings.whilePlaying;
this.gameLinkZoom = settings.gameLinkZoom;
this.layers = [...settings.collisionLayers];
this.symbolScale = clampSymbolScale(settings.symbolScale);
@@ -118,6 +135,18 @@ export class ProjectSettingsDialog extends FormDialog {
}),
);
this.gameLinkZoomButton = new Button(GAME_LINK_ZOOM_LABEL[this.gameLinkZoom], {
width: 150,
align: 'left',
onClick: () => this.openGameLinkZoomMenu(),
});
this.content.add(this.formRow(this.fieldLabel('Link zoom'), this.gameLinkZoomButton));
this.content.add(
new Label('The released game at the largest whole step that fits, or filling the window.', {
style: 'muted',
}),
);
this.symbolScaleField = new NumberField(this.symbolScale, {
width: 150,
min: SYMBOL_SCALE_MIN,
@@ -153,6 +182,7 @@ export class ProjectSettingsDialog extends FormDialog {
name: this.projectName,
playFrom: this.playFrom,
whilePlaying: this.whilePlaying,
gameLinkZoom: this.gameLinkZoom,
collisionLayers: this.layers,
symbolScale: this.symbolScale,
}),
@@ -165,12 +195,19 @@ export class ProjectSettingsDialog extends FormDialog {
return [...this.layers];
}
/** Name, start-scene switch, panel preset and symbol scale as they stand (test hook). */
values(): { name: string; playFrom: PlayFrom; whilePlaying: WhilePlaying; symbolScale: number } {
/** Name, start-scene switch, panel preset, link zoom and symbol scale as they stand (test hook). */
values(): {
name: string;
playFrom: PlayFrom;
whilePlaying: WhilePlaying;
gameLinkZoom: GameLinkZoom;
symbolScale: number;
} {
return {
name: this.projectName,
playFrom: this.playFrom,
whilePlaying: this.whilePlaying,
gameLinkZoom: this.gameLinkZoom,
symbolScale: this.symbolScale,
};
}
@@ -185,6 +222,11 @@ export class ProjectSettingsDialog extends FormDialog {
return this.whilePlayingButton;
}
/** The game link zoom switch, so a check can click it. */
get gameLinkZoomControl(): Button {
return this.gameLinkZoomButton;
}
/** The symbol scale field, so a check can type into it. */
get symbolScaleControl(): NumberField {
return this.symbolScaleField;
@@ -224,6 +266,19 @@ export class ProjectSettingsDialog extends FormDialog {
).openBelow(this.whilePlayingButton);
}
private openGameLinkZoomMenu(): void {
new Menu(
GAME_LINK_ZOOMS.map((zoom) => ({
label: GAME_LINK_ZOOM_LABEL[zoom],
current: this.gameLinkZoom === zoom,
onSelect: () => {
this.gameLinkZoom = zoom;
this.gameLinkZoomButton.setText(GAME_LINK_ZOOM_LABEL[zoom]);
},
})),
).openBelow(this.gameLinkZoomButton);
}
private addLayer(): void {
if (this.layers.length >= MAX_COLLISION_LAYERS) return;
this.layers.push(layerFallback(this.layers.length));