|
|
|
@ -74,17 +74,16 @@ namespace editor
|
|
|
|
float xPos = ImGui::GetCursorPosX();
|
|
|
|
float xPos = ImGui::GetCursorPosX();
|
|
|
|
float left = xPos;
|
|
|
|
float left = xPos;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ImGui::BeginChild("ToolBar", ImVec2(0, ImGui::GetFrameHeightWithSpacing()));
|
|
|
|
|
|
|
|
if (ImGui::Button("Back"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
mSelectedDir = mSelectedDir.parent_path();
|
|
|
|
|
|
|
|
mSyncTree = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Display each file in a row
|
|
|
|
ImGui::EndChild();
|
|
|
|
// 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());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
ImGui::BeginChild("Files");
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// List directories
|
|
|
|
// List directories
|
|
|
|
for(auto const& dir_entry: std::filesystem::directory_iterator{mSelectedDir})
|
|
|
|
for(auto const& dir_entry: std::filesystem::directory_iterator{mSelectedDir})
|
|
|
|
@ -92,6 +91,7 @@ namespace editor
|
|
|
|
if (dir_entry.is_directory())
|
|
|
|
if (dir_entry.is_directory())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ImGui::Text("DIRECTORY: %s", dir_entry.path().filename().string().c_str());
|
|
|
|
ImGui::Text("DIRECTORY: %s", dir_entry.path().filename().string().c_str());
|
|
|
|
|
|
|
|
HandleAssetDrop(dir_entry.path());
|
|
|
|
if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left))
|
|
|
|
if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// TODO: Open relevant editor
|
|
|
|
// TODO: Open relevant editor
|
|
|
|
@ -117,7 +117,9 @@ namespace editor
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ImGui::BeginDragDropSource())
|
|
|
|
if (ImGui::BeginDragDropSource())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ImGui::SetDragDropPayload("EditorAsset", (void*)(*iter), sizeof(EditorAsset));
|
|
|
|
// Need to pass a pointer to the payload data. This means we need to pass a
|
|
|
|
|
|
|
|
// pointer to the EditorAsset pointer (EditorAsset**) which &(*iter) becomes
|
|
|
|
|
|
|
|
ImGui::SetDragDropPayload("EditorAsset", (void*)&(*iter), sizeof(EditorAsset*));
|
|
|
|
ImGui::Text("%s", (*iter)->GetFileLocation().stem().string().c_str());
|
|
|
|
ImGui::Text("%s", (*iter)->GetFileLocation().stem().string().c_str());
|
|
|
|
ImGui::EndDragDropSource();
|
|
|
|
ImGui::EndDragDropSource();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -129,6 +131,8 @@ namespace editor
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DoContextMenu();
|
|
|
|
DoContextMenu();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ImGui::EndChild();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ImGui::EndChild();
|
|
|
|
ImGui::EndChild();
|
|
|
|
@ -146,27 +150,24 @@ namespace editor
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
std::string next_node_name = dir.filename().string();
|
|
|
|
std::string next_node_name = dir.filename().string();
|
|
|
|
if (mSyncTree && mSelectedDir.string().find(next_node_name) != std::string::npos)
|
|
|
|
if (mSyncTree)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ImGui::SetNextItemOpen(true);
|
|
|
|
if (mSelectedDir.string().find(next_node_name) != std::string::npos)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ImGui::SetNextItemOpen(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ImGui::SetNextItemOpen(false);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (ImGui::TreeNode(next_node_name.c_str()))
|
|
|
|
if (ImGui::TreeNode(next_node_name.c_str()))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!mSyncTree)
|
|
|
|
if (!mSyncTree)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mSelectedDir = dir;
|
|
|
|
mSelectedDir = dir;
|
|
|
|
if (ImGui::BeginDragDropTarget())
|
|
|
|
HandleAssetDrop(mSelectedDir);
|
|
|
|
{
|
|
|
|
|
|
|
|
if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload("EditorAsset"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
EditorAsset* pAsset = (EditorAsset*) payload->Data;
|
|
|
|
|
|
|
|
Logger::Info(Editor::LogCat, "Dropping asset: %s - To: %s",
|
|
|
|
|
|
|
|
pAsset->GetFileLocation().stem().string().c_str(), mSelectedDir.string().c_str());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: Handle moving the asset
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::EndDragDropTarget();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for(auto const& dir_entry: std::filesystem::directory_iterator{dir})
|
|
|
|
for(auto const& dir_entry: std::filesystem::directory_iterator{dir})
|
|
|
|
@ -229,6 +230,26 @@ namespace editor
|
|
|
|
|
|
|
|
|
|
|
|
return pNode;
|
|
|
|
return pNode;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void AssetBrowser::HandleAssetDrop(std::filesystem::path dir)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (ImGui::BeginDragDropTarget())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload("EditorAsset"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
EditorAsset* pAsset = *((EditorAsset**) payload->Data);
|
|
|
|
|
|
|
|
// EditorAsset* pAsset = ((EditorAsset*) payload->Data);
|
|
|
|
|
|
|
|
Logger::Info(Editor::LogCat, "Dropping asset: %s - To: %s",
|
|
|
|
|
|
|
|
pAsset->GetFileLocation().stem().string().c_str(), dir.string().c_str());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: Handle moving the asset
|
|
|
|
|
|
|
|
ContentManager::GetInstance().MoveAsset(pAsset, dir / pAsset->GetFileLocation().filename());
|
|
|
|
|
|
|
|
Logger::Debug(Editor::LogCat, "Asset Location: %s", pAsset->GetFileLocation().string().c_str());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::EndDragDropTarget();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|