light/Mirror/src/Panels/ContentBrowser.cpp

49 lines
971 B
C++
Raw Normal View History

#include "ContentBrowser.h"
#include <imgui.h>
namespace Light {
2022-03-04 22:40:20 +03:30
ContentBrowserPanel::ContentBrowserPanel()
: m_CurrentDirectory("Assets"), m_AssetsPath("Assets") {}
2022-03-04 22:40:20 +03:30
void ContentBrowserPanel::OnUserInterfaceUpdate()
{
ImGui::Begin("Content Browser");
2022-03-04 22:40:20 +03:30
if (m_CurrentDirectory != std::filesystem::path("Assets"))
{
if (ImGui::Button(" <-- "))
{
2022-03-04 22:40:20 +03:30
m_CurrentDirectory = m_CurrentDirectory.parent_path();
}
2022-03-04 22:40:20 +03:30
}
2022-03-04 22:40:20 +03:30
for (auto& dirEntry : std::filesystem::directory_iterator(m_CurrentDirectory))
{
const auto& path = dirEntry.path();
{
2022-03-04 22:40:20 +03:30
auto relativePath = std::filesystem::relative(path, m_AssetsPath);
std::string relativePathString = relativePath.string();
if (dirEntry.is_directory())
{
if (ImGui::Button(relativePathString.c_str()))
{
m_CurrentDirectory /= path.filename();
}
}
else
{
if (ImGui::Button(relativePathString.c_str()))
{
}
}
}
ImGui::End();
}
2022-03-04 22:40:20 +03:30
}
2022-03-04 22:40:20 +03:30
} // namespace Light