Started in File Broswe Window
This commit is contained in:
parent
4e2f6b8cfd
commit
91f8eff00d
@ -132,6 +132,8 @@ add_executable(Editor ${APP_SOURCES}
|
||||
src/editor/Windows/LoggerWindow.h
|
||||
src/editor/Windows/Viewport.cpp
|
||||
src/editor/Windows/Viewport.h
|
||||
src/editor/Windows/FileBrowser.cpp
|
||||
src/editor/Windows/FileBrowser.h
|
||||
)
|
||||
|
||||
target_include_directories(Editor PRIVATE
|
||||
|
@ -43,7 +43,6 @@ namespace OX
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
stbi_image_free(data);
|
||||
Logger::LogVerbose("Loaded texture: %s (%dx%d)", path.c_str(), m_Width, m_Height);
|
||||
return true;
|
||||
}
|
||||
} // namespace OX
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include "Windows/LoggerWindow.h"
|
||||
#include "Windows/Viewport.h"
|
||||
#include "Windows/FileBrowser.h"
|
||||
|
||||
namespace OX
|
||||
{
|
||||
@ -75,6 +76,7 @@ namespace OX
|
||||
ImGui::DockSpace(dockspaceID, ImVec2(0.0f, 0.0f), ImGuiDockNodeFlags_PassthruCentralNode);
|
||||
|
||||
LoggerWindow::Draw();
|
||||
FileBrowser::Draw();
|
||||
primaryViewport->Draw(core);
|
||||
|
||||
|
||||
|
70
src/editor/Windows/FileBrowser.cpp
Normal file
70
src/editor/Windows/FileBrowser.cpp
Normal file
@ -0,0 +1,70 @@
|
||||
//
|
||||
// Created by spenc on 5/21/2025.
|
||||
//
|
||||
|
||||
|
||||
|
||||
|
||||
#include "FileBrowser.h"
|
||||
#include "systems/AssetManager.h"
|
||||
#include "imgui.h"
|
||||
#include <filesystem>
|
||||
|
||||
namespace OX {
|
||||
|
||||
static std::string s_CurrentPath = "res://";
|
||||
|
||||
static void DrawGrid(const std::shared_ptr<ResourceTreeNode>& node) {
|
||||
const int columns = 4;
|
||||
int itemIndex = 0;
|
||||
|
||||
ImGui::BeginChild("FileGrid", ImVec2(0, 0), false, ImGuiWindowFlags_AlwaysUseWindowPadding);
|
||||
ImGui::Columns(columns, nullptr, false);
|
||||
|
||||
for (const auto& child : node->children) {
|
||||
std::string label = (child->isDirectory ? "[folder] " : "[file] ") + child->name;
|
||||
|
||||
if (ImGui::Selectable(label.c_str(), false, ImGuiSelectableFlags_AllowDoubleClick, ImVec2(0, 64))) {
|
||||
if (child->isDirectory && ImGui::IsMouseDoubleClicked(0)) {
|
||||
s_CurrentPath = child->path;
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::NextColumn();
|
||||
++itemIndex;
|
||||
}
|
||||
|
||||
ImGui::Columns(1);
|
||||
ImGui::EndChild();
|
||||
}
|
||||
|
||||
static std::shared_ptr<ResourceTreeNode> FindNode(const std::shared_ptr<ResourceTreeNode>& root, const std::string& targetPath) {
|
||||
if (root->path == targetPath) return root;
|
||||
|
||||
for (const auto& child : root->children) {
|
||||
if (child->isDirectory) {
|
||||
auto found = FindNode(child, targetPath);
|
||||
if (found) return found;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void FileBrowser::Draw() {
|
||||
ImGui::Begin("File Browser");
|
||||
|
||||
ImGui::Text("Current Path: %s", s_CurrentPath.c_str());
|
||||
ImGui::Separator();
|
||||
|
||||
auto root = AssetManager::GetFileTree();
|
||||
auto currentNode = FindNode(root, s_CurrentPath);
|
||||
if (currentNode) {
|
||||
DrawGrid(currentNode);
|
||||
} else {
|
||||
ImGui::Text("Path not found: %s", s_CurrentPath.c_str());
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
} // namespace OX
|
12
src/editor/Windows/FileBrowser.h
Normal file
12
src/editor/Windows/FileBrowser.h
Normal file
@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace OX {
|
||||
|
||||
class FileBrowser {
|
||||
public:
|
||||
static void Draw();
|
||||
};
|
||||
|
||||
} // namespace OX
|
Loading…
Reference in New Issue
Block a user