Merge pull request #4329 from aws-lumberyard-dev/carlitosan/development
Refactor and bug fix Version Explorer (which automatically versions/upgrades ScriptCanvas Editor files).
This commit is contained in:
@@ -67,7 +67,7 @@ namespace ScriptCanvas
|
||||
|
||||
void ReceiveScriptEvent::PopulateAsset(AZ::Data::Asset<ScriptEvents::ScriptEventsAsset> asset, SlotIdMapping& populationMapping)
|
||||
{
|
||||
if (CreateHandler(asset))
|
||||
if (InitializeDefinition(asset))
|
||||
{
|
||||
if (!CreateEbus())
|
||||
{
|
||||
@@ -140,7 +140,6 @@ namespace ScriptCanvas
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ReceiveScriptEvent::InitializeEvent(AZ::Data::Asset<ScriptEvents::ScriptEventsAsset> asset, int eventIndex, SlotIdMapping& populationMapping)
|
||||
{
|
||||
if (!m_handler)
|
||||
@@ -353,6 +352,13 @@ namespace ScriptCanvas
|
||||
|
||||
AZStd::optional<size_t> ReceiveScriptEvent::GetEventIndex(AZStd::string eventName) const
|
||||
{
|
||||
if (!m_handler)
|
||||
{
|
||||
const_cast<ReceiveScriptEvent*>(this)->InitializeDefinition(m_asset);
|
||||
const_cast<ReceiveScriptEvent*>(this)->CreateEbus();
|
||||
}
|
||||
|
||||
AZ_Error("ScriptCanvas", m_handler != nullptr, "GetEventIndex called and handler was not created");
|
||||
return m_handler ? AZStd::optional<size_t>(m_handler->GetFunctionIndex(eventName.c_str())) : AZStd::nullopt;
|
||||
}
|
||||
|
||||
@@ -490,15 +496,10 @@ namespace ScriptCanvas
|
||||
return m_definition.IsAddressRequired() || (slot && slot->GetDataType().IsValid());
|
||||
}
|
||||
|
||||
bool ReceiveScriptEvent::CreateHandler(AZ::Data::Asset<ScriptEvents::ScriptEventsAsset> asset)
|
||||
bool ReceiveScriptEvent::InitializeDefinition(AZ::Data::Asset<ScriptEvents::ScriptEventsAsset> asset)
|
||||
{
|
||||
AZStd::lock_guard<AZStd::recursive_mutex> lock(m_mutex);
|
||||
|
||||
if (m_handler)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!asset)
|
||||
{
|
||||
return false;
|
||||
@@ -518,12 +519,11 @@ namespace ScriptCanvas
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
void ReceiveScriptEvent::OnScriptEventReady(const AZ::Data::Asset<ScriptEvents::ScriptEventsAsset>& asset)
|
||||
{
|
||||
if (CreateHandler(asset))
|
||||
if (InitializeDefinition(asset))
|
||||
{
|
||||
CompleteInitialize(asset);
|
||||
}
|
||||
@@ -531,7 +531,7 @@ namespace ScriptCanvas
|
||||
|
||||
bool ReceiveScriptEvent::CreateEbus()
|
||||
{
|
||||
if (!m_ebus)
|
||||
if (!m_ebus || !m_handler)
|
||||
{
|
||||
AZ::BehaviorContext* behaviorContext = nullptr;
|
||||
AZ::ComponentApplicationBus::BroadcastResult(behaviorContext, &AZ::ComponentApplicationBus::Events::GetBehaviorContext);
|
||||
@@ -547,13 +547,11 @@ namespace ScriptCanvas
|
||||
AZ_Assert(m_ebus, "Behavior Context EBus does not exist: %s", m_definition.GetName().c_str());
|
||||
AZ_Assert(m_ebus->m_createHandler, "The ebus %s has no create handler!", m_definition.GetName().c_str());
|
||||
AZ_Assert(m_ebus->m_destroyHandler, "The ebus %s has no destroy handler!", m_definition.GetName().c_str());
|
||||
|
||||
AZ_Verify(m_ebus->m_createHandler->InvokeResult(m_handler, &m_definition), "Behavior Context EBus handler creation failed %s", m_definition.GetName().c_str());
|
||||
|
||||
AZ_Assert(m_handler, "Ebus create handler failed %s", m_definition.GetName().c_str());
|
||||
}
|
||||
|
||||
return true;
|
||||
return m_ebus != nullptr && m_handler != nullptr;
|
||||
}
|
||||
|
||||
bool ReceiveScriptEvent::IsOutOfDate(const VersionData& graphVersion) const
|
||||
@@ -597,7 +595,6 @@ namespace ScriptCanvas
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
AZStd::string ReceiveScriptEvent::GetUpdateString() const
|
||||
{
|
||||
if (m_ebus)
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace ScriptCanvas
|
||||
|
||||
Internal::ScriptEventEntry ConfigureEbusEntry(const ScriptEvents::Method& methodDefinition, const AZ::BehaviorEBusHandler::BusForwarderEvent& event, SlotIdMapping& populationMapping);
|
||||
|
||||
bool CreateHandler(AZ::Data::Asset<ScriptEvents::ScriptEventsAsset> asset);
|
||||
bool InitializeDefinition(AZ::Data::Asset<ScriptEvents::ScriptEventsAsset> asset);
|
||||
void CompleteInitialize(AZ::Data::Asset<ScriptEvents::ScriptEventsAsset> asset);
|
||||
void PopulateAsset(AZ::Data::Asset<ScriptEvents::ScriptEventsAsset> asset, SlotIdMapping& populationMapping);
|
||||
bool m_eventInitComplete = false;
|
||||
@@ -120,7 +120,6 @@ namespace ScriptCanvas
|
||||
bool m_autoConnectToGraphOwner = true;
|
||||
|
||||
bool m_connected;
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,11 +122,8 @@ namespace ScriptCanvas
|
||||
|
||||
void ScriptEventBase::OnActivate()
|
||||
{
|
||||
if (!m_asset || m_asset.GetStatus() == AZ::Data::AssetData::AssetStatus::NotLoaded)
|
||||
{
|
||||
m_asset = AZ::Data::AssetManager::Instance().GetAsset<ScriptEvents::ScriptEventsAsset>(m_scriptEventAssetId, AZ::Data::AssetLoadBehavior::PreLoad);
|
||||
m_asset.BlockUntilLoadComplete();
|
||||
}
|
||||
m_asset = AZ::Data::AssetManager::Instance().GetAsset<ScriptEvents::ScriptEventsAsset>(m_scriptEventAssetId, AZ::Data::AssetLoadBehavior::PreLoad);
|
||||
m_asset.BlockUntilLoadComplete();
|
||||
}
|
||||
|
||||
void ScriptEventBase::OnAssetReady(AZ::Data::Asset<AZ::Data::AssetData> asset)
|
||||
|
||||
@@ -246,8 +246,7 @@ namespace ScriptCanvas
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorList errors = { AZStd::string("provide translation failure details") };
|
||||
return AZ::Failure(errors);
|
||||
return AZ::Failure(translation.MoveErrors());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -874,7 +873,13 @@ namespace ScriptCanvas
|
||||
AZStd::optional<size_t> eventIndex = ebusHandling->m_node->GetEventIndex(nameAndEventThread.first);
|
||||
if (!eventIndex)
|
||||
{
|
||||
AddError(nullptr, aznew Internal::ParseError(ebusHandling->m_node->GetEntityId(), AZStd::string::format("EBus handler did not return a valid index for event %s", nameAndEventThread.first.c_str())));
|
||||
AddError(nullptr,
|
||||
aznew Internal::ParseError(
|
||||
ebusHandling->m_node->GetEntityId()
|
||||
, AZStd::string::format
|
||||
( "EBus Handler %s did not return a valid index for event %s"
|
||||
, ebusHandling->m_ebusName.c_str()
|
||||
, nameAndEventThread.first.c_str())));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -107,27 +107,9 @@ namespace ScriptCanvas
|
||||
m_translationDuration = AZStd::chrono::microseconds(AZStd::chrono::system_clock::now() - m_translationStartTime).count();
|
||||
}
|
||||
|
||||
AZStd::string GraphToX::ResolveScope(const AZStd::vector<AZStd::string>& namespaces)
|
||||
AZStd::vector<ValidationConstPtr>&& GraphToX::MoveErrors()
|
||||
{
|
||||
AZStd::string resolution;
|
||||
|
||||
if (!namespaces.empty())
|
||||
{
|
||||
resolution = Grammar::ToIdentifier(namespaces[0]);
|
||||
|
||||
for (size_t index = 1; index < namespaces.size(); ++index)
|
||||
{
|
||||
resolution += m_configuration.m_lexicalScopeDelimiter;
|
||||
resolution += Grammar::ToIdentifier(namespaces[index]);
|
||||
}
|
||||
}
|
||||
|
||||
return resolution;
|
||||
}
|
||||
|
||||
void GraphToX::SingleLineComment(Writer& writer)
|
||||
{
|
||||
writer.Write(m_configuration.m_singleLineComment);
|
||||
return AZStd::move(m_errors);
|
||||
}
|
||||
|
||||
void GraphToX::OpenBlockComment(Writer& writer)
|
||||
@@ -160,6 +142,29 @@ namespace ScriptCanvas
|
||||
writer.Indent();
|
||||
}
|
||||
|
||||
AZStd::string GraphToX::ResolveScope(const AZStd::vector<AZStd::string>& namespaces)
|
||||
{
|
||||
AZStd::string resolution;
|
||||
|
||||
if (!namespaces.empty())
|
||||
{
|
||||
resolution = Grammar::ToIdentifier(namespaces[0]);
|
||||
|
||||
for (size_t index = 1; index < namespaces.size(); ++index)
|
||||
{
|
||||
resolution += m_configuration.m_lexicalScopeDelimiter;
|
||||
resolution += Grammar::ToIdentifier(namespaces[index]);
|
||||
}
|
||||
}
|
||||
|
||||
return resolution;
|
||||
}
|
||||
|
||||
void GraphToX::SingleLineComment(Writer& writer)
|
||||
{
|
||||
writer.Write(m_configuration.m_singleLineComment);
|
||||
}
|
||||
|
||||
void GraphToX::WriteCopyright(Writer& writer)
|
||||
{
|
||||
OpenBlockComment(writer);
|
||||
|
||||
@@ -51,12 +51,13 @@ namespace ScriptCanvas
|
||||
AZStd::string_view GetGraphName() const;
|
||||
AZStd::string_view GetFullPath() const;
|
||||
AZStd::sys_time_t GetTranslationDuration() const;
|
||||
AZStd::string ResolveScope(const AZStd::vector<AZStd::string>& namespaces);
|
||||
void SingleLineComment(Writer& writer);
|
||||
AZStd::vector<ValidationConstPtr>&& MoveErrors();
|
||||
void OpenBlockComment(Writer& writer);
|
||||
void OpenFunctionBlock(Writer& writer);
|
||||
void OpenNamespace(Writer& writer, AZStd::string_view ns);
|
||||
void OpenScope(Writer& writer);
|
||||
AZStd::string ResolveScope(const AZStd::vector<AZStd::string>& namespaces);
|
||||
void SingleLineComment(Writer& writer);
|
||||
void WriteCopyright(Writer& writer);
|
||||
void WriteDoNotModify(Writer& writer);
|
||||
void WriteLastWritten(Writer& writer);
|
||||
|
||||
@@ -72,6 +72,15 @@ namespace ScriptCanvas
|
||||
resultString += entry->GetDescription();
|
||||
}
|
||||
|
||||
for (const auto& errors : m_errors)
|
||||
{
|
||||
for (auto& entry : errors.second)
|
||||
{
|
||||
resultString += "* ";
|
||||
resultString += entry->GetDescription();
|
||||
}
|
||||
}
|
||||
|
||||
return resultString;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,10 +12,11 @@
|
||||
#include <AzCore/Script/ScriptAsset.h>
|
||||
#include <AzCore/std/any.h>
|
||||
#include <ScriptCanvas/Core/Core.h>
|
||||
#include <ScriptCanvas/Data/Data.h>
|
||||
#include <ScriptCanvas/Core/SubgraphInterface.h>
|
||||
#include <ScriptCanvas/Grammar/PrimitivesDeclarations.h>
|
||||
#include <ScriptCanvas/Data/Data.h>
|
||||
#include <ScriptCanvas/Debugger/ValidationEvents/ValidationEvent.h>
|
||||
#include <ScriptCanvas/Grammar/DebugMap.h>
|
||||
#include <ScriptCanvas/Grammar/PrimitivesDeclarations.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -85,7 +86,7 @@ namespace ScriptCanvas
|
||||
AZStd::sys_time_t m_duration;
|
||||
};
|
||||
|
||||
using ErrorList = AZStd::vector<AZStd::string>;
|
||||
using ErrorList = AZStd::vector<ValidationConstPtr>;
|
||||
using Errors = AZStd::unordered_map<TargetFlags, ErrorList>;
|
||||
using Translations = AZStd::unordered_map<TargetFlags, TargetResult>;
|
||||
|
||||
@@ -102,7 +103,6 @@ namespace ScriptCanvas
|
||||
const AZStd::sys_time_t m_translationDuration;
|
||||
|
||||
Result(AZStd::string invalidSourceInfo);
|
||||
Result(Result&& source);
|
||||
Result(Grammar::AbstractCodeModelConstPtr model);
|
||||
Result(Grammar::AbstractCodeModelConstPtr model, Translations&& translations, Errors&& errors);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user