Tilemaps are a new placeable asset type that is painted with autotiles in the scene view, with layers, brush, eraser and rectangle, and is drawn at runtime and in the export (#128)
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0607221423
commit
33a7b1b63e
30 files changed
+2060
-20
No files matched your search
+57
-1
@@ -4,6 +4,7 @@ import { previewObjectId } from '../core/model/animationPreview';
|
||||
import { resolveObjects } from '../core/model/instance';
|
||||
import { findAsset, findAssetOf, findObjectHolder } from '../core/model/Project';
|
||||
import type { FrameRect } from '../core/model/texture';
|
||||
import { findLayer } from '../core/model/tilemap';
|
||||
import { effectiveScale, gameClock } from '../core/time';
|
||||
import {
|
||||
activeDrag,
|
||||
@@ -28,7 +29,8 @@ import { currentFontPicker } from './font/FontPicker';
|
||||
import { currentNodePalette } from './graph/NodePalette';
|
||||
import { currentSoundPicker } from './sound/SoundPicker';
|
||||
import { currentImagePicker } from './texture/ImagePicker';
|
||||
import type { EditorState } from './state';
|
||||
import { currentTilemapSection } from './inspector/tilemapSection';
|
||||
import type { EditorState, TilemapTool } from './state';
|
||||
|
||||
/**
|
||||
* Installs `window.__gm`, which the check scripts in tools/ use to find widgets by their
|
||||
@@ -248,6 +250,8 @@ export function installDebugHook(app: Application, state: EditorState, editor: E
|
||||
locate,
|
||||
locateAll,
|
||||
inspectorField: fieldOf,
|
||||
/** The inspector panel on screen – what tells whether a row of it can be clicked at all. */
|
||||
inspectorRect: () => rectOf(inspector),
|
||||
inspectorInfo: () => inspector.debugInfo(),
|
||||
textColor,
|
||||
overlayTexts,
|
||||
@@ -523,6 +527,58 @@ export function installDebugHook(app: Application, state: EditorState, editor: E
|
||||
pictureRowAt: (index: number) => editor.autotileEditor.strip.list.rowGlobal(String(index)),
|
||||
fitAt: () => centreOf(editor.autotileEditor.fitButton),
|
||||
},
|
||||
tilemap: {
|
||||
/** What the scene view painted a map with, and on which layer (#128). */
|
||||
paint: () => ({ ...state.tilemapPaint }),
|
||||
/** The cells of one layer as the model holds them: `"x,y"` to autotile id. */
|
||||
cells: (assetId: string, layerId: string) => {
|
||||
const asset = findAssetOf(state.project, assetId, 'tilemap');
|
||||
const layer = asset && findLayer(asset, layerId);
|
||||
return layer ? { ...layer.cells } : null;
|
||||
},
|
||||
layers: (assetId: string) =>
|
||||
findAssetOf(state.project, assetId, 'tilemap')?.layers.map((layer) => ({
|
||||
id: layer.id,
|
||||
name: layer.name,
|
||||
hidden: layer.hidden === true,
|
||||
cells: Object.keys(layer.cells).length,
|
||||
})) ?? null,
|
||||
/** What the scene view drew: meshes (one draw call each), cells and visible layers. */
|
||||
info: (objectId: string) => viewport.tilemapInfo(objectId),
|
||||
gameInfo: (objectId: string) => gameView.tilemapInfo(objectId),
|
||||
/** Where the widgets of the inspector section sit: their texts are on screen elsewhere too. */
|
||||
toolAt: (tool: string) => {
|
||||
const button = currentTilemapSection()?.tools.get(tool as TilemapTool);
|
||||
return button ? centreOf(button) : null;
|
||||
},
|
||||
autotileAt: (assetId: string) => {
|
||||
const button = currentTilemapSection()?.autotiles.get(assetId);
|
||||
return button ? centreOf(button) : null;
|
||||
},
|
||||
addLayerAt: () => {
|
||||
const button = currentTilemapSection()?.addLayer;
|
||||
return button ? centreOf(button) : null;
|
||||
},
|
||||
/** One row of the layer list, top-down as drawn: the layer, its switch and its buttons. */
|
||||
layerRowAt: (index: number) => {
|
||||
const row = currentTilemapSection()?.layers[index];
|
||||
return row
|
||||
? {
|
||||
id: row.id,
|
||||
// `y` is the row's own line, so a check can tell whether it is inside the panel.
|
||||
y: centreOf(row.name).y,
|
||||
name: centreOf(row.name),
|
||||
visible: centreOf(row.visible),
|
||||
up: centreOf(row.up),
|
||||
down: centreOf(row.down),
|
||||
remove: centreOf(row.remove),
|
||||
}
|
||||
: null;
|
||||
},
|
||||
/** Where a cell sits on screen – for a click that paints it or a pixel that proves it. */
|
||||
cellAt: (objectId: string, x: number, y: number) => viewport.cellScreen(objectId, x, y),
|
||||
gameCellAt: (objectId: string, x: number, y: number) => gameView.cellScreen(objectId, x, y),
|
||||
},
|
||||
container: {
|
||||
current: () => containerEditor.currentAssetId,
|
||||
pickerWidth: () => containerEditor.picker.w,
|
||||
|
||||
Reference in new issue
Block a user