Fix editor scene persistence and XC scene workflow
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
#include "ProjectPanel.h"
|
||||
#include "Core/IEditorContext.h"
|
||||
#include "Core/IProjectManager.h"
|
||||
#include "Core/ISceneManager.h"
|
||||
#include "Core/AssetItem.h"
|
||||
#include "Utils/SceneEditorUtils.h"
|
||||
#include <imgui.h>
|
||||
#include <imgui_internal.h>
|
||||
|
||||
@@ -83,7 +85,7 @@ void ProjectPanel::Render() {
|
||||
|
||||
auto& items = manager.GetCurrentItems();
|
||||
std::string searchStr = m_searchBuffer;
|
||||
int itemIndex = 0;
|
||||
int displayedCount = 0;
|
||||
|
||||
for (int i = 0; i < (int)items.size(); i++) {
|
||||
if (!searchStr.empty()) {
|
||||
@@ -92,11 +94,11 @@ void ProjectPanel::Render() {
|
||||
}
|
||||
}
|
||||
|
||||
if (itemIndex > 0 && itemIndex % columns != 0) {
|
||||
if (displayedCount > 0 && displayedCount % columns != 0) {
|
||||
ImGui::SameLine();
|
||||
}
|
||||
RenderAssetItem(items[i], itemIndex);
|
||||
itemIndex++;
|
||||
RenderAssetItem(items[i], i);
|
||||
displayedCount++;
|
||||
}
|
||||
|
||||
ImGui::PopStyleVar();
|
||||
@@ -108,9 +110,13 @@ void ProjectPanel::Render() {
|
||||
if (ImGui::BeginPopup("ItemContextMenu")) {
|
||||
if (m_contextMenuIndex >= 0 && m_contextMenuIndex < (int)items.size()) {
|
||||
auto& item = items[m_contextMenuIndex];
|
||||
if (item->isFolder) {
|
||||
if (item->isFolder || item->type == "Scene") {
|
||||
if (ImGui::MenuItem("Open")) {
|
||||
manager.NavigateToFolder(item);
|
||||
if (item->isFolder) {
|
||||
manager.NavigateToFolder(item);
|
||||
} else if (SceneEditorUtils::ConfirmSceneSwitch(*m_context)) {
|
||||
m_context->GetSceneManager().LoadScene(item->fullPath);
|
||||
}
|
||||
}
|
||||
ImGui::Separator();
|
||||
}
|
||||
@@ -276,8 +282,14 @@ void ProjectPanel::RenderAssetItem(const AssetItemPtr& item, int index) {
|
||||
}
|
||||
}
|
||||
|
||||
if (doubleClicked && item->isFolder) {
|
||||
manager.NavigateToFolder(item);
|
||||
if (doubleClicked) {
|
||||
if (item->isFolder) {
|
||||
manager.NavigateToFolder(item);
|
||||
} else if (item->type == "Scene") {
|
||||
if (SceneEditorUtils::ConfirmSceneSwitch(*m_context)) {
|
||||
m_context->GetSceneManager().LoadScene(item->fullPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::PopID();
|
||||
@@ -297,4 +309,4 @@ bool ProjectPanel::HandleDrop(const AssetItemPtr& targetFolder) {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user