Skip to content

Add in-engine Map/Chipset editors, battle-animation preview, and CLI flags to open them - #1113

Open
take-cheeze wants to merge 5 commits into
masterfrom
claude/editor-support-debugging-woxwsx
Open

Add in-engine Map/Chipset editors, battle-animation preview, and CLI flags to open them#1113
take-cheeze wants to merge 5 commits into
masterfrom
claude/editor-support-debugging-woxwsx

Conversation

@take-cheeze

Copy link
Copy Markdown
Owner

Summary

Extends the F9 debug menu (Test-Play-gated, same as every other debug tool in
this engine — never active in a released game) with authoring tools for
debugging RPG2000/2003 projects, plus CLI flags to jump straight into them:

  • Map Editor (Scene::MapViewer Edit mode, L from the existing Map
    viewer page): eyedropper-only tile painting — Ctrl picks up the tile
    under the cursor as the brush, Shift swaps lower/upper layer, C
    stamps the brush onto the cursor's tile (a single-cell rewrite via
    Game::Map#set_lower/#set_upper, deliberately separate from the
    map-wide, table-driven Tile Substitution event command), R writes the
    edited map back to its .lmu file. A brush only ever comes from the
    eyedropper, so a painted tile always already validly exists somewhere on
    the map.
  • Chipset editor (Scene::ChipsetEditor, a new F9 page): a coloured
    passability grid over the chipset's 162 lower / 144 upper cells — L
    switches lower/upper, C toggles all four direction bits on the
    selected cell without touching an upper cell's own star/counter flags,
    R writes the database back to its .ldb file and refreshes the live
    map's chipset immediately.
  • Battle animation preview (a new F9 page): Up/Down steps the animation
    id by one and L/R by ten, C plays it back on the field map through the
    same animation player a real battle round uses.
  • CLI flags--rpg2k_map_editor, --rpg2k_chipset_editor and
    --rpg2k_preview_animation=<id> each start New Game (like
    --rpg2k_new_game) and push the corresponding tool directly, skipping F9
    navigation — for headless screenshots via --iterm/--sixel +
    --timeout_ms, mirroring how --rpg2k_preview_map/--rpg2k_battle_troop
    already work. Combine with --rpg2k_preview_map to choose which map (and
    chipset) is open.

None of this touches genuine RPG_RT.exe behavior or file formats beyond
writing back valid .lmu/.ldb chunks the real editor already understands
— it's exclusively new engine-side debug tooling, gated the same way the
rest of Test Play's debug features are.

See docs/adr/0056-map-editor.md and
docs/adr/0057-chipset-editor-and-animation-preview.md for the design
rationale.

Test plan

  • ruby scripts/rpg2k_scene_check.rb — 786 checks passed
  • ruby scripts/rpg2k_logic_check.rb — 1062 checks passed
  • Full native build (scripts/native-build-without-nix.bash) compiles
    and links cleanly with the new flags in src/main.cxx

Generated by Claude Code

claude added 3 commits August 19, 2026 13:37
Press L inside the whole-map viewer to enter Edit mode, alongside
the existing pan/Select modes:

- Ctrl picks up the tile under the cursor as the brush (an
  eyedropper -- the only way to choose what to paint, so a painted
  tile is always an id that already validly exists on the map)
- Shift swaps which layer (lower/upper) is active
- C stamps the brush onto the cursor's tile via the new
  Game::Map#set_lower/#set_upper -- a direct rewrite of that one
  cell, distinct from the Tile Substitution event command's
  map-wide "every tile with this id" rewrite
- R writes the edited map back to its .lmu file
  (Game::Map#sync_layers_to_unit pushes the edit into the LCF unit,
  then LCF::File#save_to writes it -- the same writer already
  proven byte-exact for saves and, via scripts/lcf_text_convert.rb,
  the database and map files themselves)

Edits render immediately either way (in this viewer and in the live
field map), since both read the same layer arrays the paint tool
mutates -- R is only about persisting past the current session.

RPG2k#map_path is extracted from #load_map so the editor's save
action computes the identical Map0001.lmu-style path; Scene::Map's
#rebuild_chipset is exposed for the upcoming chipset editor to call
after an edit.

See docs/adr/0056-map-editor.md for the full design, including how
this interacts with (and stays independent of) Tile Substitution.

Covered by new checks in scripts/rpg2k_scene_check.rb: set_lower/
set_upper cell isolation and revision bumping, sync_layers_to_unit's
chunk targeting, and the full eyedrop/paint/layer-swap/save loop
through Scene::MapViewer against a FakeMapUnit double (the real
binary writer is already proven in
scripts/lcf_text_convert_check.rb).
Two more F9 debug menu pages, alongside Switch/Variable/Map:

- Chipset: a visual passability editor for the current map's
  chipset. A coloured grid (green passable, dark red blocked) over
  its 162 lower / 144 upper cells -- passability is spatial data,
  the same argument that kept the map itself out of
  scripts/lcf_text_convert.rb's scope. L switches between the lower
  and upper tables, arrows move the cell cursor, C toggles
  passability on the selected cell (coarse, all four direction bits
  at once, matching Game::ChipSet#landable_tile?'s own "passable
  from any direction" reading -- leaving an upper cell's star/
  counter flags untouched), R writes the database back to its .ldb
  and rebuilds the live map's chipset so the edit shows immediately.

- Animation: a battle-animation preview. Up/Down steps a database
  animation id by one and L/R by ten; C plays it back on the field
  map through Scene::Map's own animation player -- the same
  build_animation/anim_target/map_animation= trio
  Scene::Battle#start_battle_animation already uses for a real
  battle round -- then closes the debug menu so it's what's on
  screen. No new scene needed: Scene::Map's own update/render already
  drive a fire-and-forget animation (no owning battle/interpreter)
  unconditionally every frame, so firing one and getting out of the
  way is the whole feature.

RPG2k#map_scene (@scenes.first, named and documented) is the shared
seam both needed: the debug menu itself only carries Game::State,
not a live scene reference. RPG2k#db_path mirrors #map_path from the
Map Editor's own ADR for the database's save path.

See docs/adr/0057-chipset-editor-and-animation-preview.md for the
full design.

Covered by new checks in scripts/rpg2k_scene_check.rb: the chipset
toggle's flag preservation and save+rebuild call (via a
FakeChipsetRow double answering the same integer-chunk-id #[]/#[]=
protocol a real LCF::Array1D does, proving the wiring rather than
re-proving the LCF writer lcf_text_convert_check.rb already covers),
and the Animation page's id adjustment and play/pop_to_map call.
preview directly

--rpg2k_map_editor, --rpg2k_chipset_editor and
--rpg2k_preview_animation=<id> each start New Game and push the
corresponding F9 debug-menu tool straight onto the screen, mirroring
how --rpg2k_preview_map/--rpg2k_battle_troop already skip menu
navigation for headless previews. Scene::MapViewer.new gained a
start_mode: parameter to land directly in Edit mode.
@github-actions github-actions Bot added engine:rpg2k RPG Maker 2000 games (LCF data, RPG_RT parity) component:scenes Scenes and UI flow: title, map, menus, message windows component:docs README, /docs, ADRs, changelog fragments component:tooling scripts/, test beds, parity harnesses, download helpers labels Aug 19, 2026
…rt-debugging-woxwsx

# Conflicts:
#	README.md
@take-cheeze

Copy link
Copy Markdown
Owner Author
Screenshot 2026-08-20 at 13 16 48 Seems the key navigation is out of bound. Could you line break it so I could see all? Also, I don't want test_play flag every time to edit so could you make it optional in editor modes? Is screen size configurable? I want to use more bigger screen for editor

for the editor CLI flags

Scene::MapViewer's Edit mode hint is wider than the 320px screen and
Bitmap#draw_text neither wraps nor clips, so it used to run off the
right edge and vanish there. Scene::Base gained a generic word-wrap
helper (#wrap_text_to_width/#draw_wrapped_hint) that both
Scene::MapViewer and Scene::ChipsetEditor's footers now use.

--rpg2k_map_editor/--rpg2k_chipset_editor/--rpg2k_preview_animation no
longer also require --test_play: passing one is already the same kind
of deliberate opt-in --test_play itself is, so the redundant flag was
just extra typing to open an editor. Interactive F9 access is
unaffected, still gated on RPG2k#test_play as before.

Addresses review feedback on PR #1113.
@take-cheeze

Copy link
Copy Markdown
Owner Author

Pushed fixes for the first two:

  1. Line wrap. Bitmap#draw_text doesn't wrap or clip on its own, so the Edit mode hint (Arrows:Move C:Paint CTRL:Pick SHIFT:Layer R:Save B:Exit) was wider than the 320px screen and the tail just ran off the edge and vanished. Added a generic word-wrap helper (Scene::Base#wrap_text_to_width/#draw_wrapped_hint) and switched both MapViewer and ChipsetEditor's footers to use it — the hint now wraps onto two lines instead.
  2. --test_play no longer required for the editor flags. --rpg2k_map_editor/--rpg2k_chipset_editor/--rpg2k_preview_animation are now excluded from the engine's general test-play reset — passing one of them is already the same kind of deliberate opt-in --test_play itself is, so requiring both was redundant. Interactive F9 access during ordinary play is untouched, still gated on --test_play as before — this only affects launching straight into a tool from the command line.

On screen size: it's already configurable, just not under that name. Two separate things depending on how you're running it:

  • Terminal backends (--iterm/--sixel): --iterm_scale=N / --sixel_scale=N upscale the rendered image by an integer factor, e.g. --iterm --iterm_scale=2.
  • Native SDL window: RPG2000/2003's 320x240 is auto-zoomed 2x already (--width/--height control the actual render resolution, not a display zoom, so raising those would break every hardcoded 320x240 layout rather than just make things bigger).

If you're on the SDL path and want a configurable zoom beyond the fixed 2x, let me know and I'll add a flag for it — didn't want to guess at a multiplier without knowing which path you're using (the screenshot looks like a terminal capture).


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component:docs README, /docs, ADRs, changelog fragments component:scenes Scenes and UI flow: title, map, menus, message windows component:tooling scripts/, test beds, parity harnesses, download helpers engine:rpg2k RPG Maker 2000 games (LCF data, RPG_RT parity)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants