|
|
|
|
@ -9,14 +9,17 @@
|
|
|
|
|
#include "asset_browser.h"
|
|
|
|
|
#include <dearimgui/imgui.h>
|
|
|
|
|
#include <editor/editor.h>
|
|
|
|
|
#include <editor/contents/content_manager.h>
|
|
|
|
|
#include <editor/contents/editor_asset.h>
|
|
|
|
|
#include <utils/logger.h>
|
|
|
|
|
|
|
|
|
|
namespace lunarium
|
|
|
|
|
{
|
|
|
|
|
namespace editor
|
|
|
|
|
{
|
|
|
|
|
AssetBrowser::AssetBrowser(std::filesystem::path dir)
|
|
|
|
|
AssetBrowser::AssetBrowser(std::filesystem::path dir, Editor* pEditor)
|
|
|
|
|
: Panel("Asset Browser", gui::PanelDockZone::DDZ_BOTTOM, true),
|
|
|
|
|
mAssetDirectory(dir), mTreeRoot(nullptr), mSelectedNode(nullptr)
|
|
|
|
|
mAssetDirectory(dir), mTreeRoot(nullptr), mSelectedNode(nullptr), mpEditor(pEditor)
|
|
|
|
|
{
|
|
|
|
|
mTreeRoot = ReloadAssets(mAssetDirectory);
|
|
|
|
|
mSelectedNode = mTreeRoot;
|
|
|
|
|
@ -72,15 +75,44 @@ namespace editor
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Display each file in a row
|
|
|
|
|
for(auto const& dir_entry: std::filesystem::directory_iterator{mSelectedDir})
|
|
|
|
|
// for(auto const& dir_entry: std::filesystem::directory_iterator{mSelectedDir})
|
|
|
|
|
// {
|
|
|
|
|
// if (!std::filesystem::is_directory(dir_entry))
|
|
|
|
|
// {
|
|
|
|
|
// // TODO: Turn into a table with file properties as columns
|
|
|
|
|
// ImGui::TextWrapped(dir_entry.path().filename().string().c_str());
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
std::filesystem::path selected_final = mpEditor->GetProject()->MakeRelativeToAssets(mSelectedDir);
|
|
|
|
|
std::vector<EditorAsset*> assets;
|
|
|
|
|
ContentManager::GetInstance().GetAllAssetsInDirectory(assets, selected_final);
|
|
|
|
|
|
|
|
|
|
for (auto iter = assets.begin(); iter != assets.end(); iter++)
|
|
|
|
|
{
|
|
|
|
|
if (!std::filesystem::is_directory(dir_entry))
|
|
|
|
|
if (ImGui::Selectable((*iter)->GetFileLocation().stem().string().c_str()))
|
|
|
|
|
{
|
|
|
|
|
// TODO: Turn into a table with file properties as columns
|
|
|
|
|
ImGui::TextWrapped(dir_entry.path().filename().string().c_str());
|
|
|
|
|
// TODO: Show properties if this is new selection (meaning wasn't selected last frame)
|
|
|
|
|
Logger::Info(Editor::LogCat, "Asset selected. Properties shold show in the PropertiesView Panel");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left))
|
|
|
|
|
{
|
|
|
|
|
// TODO: Open relevant editor
|
|
|
|
|
Logger::Info(Editor::LogCat, "Asset double clicked on. Relevant editor should open!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ImGui::BeginPopupContextWindow(0, 1, false))
|
|
|
|
|
{
|
|
|
|
|
if (ImGui::Button("Click Me!"))
|
|
|
|
|
{
|
|
|
|
|
Logger::Info(Editor::LogCat, "Context menu button clicked!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImGui::EndPopup();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ImGui::EndChild();
|
|
|
|
|
|