feat(editor): Stage 4 - palette, object/NPC browsers, terrain, and placement - #109
feat(editor): Stage 4 - palette, object/NPC browsers, terrain, and placement#109Shadow-MMN wants to merge 3 commits into
Conversation
…acement Implements the visual editor content browser (issue Bitcoindefi#29): API (api/): - New game_map_tile_entities table for objects/NPCs placed on tiles (draft/published lifecycle, same model as tile overrides) - Admin endpoints: PUT/DELETE entities, GET terrain palette, admin overrides - all=true query param on objects/NPCs for full catalog in one page - grhIndex added to object summaries - Publish/discard/revert/status extended to include entities - Restored seed files (objs.json, npcs.json) for internal endpoints - 5 integration tests for admin endpoint access and entity data Frontend (frontend/): - /construccion page with tabbed sidebar (Terrain / Objects / NPCs) - VirtualizedList: dependency-free virtualized list for 1000+ items - GraphicPreview: resolves grhIndex to cropped sprite via shared lib/graphicTextures.ts (extracted from CharacterSpritePreview) - ObjectsBrowser: searchable, filterable by type, with graphic preview - NpcsBrowser: searchable, NPC sprite preview via CharacterSpritePreview - TerrainPalette: tile palette from terrain.json + uploaded PNGs, upload - EditorCanvas: PixiJS pan/zoom/grid, places objects/NPCs via entity API - EditorToolbar: tool selection, publish/discard/revert actions, status - RecentsStrip: recently used items persisted in localStorage - editorStore: React context for shared editor state - editorApi: typed API client via /api/editor proxy - data/objectTypes: original type catalog (not copied from reference) - /api/editor/[...path] proxy route (server-side auth + admin token) Documentation: - docs/licensing-notes.md: AO-object-editor used as reference only - docs/modo-construccion-guide.md: manual test guide No new dependencies added. Uses existing pixi.js + react + next stack.
ab0f1b8 to
9e4bf69
Compare
* Use shared 2D canvas previews and virtualized lists to improve performance. * Fix terrain brushes to paint full tiles and correctly handle empty layers. * Optimize tile rendering with caching and selective updates. * Fix deletion, drawing order, map switching, and pointer handling. * Add admin session permission checks and confirmation dialogs. * Add tests for terrain palette data, session permissions, and catalog flags.
* Treat invalid catalog flags as `false` instead of returning 500 errors. * Wait for catalogs before saving NPC recents to prevent empty thumbnails. * Avoid saving invalid graphics when catalog loading fails. * Add regression test for invalid catalog flags.
Code Review ✅ Approved 4 resolved / 4 findingsImplements the visual editor Stage 4 content browser with object/NPC catalogs, terrain palette, and map placement, addressing batch paint limits, flush race conditions, and NPC recent persistence issues. ✅ 4 resolved✅ Bug: Batch paint can exceed server's 500-tile cap and silently fail
✅ Bug: Pending paint tiles can be lost if flush races with an in-flight apply
✅ Edge Case: NPC recents can persist grhIndex 0 if catalogs not loaded
✅ Edge Case: Malformed catalog query flag throws instead of defaulting
OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |
Closes #29
Implements the visual editor content browser: object catalog, NPC catalog, terrain palette with upload, and entity placement on the map.
What's included
API (
api/)game_map_tile_entitiestable for objects/NPCs placed on tiles (draft/published lifecycle, same model as tile overrides)PUT/DELETE /admin/game-data/maps/:n/entities,GET /admin/game-data/maps/:n/terrain,GET /admin/game-data/maps/:n/overrides(with drafts)?all=truequery param on objects/NPCs for full catalog in one page (1,062 objects, 340 NPCs)grhIndexadded to object summariespublish/discard/revert/statusextended to include entitiesapi/src/jsons/objs.json,api/src/jsons/npcs.json) — without them internal endpoints return 500world-builder.integration.test.tsFrontend (
frontend/)/construccionpage with tabbed sidebar (Terreno / Objetos / NPCs)VirtualizedList: dependency-free virtualized list (no react-window) for 1,000+ items — no DOM nodes created for off-screen rowsGraphicPreview: resolvesgrhIndex→ cropped sprite via sharedlib/graphicTextures.ts(extracted fromCharacterSpritePreview)ObjectsBrowser: searchable, filterable by type (30+ categories with counts), each item shows real sprite preview + type color dotNpcsBrowser: searchable, preview via existingCharacterSpritePreview(body + head)TerrainPalette: tile grid fromterrain.json+ uploaded PNGs, with PNG upload buttonEditorCanvas: PixiJS canvas with zoom (scroll wheel, cursor-anchored), pan (Shift+click / middle-click), grid overlay, blocked-tile overlay, hover highlight, entity placement with bottom-anchor positioning, batch paint (up to 500 tiles per request)EditorToolbar: map selector, tool buttons, publish/discard/revert actions, live status countersRecentsStrip: recently used items persisted inlocalStorage, click to re-selecteditorStore: React context providing all shared editor stateeditorApi: typed API client via/api/editor/[...path]server-side proxydata/objectTypes.ts: original type catalog with labels + colors (not copied from any reference repo)/api/editor/[...path]proxy route: forwards to API with session cookie + admin proxy token (token never reaches the browser)Documentation
docs/licensing-notes.md: AO-object-editor used as conceptual reference only; all code is original (no LICENSE declared in reference repo)docs/modo-construccion-guide.md: step-by-step manual test guideAcceptance criteria
docs/licensing-notes.mdHow to test
GAME_DATA_ADMIN_*env vars, frontend withAPI_BASE_URLpointing to it/construccionNotes
objs.json/npcs.jsonseeds overlap with PRs fix(api): provide seed npcs.json fixture and safe file loader (#83) #96, fix: add npcs.json and objs.json seed data with build validation #98, fix(api): provide seed npcs.json fixture (#83) #100 (issue Falta api/src/jsons/npcs.json en el repositorio y el test de market no puede correr #83); conflicts are trivial (identical content)