Skip to content

feat(editor): complete level editor integration and fixes - #173

Open
alfonsoalvarohervas-sudo wants to merge 1 commit into
999sian:masterfrom
alfonsoalvarohervas-sudo:feature/level-editor-clean
Open

feat(editor): complete level editor integration and fixes#173
alfonsoalvarohervas-sudo wants to merge 1 commit into
999sian:masterfrom
alfonsoalvarohervas-sudo:feature/level-editor-clean

Conversation

@alfonsoalvarohervas-sudo

@alfonsoalvarohervas-sudo alfonsoalvarohervas-sudo commented Jul 22, 2026

Copy link
Copy Markdown

As requested in the feedback for splitting PR #165 , this Pull Request isolates the Level Editor feature. It has been built and rebased cleanly against the latest upstream/master, removing all unrelated engine bugfixes.

This feature allows developer/modder painting and saving of custom level maps directly from the GBA PC port runtime using an ImGui overlay.

Detailed Changes per File

  • port/port_level_editor.cpp (NEW)

    • Implements the complete Level Editor backend.
    • Handles mouse tile painting, eyedropper sampling, undo/redo states, and custom entity vectors loading/parsing.
    • Implements the custom level saving logic (SaveCurrentRoom) to output binary file layouts to edited_levels/area%02X_room%02X.bin.
    • Implements the loader logic (Port_LevelEditor_OnRoomLoad) to parse saved levels and rebuild collision matrices.
    • Implements the rendering logic using SDL_Renderer primitives (outline overlay, tile previews, overlay sidebar).
  • port/port_level_editor.h (NEW)

    • Declares the C-compatible linkage interface (Port_LevelEditor_*) to integrate with the GBA engine and port layer.
  • xmake.lua (MODIFIED)

    • Added port/port_level_editor.cpp to the compile list of the main tmc_pc target.
  • port/port_bios.c (MODIFIED)

    • Restored to the modern upstream/master version containing decoupled pacing variables.
    • Hooked keyboard events in Port_PumpEvents using Port_LevelEditor_HandleKey to capture layout hotkeys.
    • Hooked mouse button down/up events (Port_LevelEditor_HandleMouseButton) and mouse motion (Port_LevelEditor_HandleMouseMotion) when the editor is active to intercept clicks and prevent forwarding inputs to the GBA game thread.
  • port/port_imgui_menu.cpp (MODIFIED)

    • Added the "Map Editor" tab to the F8 Ribbon menu (DrawRibbonMapEditorTab).
    • Added checkbox "Enable Direct Painting Overlay" to toggle editor state.
    • Automatically toggles the F8 debug menu off when the editor is enabled to immediately allow tile painting.
    • Hooked Port_LevelEditor_Render right before ImGui presentation to draw overlays on the SDL backend.
  • port/port_ppu.cpp (MODIFIED)

    • Restored to the modern upstream/master version.
    • Changed Port_PPU_VisibleFrameWidth() declaration to extern "C" so it can be resolved inside the C++ level editor module.
  • src/playerUtils.c (MODIFIED)

    • Added the call Port_LevelEditor_OnRoomLoad() to the end of the general room graphic initialization function LoadRoomGfx(). This ensures edited room binaries are loaded cleanly on warps, saves, transitions, and startup.
  • include/room.h (MODIFIED)

    • Renamed RoomTransition to RoomTransitionType to avoid C++ linkage conflicts.
  • src/game.c (RESTORED)

    • Restored to 100% parity with upstream/master.

Verification

  • Syntactically clean and compiles cleanly on Windows.
  • Verified that room modifications are persisted inside dist/<REGION>/edited_levels/ and load correctly upon room entry.
  • Compatible with both software and GPU renderers (requires the sdl or software backend for overlay drawing).

@alfonsoalvarohervas-sudo
alfonsoalvarohervas-sudo force-pushed the feature/level-editor-clean branch 2 times, most recently from fc6f9d7 to b6ae548 Compare July 22, 2026 23:07
@alfonsoalvarohervas-sudo
alfonsoalvarohervas-sudo marked this pull request as draft July 23, 2026 01:03
@alfonsoalvarohervas-sudo
alfonsoalvarohervas-sudo marked this pull request as ready for review July 23, 2026 01:06
@alfonsoalvarohervas-sudo
alfonsoalvarohervas-sudo marked this pull request as draft July 23, 2026 01:07
@alfonsoalvarohervas-sudo
alfonsoalvarohervas-sudo marked this pull request as ready for review July 23, 2026 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant