Enhance DungeonEditor functionality by adding room graphics loading and rendering capabilities; implement bitmap drawing for background layers and room objects in the canvas, improving visual representation of dungeon rooms.

This commit is contained in:
scawful
2025-04-27 14:00:40 -04:00
parent 5c20d867ad
commit ff74c0c92a
4 changed files with 29 additions and 15 deletions

View File

@@ -3,6 +3,7 @@
#include "absl/container/flat_hash_map.h"
#include "app/core/features.h"
#include "app/core/platform/renderer.h"
#include "app/gfx/arena.h"
#include "app/gfx/snes_palette.h"
#include "app/gui/canvas.h"
#include "app/gui/color.h"
@@ -60,6 +61,8 @@ absl::Status DungeonEditor::Load() {
rooms_[i].LoadRoomGraphics();
}
// rooms_[i].LoadObjects();
auto dungeon_palette_ptr = rom()->paletteset_ids[rooms_[i].palette][0];
auto palette_id = rom()->ReadWord(0xDEC4B + dungeon_palette_ptr);
if (palette_id.status() != absl::OkStatus()) {
@@ -477,11 +480,22 @@ void DungeonEditor::DrawDungeonCanvas(int room_id) {
gui::InputHexWord("Message ID", &rooms_[room_id].message_id_);
SameLine();
if (Button("Load Room")) {
rooms_[room_id].LoadRoomGraphics();
}
ImGui::EndGroup();
canvas_.DrawBackground(ImVec2(0x200, 0x200));
canvas_.DrawBackground();
canvas_.DrawContextMenu();
if (is_loaded_) {
canvas_.DrawBitmap(gfx::Arena::Get().bg1_bitmap(), 0, 0);
canvas_.DrawBitmap(gfx::Arena::Get().bg2_bitmap(), 0, 0);
for (const auto &object : rooms_[room_id].tile_objects_) {
canvas_.DrawOutline(object.x_, object.y_, object.width_ * 16,
object.height_ * 16);
}
canvas_.DrawBitmap(rooms_[room_id].layer1(), 0, 0);
}
canvas_.DrawGrid();