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

View File

@@ -64,6 +64,7 @@ class OverworldEditor {
void LoadGraphics();
int current_world_ = 0;
int current_map_ = 0;
char map_gfx_[3] = "";
char map_palette_[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> current_graphics_set_;
std::unordered_map<int, gfx::Bitmap> maps_bmp_;
ROM rom_;
zelda3::Overworld overworld_;
@@ -94,7 +96,6 @@ 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_;