Compare commits
36 Commits
8f5e59a9f7
...
v0.3.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
451da04cbd | ||
|
|
bde1f7acfa | ||
|
|
2734efa1a9 | ||
|
|
340dd5f700 | ||
|
|
46d1e78758 | ||
|
|
51138e257f | ||
|
|
6eacde3eaa | ||
|
|
e745be8d07 | ||
|
|
f06ef5e2cb | ||
|
|
398d3b4dd9 | ||
|
|
1945e91441 | ||
|
|
107eade2fa | ||
|
|
f2123ba79c | ||
|
|
9213d3f91b | ||
|
|
211056ac8c | ||
|
|
b5afe35df8 | ||
|
|
2c3015685c | ||
|
|
2eebd3d2d5 | ||
|
|
1a9daa8ce1 | ||
|
|
6956919414 | ||
|
|
15159d7fd5 | ||
|
|
e373aa8a1f | ||
|
|
1bf5f46924 | ||
|
|
5a3f633ab2 | ||
|
|
7df21d62fa | ||
|
|
cf5771a573 | ||
|
|
c66e670336 | ||
|
|
70b841c8d6 | ||
|
|
c0a1bcf162 | ||
|
|
77832c07b2 | ||
|
|
30f38d771f | ||
|
|
497c139727 | ||
|
|
25e838c54f | ||
|
|
35d9940d63 | ||
|
|
8dbb5b9d9c | ||
|
|
34f8b85d57 |
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# Screenshots from debug-ipc screenshot.take method (written to <cwd>/screenshots/)
|
||||||
|
/screenshots/
|
||||||
145
README.md
145
README.md
@@ -1,10 +1,16 @@
|
|||||||
# sporel-module-map-editor
|
# sporel-module-map-editor
|
||||||
|
|
||||||
Interactive map editor for v2 Sporel map files. Click-to-paint, vertical layer-chip overlay on the left edge, collapsible atlas+tile picker bottom-left.
|
Interactive map editor for Sporel `.map.json` files. v0.2 series ships
|
||||||
|
the Rev 4 UX architecture (see design paper
|
||||||
|
`design/2026-05-28-autotile-blob-styles-design.md` §11 in `sporel-meta`):
|
||||||
|
top toolbar with mode-switch + actions, right Layers side-panel, bottom
|
||||||
|
palette strip of material slot thumbnails, mouse drag-paint, and two
|
||||||
|
mutually-exclusive paint modes (Auto-Tile vs Direct).
|
||||||
|
|
||||||
## Run
|
## Run
|
||||||
|
|
||||||
Default — edit the module's in-place work map:
|
Default — edit the module's in-place work map (`maps/work.map.json`,
|
||||||
|
a 16×16 schema-v3 map bound to the `blob_rect_stone` material):
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
bash scripts/run-map-editor.sh
|
bash scripts/run-map-editor.sh
|
||||||
@@ -16,31 +22,134 @@ With a target — copy a real map in, edit, copy back out:
|
|||||||
bash scripts/run-map-editor.sh ~/Projects/Sporel/sporel-modules/spine-prototype/maps/demo.map.json
|
bash scripts/run-map-editor.sh ~/Projects/Sporel/sporel-modules/spine-prototype/maps/demo.map.json
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Or via the install layer (per `install-reference.sh`):
|
||||||
|
|
||||||
|
```text
|
||||||
|
Doubleclick C:/Games/Sporel/bin/Sporel.exe → launcher → map-editor
|
||||||
|
```
|
||||||
|
|
||||||
## UI
|
## UI
|
||||||
|
|
||||||
- **Layer chips** (left edge, vertical): top-of-stack down. `Rf` at top toggles roof-edit mode; the other eight chips select the active layer.
|
- **Top toolbar** (full-width): `Auto-Tile`/`Direct` mode buttons (mutually
|
||||||
- **Left-click** = set active layer (or toggle roof mode)
|
exclusive, Tab toggles), `Save` (S), `Erase` (E), `Rotate` (R),
|
||||||
- **Right-click** = toggle layer visibility (Rf chip ignores right-click)
|
`Flip` (H), `Reset` (0), `Help` (I). Each button shows its hotkey
|
||||||
- **Atlas + tile picker** (bottom-left): collapsed chip shows the active tile. Click to expand; click again or outside to collapse.
|
label inline. The active mode is highlighted.
|
||||||
- **Status chip** (bottom-right): current mouse-cell coordinate plus a `*` when the map has unsaved changes.
|
- **Right Layers side-panel** (8 rows top-down: `canopy`, `upper_wall`,
|
||||||
|
`wall`, `lower_wall`, `topsurface`, `surface`, `subsurface`,
|
||||||
|
`foundation`). Per row: visibility eye + active marker + layer name.
|
||||||
|
- **Left-click name** → set active layer
|
||||||
|
- **Left-click eye** → toggle layer visibility
|
||||||
|
- **Right-click row** → also toggles visibility
|
||||||
|
- **Bottom palette strip**: 14 swatches (slots 1-14). Real tile
|
||||||
|
thumbnails rendered from the active atlas via
|
||||||
|
`maps.atlas_tile_uv`. Active slot has a gold border.
|
||||||
|
- **Left-click** → set active slot
|
||||||
|
- **Status chip** (bottom-left of palette band): mouse-cell, dirty flag
|
||||||
|
(`*` when unsaved), and current transform indicator
|
||||||
|
(`slot=N rot=N flip=N`) for Direct-mode awareness.
|
||||||
|
- **Auto-Tile-mode world overlay**: cell grid (1 px), vertex dots (4 px
|
||||||
|
squares), and a snapped-vertex highlight ring (green) at the nearest
|
||||||
|
vertex to the cursor.
|
||||||
|
- **Cheatsheet modal** (I): centered dim-overlay listing all hotkeys
|
||||||
|
+ LMB/RMB drag semantics.
|
||||||
|
|
||||||
|
## Modes
|
||||||
|
|
||||||
|
| Mode | LMB on canvas | RMB on canvas | Notes |
|
||||||
|
|---|---|---|---|
|
||||||
|
| **Auto-Tile** | Paints vertex at snap target — `maps.set_vertex(layer, vx, vy, true)`. Any-corner rule flips up to 4 surrounding cells to material; renderer derives slot/rot/flip from neighbour bitmask. | Clears vertex — `set_vertex(..., false)` | Transform controls ignored (slot is derived from neighbours). |
|
||||||
|
| **Direct** | Writes per-cell override — `maps.set_override(layer, x, y, {slot, rot, flip})`. Bare slot int when canonical (rot=0+flip=0). | Clears override — `maps.clear_override(layer, x, y)` | Honours active Rot/Flip from toolbar. Use to force-place a specific orientation that the auto-derived slot wouldn't pick. |
|
||||||
|
|
||||||
|
Both modes support **drag-paint**: hold LMB (or RMB) and stroke across
|
||||||
|
the canvas to apply the action at every hovered vertex/cell. UI hits
|
||||||
|
on the toolbar / side-panel / palette never enter drag-mode.
|
||||||
|
|
||||||
## Hotkeys
|
## Hotkeys
|
||||||
|
|
||||||
| Key | Action |
|
| Key | Action |
|
||||||
|---|---|
|
|---|---|
|
||||||
| `Left click` on map | Paint cell with active tile (or set roof flag in roof-mode) |
|
| `Tab` | Toggle mode (Auto-Tile ↔ Direct) |
|
||||||
| `E` | Erase the cell under the mouse |
|
| `I` | Show / hide cheatsheet |
|
||||||
| `R` | Cycle rotation 0 → 1 → 2 → 3 → 0 |
|
| `S` | Save current map to `work.map.json` |
|
||||||
| `S` | Save to disk (overwrites the work map) |
|
| `E` | Erase tile at mouse cell |
|
||||||
|
| `R` | Cycle rotation 0 → 1 → 2 → 3 → 0 (Direct-mode override) |
|
||||||
|
| `H` | Toggle flip 0 ↔ 1 (Direct-mode override) |
|
||||||
|
| `0` | Reset transform (rot=0, flip=0) |
|
||||||
| `Esc` | Quit |
|
| `Esc` | Quit |
|
||||||
|
| `LMB-drag` | Stroke-paint (mode-dependent) |
|
||||||
|
| `RMB-drag` | Stroke-clear |
|
||||||
|
|
||||||
## Limitations (v0.1.0)
|
## Headless / smoke
|
||||||
|
|
||||||
- Tile thumbnails in the picker render as gray placeholders with tile-IDs as text — lib-core.maps v0.4.0 does not expose per-tile UVs to Lua, so visual thumbnails are a v0.2.0 task.
|
`ci_frames = 30` in `manifest.module`. The editor reads
|
||||||
- Atlas list in the picker is purely informational; if a map declares multiple atlases, the active atlas is set from `state.lua` defaults at startup and cannot yet be switched via UI (v0.2.0 hit-tests inside the expanded picker).
|
`SPOREL_CI=1` and auto-exits after 30 frames so the smoke harness
|
||||||
- Engine bindings `engine.render.draw_rect_lines` and `engine.render.draw_line` are not yet registered — active-chip borders, hidden-layer strikethroughs, and the entity-slot divider will trigger runtime errors when their code paths execute. Adding the bindings is a small engine-side follow-up.
|
can run it without a window-close click.
|
||||||
- No undo/redo, no multi-tile brush, no entity placement, no heightmap editing — see the design spec §1 for the full out-of-scope list.
|
|
||||||
|
|
||||||
## Spec
|
```bash
|
||||||
|
SPOREL_CI=1 ./Sporel.exe --module=map-editor # exits with rc=0 after ~0.5 s
|
||||||
|
```
|
||||||
|
|
||||||
`docs/superpowers/specs/2026-05-23-sporel-module-map-editor-design.md` in the `sporel-meta` repo.
|
## Limitations (current scope)
|
||||||
|
|
||||||
|
- **Single-atlas palette**: the palette draws from `atlas_idx=0` only.
|
||||||
|
Multi-atlas selector is a future slice. Workaround: keep one material
|
||||||
|
atlas per map for now.
|
||||||
|
- **Single Flip flag**: design paper mentions Flip-H + Flip-V as
|
||||||
|
separate controls, but the override format only stores one `flip`
|
||||||
|
field; combined with `rot` (0-3) the single flip covers all 8 D4
|
||||||
|
orientations, so the second button would be redundant.
|
||||||
|
- **No modifier hotkeys**: `lib-core.input` doesn't expose modifier
|
||||||
|
combos, so Shift+R for CCW rotation isn't supported. Workaround:
|
||||||
|
press R three times.
|
||||||
|
- **No Decal / Entity sub-selectors**: Direct mode on non-terrain
|
||||||
|
layers is unimplemented (lands in `0.2.0d`).
|
||||||
|
- **No Material-Properties modal**: `base_color` re-bake trigger
|
||||||
|
+ tint editor are deferred (also `0.2.0d`).
|
||||||
|
- **No multi-vertex brush sizes / procedural fill / undo-redo** — see
|
||||||
|
design paper §11 "Out of scope" for the full list.
|
||||||
|
|
||||||
|
## Plan + spec
|
||||||
|
|
||||||
|
- Design paper: `docs/design/2026-05-28-autotile-blob-styles-design.md`
|
||||||
|
§11 in `sporel-meta`
|
||||||
|
- Plan: `docs/superpowers/plans/2026-05-28-map-editor-blob-v2.md`
|
||||||
|
|
||||||
|
## Menu UI (v0.3.0)
|
||||||
|
|
||||||
|
Top toolbar replaced with a seven-category menu bar (File, Edit, View,
|
||||||
|
Map, Tools, Window, Help) plus a sticky two-segment Mode-pill on the
|
||||||
|
right end. Item types: action, modal, toggle, submenu, separator;
|
||||||
|
items can be conditionally disabled. A single-stack modal framework
|
||||||
|
hosts the existing Cheatsheet (I) and three new modals: Save As, Map
|
||||||
|
Properties (read-only), About. The Esc key cascades modal -> menu ->
|
||||||
|
quit.
|
||||||
|
|
||||||
|
New Map and Open Map appear in the File menu as disabled placeholders
|
||||||
|
pending a v3-aware maps.create and an engine.asset.list_dir in a
|
||||||
|
future engine + lib slice.
|
||||||
|
|
||||||
|
All previous hotkeys (Tab, S, E, R, H, 0, D, G, I, Esc) continue to
|
||||||
|
work; their bindings are documented in the items where applicable
|
||||||
|
and in the in-editor Cheatsheet modal.
|
||||||
|
|
||||||
|
## Cell-Tile Mode (v0.3.1)
|
||||||
|
|
||||||
|
Third painting mechanic alongside Auto-Tile and Direct. LMB paints a
|
||||||
|
per-cell material flag at the cursor cell; RMB clears it. The
|
||||||
|
renderer uses the classical 47-blob 8-neighbour bitmask for
|
||||||
|
cell-tile cells, unlocking the 9 atlas slots that Auto-Tile's
|
||||||
|
dual-grid 4-corner rule structurally cannot reach (isolated, end,
|
||||||
|
corner_open, straight, tee_open, tee_half, cross_open, cross_q1,
|
||||||
|
cross_q2adj).
|
||||||
|
|
||||||
|
Auto-Tile (vertex-paint, 5 reachable slots, dual-grid look) and
|
||||||
|
Direct (manual override placement, all 14 slots via explicit pick)
|
||||||
|
are unchanged. Tab cycles through all three modes.
|
||||||
|
|
||||||
|
For clean visuals, use a single painting mode per layer. Mixing
|
||||||
|
Vertex-Tile and Cell-Tile material in the same layer is allowed but
|
||||||
|
produces an asymmetric seam at the boundary because vertex-tile
|
||||||
|
cells are structurally blind to their cell-tile neighbours.
|
||||||
|
|
||||||
|
See `sporel-meta/docs/superpowers/specs/2026-06-01-map-editor-cell-tile-mode-design.md`
|
||||||
|
for the full design rationale and the Boris-taxonomy background.
|
||||||
|
|||||||
17
manifest.launcher.md
Normal file
17
manifest.launcher.md
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
{"summary":"Map editor — vertical layer-chip overlay + atlas-tile picker","author":"calic","tags":["tool","map-editor"],"teaser_images":[]}
|
||||||
|
---
|
||||||
|
|
||||||
|
# Map Editor
|
||||||
|
|
||||||
|
Click-to-paint tile editor with collapsible atlas/tile-picker. Vertical layer-chip overlay (left), atlas+tile picker (bottom-left), status chip (bottom-right).
|
||||||
|
|
||||||
|
## Controls
|
||||||
|
|
||||||
|
- Mouse-left on grid: paint
|
||||||
|
- Mouse-left on layer-chip: switch active layer
|
||||||
|
- Mouse-right on layer-chip: toggle visibility
|
||||||
|
- E: erase mode
|
||||||
|
- R: rotate
|
||||||
|
- S: save
|
||||||
|
- ESC: quit to launcher
|
||||||
@@ -1,18 +1,19 @@
|
|||||||
{
|
{
|
||||||
"id": "map-editor",
|
"id": "map-editor",
|
||||||
"version": "0.1.0",
|
"version": "0.3.3",
|
||||||
"kind": "module",
|
"kind": "module",
|
||||||
"api": "^0.1",
|
"api": "^0.1",
|
||||||
"ci_frames": 30,
|
"ci_frames": 30,
|
||||||
"entry_point": "init.lua",
|
"entry_point": "init.lua",
|
||||||
"asset_aliases": {
|
"asset_aliases": {
|
||||||
"fa_terrain_v1": "lib-asset.prototype-fa-starter"
|
"blob_rect_stone": "lib-asset.prototype-blob-geom"
|
||||||
},
|
},
|
||||||
"deps": [
|
"deps": [
|
||||||
{"id":"lib-core.maps","version":"0.4.0"},
|
{"id":"lib-core.maps","version":"0.5.7"},
|
||||||
{"id":"lib-core.render","version":"0.1.0"},
|
{"id":"lib-core.render","version":"0.2.0"},
|
||||||
|
{"id":"lib-core.composition","version":"0.1.0"},
|
||||||
{"id":"lib-core.camera","version":"0.3.0"},
|
{"id":"lib-core.camera","version":"0.3.0"},
|
||||||
{"id":"lib-core.input","version":"0.4.0"},
|
{"id":"lib-core.input","version":"0.4.0"},
|
||||||
{"id":"lib-asset.prototype-fa-starter","version":"0.2.0"}
|
{"id":"lib-asset.prototype-blob-geom","version":"0.1.0"}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
{
|
{
|
||||||
"schema_version": 2,
|
"schema_version": 3,
|
||||||
"id": "work",
|
"id": "work",
|
||||||
"size": { "w": 4, "h": 4 },
|
"size": { "w": 16, "h": 16 },
|
||||||
"atlases": ["fa_terrain_v1"],
|
"atlases": [ "blob_rect_stone" ],
|
||||||
"layers": {
|
"layers": {
|
||||||
"surface": {
|
"surface": { "material": "blob_rect_stone" },
|
||||||
"tiles": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
"wall": { "material": "blob_rect_stone" }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user