Paint an asset's name gold while any of its values deviates

The inspector already marked an asset value that differs from its schema
default, but the Assets panel gave no hint, so a changed asset looked
like an untouched one until you opened it.

The rule sits next to the existing objectDeviates as a pure function:
assetDeviates asks whether any marked property differs, markedAssetSchema
says which rows the inspector marks at all. buildAssetSection now builds
its rows from that same list, replacing the behavior/rest split it used
to carry, so the list cannot claim a deviation the inspector then fails
to show.

A behavior's variables are deliberately not in it. Their default is
declared on the variable itself, which means the asset value *is* that
default; counting them would paint the fixture's Mover gold while the
inspector beside it marks nothing.
This commit is contained in:
root committed 2026-09-09 15:21:39 +02:00
1 parent e0d43e12aa
commit e9634f0f0d
10 files changed
+166 -15

No files matched your search

+16 -2
View File
@@ -1,9 +1,23 @@
import type { Asset } from '../model/Asset';
import { ancestorIdsOf, type ObjectTree } from '../model/hierarchy';
import { instanceTargetOf, isEmptyEdit, resolveObjects } from '../model/instance';
import { findAsset, type Project } from '../model/Project';
import type { SceneObject } from '../model/SceneObject';
import { schemaForAsset } from './PropertySchema';
import { deviatesFromAsset } from './resolve';
import { COMMON_PROPS, type PropertySchema, schemaForAsset } from './PropertySchema';
import { deviatesFromAsset, isModified } from './resolve';
/**
* The rows the asset inspector marks as modified. A behavior's variables are left out: their
* default is declared on the variable itself, so the asset value cannot differ from it.
*/
export function markedAssetSchema(asset: Asset): PropertySchema {
return asset.type === 'behavior' ? COMMON_PROPS : schemaForAsset(asset);
}
/** Whether any asset property the inspector would mark gold differs from its default. */
export function assetDeviates(asset: Asset): boolean {
return markedAssetSchema(asset).some((def) => isModified(asset, def.key));
}
/**
* Whether a placed object deviates from whatever it follows: the container template it was
+1
View File
@@ -143,6 +143,7 @@ export function installDebugHook(app: Application, state: EditorState, editor: E
dropPreview: () => viewport.dropInfo(),
/** An asset row by id – two assets can share a name with the container picker's label. */
assetRow: (id: string) => assets.rowGlobal(id),
assetRowColor: (id: string) => assets.rowColor(id),
gameInfo: () => gameView.debugInfo(),
layerOf: (id: string) => viewport.layerOf(id),
drawOrder: () => viewport.drawOrder(),
+3 -7
View File
@@ -12,12 +12,12 @@ import {
import type { Asset, BehaviorAsset } from '../../core/model/Asset';
import { findAsset, type Project } from '../../core/model/Project';
import {
COMMON_PROPS,
type PropertyDef,
schemaForAsset,
VARIABLE_KINDS,
type VariableKind,
} from '../../core/properties/PropertySchema';
import { markedAssetSchema } from '../../core/properties/deviation';
import { isModified, resolveAssetProps } from '../../core/properties/resolve';
import { Button, Dropdown, HStack, Label, Menu, Spacer, TextField, Theme } from '../../ui';
import { aspectActions, sizeCommand } from './aspectAction';
@@ -63,12 +63,8 @@ export function buildAssetSection(host: InspectorHost, assetId: string): void {
row.add(host.nameField, 1);
host.body.add(row);
if (asset.type === 'behavior') {
buildProps(host, asset, COMMON_PROPS);
buildVariables(host, asset);
} else {
buildProps(host, asset, schemaForAsset(asset));
}
buildProps(host, asset, markedAssetSchema(asset));
if (asset.type === 'behavior') buildVariables(host, asset);
}
/** Pushes the current asset values into the rows. False when the asset is gone (rebuild). */
+13 -1
View File
@@ -8,13 +8,19 @@ import {
isPlaceableType,
} from '../../core/model/AssetTypes';
import { findAsset } from '../../core/model/Project';
import { assetDeviates } from '../../core/properties/deviation';
import type { TextureStore } from '../../core/store/TextureStore';
import { Button, ListView, Menu, type MenuItem, Panel, ScrollContainer, startDrag } from '../../ui';
import { confirmDeleteAsset } from '../actions';
import type { EditorState } from '../state';
import { pickAndImport } from '../textureImport';
/** Lists all assets of the project; creates and deletes them. Placing is a drag into a view. */
/**
* Lists all assets of the project; creates and deletes them. Placing is a drag into a view.
*
* A row's name turns gold when the asset carries a property the inspector marks – the same rule,
* so the list cannot promise a deviation the inspector then fails to show.
*/
export class AssetPanel extends Panel {
private readonly list = new ListView();
private readonly scroll = new ScrollContainer();
@@ -59,6 +65,7 @@ export class AssetPanel extends Panel {
label: asset.name,
hint: asset.type === 'scene' && asset.id === active ? 'scene ●' : asset.type,
swatch: hasColorSwatch(asset.type) ? Number(asset.props.color ?? 0) : undefined,
overridden: assetDeviates(asset),
})),
);
this.syncSelection();
@@ -98,6 +105,11 @@ export class AssetPanel extends Panel {
return this.list.rowGlobal(assetId);
}
/** Label colour of a row as `#rrggbb` – gold means the asset deviates from the defaults (test hook). */
rowColor(assetId: string): string | null {
return this.list.rowColor(assetId);
}
/** Hands the asset to the viewport under the pointer; a scene has nowhere to be placed into. */
private startPlacementDrag(assetId: string): void {
const asset = findAsset(this.state.project, assetId);