SC Editor serialization update in JSON
Signed-off-by: chcurran <82187351+carlitosan@users.noreply.github.com>
This commit is contained in:
@@ -204,6 +204,22 @@ namespace AZ
|
||||
// BaseJsonSerializer
|
||||
//
|
||||
|
||||
JsonSerializationResult::Result BaseJsonSerializer::Load(void* outputValue, const Uuid& outputValueTypeId, const rapidjson::Value& inputValue,
|
||||
JsonDeserializerContext& context)
|
||||
{
|
||||
JsonSerializationResult::ResultCode result(JsonSerializationResult::Tasks::ReadField);
|
||||
result.Combine(ContinueLoading(outputValue, outputValueTypeId, inputValue, context, ContinuationFlags::IgnoreTypeSerializer));
|
||||
return context.Report(result, "Ignoring custom serialization during load");
|
||||
}
|
||||
|
||||
JsonSerializationResult::Result BaseJsonSerializer::Store(rapidjson::Value& outputValue, const void* inputValue, const void* defaultValue,
|
||||
const Uuid& valueTypeId, JsonSerializerContext& context)
|
||||
{
|
||||
JsonSerializationResult::ResultCode result(JsonSerializationResult::Tasks::WriteValue);
|
||||
result.Combine(ContinueStoring(outputValue, inputValue, defaultValue, valueTypeId, context, ContinuationFlags::IgnoreTypeSerializer));
|
||||
return context.Report(result, "Ignoring custom serialization during store");
|
||||
}
|
||||
|
||||
BaseJsonSerializer::OperationFlags BaseJsonSerializer::GetOperationsFlags() const
|
||||
{
|
||||
return OperationFlags::None;
|
||||
|
||||
@@ -180,13 +180,16 @@ namespace AZ
|
||||
|
||||
//! Transforms the data from the rapidjson Value to outputValue, if the conversion is possible and supported.
|
||||
//! The serializer is responsible for casting to the proper type and safely writing to the outputValue memory.
|
||||
//! \note The default implementation is to load the object ignoring a custom serializers for the type, which allows for custom serializers
|
||||
//! to modify the object after all default loading has occurred.
|
||||
virtual JsonSerializationResult::Result Load(void* outputValue, const Uuid& outputValueTypeId, const rapidjson::Value& inputValue,
|
||||
JsonDeserializerContext& context) = 0;
|
||||
JsonDeserializerContext& context);
|
||||
|
||||
//! Write the input value to a rapidjson value if the default value is not null and doesn't match the input value, otherwise
|
||||
//! an error is returned and sets the rapidjson value to a null value.
|
||||
//! \note The default implementation is to store the object ignoring custom serializers.
|
||||
virtual JsonSerializationResult::Result Store(rapidjson::Value& outputValue, const void* inputValue, const void* defaultValue,
|
||||
const Uuid& valueTypeId, JsonSerializerContext& context) = 0;
|
||||
const Uuid& valueTypeId, JsonSerializerContext& context);
|
||||
|
||||
//! Returns the operation flags which tells the Json Serialization how this custom json serializer can be used.
|
||||
virtual OperationFlags GetOperationsFlags() const;
|
||||
|
||||
@@ -144,7 +144,7 @@ namespace ScriptCanvasEditor
|
||||
{
|
||||
namespace JSRU = AZ::JsonSerializationUtils;
|
||||
|
||||
if (!source.IsValid())
|
||||
if (!source.IsGraphValid())
|
||||
{
|
||||
return AZ::Failure(AZStd::string("no source graph to save"));
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <AzCore/Asset/AssetManagerBus.h>
|
||||
#include <AzCore/Component/ComponentApplicationBus.h>
|
||||
#include <AzCore/Component/NamedEntityId.h>
|
||||
@@ -14,6 +13,7 @@
|
||||
#include <AzCore/Script/ScriptSystemBus.h>
|
||||
#include <AzCore/Serialization/EditContext.h>
|
||||
#include <AzCore/Serialization/IdUtils.h>
|
||||
#include <AzCore/Serialization/Json/RegistrationContext.h>
|
||||
#include <AzCore/Serialization/Utils.h>
|
||||
#include <AzFramework/Asset/AssetSystemBus.h>
|
||||
#include <AzFramework/StringFunc/StringFunc.h>
|
||||
@@ -21,24 +21,26 @@
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
#include <Core/ScriptCanvasBus.h>
|
||||
#include <Editor/Assets/ScriptCanvasAssetTrackerBus.h>
|
||||
#include <LyViewPaneNames.h>
|
||||
#include <ScriptCanvas/Asset/RuntimeAsset.h>
|
||||
#include <ScriptCanvas/Asset/RuntimeAsset.h>
|
||||
#include <ScriptCanvas/Assets/ScriptCanvasAsset.h>
|
||||
#include <ScriptCanvas/Assets/ScriptCanvasFileHandling.h>
|
||||
#include <ScriptCanvas/Bus/RequestBus.h>
|
||||
#include <ScriptCanvas/Components/EditorGraph.h>
|
||||
#include <ScriptCanvas/Components/EditorUtils.h>
|
||||
#include <ScriptCanvas/Components/EditorGraphVariableManagerComponent.h>
|
||||
#include <ScriptCanvas/Components/EditorScriptCanvasComponent.h>
|
||||
#include <ScriptCanvas/Components/EditorScriptCanvasComponentSerializer.h>
|
||||
#include <ScriptCanvas/Components/EditorUtils.h>
|
||||
#include <ScriptCanvas/Core/Node.h>
|
||||
#include <ScriptCanvas/PerformanceStatisticsBus.h>
|
||||
#include <LyViewPaneNames.h>
|
||||
#include <ScriptCanvas/Assets/ScriptCanvasFileHandling.h>
|
||||
|
||||
namespace EditorScriptCanvasComponentCpp
|
||||
{
|
||||
enum Version
|
||||
{
|
||||
PrefabIntegration = 10,
|
||||
InternalDev,
|
||||
AddSourceHandle,
|
||||
// add description above
|
||||
Current
|
||||
@@ -49,6 +51,8 @@ namespace ScriptCanvasEditor
|
||||
{
|
||||
static bool EditorScriptCanvasComponentVersionConverter(AZ::SerializeContext& serializeContext, AZ::SerializeContext::DataElementNode& rootElement)
|
||||
{
|
||||
AZ_TracePrintf("ScriptCanvas", "EditorScriptCanvasComponentVersionConverter called!");
|
||||
|
||||
if (rootElement.GetVersion() <= 4)
|
||||
{
|
||||
int assetElementIndex = rootElement.FindElement(AZ::Crc32("m_asset"));
|
||||
@@ -204,6 +208,11 @@ namespace ScriptCanvasEditor
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
if (AZ::JsonRegistrationContext* jsonContext = azrtti_cast<AZ::JsonRegistrationContext*>(context))
|
||||
{
|
||||
jsonContext->Serializer<AZ::EditorScriptCanvasComponentSerializer>()->HandlesType<EditorScriptCanvasComponent>();
|
||||
}
|
||||
}
|
||||
|
||||
EditorScriptCanvasComponent::EditorScriptCanvasComponent()
|
||||
@@ -238,7 +247,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
AZ::Outcome<int, AZStd::string> openOutcome = AZ::Failure(AZStd::string());
|
||||
|
||||
if (m_sourceHandle.IsValid())
|
||||
if (m_sourceHandle.IsDescriptionValid())
|
||||
{
|
||||
GeneralRequestBus::BroadcastResult(openOutcome, &GeneralRequests::OpenScriptCanvasAsset, m_sourceHandle, Tracker::ScriptCanvasFileState::UNMODIFIED, -1);
|
||||
|
||||
@@ -265,7 +274,11 @@ namespace ScriptCanvasEditor
|
||||
EditorComponentBase::Init();
|
||||
AzFramework::AssetCatalogEventBus::Handler::BusConnect();
|
||||
AzToolsFramework::EditorEntityContextNotificationBus::Handler::BusConnect();
|
||||
// m_scriptCanvasAssetHolder.Init(GetEntityId(), GetId());
|
||||
}
|
||||
|
||||
void EditorScriptCanvasComponent::InitializeSource(const SourceHandle& sourceHandle)
|
||||
{
|
||||
m_sourceHandle = sourceHandle;
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
@@ -389,13 +402,13 @@ namespace ScriptCanvasEditor
|
||||
// or when the asset was explicitly set to empty.
|
||||
//
|
||||
// i.e. do not clear variables when we lose the catalog asset.
|
||||
if ((assetId.IsValidDescription() && assetId.Describe() != m_removedHandle.Describe())
|
||||
|| (!assetId.IsValidDescription() && !m_removedHandle.IsValidDescription()))
|
||||
if ((assetId.IsDescriptionValid() && assetId.Describe() != m_removedHandle.Describe())
|
||||
|| (!assetId.IsDescriptionValid() && !m_removedHandle.IsDescriptionValid()))
|
||||
{
|
||||
ClearVariables();
|
||||
}
|
||||
|
||||
if (assetId.IsValidDescription())
|
||||
if (assetId.IsDescriptionValid())
|
||||
{
|
||||
if (auto loaded = LoadFromFile(assetId.Path().c_str()); loaded.IsSuccess())
|
||||
{
|
||||
@@ -473,7 +486,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
void EditorScriptCanvasComponent::UpdatePropertyDisplay(const SourceHandle& sourceHandle)
|
||||
{
|
||||
if (sourceHandle.IsValid())
|
||||
if (sourceHandle.IsGraphValid())
|
||||
{
|
||||
BuildGameEntityData();
|
||||
UpdateName();
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace ScriptCanvasEditor
|
||||
{
|
||||
AZStd::optional<SourceHandle> CompleteDescription(const SourceHandle& source)
|
||||
{
|
||||
if (source.IsValidDescription())
|
||||
if (source.IsDescriptionValid())
|
||||
{
|
||||
return source;
|
||||
}
|
||||
|
||||
+3
@@ -48,6 +48,9 @@ namespace ScriptCanvasEditor
|
||||
EditorScriptCanvasComponent(const SourceHandle& sourceHandle);
|
||||
~EditorScriptCanvasComponent() override;
|
||||
|
||||
// sets the soure but does not attempt to load anything;
|
||||
void InitializeSource(const SourceHandle& sourceHandle);
|
||||
|
||||
//=====================================================================
|
||||
// AZ::Component
|
||||
void Init() override;
|
||||
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/Serialization/Json/JsonSerialization.h>
|
||||
#include <ScriptCanvas/Asset/RuntimeAsset.h>
|
||||
#include <ScriptCanvas/Components/EditorScriptCanvasComponentSerializer.h>
|
||||
#include <ScriptCanvas/Components/EditorScriptCanvasComponent.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
AZ_CLASS_ALLOCATOR_IMPL(EditorScriptCanvasComponentSerializer, SystemAllocator, 0);
|
||||
|
||||
JsonSerializationResult::Result EditorScriptCanvasComponentSerializer::Load
|
||||
( void* outputValue
|
||||
, const Uuid& outputValueTypeId
|
||||
, const rapidjson::Value& inputValue
|
||||
, JsonDeserializerContext& context)
|
||||
{
|
||||
namespace JSR = JsonSerializationResult;
|
||||
|
||||
AZ_Assert(outputValueTypeId == azrtti_typeid<ScriptCanvasEditor::EditorScriptCanvasComponent>()
|
||||
, "EditorScriptCanvasComponentSerializer Load against output typeID that was not EditorScriptCanvasComponent");
|
||||
AZ_Assert(outputValue, "EditorScriptCanvasComponentSerializer Load against null output");
|
||||
|
||||
auto outputComponent = reinterpret_cast<ScriptCanvasEditor::EditorScriptCanvasComponent*>(outputValue);
|
||||
JsonSerializationResult::ResultCode result = BaseJsonSerializer::Load(outputValue, outputValueTypeId, inputValue, context);
|
||||
|
||||
if (result.GetProcessing() != JSR::Processing::Halted)
|
||||
{
|
||||
auto assetHolderMember = inputValue.FindMember("m_assetHolder");
|
||||
if (assetHolderMember != inputValue.MemberEnd())
|
||||
{
|
||||
ScriptCanvasEditor::ScriptCanvasAssetHolder assetHolder;
|
||||
result.Combine
|
||||
( ContinueLoading(&assetHolder
|
||||
, azrtti_typeid<ScriptCanvasEditor::ScriptCanvasAssetHolder>(), assetHolderMember->value, context));
|
||||
|
||||
if (result.GetProcessing() != JSR::Processing::Halted)
|
||||
{
|
||||
outputComponent->InitializeSource
|
||||
( ScriptCanvasEditor::SourceHandle(nullptr, assetHolder.GetAssetId().m_guid, assetHolder.GetAssetHint()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return context.Report(result, result.GetProcessing() != JSR::Processing::Halted
|
||||
? "EditorScriptCanvasComponentSerializer Load finished loading EditorScriptCanvasComponent"
|
||||
: "EditorScriptCanvasComponentSerializer Load failed to load EditorScriptCanvasComponent");
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Memory/Memory.h>
|
||||
#include <AzCore/Serialization/Json/BaseJsonSerializer.h>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
class EditorScriptCanvasComponentSerializer
|
||||
: public BaseJsonSerializer
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(EditorScriptCanvasComponentSerializer, "{80B497B3-ABC1-4991-A3C4-047A8CB2C26C}", BaseJsonSerializer);
|
||||
AZ_CLASS_ALLOCATOR_DECL;
|
||||
|
||||
private:
|
||||
JsonSerializationResult::Result Load
|
||||
( void* outputValue
|
||||
, const Uuid& outputValueTypeId
|
||||
, const rapidjson::Value& inputValue
|
||||
, JsonDeserializerContext& context) override;
|
||||
};
|
||||
}
|
||||
@@ -235,7 +235,7 @@ namespace ScriptCanvasEditor
|
||||
if (tabdata.isValid())
|
||||
{
|
||||
auto tabAssetId = tabdata.value<GraphTabMetadata>();
|
||||
if (tabAssetId.m_assetId.IsValid()
|
||||
if (tabAssetId.m_assetId.IsGraphValid()
|
||||
&& tabAssetId.m_assetId.Get()->GetGraphCanvasGraphId() == graphCanvasGraphId)
|
||||
{
|
||||
return tabAssetId.m_assetId.Get()->GetScriptCanvasId();
|
||||
|
||||
@@ -251,7 +251,7 @@ namespace ScriptCanvasEditor
|
||||
if (fileState == Tracker::ScriptCanvasFileState::MODIFIED || fileState == Tracker::ScriptCanvasFileState::UNMODIFIED)
|
||||
{
|
||||
ScriptCanvasEditor::SourceHandle sourceId = GetSourceAssetId(assetId);
|
||||
if (sourceId.IsValid())
|
||||
if (sourceId.IsGraphValid())
|
||||
{
|
||||
EditorSettings::EditorWorkspace::WorkspaceAssetSaveData assetSaveData;
|
||||
assetSaveData.m_assetId = sourceId;
|
||||
@@ -267,13 +267,13 @@ namespace ScriptCanvasEditor
|
||||
}
|
||||
|
||||
// The assetId needs to be the file AssetId to restore the workspace
|
||||
if (focusedAssetId.IsValid())
|
||||
if (focusedAssetId.IsGraphValid())
|
||||
{
|
||||
focusedAssetId = GetSourceAssetId(focusedAssetId);
|
||||
}
|
||||
|
||||
// If our currently focused asset won't be restored, just show the first element.
|
||||
if (!focusedAssetId.IsValid())
|
||||
if (!focusedAssetId.IsGraphValid())
|
||||
{
|
||||
if (!activeAssets.empty())
|
||||
{
|
||||
@@ -643,7 +643,7 @@ namespace ScriptCanvasEditor
|
||||
QTimer::singleShot(0, [this]() {
|
||||
SetDefaultLayout();
|
||||
|
||||
if (m_activeGraph.IsValid())
|
||||
if (m_activeGraph.IsGraphValid())
|
||||
{
|
||||
m_queuedFocusOverride = m_activeGraph;
|
||||
}
|
||||
@@ -824,7 +824,7 @@ namespace ScriptCanvasEditor
|
||||
void MainWindow::SignalActiveSceneChanged(ScriptCanvasEditor::SourceHandle assetId)
|
||||
{
|
||||
AZ::EntityId graphId;
|
||||
if (assetId.IsValid())
|
||||
if (assetId.IsGraphValid())
|
||||
{
|
||||
EditorGraphRequestBus::EventResult(graphId, assetId.Get()->GetScriptCanvasId(), &EditorGraphRequests::GetGraphCanvasGraphId);
|
||||
}
|
||||
@@ -1199,17 +1199,23 @@ namespace ScriptCanvasEditor
|
||||
return AZ::Success(outTabIndex);
|
||||
}
|
||||
|
||||
outTabIndex = CreateAssetTab(fileAssetId, fileState);
|
||||
auto loadedGraph = LoadFromFile(fileAssetId.Path().c_str());
|
||||
if (!loadedGraph.IsSuccess())
|
||||
{
|
||||
return AZ::Failure(AZStd::string("Failed to load graph at %s", fileAssetId.Path().c_str()));
|
||||
}
|
||||
|
||||
outTabIndex = CreateAssetTab(loadedGraph.GetValue(), fileState);
|
||||
|
||||
if (!m_isRestoringWorkspace)
|
||||
{
|
||||
SetActiveAsset(fileAssetId);
|
||||
SetActiveAsset(loadedGraph.GetValue());
|
||||
}
|
||||
|
||||
if (outTabIndex >= 0)
|
||||
{
|
||||
AddRecentFile(fileAssetId.Path().c_str());
|
||||
OpenScriptCanvasAssetImplementation(fileAssetId, fileState);
|
||||
AddRecentFile(loadedGraph.GetValue().Path().c_str());
|
||||
OpenScriptCanvasAssetImplementation(loadedGraph.GetValue(), fileState);
|
||||
return AZ::Success(outTabIndex);
|
||||
}
|
||||
else
|
||||
@@ -1221,12 +1227,12 @@ namespace ScriptCanvasEditor
|
||||
AZ::Outcome<int, AZStd::string> MainWindow::OpenScriptCanvasAssetImplementation(const SourceHandle& scriptCanvasAsset, Tracker::ScriptCanvasFileState fileState, int tabIndex)
|
||||
{
|
||||
const ScriptCanvasEditor::SourceHandle& fileAssetId = scriptCanvasAsset;
|
||||
if (!fileAssetId.IsValid())
|
||||
if (!fileAssetId.IsDescriptionValid())
|
||||
{
|
||||
return AZ::Failure(AZStd::string("Unable to open asset with invalid asset id"));
|
||||
}
|
||||
|
||||
if (!scriptCanvasAsset.IsValid())
|
||||
if (!scriptCanvasAsset.IsDescriptionValid())
|
||||
{
|
||||
if (!m_isRestoringWorkspace)
|
||||
{
|
||||
@@ -1282,7 +1288,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
AZ::Outcome<int, AZStd::string> MainWindow::OpenScriptCanvasAsset(ScriptCanvasEditor::SourceHandle scriptCanvasAssetId, Tracker::ScriptCanvasFileState fileState, int tabIndex)
|
||||
{
|
||||
if (scriptCanvasAssetId.IsValid())
|
||||
if (scriptCanvasAssetId.IsGraphValid())
|
||||
{
|
||||
return OpenScriptCanvasAssetImplementation(scriptCanvasAssetId, fileState, tabIndex);
|
||||
}
|
||||
@@ -1303,7 +1309,7 @@ namespace ScriptCanvasEditor
|
||||
m_assetCreationRequests.erase(assetId);
|
||||
GeneralAssetNotificationBus::Event(assetId, &GeneralAssetNotifications::OnAssetUnloaded);
|
||||
|
||||
if (assetId.IsValid())
|
||||
if (assetId.IsGraphValid())
|
||||
{
|
||||
// Disconnect scene and asset editor buses
|
||||
GraphCanvas::SceneNotificationBus::MultiHandler::BusDisconnect(assetId.Get()->GetScriptCanvasId());
|
||||
@@ -1379,7 +1385,7 @@ namespace ScriptCanvasEditor
|
||||
void MainWindow::OpenFile(const char* fullPath)
|
||||
{
|
||||
auto tabIndex = m_tabBar->FindTabByPath(fullPath);
|
||||
if (tabIndex.IsValid())
|
||||
if (tabIndex.IsGraphValid())
|
||||
{
|
||||
SetActiveAsset(tabIndex);
|
||||
return;
|
||||
@@ -1699,7 +1705,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
bool MainWindow::SaveAssetImpl(const ScriptCanvasEditor::SourceHandle& inMemoryAssetId, Save save)
|
||||
{
|
||||
if (!inMemoryAssetId.IsValid())
|
||||
if (!inMemoryAssetId.IsGraphValid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -2446,7 +2452,7 @@ namespace ScriptCanvasEditor
|
||||
{
|
||||
AZ::EntityId graphId{};
|
||||
|
||||
if (m_activeGraph.IsValid())
|
||||
if (m_activeGraph.IsGraphValid())
|
||||
{
|
||||
EditorGraphRequestBus::EventResult
|
||||
( graphId, m_activeGraph.Get()->GetScriptCanvasId(), &EditorGraphRequests::GetGraphCanvasGraphId);
|
||||
@@ -2471,7 +2477,7 @@ namespace ScriptCanvasEditor
|
||||
{
|
||||
AZ::EntityId graphId{};
|
||||
|
||||
if (assetId.IsValid())
|
||||
if (assetId.IsGraphValid())
|
||||
{
|
||||
EditorGraphRequestBus::EventResult
|
||||
( graphId, assetId.Get()->GetScriptCanvasId(), &EditorGraphRequests::GetGraphCanvasGraphId);
|
||||
@@ -2482,7 +2488,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
ScriptCanvas::ScriptCanvasId MainWindow::FindScriptCanvasIdByAssetId(const ScriptCanvasEditor::SourceHandle& assetId) const
|
||||
{
|
||||
return assetId.IsValid() ? assetId.Get()->GetScriptCanvasId() : ScriptCanvas::ScriptCanvasId{};
|
||||
return assetId.IsGraphValid() ? assetId.Get()->GetScriptCanvasId() : ScriptCanvas::ScriptCanvasId{};
|
||||
}
|
||||
|
||||
ScriptCanvas::ScriptCanvasId MainWindow::GetScriptCanvasId(const GraphCanvas::GraphId& graphCanvasGraphId) const
|
||||
@@ -2548,14 +2554,14 @@ namespace ScriptCanvasEditor
|
||||
{
|
||||
// Disconnect previous asset
|
||||
AZ::EntityId previousScriptCanvasSceneId;
|
||||
if (previousAsset.IsValid())
|
||||
if (previousAsset.IsGraphValid())
|
||||
{
|
||||
previousScriptCanvasSceneId = previousAsset.Get()->GetScriptCanvasId();
|
||||
GraphCanvas::SceneNotificationBus::MultiHandler::BusDisconnect(previousScriptCanvasSceneId);
|
||||
}
|
||||
|
||||
AZ::EntityId nextAssetGraphCanvasId;
|
||||
if (nextAsset.IsValid())
|
||||
if (nextAsset.IsGraphValid())
|
||||
{
|
||||
// Connect the next asset
|
||||
EditorGraphRequestBus::EventResult(nextAssetGraphCanvasId, nextAsset.Get()->GetScriptCanvasId(), &EditorGraphRequests::GetGraphCanvasGraphId);
|
||||
@@ -2583,7 +2589,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
AssetHelpers::PrintInfo("SetActiveAsset : from: %s to %s", m_activeGraph.ToString().c_str(), fileAssetId.ToString().c_str());
|
||||
|
||||
if (fileAssetId.IsValid())
|
||||
if (fileAssetId.IsGraphValid())
|
||||
{
|
||||
if (m_tabBar->FindTab(fileAssetId) >= 0)
|
||||
{
|
||||
@@ -2596,7 +2602,7 @@ namespace ScriptCanvasEditor
|
||||
}
|
||||
}
|
||||
|
||||
if (m_activeGraph.IsValid())
|
||||
if (m_activeGraph.IsGraphValid())
|
||||
{
|
||||
// If we are saving the asset, the Id may have changed from the in-memory to the file asset Id, in that case,
|
||||
// there's no need to hide the view or remove the widget
|
||||
@@ -2609,7 +2615,7 @@ namespace ScriptCanvasEditor
|
||||
}
|
||||
}
|
||||
|
||||
if (fileAssetId.IsValid())
|
||||
if (fileAssetId.IsGraphValid())
|
||||
{
|
||||
ScriptCanvasEditor::SourceHandle previousAssetId = m_activeGraph;
|
||||
m_activeGraph = fileAssetId;
|
||||
@@ -2631,7 +2637,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
void MainWindow::RefreshActiveAsset()
|
||||
{
|
||||
if (m_activeGraph.IsValid())
|
||||
if (m_activeGraph.IsGraphValid())
|
||||
{
|
||||
AssetHelpers::PrintInfo("RefreshActiveAsset : m_activeGraph (%s)", m_activeGraph.ToString().c_str());
|
||||
if (auto view = m_tabBar->ModOrCreateTabView(m_tabBar->FindTab(m_activeGraph)))
|
||||
@@ -2762,7 +2768,7 @@ namespace ScriptCanvasEditor
|
||||
if (m_isClosingTabs)
|
||||
{
|
||||
if (m_tabBar->count() == 0
|
||||
|| (m_tabBar->count() == 1 && m_skipTabOnClose.IsValid()))
|
||||
|| (m_tabBar->count() == 1 && m_skipTabOnClose.IsGraphValid()))
|
||||
{
|
||||
m_isClosingTabs = false;
|
||||
m_skipTabOnClose.Clear();
|
||||
@@ -3003,7 +3009,7 @@ namespace ScriptCanvasEditor
|
||||
bool hasCopiableSelection = false;
|
||||
bool hasSelection = false;
|
||||
|
||||
if (m_activeGraph.IsValid())
|
||||
if (m_activeGraph.IsGraphValid())
|
||||
{
|
||||
if (graphCanvasGraphId.IsValid())
|
||||
{
|
||||
@@ -3396,17 +3402,17 @@ namespace ScriptCanvasEditor
|
||||
{
|
||||
m_isRestoringWorkspace = false;
|
||||
|
||||
if (m_queuedFocusOverride.IsValid())
|
||||
if (m_queuedFocusOverride.IsGraphValid())
|
||||
{
|
||||
SetActiveAsset(m_queuedFocusOverride);
|
||||
m_queuedFocusOverride.Clear();
|
||||
}
|
||||
else if (lastFocusAsset.IsValid())
|
||||
else if (lastFocusAsset.IsGraphValid())
|
||||
{
|
||||
SetActiveAsset(lastFocusAsset);
|
||||
}
|
||||
|
||||
if (!m_activeGraph.IsValid())
|
||||
if (!m_activeGraph.IsGraphValid())
|
||||
{
|
||||
if (m_tabBar->count() > 0)
|
||||
{
|
||||
@@ -3429,7 +3435,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
void MainWindow::UpdateAssignToSelectionState()
|
||||
{
|
||||
bool buttonEnabled = m_activeGraph.IsValid();
|
||||
bool buttonEnabled = m_activeGraph.IsGraphValid();
|
||||
|
||||
if (buttonEnabled)
|
||||
{
|
||||
@@ -3789,7 +3795,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
OnFileNew();
|
||||
|
||||
if (m_activeGraph.IsValid())
|
||||
if (m_activeGraph.IsGraphValid())
|
||||
{
|
||||
graphId = GetActiveGraphCanvasGraphId();
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace ScriptCanvasEditor
|
||||
SourceHandle Modifier::LoadAsset()
|
||||
{
|
||||
auto& handle = ModCurrentAsset();
|
||||
if (!handle.IsValid())
|
||||
if (!handle.IsGraphValid())
|
||||
{
|
||||
auto outcome = LoadFromFile(handle.Path().c_str());
|
||||
if (outcome.IsSuccess())
|
||||
@@ -158,7 +158,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
ModelNotificationsBus::Broadcast(&ModelNotificationsTraits::OnUpgradeModificationBegin, m_config, ModCurrentAsset());
|
||||
|
||||
if (auto asset = LoadAsset(); asset.IsValid())
|
||||
if (auto asset = LoadAsset(); asset.IsGraphValid())
|
||||
{
|
||||
ModificationNotificationsBus::Handler::BusConnect();
|
||||
m_modifyState = ModifyState::InProgress;
|
||||
|
||||
@@ -132,7 +132,7 @@ namespace ScriptCanvasEditor
|
||||
}
|
||||
else
|
||||
{
|
||||
if (auto asset = LoadAsset(); asset.IsValid())
|
||||
if (auto asset = LoadAsset(); asset.IsGraphValid())
|
||||
{
|
||||
VE_LOG("Scanner: Loaded: %s ", ModCurrentAsset().Path().c_str());
|
||||
FilterAsset(asset);
|
||||
|
||||
@@ -237,16 +237,16 @@ namespace ScriptCanvasEditor
|
||||
return m_id;
|
||||
}
|
||||
|
||||
bool SourceHandle::IsValid() const
|
||||
{
|
||||
return m_data != nullptr;
|
||||
}
|
||||
|
||||
bool SourceHandle::IsValidDescription() const
|
||||
bool SourceHandle::IsDescriptionValid() const
|
||||
{
|
||||
return !m_id.IsNull() && !m_path.empty();
|
||||
}
|
||||
|
||||
bool SourceHandle::IsGraphValid() const
|
||||
{
|
||||
return m_data != nullptr;
|
||||
}
|
||||
|
||||
GraphPtr SourceHandle::Mod() const
|
||||
{
|
||||
return m_data ? m_data->ModEditorGraph() : nullptr;
|
||||
@@ -290,7 +290,7 @@ namespace ScriptCanvasEditor
|
||||
{
|
||||
return AZStd::string::format
|
||||
( "%s, %s, %s"
|
||||
, IsValid() ? "O" : "X"
|
||||
, IsGraphValid() ? "O" : "X"
|
||||
, m_path.empty() ? m_path.c_str() : "<no name>"
|
||||
, m_id.IsNull() ? "<null id>" : m_id.ToString<AZStd::string>().c_str());
|
||||
}
|
||||
|
||||
@@ -342,9 +342,9 @@ namespace ScriptCanvasEditor
|
||||
|
||||
const AZ::Uuid& Id() const;
|
||||
|
||||
bool IsValid() const;
|
||||
bool IsDescriptionValid() const;
|
||||
|
||||
bool IsValidDescription() const;
|
||||
bool IsGraphValid() const;
|
||||
|
||||
GraphPtr Mod() const;
|
||||
|
||||
|
||||
@@ -59,6 +59,8 @@ set(FILES
|
||||
Editor/Components/EditorGraphVariableManagerComponent.cpp
|
||||
Editor/Include/ScriptCanvas/Components/EditorScriptCanvasComponent.h
|
||||
Editor/Components/EditorScriptCanvasComponent.cpp
|
||||
Editor/Include/ScriptCanvas/Components/EditorScriptCanvasComponentSerializer.h
|
||||
Editor/Include/ScriptCanvas/Components/EditorScriptCanvasComponentSerializer.cpp
|
||||
Editor/Components/IconComponent.h
|
||||
Editor/Components/IconComponent.cpp
|
||||
Editor/Include/ScriptCanvas/GraphCanvas/DynamicSlotBus.h
|
||||
|
||||
Reference in New Issue
Block a user