add OverworldDebug menu
This commit is contained in:
@@ -44,7 +44,7 @@ void NewMasterFrame() {
|
||||
}
|
||||
|
||||
bool BeginCentered(const char *name) {
|
||||
ImGuiIO &io = ImGui::GetIO();
|
||||
ImGuiIO const &io = ImGui::GetIO();
|
||||
ImVec2 pos(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.5f);
|
||||
ImGui::SetNextWindowPos(pos, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
|
||||
ImGuiWindowFlags flags =
|
||||
@@ -236,6 +236,9 @@ void MasterEditor::DrawViewMenu() {
|
||||
ImGui::MenuItem("HEX Editor", nullptr, &show_memory_editor);
|
||||
ImGui::MenuItem("ASM Editor", nullptr, &show_asm_editor);
|
||||
ImGui::MenuItem("ImGui Demo", nullptr, &show_imgui_demo);
|
||||
if (ImGui::MenuItem("Overworld Debug")) {
|
||||
overworld_editor_.OverworldDebugMenu();
|
||||
}
|
||||
ImGui::Separator();
|
||||
if (ImGui::BeginMenu("GUI Tools")) {
|
||||
ImGui::MenuItem("Metrics (ImGui)", nullptr, &show_imgui_metrics);
|
||||
|
||||
@@ -43,8 +43,12 @@ absl::Status OverworldEditor::Update() {
|
||||
all_gfx_loaded_ = true;
|
||||
}
|
||||
|
||||
if (overworld_debug_menu_) {
|
||||
DrawOverworldDebugMenu();
|
||||
}
|
||||
|
||||
auto toolset_status = DrawToolset();
|
||||
RETURN_IF_ERROR(toolset_status);
|
||||
RETURN_IF_ERROR(toolset_status)
|
||||
|
||||
ImGui::Separator();
|
||||
if (ImGui::BeginTable("#owEditTable", 2, ow_edit_flags, ImVec2(0, 0))) {
|
||||
@@ -102,21 +106,6 @@ absl::Status OverworldEditor::DrawToolset() {
|
||||
// Music
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Button(ICON_MD_MUSIC_NOTE);
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text(ICON_MD_MORE_VERT);
|
||||
// Load Overworld
|
||||
ImGui::TableNextColumn();
|
||||
if (ImGui::Button(ICON_MD_UPDATE)) {
|
||||
RETURN_IF_ERROR(overworld_.Load(rom_))
|
||||
current_gfx_bmp_.Create(128, 512, 8,
|
||||
overworld_.GetCurrentGraphics().data(), 32768);
|
||||
tile16_blockset_bmp_.Create(
|
||||
512, 8192 * 2, 8, (uchar *)overworld_.GetCurrentBlockset().data(),
|
||||
1048576);
|
||||
rom_.RenderBitmap(current_gfx_bmp_);
|
||||
rom_.RenderBitmap(tile16_blockset_bmp_);
|
||||
}
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text(ICON_MD_MORE_VERT);
|
||||
|
||||
@@ -270,23 +259,48 @@ void OverworldEditor::DrawAreaGraphics() {
|
||||
}
|
||||
current_gfx_canvas_.DrawBackground(ImVec2(256 + 1, 16 * 64 + 1));
|
||||
current_gfx_canvas_.DrawContextMenu();
|
||||
for (const auto &[key, value] : current_graphics_set_) {
|
||||
int offset = 64 * (key + 1);
|
||||
int top_left_y = current_gfx_canvas_.GetZeroPoint().y + 2;
|
||||
if (key >= 1) {
|
||||
top_left_y = current_gfx_canvas_.GetZeroPoint().y + 64 * key;
|
||||
}
|
||||
current_gfx_canvas_.GetDrawList()->AddImage(
|
||||
(void *)value.GetTexture(),
|
||||
ImVec2(current_gfx_canvas_.GetZeroPoint().x + 2, top_left_y),
|
||||
ImVec2(current_gfx_canvas_.GetZeroPoint().x + 256,
|
||||
current_gfx_canvas_.GetZeroPoint().y + offset));
|
||||
}
|
||||
current_gfx_canvas_.DrawBitmap(current_gfx_bmp_);
|
||||
// for (const auto &[key, value] : current_graphics_set_) {
|
||||
// int offset = 64 * (key + 1);
|
||||
// int top_left_y = current_gfx_canvas_.GetZeroPoint().y + 2;
|
||||
// if (key >= 1) {
|
||||
// top_left_y = current_gfx_canvas_.GetZeroPoint().y + 64 * key;
|
||||
// }
|
||||
// current_gfx_canvas_.GetDrawList()->AddImage(
|
||||
// (void *)value.GetTexture(),
|
||||
// ImVec2(current_gfx_canvas_.GetZeroPoint().x + 2, top_left_y),
|
||||
// ImVec2(current_gfx_canvas_.GetZeroPoint().x + 256,
|
||||
// current_gfx_canvas_.GetZeroPoint().y + offset));
|
||||
// }
|
||||
current_gfx_canvas_.DrawGrid(32.0f);
|
||||
current_gfx_canvas_.DrawOverlay();
|
||||
}
|
||||
}
|
||||
|
||||
absl::Status OverworldEditor::DrawOverworldDebugMenu() {
|
||||
ImGui::Begin("Overworld Debug Menu");
|
||||
if (ImGui::Button("Load Overworld")) {
|
||||
RETURN_IF_ERROR(overworld_.Load(rom_))
|
||||
}
|
||||
if (ImGui::Button("Current Graphics Bitmap")) {
|
||||
current_gfx_bmp_.Create(128, 512, 8, overworld_.GetCurrentGraphics().data(),
|
||||
32768);
|
||||
rom_.RenderBitmap(¤t_gfx_bmp_);
|
||||
}
|
||||
if (ImGui::Button("Tile16 Blockset Bitmap")) {
|
||||
tile16_blockset_bmp_.Create(
|
||||
512, 16384, 8, overworld_.GetCurrentBlockset().data(), 1048576);
|
||||
rom_.RenderBitmap(&tile16_blockset_bmp_);
|
||||
}
|
||||
if (ImGui::Button("Overworld Map Bitmap")) {
|
||||
overworld_map_bmp_.Create(1024, 1024, 8, overworld_.GetCurrentBitmapData().data());
|
||||
rom_.RenderBitmap(&overworld_map_bmp_);
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
void OverworldEditor::LoadGraphics() {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
current_palette_[i].x = (i * 0.21f);
|
||||
|
||||
@@ -48,6 +48,8 @@ class OverworldEditor {
|
||||
absl::Status Copy() { return absl::UnimplementedError("Copy"); }
|
||||
absl::Status Paste() { return absl::UnimplementedError("Paste"); }
|
||||
|
||||
void OverworldDebugMenu() { overworld_debug_menu_ = true; }
|
||||
|
||||
private:
|
||||
absl::Status DrawToolset();
|
||||
void DrawOverworldMapSettings();
|
||||
@@ -57,6 +59,8 @@ class OverworldEditor {
|
||||
void DrawTile8Selector();
|
||||
void DrawAreaGraphics();
|
||||
|
||||
absl::Status DrawOverworldDebugMenu();
|
||||
|
||||
void LoadGraphics();
|
||||
|
||||
int current_world_ = 0;
|
||||
@@ -70,6 +74,7 @@ class OverworldEditor {
|
||||
bool opt_enable_grid = true;
|
||||
bool all_gfx_loaded_ = false;
|
||||
bool map_blockset_loaded_ = false;
|
||||
bool overworld_debug_menu_ = false;
|
||||
|
||||
ImVec4 current_palette_[8];
|
||||
|
||||
@@ -89,6 +94,7 @@ class OverworldEditor {
|
||||
gfx::Bitmap tile16_blockset_bmp_; // pointer size 1048576
|
||||
gfx::Bitmap current_gfx_bmp_; // pointer size 32768
|
||||
gfx::Bitmap all_gfx_bmp; // pointer size 456704
|
||||
gfx::Bitmap overworld_map_bmp_;
|
||||
|
||||
gui::Canvas overworld_map_canvas_;
|
||||
gui::Canvas current_gfx_canvas_;
|
||||
|
||||
Reference in New Issue
Block a user