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
Open
Add in-engine Map/Chipset editors, battle-animation preview, and CLI flags to open them#1113take-cheeze wants to merge 5 commits into
take-cheeze wants to merge 5 commits into
Conversation
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.
…rt-debugging-woxwsx # Conflicts: # README.md
Owner
Author
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.
Owner
Author
|
Pushed fixes for the first two:
On screen size: it's already configurable, just not under that name. Two separate things depending on how you're running it:
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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:
Scene::MapViewerEdit mode, L from the existing Mapviewer 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 themap-wide, table-driven Tile Substitution event command), R writes the
edited map back to its
.lmufile. A brush only ever comes from theeyedropper, so a painted tile always already validly exists somewhere on
the map.
Scene::ChipsetEditor, a new F9 page): a colouredpassability 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
.ldbfile and refreshes the livemap's chipset immediately.
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.
--rpg2k_map_editor,--rpg2k_chipset_editorand--rpg2k_preview_animation=<id>each start New Game (like--rpg2k_new_game) and push the corresponding tool directly, skipping F9navigation — for headless screenshots via
--iterm/--sixel+--timeout_ms, mirroring how--rpg2k_preview_map/--rpg2k_battle_troopalready work. Combine with
--rpg2k_preview_mapto choose which map (andchipset) is open.
None of this touches genuine
RPG_RT.exebehavior or file formats beyondwriting back valid
.lmu/.ldbchunks 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.mdanddocs/adr/0057-chipset-editor-and-animation-preview.mdfor the designrationale.
Test plan
ruby scripts/rpg2k_scene_check.rb— 786 checks passedruby scripts/rpg2k_logic_check.rb— 1062 checks passedscripts/native-build-without-nix.bash) compilesand links cleanly with the new flags in
src/main.cxxGenerated by Claude Code