From 57e610b893bbe5106870048ab991dc7aaefc40df Mon Sep 17 00:00:00 2001 From: Joey Pollack Date: Tue, 5 Jul 2022 13:54:26 -0400 Subject: [PATCH] Fixed bug that allowed the asset browser's back button to leave the project's assets directory --- docs/tasks/Bugs.todo | 2 +- src/run_modes/editor/panels/asset_browser.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/tasks/Bugs.todo b/docs/tasks/Bugs.todo index ba33e8f..9094a85 100644 --- a/docs/tasks/Bugs.todo +++ b/docs/tasks/Bugs.todo @@ -1,6 +1,6 @@ High Importance: - ☐ AssetBrowser back button does not stop at the asset root directory @high + ✔ AssetBrowser back button does not stop at the asset root directory @high @done(22-07-05 13:53) ✔ Editor does not get absolute paths from the file browser - replace with NFD dialogs @critical @done(22-05-20 18:36) ✔ The Map Editor does not get the tile maps when a project is opened @high @done (3/3/2022, 2:47:41 PM) ✔ Tile Set IDs (as opposed to the Asset ID) is not saved or loaded yet @high @done (3/11/2022, 2:10:30 PM) diff --git a/src/run_modes/editor/panels/asset_browser.cpp b/src/run_modes/editor/panels/asset_browser.cpp index 758da6b..8a63d35 100644 --- a/src/run_modes/editor/panels/asset_browser.cpp +++ b/src/run_modes/editor/panels/asset_browser.cpp @@ -144,7 +144,12 @@ namespace editor ImGui::PushFont(GUI::GetInstance().GetFont(GuiFont::FONT_ROBO_SMALL)); ImGui::TextUnformatted(mpEditor->GetProject()->MakeRelativeToAssets(mSelectedDir, true).string().c_str()); ImGui::PopFont(); - if (ImGui::Button("Back")) + + // Prevent the back button from leaving the projects asset directory + std::string parent = mSelectedDir.parent_path().lexically_normal().string(); + std::string assets_str = mpEditor->GetProject()->GetAssetDirectory().lexically_normal().string(); + size_t loc = parent.find(assets_str); + if (ImGui::Button("Back") && (loc != std::string::npos)) { mSelectedDir = mSelectedDir.parent_path(); mSyncTree = true;