Let the project set the size of scene view symbols
game-maker / gate (push) Successful in 3m0s
game-maker / suite (push) Failing after 9m27s

Pixel art projects draw at very different sizes, so the fixed 18 px
icons of behaviors, containers and rigidbodies were too big in some
projects and too small in others. The size now lives in the project
settings and travels with the project.

- New field Symbol scale in the project settings dialog, below Play
  starts. It takes 0.1 to 4 with two decimals and defaults to 1.
- The value is stored as project.symbolScale. Older projects load
  with 1, and values out of range are clamped on load.
- Every change is its own undo step through a project command.
- The factor scales the icon size, the spacing of icons that share a
  spot, the label offset and the selection frame of icon-only symbols.
- The footprints in bounds.ts that Fit uses stay as they were. The
  hit area follows the icon, so clicks match what is drawn.
- uiHooks reports the icon size so e2e can measure it.

The e2e sum in the README is 1375. That is 1374 plus one new check,
and 1374 itself has not been confirmed by CI yet.

Tests:
- ./check.sh: 157 files, 2326 tests, CHECK EXIT 0 (before 2320).
- New tests/core/symbol-scale.test.ts with 5 tests (default, save
  and load, clamping, undo, icon frame), one more in
  project-settings.test.ts.
- e2e 46f: dialog opens with 1, 0.5 plus Apply gives a 9 px icon,
  undo gives 18 again. Module 46: ALL PASSED, 13 checks.
- Counter checks: without loading the value the save and load test
  fails. With the icon ignoring the factor exactly 46f fails. Both
  originals restored per cmp.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 5.5 committed 2026-09-24 10:55:42 +02:00
1 parent 5399ef17e5
commit 5afb70a92e
14 files changed
+233 -23

No files matched your search

+1
View File
@@ -151,6 +151,7 @@ describe('CommandStack', () => {
startSceneId: '',
plugins: [],
collisionLayers: ['Default'],
symbolScale: 1,
};
const stack = new CommandStack(project);
let failing = false;
+51
View File
@@ -0,0 +1,51 @@
/**
* The project's symbol scale: how large the scene view draws its icons, 0.1 to 4, default 1.
*/
import { describe, expect, it } from 'vitest';
import { SetSymbolScaleCommand } from '../../src/core/commands/projectCommands';
import { createEmptyProject } from '../../src/core/model/Project';
import { symbolScaleOf } from '../../src/core/model/symbolScale';
import { footprintOf, iconCorners } from '../../src/core/properties/bounds';
import { deserializeProject, serializeProject } from '../../src/core/store/serialize';
describe('symbol scale', () => {
it('is 1 in a new project and in one written before there was any', () => {
expect(createEmptyProject('p', 'P').symbolScale).toBe(1);
expect(deserializeProject({ id: 'p', name: 'P', assets: [] }).symbolScale).toBe(1);
});
it('survives a save and a load', () => {
const project = { ...createEmptyProject('p', 'P'), symbolScale: 0.25 };
expect(deserializeProject(serializeProject(project)).symbolScale).toBe(0.25);
});
it('reads untrusted JSON into the range 0.1 to 4', () => {
expect(symbolScaleOf({ symbolScale: 0.05 })).toBe(0.1);
expect(symbolScaleOf({ symbolScale: 12 })).toBe(4);
expect(symbolScaleOf({ symbolScale: 2.5 })).toBe(2.5);
expect(symbolScaleOf({ symbolScale: '2' })).toBe(1);
expect(symbolScaleOf({ symbolScale: Number.NaN })).toBe(1);
expect(symbolScaleOf(null)).toBe(1);
});
it('is one undo step, clamped like a loaded project', () => {
const project = createEmptyProject('p', 'P');
const command = new SetSymbolScaleCommand(7);
command.execute(project);
expect(project.symbolScale).toBe(4);
command.undo(project);
expect(project.symbolScale).toBe(1);
});
it('grows the outline of an icon-only symbol with the icon, the padding stays', () => {
const { w } = footprintOf('behavior', {});
const at = { x: 100, y: 50 };
const half = (corners: { x: number }[]) => (corners[1]!.x - corners[0]!.x) / 2;
expect(half(iconCorners('behavior', {}, at, 1))).toBe(w / 2);
expect(half(iconCorners('behavior', {}, at, 0.5))).toBe(w / 4);
expect(half(iconCorners('behavior', {}, at, 2, 3))).toBe(w + 3);
const corners = iconCorners('behavior', {}, at, 0.5);
expect((corners[0]!.x + corners[2]!.x) / 2).toBe(100);
expect((corners[0]!.y + corners[2]!.y) / 2).toBe(50);
});
});
+9
View File
@@ -9,6 +9,7 @@ const before: ProjectSettings = {
name: 'Demo project',
playFrom: 'start',
collisionLayers: ['Default', 'Enemies'],
symbolScale: 1,
};
describe('project settings', () => {
@@ -46,6 +47,14 @@ describe('project settings', () => {
expect(change.collisionLayers).toEqual(['Default', 'Foes']);
});
it('writes the symbol scale only when it changed, kept inside 0.1 to 4', () => {
expect(settingsChanges(before, { ...before, symbolScale: 1 }).symbolScale).toBeUndefined();
expect(settingsChanges(before, { ...before, symbolScale: 0.5 }).symbolScale).toBe(0.5);
expect(settingsChanges(before, { ...before, symbolScale: 0.01 }).symbolScale).toBe(0.1);
expect(settingsChanges(before, { ...before, symbolScale: 9 }).symbolScale).toBe(4);
expect(settingsChanges(before, { ...before, symbolScale: Number.NaN }).symbolScale).toBeUndefined();
});
it('always reports the start-scene switch – it is a preference, not an undo step', () => {
expect(settingsChanges(before, { ...before, playFrom: 'active' }).playFrom).toBe('active');
expect(settingsChanges(before, { ...before, playFrom: 'start' }).playFrom).toBe('start');