2021-10-23 19:04:29 +03:30
|
|
|
#include "ContentBrowser.h"
|
|
|
|
|
|
|
|
#include <imgui.h>
|
|
|
|
|
|
|
|
namespace Light {
|
|
|
|
|
2022-03-04 22:40:20 +03:30
|
|
|
ContentBrowserPanel::ContentBrowserPanel()
|
|
|
|
: m_CurrentDirectory("Assets"), m_AssetsPath("Assets") {}
|
2021-10-23 19:04:29 +03:30
|
|
|
|
2022-03-04 22:40:20 +03:30
|
|
|
void ContentBrowserPanel::OnUserInterfaceUpdate()
|
|
|
|
{
|
|
|
|
ImGui::Begin("Content Browser");
|
2021-10-23 19:04:29 +03:30
|
|
|
|
2022-03-04 22:40:20 +03:30
|
|
|
if (m_CurrentDirectory != std::filesystem::path("Assets"))
|
|
|
|
{
|
|
|
|
if (ImGui::Button(" <-- "))
|
2021-10-23 19:04:29 +03:30
|
|
|
{
|
2022-03-04 22:40:20 +03:30
|
|
|
m_CurrentDirectory = m_CurrentDirectory.parent_path();
|
2021-10-23 19:04:29 +03:30
|
|
|
}
|
2022-03-04 22:40:20 +03:30
|
|
|
}
|
2021-10-23 19:04:29 +03:30
|
|
|
|
2022-03-04 22:40:20 +03:30
|
|
|
for (auto& dirEntry : std::filesystem::directory_iterator(m_CurrentDirectory))
|
|
|
|
{
|
|
|
|
const auto& path = dirEntry.path();
|
2021-10-23 19:04:29 +03:30
|
|
|
{
|
2022-03-04 22:40:20 +03:30
|
|
|
auto relativePath = std::filesystem::relative(path, m_AssetsPath);
|
2021-10-23 19:04:29 +03:30
|
|
|
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
|
|
|
}
|
2021-10-23 19:04:29 +03:30
|
|
|
|
2022-03-04 22:40:20 +03:30
|
|
|
} // namespace Light
|