From d253aed635f41eea79938312010faec660bd8929 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Tue, 5 May 2026 06:35:37 -0700 Subject: [PATCH] feat(editor): Find Valid Tile button, improved ADT loading workflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - "Find Valid Tile" button in Load dialog: auto-scans manifest for the first available ADT tile of the selected map (checks center range 25-45 first for open world, then full 0-63 for dungeons) - Fixes "wrong coords" issue — dungeons use different tile coords than open world maps, now auto-detected - Map name lowercased for manifest lookup consistency - Tile check shows green "Tile found" or red "Tile not found" indicator --- tools/editor/asset_browser.cpp | 21 ++++++++++++++++- tools/editor/asset_browser.hpp | 1 + tools/editor/editor_ui.cpp | 41 +++++++++++++++++++++++++++------- 3 files changed, 54 insertions(+), 9 deletions(-) diff --git a/tools/editor/asset_browser.cpp b/tools/editor/asset_browser.cpp index 1046e4fd..2a4ae8fe 100644 --- a/tools/editor/asset_browser.cpp +++ b/tools/editor/asset_browser.cpp @@ -89,6 +89,8 @@ void AssetBrowser::initialize(pipeline::AssetManager* am) { mapNames_.assign(mapSet.begin(), mapSet.end()); std::sort(mapNames_.begin(), mapNames_.end()); + LOG_INFO(" Maps found: ", mapNames_.size()); + std::sort(textures_.begin(), textures_.end(), [](const AssetEntry& a, const AssetEntry& b) { return a.wowPath < b.wowPath; }); std::sort(m2Models_.begin(), m2Models_.end(), @@ -105,7 +107,24 @@ void AssetBrowser::initialize(pipeline::AssetManager* am) { std::sort(wmoDirs_.begin(), wmoDirs_.end()); LOG_INFO("Asset browser: ", textures_.size(), " textures, ", - m2Models_.size(), " M2s, ", wmos_.size(), " WMOs indexed"); + m2Models_.size(), " M2s, ", wmos_.size(), " WMOs indexed, ", + mapNames_.size(), " maps"); +} + +std::vector> AssetBrowser::getMapTiles(const std::string& mapName) const { + // Build tile list by checking manifest for each possible ADT + // Only called when user selects a map, so 64x64 is fine + std::vector> tiles; + for (int x = 0; x < 64; x++) { + for (int y = 0; y < 64; y++) { + std::string path = "world\\maps\\" + mapName + "\\" + mapName + "_" + + std::to_string(x) + "_" + std::to_string(y) + ".adt"; + // We stored entries as lowercase, so this should match + // But we don't have direct access to entries here + // Use a dummy check — the UI already does manifest lookups + } + } + return tiles; // Empty for now — UI uses direct manifest check per tile } } // namespace editor diff --git a/tools/editor/asset_browser.hpp b/tools/editor/asset_browser.hpp index 914d9d8c..a9ec8559 100644 --- a/tools/editor/asset_browser.hpp +++ b/tools/editor/asset_browser.hpp @@ -28,6 +28,7 @@ public: const std::vector& getWMODirectories() const { return wmoDirs_; } const std::vector& getMapNames() const { return mapNames_; } + std::vector> getMapTiles(const std::string& mapName) const; bool isInitialized() const { return initialized_; } diff --git a/tools/editor/editor_ui.cpp b/tools/editor/editor_ui.cpp index dfcaee59..091808a0 100644 --- a/tools/editor/editor_ui.cpp +++ b/tools/editor/editor_ui.cpp @@ -343,17 +343,42 @@ void EditorUI::renderLoadDialog(EditorApp& app) { // Check if the selected tile exists { - std::string testPath = std::string("world\\maps\\") + loadMapNameBuf_ + "\\" + - loadMapNameBuf_ + "_" + std::to_string(loadTileX_) + "_" + - std::to_string(loadTileY_) + ".adt"; - std::string lower = testPath; - std::transform(lower.begin(), lower.end(), lower.begin(), + std::string mapLower(loadMapNameBuf_); + std::transform(mapLower.begin(), mapLower.end(), mapLower.begin(), [](unsigned char c) { return std::tolower(c); }); - bool exists = app.getAssetManager()->getManifest().hasEntry(lower); + std::string testPath = "world\\maps\\" + mapLower + "\\" + mapLower + "_" + + std::to_string(loadTileX_) + "_" + std::to_string(loadTileY_) + ".adt"; + bool exists = app.getAssetManager()->getManifest().hasEntry(testPath); if (exists) - ImGui::TextColored(ImVec4(0.3f, 0.9f, 0.3f, 1), "Tile found in manifest"); + ImGui::TextColored(ImVec4(0.3f, 0.9f, 0.3f, 1), "Tile found"); else - ImGui::TextColored(ImVec4(0.9f, 0.4f, 0.3f, 1), "Tile not found — try different coords"); + ImGui::TextColored(ImVec4(0.9f, 0.4f, 0.3f, 1), "Tile not found"); + + ImGui::SameLine(); + if (ImGui::SmallButton("Find Valid Tile")) { + bool found = false; + for (int x = 25; x < 45 && !found; x++) { + for (int y = 25; y < 45 && !found; y++) { + std::string tp = "world\\maps\\" + mapLower + "\\" + mapLower + "_" + + std::to_string(x) + "_" + std::to_string(y) + ".adt"; + if (app.getAssetManager()->getManifest().hasEntry(tp)) { + loadTileX_ = x; loadTileY_ = y; found = true; + } + } + } + if (!found) { + for (int x = 0; x < 64 && !found; x++) { + for (int y = 0; y < 64 && !found; y++) { + std::string tp = "world\\maps\\" + mapLower + "\\" + mapLower + "_" + + std::to_string(x) + "_" + std::to_string(y) + ".adt"; + if (app.getAssetManager()->getManifest().hasEntry(tp)) { + loadTileX_ = x; loadTileY_ = y; found = true; + } + } + } + } + } + if (ImGui::IsItemHovered()) ImGui::SetTooltip("Scans for the first available tile"); } ImGui::Spacing();