Clean up duplicates and dead code, and fix the + menu check (#85)
game-maker / gate (push) Successful in 3m2s
game-maker / suite (push) Successful in 15m29s

Refactoring round 9 covers everything since round 8 (14972d0): 62
commits with about 29 000 new lines in src, api, tools and tests.
Behaviour is unchanged. The one fix is in a check: e2e 04 counted 25
asset types, and the shader function from #303 makes 26, so the run
of a526e1b failed there.

Duplicate code (jscpd over src, 50 tokens, without the two licence
texts: 35 clones / 289 lines before, 29 / 232 after):

- ShaderPicture (new, viewport/shaderPicture.ts) is the picture a
  camera's shader and a particle field's shader are laid over. It
  keeps the render texture while its size holds and frees the
  replaced one once the shader holds the new one. CameraShade and
  ParticleField.shadeField drew it the same way, line for line.
- CameraShade builds its mesh on the first draw. Before, every redraw
  of a view without a camera shader built a mesh and threw it away.
- emptyHost in inspector/host.ts builds the empty host the Inspector,
  the Variables tab and the Tilemap panel start from.
- paddedQuad(null) is the plain unit quad. symbols.ts and
  shaderPasses.ts each wrote it out by hand.
- In graph/nested.ts, calls of shader functions and On behavior
  nodes are followed by one walk, `reaches`, over ids `namedBy` a
  node type.

Dead code:

- ShaderEditor.colorFieldOf and the getter CurveCanvas.snapping had
  no reader.
- 22 values used only in their own file lose their `export`. Types
  and the node catalogues of shaders and particles stay exported.
- Kept on purpose: PhysicsSystem.holdsJoint is read by tests only,
  but it is their one view of whether a joint holds.
- A pass with stricter lint rules over every file changed since
  round 8 found no bug. PixelArtEditor.started is now readonly.

Comments and docs:

- Ten comments told history ("since #190", "used to", "any more").
  They now describe what is. The bundle is md5-identical before and
  after, and the four e2e files minify to the same bytes.
- README: joint and shader function in the asset list, joints on the
  Physics row, what the Shaders page covers, two CI runners.
- e2e 04 keeps the number of asset types once, as ASSET_TYPE_COUNT.
- screenshot.png in the README is a new picture of the editor
  (3840x2160 instead of 1825x1140), taken by the user.

Tests:
- Gate on melektaus-atx: 229 files, 3514 tests, CHECK EXIT 0
  (+3 for emptyHost, +1 for the unit quad).
- e2e 1-4, 31, 63 on melektaus-atx: ALL PASSED, 195 checks. That is
  the + menu of 04, the field shader of 31 and the camera shader of
  63, both through ShaderPicture.
- No new e2e check, so the sum stays 1728.
- Counter-checks, each put back and compared with cmp: reaches that
  never goes on fails 1 test, listensTo reading the wrong parameter
  fails 1, emptyHost dropping what a panel hands in fails 1, folding
  without a relayout fails 1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 5.5 committed 2026-10-03 17:38:39 +02:00
1 parent a526e1b40f
commit 808e1eefc2
43 files changed
+314 -224

No files matched your search

-4
View File
@@ -136,10 +136,6 @@ export class CurveCanvas extends SheetCanvas<CurveAsset> {
this.snap = on;
}
get snapping(): boolean {
return this.snap;
}
/** Where the preview stands: the share of time, the value the curve gives it, its two dots and its knob. */
previewState(): { t: number; v: number; dot: Vec2; bar: Vec2; knob: Vec2 } | null {
const asset = this.asset();
+1 -1
View File
@@ -147,7 +147,7 @@ export function renderHooks({ app, state, editor }: HookContext) {
* where a deadline is only the harness hoping it has.
*/
afterFrames: (count = 2, timeoutMs = 2000) => afterFrames(count, timeoutMs),
/** Visible nodes carrying a filter – one extra render pass each; since #77 a shader is none. */
/** Visible nodes carrying a filter – one extra render pass each; a shader is none. */
filterCount: () => {
let n = 0;
const walk = (node: Container): void => {
+1 -1
View File
@@ -7,7 +7,7 @@ import { centreOf, snapButton, type HookContext } from './hookHelpers';
/** The Vector art tab (#129). */
export function vectorArtHooks({ state, editor }: HookContext) {
const { vectorArtEditor, inspector } = editor;
/** The two lists, scrolled into view first: since #190 the layers stand over the shapes. */
/** The two lists, scrolled into view first: the layers stand over the shapes. */
const shapeList = () => {
const list = currentShapeList();
if (list) inspector.reveal(list);
+2 -2
View File
@@ -3,12 +3,12 @@
* game, and what the editor does around them. Averaged per frame over half a second, the same
* window the fps readout counts over.
*/
export const FRAME_AREAS = ['behaviors', 'physics', 'animation', 'drawing', 'editor'] as const;
const FRAME_AREAS = ['behaviors', 'physics', 'animation', 'drawing', 'editor'] as const;
export type FrameArea = (typeof FRAME_AREAS)[number];
export type FrameTimes = Record<FrameArea, number>;
/** Seconds one average runs over. */
export const FRAME_WINDOW = 0.5;
const FRAME_WINDOW = 0.5;
const LABELS: Record<FrameArea, string> = {
behaviors: 'Behaviors',
+1 -1
View File
@@ -17,7 +17,7 @@ export type EdgePlate = Rect & { edgeId: string };
/** Straight pieces a curve is tested as; at 24 the error stays far below a pixel of tolerance. */
const CURVE_STEPS = 24;
export function pathPoints(path: EdgePath): Point[] {
function pathPoints(path: EdgePath): Point[] {
if (path.kind === 'line') return [path.start, path.end];
const at = (t: number) =>
path.kind === 'loop'
+4 -12
View File
@@ -1,13 +1,13 @@
import type { PropertyBag } from '../../core/model/Properties';
import type { FederatedPointerEvent } from 'pixi.js';
import { Label, Panel, pressCount, ScrollContainer, SectionStack, Theme, ui, type Widget } from '../../ui';
import { Label, Panel, pressCount, ScrollContainer, ui, type Widget } from '../../ui';
import { activateAsset } from '../actions';
import { type EditorState, sameSelection, type Selection } from '../state';
import { assetSignature, buildAssetSection, refreshAssetSection } from './assetSection';
import { annotationSignature, buildAnnotationSection, refreshAnnotationSection } from './annotationSection';
import { buildEdgeSection, edgeSignature, refreshEdgeSection } from './edgeSection';
import { buildFrameSection, frameSignature, refreshFrameSection } from './frameSection';
import type { InspectorHost } from './host';
import { emptyHost, type InspectorHost } from './host';
import { buildNodeSection, nodeSignature, refreshNodeSection } from './nodeSection';
import { buildShapeSection, refreshShapeSection, shapeSignature } from './shapeSection';
import {
@@ -95,19 +95,11 @@ export class Inspector extends Panel {
}
private emptyHost(): InspectorHost {
const body = new SectionStack({ padding: Theme.padding, gap: Theme.gap });
body.onFold = () => this.scroll.relayoutContent();
return {
state: this.state,
// Read through the state on every call: load and play mode replace the project object.
project: () => this.state.project,
return emptyHost(this.state, this.scroll, {
liveVariables: (assetId) => this.liveVariables(assetId),
followReference: (assetId, e) => this.followReference(assetId, e),
listLimit: INLINE_LIMIT,
body,
fields: new Map(),
nameField: null,
};
});
}
/**
+35 -1
View File
@@ -1,5 +1,14 @@
import type { PropertyBag } from '../../core/model/Properties';
import { Label, SectionHeader, TextField, type TextFieldOptions, type VStack } from '../../ui';
import {
Label,
type ScrollContainer,
SectionHeader,
SectionStack,
TextField,
type TextFieldOptions,
Theme,
type VStack,
} from '../../ui';
import { foldKey, isFolded, setFolded } from '../sectionFolds';
import type { EditorState } from '../state';
import { type FieldContext, type FieldRow, labelledRow } from './fieldFactory';
@@ -18,6 +27,31 @@ export interface InspectorHost extends FieldContext {
readonly foldScope?: string;
}
/**
* A host with an empty body that sits in `scroll`, which lays itself out anew when a group folds.
* `own` is what sets a panel apart: its fold scope, the live values it shows, how its links act.
*/
export function emptyHost(
state: EditorState,
scroll: ScrollContainer,
own: Pick<InspectorHost, 'foldScope' | 'followReference' | 'listLimit'> & {
liveVariables?: InspectorHost['liveVariables'];
} = {},
): InspectorHost {
const body = new SectionStack({ padding: Theme.padding, gap: Theme.gap });
body.onFold = () => scroll.relayoutContent();
return {
state,
// Read through the state on every call: load and play mode replace the project object.
project: () => state.project,
liveVariables: () => null,
body,
fields: new Map(),
nameField: null,
...own,
};
}
/** The band that opens a group of rows; controls go to its right end with `add()`. Not yet in the body. */
export function sectionHeader(host: InspectorHost, text: string): SectionHeader {
const key = foldKey(host.foldScope ?? 'inspector', text);
+1 -1
View File
@@ -100,7 +100,7 @@ function stepLabel(verb: string, count: number): string {
* Takes the selected shapes through the map `toMap` makes of their frame, as one undo step. False
* when there is no frame or the map changes nothing. Exported for the buttons and the tests.
*/
export function transformSelection(
function transformSelection(
state: EditorState,
assetId: string,
shapeIds: readonly string[],
+2 -13
View File
@@ -30,7 +30,6 @@ import {
Menu,
Panel,
ScrollContainer,
SectionStack,
SortableList,
Theme,
ui,
@@ -39,7 +38,7 @@ import {
import type { EditorState, TilemapFocus, TilemapTool } from '../state';
import { TilePalette } from '../tile/TilePalette';
import { labelledRow } from '../inspector/fieldFactory';
import { addNote, addTitle, type InspectorHost } from '../inspector/host';
import { addNote, addTitle, emptyHost, type InspectorHost } from '../inspector/host';
import { listFold } from '../sectionFolds';
const FOCUS: { focus: TilemapFocus; label: string }[] = [
@@ -218,17 +217,7 @@ export class TilemapPanel extends Panel {
}
private emptyHost(): InspectorHost {
const body = new SectionStack({ padding: Theme.padding, gap: Theme.gap });
body.onFold = () => this.scroll.relayoutContent();
return {
state: this.state,
project: () => this.state.project,
liveVariables: () => null,
body,
fields: new Map(),
nameField: null,
foldScope: FOLD_SCOPE,
};
return emptyHost(this.state, this.scroll, { foldScope: FOLD_SCOPE });
}
private currentSignature(): string {
+1 -1
View File
@@ -21,7 +21,7 @@ export class PixelArtEditor extends AssetTabEditor<PixelArtAsset, PixelArtCanvas
/** Assigned by `body`; public for the check scripts, which press everything on it. */
side!: PixelArtSide;
splitter!: Splitter;
private started = performance.now();
private readonly started = performance.now();
constructor(state: EditorState) {
super(state, { infoWidth: INFO_WIDTH });
+1 -6
View File
@@ -42,7 +42,7 @@ const PARAM_VALUE_WIDTH = 44;
type ShaderTabAsset = ShaderAsset | ShaderFunctionAsset;
/** The panel's line while a function is open: it is seen in the shaders that call it. */
export const FUNCTION_SUBJECT = 'A function shows in the shaders calling it';
const FUNCTION_SUBJECT = 'A function shows in the shaders calling it';
/**
* The nodes of one shader asset, on the graph canvas the Behavior tab uses, and beside them a picture
@@ -150,11 +150,6 @@ export class ShaderEditor extends AssetTabEditor<ShaderTabAsset, GraphCanvas> {
return this.sliders.get(key)?.slider;
}
/** The colour field of one colour property, for the check scripts. */
colorFieldOf(key: string): ColorField | undefined {
return this.colors.get(key);
}
override selectedId(): string {
return this.state.selectedShaderId ?? '';
}
+4 -11
View File
@@ -8,9 +8,9 @@ import { isVariableOwner } from '../../core/model/Asset';
import { findObject } from '../../core/model/hierarchy';
import { findAsset } from '../../core/model/Project';
import { objectName } from '../../core/model/SceneObject';
import { Label, ScrollContainer, SectionStack, Theme, ui, VStack, HStack } from '../../ui';
import { Label, ScrollContainer, Theme, ui, VStack, HStack } from '../../ui';
import { assetSignature, buildVariables, refreshAssetSection } from '../inspector/assetSection';
import type { InspectorHost } from '../inspector/host';
import { emptyHost, type InspectorHost } from '../inspector/host';
import { viewOf } from '../inspector/objectQueries';
import {
buildOwnRows,
@@ -101,17 +101,10 @@ export class VariablesEditor extends VStack {
}
private emptyHost(): InspectorHost {
const body = new SectionStack({ padding: Theme.padding, gap: Theme.gap });
body.onFold = () => this.scroll.relayoutContent();
return {
state: this.state,
project: () => this.state.project,
return emptyHost(this.state, this.scroll, {
liveVariables: (assetId) => this.liveVariables(assetId),
body,
fields: new Map(),
nameField: null,
foldScope: 'variables',
};
});
}
private currentSignature(): string {
+2 -2
View File
@@ -22,11 +22,11 @@ import { knobAt, type SizeGrip, sizeGripAt } from '../sizeGizmo';
/** Screen pixels between what is framed and the frame. More than a point's reach plus a handle's. */
export const FRAME_PAD = 15;
/** Screen pixels around a handle that grab it. */
export const FRAME_GRIP = 6;
const FRAME_GRIP = 6;
/** How far the knob stands out from the top edge, in screen pixels. */
export const FRAME_STEM = 26;
/** Degrees a turn snaps to while Shift is held. */
export const TURN_SNAP = 15;
const TURN_SNAP = 15;
export interface FrameBox {
/** Top left, top right, bottom right, bottom left – in the pixels `toLocal` hands out. */