Update ProjectManager.cpp
This commit is contained in:
parent
c5d9985d00
commit
c95eb8e1e1
@ -153,7 +153,6 @@ void FileExplorer::Show(bool* p_open)
|
||||
{
|
||||
if (!s_initialized) return;
|
||||
|
||||
// rebuild tree if the root changed
|
||||
if (s_root != lastTreeRoot) treeDirty = true;
|
||||
EnsureTreeCache(s_root);
|
||||
|
||||
@ -164,12 +163,8 @@ void FileExplorer::Show(bool* p_open)
|
||||
return;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// LEFT PANE: interactive folder‐tree with icons
|
||||
// -------------------------------------------------------------------------
|
||||
ImGui::BeginChild("##FolderPane", ImVec2(250,0), true);
|
||||
{
|
||||
// recursive lambda to draw each node
|
||||
std::function<void(const TreeNode&)> drawNode = [&](const TreeNode& node) {
|
||||
ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_OpenOnArrow
|
||||
| ImGuiTreeNodeFlags_SpanAvailWidth;
|
||||
@ -191,14 +186,12 @@ void FileExplorer::Show(bool* p_open)
|
||||
label
|
||||
);
|
||||
|
||||
// 3) click to change directory
|
||||
if (ImGui::IsItemClicked()) {
|
||||
s_currentDir = node.path;
|
||||
treeDirty = true; // also force tree repaint?
|
||||
rebuild = true; // file‐grid rebuild
|
||||
}
|
||||
|
||||
// 4) children
|
||||
if (open) {
|
||||
for (auto& child : node.children)
|
||||
drawNode(child);
|
||||
@ -212,12 +205,8 @@ void FileExplorer::Show(bool* p_open)
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// RIGHT PANE: toolbar + file‐grid
|
||||
// -------------------------------------------------------------------------
|
||||
ImGui::BeginChild("##ContentPane", ImVec2(0,0), false);
|
||||
|
||||
// --- Filters / Sort / Search state (static to persist frame-to-frame) ---
|
||||
static char searchBuf[256] = "";
|
||||
static fs::path lastDir;
|
||||
static int lastSortMode = -1;
|
||||
@ -230,7 +219,6 @@ void FileExplorer::Show(bool* p_open)
|
||||
static std::string lastSearch;
|
||||
static bool rebuild = true;
|
||||
|
||||
// Filters / Sort popup
|
||||
if (ImGui::Button("Filters / Sort")) ImGui::OpenPopup("FileFilterPopup");
|
||||
ImGui::SameLine();
|
||||
ImGui::SetNextItemWidth(200);
|
||||
@ -251,7 +239,6 @@ void FileExplorer::Show(bool* p_open)
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
// “Up” button + current path display
|
||||
if (s_currentDir != s_root) {
|
||||
if (ImGui::Button("Up")) {
|
||||
s_currentDir = s_currentDir.parent_path();
|
||||
@ -267,7 +254,6 @@ void FileExplorer::Show(bool* p_open)
|
||||
}
|
||||
ImGui::Separator();
|
||||
|
||||
// Detect any state changes → rebuild the file‐grid cache
|
||||
if ( lastDir != s_currentDir
|
||||
|| lastSortMode != sortMode
|
||||
|| lastSortAsc != sortAscending
|
||||
@ -298,7 +284,6 @@ void FileExplorer::Show(bool* p_open)
|
||||
bool isDir = e.is_directory();
|
||||
AssetType t = AssetManager::AssetTypeFromPath(e.path().string());
|
||||
|
||||
// type filters
|
||||
if (!isDir) {
|
||||
if ((t==AssetType::Scene && !showScenes )||
|
||||
(t==AssetType::Image && !showImages )||
|
||||
@ -308,7 +293,6 @@ void FileExplorer::Show(bool* p_open)
|
||||
continue;
|
||||
}
|
||||
|
||||
// search filter
|
||||
if (!fileSearchQuery.empty()
|
||||
&& e.path().filename().string().find(fileSearchQuery)==std::string::npos)
|
||||
continue;
|
||||
@ -318,7 +302,6 @@ void FileExplorer::Show(bool* p_open)
|
||||
ce.isDirectory = isDir;
|
||||
ce.type = t;
|
||||
|
||||
// thumbnail
|
||||
if (isDir) {
|
||||
ce.thumbID = (ImTextureID)(intptr_t)s_folderIcon;
|
||||
}
|
||||
@ -332,7 +315,6 @@ void FileExplorer::Show(bool* p_open)
|
||||
EngineLoadTextureIfNeeded(ICONS_PATH + IconFileForPath(ce.path));
|
||||
}
|
||||
|
||||
// label for non‐image files
|
||||
if (!isDir && t!=AssetType::Image) {
|
||||
static const std::unordered_map<AssetType,const char*> L = {
|
||||
{AssetType::Prefab,"Prefab"},
|
||||
@ -354,7 +336,6 @@ void FileExplorer::Show(bool* p_open)
|
||||
cacheEntries.push_back(std::move(ce));
|
||||
}
|
||||
|
||||
// sort
|
||||
std::sort(cacheEntries.begin(), cacheEntries.end(),
|
||||
[&](auto& a, auto& b){
|
||||
if (sortMode==1) {
|
||||
|
Loading…
Reference in New Issue
Block a user