draw all overworld maps on canvas

This commit is contained in:
scawful
2022-09-08 09:19:38 -05:00
parent f2feaa78da
commit fb02608c6f
2 changed files with 32 additions and 17 deletions

View File

@@ -48,8 +48,11 @@ absl::Status OverworldEditor::Update() {
overworld_.GetCurrentBlockset()); overworld_.GetCurrentBlockset());
rom_.RenderBitmap(&tile16_blockset_bmp_); rom_.RenderBitmap(&tile16_blockset_bmp_);
map_blockset_loaded_ = true; map_blockset_loaded_ = true;
overworld_map_bmp_.Create(512, 512, 512, overworld_.GetCurrentBitmapData()); for (int i = 0; i < core::kNumOverworldMaps; ++i) {
rom_.RenderBitmap(&overworld_map_bmp_); overworld_.SetCurrentMap(i);
maps_bmp_[i].Create(512, 512, 512, overworld_.GetCurrentBitmapData());
rom_.RenderBitmap(&(maps_bmp_[i]));
}
} }
if (overworld_debug_menu_) { if (overworld_debug_menu_) {
@@ -135,10 +138,14 @@ absl::Status OverworldEditor::DrawToolset() {
} }
void OverworldEditor::DrawOverworldMapSettings() { void OverworldEditor::DrawOverworldMapSettings() {
if (ImGui::BeginTable("#mapSettings", 7, ow_map_flags, ImVec2(0, 0), -1)) { if (ImGui::BeginTable("#mapSettings", 8, ow_map_flags, ImVec2(0, 0), -1)) {
for (const auto &name : kOverworldSettingsColumnNames) for (const auto &name : kOverworldSettingsColumnNames)
ImGui::TableSetupColumn(name.data()); ImGui::TableSetupColumn(name.data());
ImGui::TableNextColumn();
ImGui::SetNextItemWidth(50.f);
ImGui::InputInt("Current Map", &current_map_);
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::SetNextItemWidth(100.f); ImGui::SetNextItemWidth(100.f);
ImGui::Combo("##world", &current_world_, ImGui::Combo("##world", &current_world_,
@@ -183,20 +190,29 @@ void OverworldEditor::DrawOverworldMapSettings() {
void OverworldEditor::DrawOverworldCanvas() { void OverworldEditor::DrawOverworldCanvas() {
DrawOverworldMapSettings(); DrawOverworldMapSettings();
ImGui::Separator(); ImGui::Separator();
overworld_map_canvas_.DrawBackground(); ImGuiID child_id = ImGui::GetID((void *)(intptr_t)7);
overworld_map_canvas_.DrawContextMenu(); if (ImGui::BeginChild(child_id, ImGui::GetContentRegionAvail(), true,
if (overworld_.isLoaded()) { ImGuiWindowFlags_AlwaysVerticalScrollbar |
auto map = overworld_.GetOverworldMap(0); ImGuiWindowFlags_AlwaysHorizontalScrollbar)) {
if (map.IsBuilt()) { overworld_map_canvas_.DrawBackground(ImVec2(512 * 8, 512 * 8));
if (map.IsLargeMap() && map.IsInitialized()) { overworld_map_canvas_.DrawContextMenu();
overworld_map_canvas_.DrawBitmap(overworld_map_bmp_, 2); if (overworld_.isLoaded()) {
} else { int xx = 0;
overworld_map_canvas_.DrawBitmap(overworld_map_bmp_, 2); int yy = 0;
for (int i = 0; i < 0x40; i++) {
overworld_map_canvas_.DrawBitmap(maps_bmp_[i], (xx * 512), (yy * 512));
xx++;
if (xx >= 8) {
yy++;
xx = 0;
}
} }
} }
overworld_map_canvas_.DrawGrid(64.f);
overworld_map_canvas_.DrawOverlay();
} }
overworld_map_canvas_.DrawGrid(64.f); ImGui::EndChild();
overworld_map_canvas_.DrawOverlay();
} }
void OverworldEditor::DrawTileSelector() { void OverworldEditor::DrawTileSelector() {
@@ -303,8 +319,6 @@ absl::Status OverworldEditor::DrawOverworldDebugMenu() {
overworld_.GetCurrentBlockset()); overworld_.GetCurrentBlockset());
rom_.RenderBitmap(&tile16_blockset_bmp_); rom_.RenderBitmap(&tile16_blockset_bmp_);
map_blockset_loaded_ = true; map_blockset_loaded_ = true;
overworld_map_bmp_.Create(512, 512, 512, overworld_.GetCurrentBitmapData());
rom_.RenderBitmap(&overworld_map_bmp_);
} }
ImGui::End(); ImGui::End();

View File

@@ -64,6 +64,7 @@ class OverworldEditor {
void LoadGraphics(); void LoadGraphics();
int current_world_ = 0; int current_world_ = 0;
int current_map_ = 0;
char map_gfx_[3] = ""; char map_gfx_[3] = "";
char map_palette_[3] = ""; char map_palette_[3] = "";
char spr_gfx_[3] = ""; char spr_gfx_[3] = "";
@@ -86,6 +87,7 @@ class OverworldEditor {
std::unordered_map<int, gfx::Bitmap> graphics_bin_; std::unordered_map<int, gfx::Bitmap> graphics_bin_;
std::unordered_map<int, gfx::Bitmap> current_graphics_set_; std::unordered_map<int, gfx::Bitmap> current_graphics_set_;
std::unordered_map<int, gfx::Bitmap> maps_bmp_;
ROM rom_; ROM rom_;
zelda3::Overworld overworld_; zelda3::Overworld overworld_;
@@ -94,7 +96,6 @@ class OverworldEditor {
gfx::Bitmap tile16_blockset_bmp_; // pointer size 1048576 gfx::Bitmap tile16_blockset_bmp_; // pointer size 1048576
gfx::Bitmap current_gfx_bmp_; // pointer size 32768 gfx::Bitmap current_gfx_bmp_; // pointer size 32768
gfx::Bitmap all_gfx_bmp; // pointer size 456704 gfx::Bitmap all_gfx_bmp; // pointer size 456704
gfx::Bitmap overworld_map_bmp_;
gui::Canvas overworld_map_canvas_; gui::Canvas overworld_map_canvas_;
gui::Canvas current_gfx_canvas_; gui::Canvas current_gfx_canvas_;