Fixed editor bugs - Copy/Paste values caused entities to get pasted, filtered asset browser could not expand compilable assets, EditorConfig workingscene does not get saved sometimes #375
|
@ -1,4 +0,0 @@
|
||||||
Start Maximized: true
|
|
||||||
Working Scene ID: 97158628
|
|
||||||
Window Size: {x: 1920, y: 1013}
|
|
||||||
Style: 0
|
|
|
@ -254,7 +254,7 @@ namespace SHADE
|
||||||
return ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax());
|
return ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax());
|
||||||
}
|
}
|
||||||
|
|
||||||
ImRect SHAssetBrowser::DrawAsset(SHAsset const* const asset, FileExt const& ext /*= ""*/) noexcept
|
ImRect SHAssetBrowser::DrawAsset(SHAsset const* const asset, FileExt const& ext /*= ""*/, bool isSubAsset /*= false*/) noexcept
|
||||||
{
|
{
|
||||||
if (asset == nullptr)
|
if (asset == nullptr)
|
||||||
return ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax());
|
return ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax());
|
||||||
|
@ -267,10 +267,20 @@ namespace SHADE
|
||||||
bool highlighted = false;
|
bool highlighted = false;
|
||||||
if(!filter.empty())
|
if(!filter.empty())
|
||||||
{
|
{
|
||||||
ImGui::SetNextItemOpen(true);
|
//ImGui::SetNextItemOpen(true);
|
||||||
if(SHStringUtilities::StringFindInsensitive(asset->name.data(), filter) == std::string::npos)
|
if(SHStringUtilities::StringFindInsensitive(asset->name.data(), filter) == std::string::npos)
|
||||||
{
|
{
|
||||||
return ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax());
|
bool subAssetFiltered = false;
|
||||||
|
for (auto const& subAsset : asset->subAssets)
|
||||||
|
{
|
||||||
|
subAssetFiltered |= (SHStringUtilities::StringFindInsensitive(subAsset->name.data(), filter) != std::string::npos);
|
||||||
|
}
|
||||||
|
if(!subAssetFiltered)
|
||||||
|
return ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax());
|
||||||
|
else if(!asset->subAssets.empty())
|
||||||
|
{
|
||||||
|
ImGui::SetNextItemOpen(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -350,7 +360,12 @@ namespace SHADE
|
||||||
case AssetType::TEXTURE: break;
|
case AssetType::TEXTURE: break;
|
||||||
case AssetType::MESH: break;
|
case AssetType::MESH: break;
|
||||||
case AssetType::SCENE:
|
case AssetType::SCENE:
|
||||||
editor->LoadScene(asset->id);
|
{
|
||||||
|
if(editor->LoadScene(asset->id))
|
||||||
|
{
|
||||||
|
editor->editorConfig->workingSceneID = asset->id;
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case AssetType::PREFAB: break;
|
case AssetType::PREFAB: break;
|
||||||
case AssetType::MATERIAL:
|
case AssetType::MATERIAL:
|
||||||
|
@ -418,7 +433,7 @@ namespace SHADE
|
||||||
for(auto const& subAsset : asset->subAssets)
|
for(auto const& subAsset : asset->subAssets)
|
||||||
{
|
{
|
||||||
const float horizontalLineSize = 25.0f;
|
const float horizontalLineSize = 25.0f;
|
||||||
const ImRect childRect = DrawAsset(subAsset);
|
const ImRect childRect = DrawAsset(subAsset, "", true);
|
||||||
const float midPoint = (childRect.Min.y + childRect.Max.y) * 0.5f;
|
const float midPoint = (childRect.Min.y + childRect.Max.y) * 0.5f;
|
||||||
drawList->AddLine(ImVec2(vertLineStart.x, midPoint), ImVec2(vertLineStart.x + horizontalLineSize, midPoint), treeLineColor, 1);
|
drawList->AddLine(ImVec2(vertLineStart.x, midPoint), ImVec2(vertLineStart.x + horizontalLineSize, midPoint), treeLineColor, 1);
|
||||||
vertLineEnd.y = midPoint;
|
vertLineEnd.y = midPoint;
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace SHADE
|
||||||
ImRect RecursivelyDrawTree(FolderPointer folder);
|
ImRect RecursivelyDrawTree(FolderPointer folder);
|
||||||
void DrawCurrentFolder();
|
void DrawCurrentFolder();
|
||||||
ImRect DrawFile(SHFile& file) noexcept;
|
ImRect DrawFile(SHFile& file) noexcept;
|
||||||
ImRect DrawAsset(SHAsset const* const asset, FileExt const& ext = "") noexcept;
|
ImRect DrawAsset(SHAsset const* const asset, FileExt const& ext = "", bool isSubAsset = false) noexcept;
|
||||||
void DrawAssetBeingCreated() noexcept;
|
void DrawAssetBeingCreated() noexcept;
|
||||||
void DrawAssetBrowserFilter();
|
void DrawAssetBrowserFilter();
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
#include "Serialization/Prefab/SHPrefabManager.h"
|
#include "Serialization/Prefab/SHPrefabManager.h"
|
||||||
#include "../SHEditorWindowManager.h"
|
#include "../SHEditorWindowManager.h"
|
||||||
#include "../AssetBrowser/SHAssetBrowser.h"
|
#include "../AssetBrowser/SHAssetBrowser.h"
|
||||||
|
#include "Assets/SHAssetManager.h"
|
||||||
|
#include "Assets/Asset Types/SHPrefabAsset.h"
|
||||||
|
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
|
@ -99,7 +101,7 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
ImGui::SeparatorEx(ImGuiSeparatorFlags_Horizontal);
|
ImGui::SeparatorEx(ImGuiSeparatorFlags_Horizontal);
|
||||||
|
|
||||||
if (!ImGui::IsAnyItemFocused())
|
if (!ImGui::IsAnyItemActive())
|
||||||
{
|
{
|
||||||
if (ImGui::IsKeyDown(ImGuiKey_LeftCtrl) && ImGui::IsKeyReleased(ImGuiKey_A))
|
if (ImGui::IsKeyDown(ImGuiKey_LeftCtrl) && ImGui::IsKeyReleased(ImGuiKey_A))
|
||||||
{
|
{
|
||||||
|
@ -136,6 +138,23 @@ namespace SHADE
|
||||||
draggingEntities.clear();
|
draggingEntities.clear();
|
||||||
ImGui::ClearDragDrop();
|
ImGui::ClearDragDrop();
|
||||||
}
|
}
|
||||||
|
//else if(SHDragDrop::currentDragDropTag == SHDragDrop::DRAG_RESOURCE)
|
||||||
|
//{
|
||||||
|
// if (const AssetID* assetPayload = SHDragDrop::AcceptPayload<AssetID>(SHDragDrop::DRAG_RESOURCE)) //If payload is valid
|
||||||
|
// {
|
||||||
|
// auto assetId = *assetPayload;
|
||||||
|
// auto createdEntitiesList = SHSerialization::DeserializeEntitiesFromString(SHAssetManager::GetData<SHPrefabAsset>(assetId)->data);
|
||||||
|
// if (!createdEntitiesList.empty())
|
||||||
|
// {
|
||||||
|
// std::vector<EntityID> eidList;
|
||||||
|
// std::ranges::transform(createdEntitiesList, std::back_inserter(eidList), [](std::pair<EntityID, EntityID> pair) {return pair.second; });
|
||||||
|
// ParentSelectedEntities(eid, eidList);
|
||||||
|
// SetScrollTo(createdEntitiesList.begin()->second);
|
||||||
|
// SHPrefabManager::AddEntity(assetId, createdEntitiesList.begin()->second);
|
||||||
|
// skipFrame = true;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
@ -359,6 +378,20 @@ namespace SHADE
|
||||||
draggingEntities.clear();
|
draggingEntities.clear();
|
||||||
//ImGui::ClearDragDrop();
|
//ImGui::ClearDragDrop();
|
||||||
}
|
}
|
||||||
|
if (const AssetID* assetPayload = SHDragDrop::AcceptPayload<AssetID>(SHDragDrop::DRAG_RESOURCE)) //If payload is valid
|
||||||
|
{
|
||||||
|
auto assetId = *assetPayload;
|
||||||
|
auto createdEntitiesList = SHSerialization::DeserializeEntitiesFromString(SHAssetManager::GetData<SHPrefabAsset>(assetId)->data);
|
||||||
|
if(!createdEntitiesList.empty())
|
||||||
|
{
|
||||||
|
std::vector<EntityID> eidList;
|
||||||
|
std::ranges::transform(createdEntitiesList, std::back_inserter(eidList), [](std::pair<EntityID, EntityID> pair){return pair.second;} );
|
||||||
|
ParentSelectedEntities(eid, eidList);
|
||||||
|
SetScrollTo(createdEntitiesList.begin()->second);
|
||||||
|
SHPrefabManager::AddEntity(assetId, createdEntitiesList.begin()->second);
|
||||||
|
skipFrame = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
SHDragDrop::EndTarget();
|
SHDragDrop::EndTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,8 @@ namespace SHADE
|
||||||
data.createdEntities.clear();
|
data.createdEntities.clear();
|
||||||
data.createdEntities = SHSerialization::DeserializeEntitiesFromString(data.entityData, data.parentEID);
|
data.createdEntities = SHSerialization::DeserializeEntitiesFromString(data.entityData, data.parentEID);
|
||||||
data.entityData = SHSerialization::ResolveSerializedEntityIndices(data.entityData, data.createdEntities);
|
data.entityData = SHSerialization::ResolveSerializedEntityIndices(data.entityData, data.createdEntities);
|
||||||
SHEditorWindowManager::GetEditorWindow<SHHierarchyPanel>()->SetScrollTo(data.createdEntities.begin()->second);
|
if(!data.createdEntities.empty())
|
||||||
|
SHEditorWindowManager::GetEditorWindow<SHHierarchyPanel>()->SetScrollTo(data.createdEntities.begin()->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHPasteEntitiesCommand::Undo()
|
void SHPasteEntitiesCommand::Undo()
|
||||||
|
|
|
@ -579,19 +579,23 @@ namespace SHADE
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHEditor::LoadScene(AssetID const& assetID) noexcept
|
bool SHEditor::LoadScene(AssetID const& assetID) noexcept
|
||||||
{
|
{
|
||||||
if(shWindow->IsUnsavedChanges())
|
if(shWindow->IsUnsavedChanges())
|
||||||
{
|
{
|
||||||
//Unsaved changes prompt
|
//Unsaved changes prompt
|
||||||
isUnsavedChangesPromptOpen = true;
|
isUnsavedChangesPromptOpen = true;
|
||||||
sceneToLoad = assetID;
|
sceneToLoad = assetID;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Load the scene
|
//Load the scene
|
||||||
sceneToLoad = 0;
|
sceneToLoad = 0;
|
||||||
|
editorConfig->workingSceneID = assetID;
|
||||||
|
SHConfigurationManager::SaveEditorConfig();
|
||||||
SHSceneManager::RestartScene(assetID);
|
SHSceneManager::RestartScene(assetID);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@ namespace SHADE
|
||||||
|
|
||||||
bool SaveScene(std::string const& newSceneName = {});
|
bool SaveScene(std::string const& newSceneName = {});
|
||||||
|
|
||||||
void LoadScene(AssetID const& assetID) noexcept;
|
bool LoadScene(AssetID const& assetID) noexcept;
|
||||||
|
|
||||||
void Play();
|
void Play();
|
||||||
void Pause();
|
void Pause();
|
||||||
|
|
Loading…
Reference in New Issue