fixed unit tests bugs, removed commented out code, removed loading spam

Signed-off-by: chcurran <82187351+carlitosan@users.noreply.github.com>
This commit is contained in:
chcurran
2021-11-24 18:55:11 -08:00
parent 30bcddc694
commit 132d06b6da
23 changed files with 52 additions and 640 deletions
@@ -16,6 +16,38 @@
#include <ScriptCanvas/Assets/ScriptCanvasFileHandling.h>
#include <ScriptCanvas/Components/EditorGraph.h>
namespace BuildVariableOverridesCpp
{
enum Version
{
EditorAssetRedux,
// add description above
Current
};
bool VersionConverter
( [[maybe_unused]] AZ::SerializeContext& serializeContext
, [[maybe_unused]] AZ::SerializeContext::DataElementNode& rootElement)
{
// #sc_editor_asset
// ScriptCanvasBuilder::BuildVariableOverrides overrides;
// overrides.m_source = SourceHandle(nullptr, assetHolder.GetAssetId().m_guid, {});
//
// for (auto& variable : editableData.GetVariables())
// {
// overrides.m_overrides.push_back(variable.m_graphVariable);
// }
//
// if (!rootElement.AddElementWithData(serializeContext, "runtimeDataOverrides", overrides))
// {
// AZ_Error("ScriptCanvas", false, "EditorScriptCanvasComponent conversion failed: failed to add 'runtimeDataOverrides'");
// return false;
// }
return true;
}
}
namespace ScriptCanvasBuilder
{
void BuildVariableOverrides::Clear()
@@ -109,7 +141,7 @@ namespace ScriptCanvasBuilder
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(reflectContext))
{
serializeContext->Class<BuildVariableOverrides>()
->Version(1)
->Version(BuildVariableOverridesCpp::Version::Current, &BuildVariableOverridesCpp::VersionConverter)
->Field("source", &BuildVariableOverrides::m_source)
->Field("variables", &BuildVariableOverrides::m_variables)
->Field("entityId", &BuildVariableOverrides::m_entityIds)
@@ -49,7 +49,6 @@ namespace ScriptCanvasBuilder
// these two variable lists are all that gets exposed to the edit context
AZStd::vector<ScriptCanvas::GraphVariable> m_overrides;
AZStd::vector<ScriptCanvas::GraphVariable> m_overridesUnused;
// AZStd::vector<size_t> m_entityIdRuntimeInputIndices; since all oSf the entity ids need to go in, they may not need indices
AZStd::vector<BuildVariableOverrides> m_dependencies;
};
@@ -59,10 +59,7 @@ namespace ScriptCanvasBuilder
PrefabIntegration,
CorrectGraphVariableVersion,
ReflectEntityIdNodes,
ForceBuildForDevTest0,
ForceBuildForDevTest1,
ForceBuildForDevTest2,
FixExecutionStateNodeableConstrution,
// add new entries above
Current,
@@ -82,31 +82,6 @@ namespace ScriptCanvasEditor
void ScriptCanvasAssetHolder::OpenEditor() const
{
// #sc_editor_asset
// AzToolsFramework::OpenViewPane(LyViewPane::ScriptCanvas);
//
// AZ::Outcome<int, AZStd::string> openOutcome = AZ::Failure(AZStd::string());
//
// if (m_scriptCanvasAsset.IsReady())
// {
// GeneralRequestBus::BroadcastResult(openOutcome, &GeneralRequests::OpenScriptCanvasAsset, m_scriptCanvasAsset.GetId(), -1);
//
// if (!openOutcome)
// {
// AZ_Warning("Script Canvas", openOutcome, "%s", openOutcome.GetError().data());
// }
// }
// else if (m_ownerId.first.IsValid())
// {
// AzToolsFramework::EntityIdList selectedEntityIds;
// AzToolsFramework::ToolsApplicationRequestBus::BroadcastResult(selectedEntityIds, &AzToolsFramework::ToolsApplicationRequests::GetSelectedEntities);
//
// // Going to bypass the multiple selected entities flow for right now.
// if (selectedEntityIds.size() == 1)
// {
// GeneralRequestBus::Broadcast(&GeneralRequests::CreateScriptCanvasAssetFor, m_ownerId);
// }
// }
}
ScriptCanvas::ScriptCanvasId ScriptCanvasAssetHolder::GetScriptCanvasId() const
@@ -60,109 +60,6 @@ namespace ScriptCanvasEditor
void AssetTracker::SaveAs(AZ::Data::AssetId /*assetId*/, const AZStd::string& /*path*/, Callbacks::OnSave /*onSaveCallback*/)
{
// auto assetIter = m_assetsInUse.find(assetId);
//
// if (assetIter != m_assetsInUse.end())
// {
// auto onSave = [this, assetId, onSaveCallback](bool saveSuccess, AZ::Data::AssetPtr asset, AZ::Data::AssetId previousFileAssetId)
// {
// AZ::Data::AssetId signalId = assetId;
// AZ::Data::AssetId fileAssetId = asset->GetId();
//
// // If there is a previous file Id is valid, it means this is a save-as operation and we need to remap the tracking.
// if (previousFileAssetId.IsValid())
// {
// if (saveSuccess)
// {
// fileAssetId = m_assetsInUse[assetId]->GetFileAssetId();
// m_remappedAsset[asset->GetId()] = fileAssetId;
//
// // Erase the asset first so the smart pointer can deal with it's things.
// m_assetsInUse.erase(fileAssetId);
//
// // Then perform the insert once we know nothing will attempt to delete this while we are operating on it.
// m_assetsInUse[fileAssetId] = m_assetsInUse[assetId];
// m_assetsInUse.erase(assetId);
// }
//
// m_savingAssets.erase(assetId);
// m_savingAssets.insert(fileAssetId);
//
// signalId = fileAssetId;
//
// if (m_queuedCloses.erase(assetId))
// {
// m_queuedCloses.insert(fileAssetId);
// }
//
// auto assetIter = m_assetsInUse.find(fileAssetId);
//
// if (assetIter != m_assetsInUse.end())
// {
// AZStd::invoke(onSaveCallback, saveSuccess, m_assetsInUse[fileAssetId]->GetAsset().Get(), previousFileAssetId);
// }
// else
// {
// AZ_Error("ScriptCanvas", !saveSuccess, "Unable to find Memory Asset for Asset(%s)", fileAssetId.ToString<AZStd::string>().c_str());
// AZStd::invoke(onSaveCallback, saveSuccess, asset, previousFileAssetId);
// }
// }
// else
// {
// if (saveSuccess)
// {
// // This should be the case when we get a save as from a newly created file.
// //
// // If we find the 'memory' asset id in the assets in use. This means this was a new file that was saved.
// // To maintain all of the look-up stuff, we need to treat this like a remapping stage.
// auto assetInUseIter = m_assetsInUse.find(assetId);
// if (assetInUseIter != m_assetsInUse.end())
// {
// fileAssetId = assetInUseIter->second->GetFileAssetId();
//
// if (assetId != fileAssetId)
// {
// m_remappedAsset[assetId] = fileAssetId;
//
// m_assetsInUse.erase(fileAssetId);
// m_assetsInUse[fileAssetId] = AZStd::move(assetInUseIter->second);
// m_assetsInUse.erase(assetId);
//
// m_savingAssets.erase(assetId);
// m_savingAssets.insert(fileAssetId);
//
// if (m_queuedCloses.erase(assetId))
// {
// m_queuedCloses.insert(fileAssetId);
// }
// }
// }
// else
// {
// fileAssetId = CheckAssetId(fileAssetId);
// }
//
// signalId = fileAssetId;
// }
//
// if (onSaveCallback)
// {
// AZStd::invoke(onSaveCallback, saveSuccess, m_assetsInUse[signalId]->GetAsset().Get(), previousFileAssetId);
// }
//
// AssetTrackerNotificationBus::Broadcast(&AssetTrackerNotifications::OnAssetSaved, m_assetsInUse[signalId], saveSuccess);
// }
//
// SignalSaveComplete(signalId);
// };
//
// m_savingAssets.insert(assetId);
// assetIter->second->SaveAs(path, onSave);
// }
// else
// {
// AZ_Assert(false, "Cannot SaveAs into an existing AssetId");
// }
}
bool AssetTracker::Load(AZ::Data::AssetId fileAssetId, AZ::Data::AssetType assetType, Callbacks::OnAssetReadyCallback onAssetReadyCallback)
@@ -23,9 +23,6 @@ namespace ScriptCanvasEditor
{
class ScriptCanvasMemoryAsset;
// MOVE THIS MOSTLY TO TAB BAR, MAIN WINDOW AND THE CANVAS WIDGET
// This class tracks all things related to the assets that the Script Canvas editor
// has in play. It also provides helper functionality to quickly getting asset information
// from GraphCanvas
@@ -155,17 +155,5 @@ namespace ScriptCanvasEditor
using MemoryAssetSystemNotificationBus = AZ::EBus<MemoryAssetSystemNotifications>;
}
class MemoryAssetNotifications
: public AZ::EBusTraits
{
public:
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
using BusIdType = AZ::Data::AssetId;
virtual void OnFileStateChanged(Tracker::ScriptCanvasFileState) {}
};
using MemoryAssetNotificationBus = AZ::EBus<MemoryAssetNotifications>;
//////////////////////////////////////////////////////////////////////////////////////////////////////////
}
@@ -285,8 +285,6 @@ namespace ScriptCanvasEditor
ScriptCanvasEditor::Widget::CanvasWidget* ScriptCanvasMemoryAsset::CreateView(QWidget* /*parent*/)
{
//m_canvasWidget = new Widget::CanvasWidget(m_fileAssetId, parent);
//return m_canvasWidget;
return nullptr;
}
@@ -433,66 +431,11 @@ namespace ScriptCanvasEditor
void ScriptCanvasMemoryAsset::SourceFileFailed(AZStd::string /*relativePath*/, AZStd::string /*scanFolder*/, AZ::Uuid)
{
// AZStd::string fullPath;
// AzFramework::StringFunc::Path::Join(scanFolder.data(), relativePath.data(), fullPath);
// AzFramework::ApplicationRequests::Bus::Broadcast(&AzFramework::ApplicationRequests::NormalizePath, fullPath);
//
// auto assetPathIdIt = AZStd::find(m_pendingSave.begin(), m_pendingSave.end(), fullPath);
//
// if (assetPathIdIt != m_pendingSave.end())
// {
// if (m_onSaveCallback)
// {
// m_onSaveCallback(false, m_inMemoryAsset.Get(), AZ::Data::AssetId());
// m_onSaveCallback = nullptr;
// }
//
// m_pendingSave.erase(assetPathIdIt);
// }
}
void ScriptCanvasMemoryAsset::SavingComplete(const AZStd::string& /*streamName*/, AZ::Uuid /*sourceAssetId*/)
{
// AZStd::string normPath = streamName;
// AzFramework::ApplicationRequests::Bus::Broadcast(&AzFramework::ApplicationRequests::NormalizePath, normPath);
//
// auto assetPathIdIt = AZStd::find(m_pendingSave.begin(), m_pendingSave.end(), normPath);
// if (assetPathIdIt != m_pendingSave.end())
// {
// AZ::Data::AssetId previousFileAssetId;
//
// if (sourceAssetId != m_fileAssetId.m_guid)
// {
// previousFileAssetId = m_fileAssetId;
//
// // The source file has changed, store the AssetId to the canonical asset on file
// SetFileAssetId(sourceAssetId);
//
// }
// else if (!m_fileAssetId.IsValid())
// {
// SetFileAssetId(sourceAssetId);
// }
//
// m_formerGraphIdPair = AZStd::make_pair(m_scriptCanvasId, m_graphId);
//
// m_fileState = Tracker::ScriptCanvasFileState::UNMODIFIED;
//
// m_pendingSave.erase(assetPathIdIt);
//
// m_absolutePath = m_saveAsPath;
// m_saveAsPath.clear();
//
// // Connect to the source asset's bus to monitor for situations we may need to handle
// AZ::Data::AssetBus::MultiHandler::BusConnect(m_inMemoryAsset.GetId());
// AZ::Data::AssetBus::MultiHandler::BusConnect(m_fileAssetId);
//
// if (m_onSaveCallback)
// {
// m_onSaveCallback(true, m_inMemoryAsset.Get(), previousFileAssetId);
// m_onSaveCallback = nullptr;
// }
// }
}
void ScriptCanvasMemoryAsset::FinalizeAssetSave(bool, const AzToolsFramework::SourceControlFileInfo& fileInfo, const AZ::Data::AssetStreamInfo& saveInfo, Callbacks::OnSave onSaveCallback)
@@ -528,17 +471,11 @@ namespace ScriptCanvasEditor
void ScriptCanvasMemoryAsset::SetFileAssetId(const AZ::Data::AssetId& /*fileAssetId*/)
{
// m_fileAssetId = fileAssetId;
//
// if (m_canvasWidget)
// {
// m_canvasWidget->SetAssetId(fileAssetId);
// }
}
void ScriptCanvasMemoryAsset::SignalFileStateChanged()
{
MemoryAssetNotificationBus::Event(m_fileAssetId, &MemoryAssetNotifications::OnFileStateChanged, GetFileState());
}
AZStd::string ScriptCanvasMemoryAsset::MakeTemporaryFilePathForSave(AZStd::string_view targetFilename)
@@ -607,25 +544,6 @@ namespace ScriptCanvasEditor
bool AssetSaveFinalizer::ValidateStatus(const AzToolsFramework::SourceControlFileInfo& /*fileInfo*/)
{
// auto fileIO = AZ::IO::FileIOBase::GetInstance();
// if (fileInfo.IsLockedByOther())
// {
// AZ_Error("Script Canvas", !fileInfo.IsLockedByOther(), "The file is already exclusively opened by another user: %s", fileInfo.m_filePath.data());
// AZStd::invoke(m_onSave, false, m_inMemoryAsset, m_fileAssetId);
// return false;
// }
// else if (fileInfo.IsReadOnly() && fileIO->Exists(fileInfo.m_filePath.c_str()))
// {
// AZ_Error("Script Canvas", !fileInfo.IsReadOnly(), "File %s is read-only. It cannot be saved."
// " If this file is in Perforce it may not have been checked out by the Source Control API.", fileInfo.m_filePath.data());
// AZStd::invoke(m_onSave, false, m_inMemoryAsset, m_fileAssetId);
// return false;
// }
// else if (m_saving)
// {
// AZ_Warning("Script Canvas", false, "Trying to save the same file twice. Will result in one save callback being ignored.");
// return false;
// }
return true;
}
@@ -51,8 +51,6 @@ 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"));
@@ -54,11 +54,7 @@ namespace ScriptCanvasEditor
if (assetSystem->GetSourceInfoBySourcePath(fullPathHandle.Path().c_str(), assetInfo, watchFolder) && assetInfo.m_assetId.IsValid())
{
if (assetInfo.m_assetId.m_guid != source.Id())
{
AZ_TracePrintf("ScriptCanvas", "This is what I don't get");
}
AZ_Warning("ScriptCanvas", assetInfo.m_assetId.m_guid == source.Id(), "SourceHandle completion produced conflicting AssetId.");
auto path = fullPathHandle.Path();
return SourceHandle(source, assetInfo.m_assetId.m_guid, path.MakePreferred());
}
@@ -163,13 +163,13 @@ namespace ScriptCanvasEditor
{
ScopedOutputSuppression([[maybe_unused]] bool suppressState = true)
{
// AZ::Debug::TraceMessageBus::BroadcastResult(m_oldSuppression, &AZ::Debug::TraceMessageEvents::OnOutput, "", "");
// TraceSuppressionBus::Broadcast(&TraceSuppressionRequests::SuppressAllOutput, suppressState);
AZ::Debug::TraceMessageBus::BroadcastResult(m_oldSuppression, &AZ::Debug::TraceMessageEvents::OnOutput, "", "");
TraceSuppressionBus::Broadcast(&TraceSuppressionRequests::SuppressAllOutput, suppressState);
}
~ScopedOutputSuppression()
{
// TraceSuppressionBus::Broadcast(&TraceSuppressionRequests::SuppressAllOutput, m_oldSuppression);
TraceSuppressionBus::Broadcast(&TraceSuppressionRequests::SuppressAllOutput, m_oldSuppression);
}
private:
bool m_oldSuppression = false;
@@ -54,7 +54,6 @@ namespace ScriptCanvasEditor
NEW,
MODIFIED,
UNMODIFIED,
// #sc_editor_asset restore this
SOURCE_REMOVED,
INVALID = -1
};
@@ -140,10 +140,6 @@ namespace ScriptCanvasEditor
void ReleaseVariableCounter(AZ::u32 variableCounter) override;
////
// RuntimeBus
//AZ::Data::AssetId GetAssetId() const override { return m_assetId; }
////
// GraphCanvas::GraphModelRequestBus
void RequestUndoPoint() override;
@@ -223,9 +219,6 @@ namespace ScriptCanvasEditor
void OnGraphCanvasNodeCreated(const AZ::EntityId& nodeId) override;
///////////////////////////
// EditorGraphRequestBus
// void SetAssetId(const AZ::Data::AssetId& assetId) override { m_assetId = assetId; }
void CreateGraphCanvasScene() override;
void ClearGraphCanvasScene() override;
void DisplayGraphCanvasScene() override;
@@ -251,16 +251,6 @@ namespace ScriptCanvasEditor
{
if (index >= 0 && index < count())
{
QVariant tabdata = tabData(index);
if (tabdata.isValid())
{
// #sc_editor_asset fix tabData
auto tabAssetId = tabdata.value<GraphTabMetadata>();
//MemoryAssetNotificationBus::MultiHandler::BusDisconnect(tabAssetId);
//AssetTrackerRequestBus::Broadcast(&AssetTrackerRequests::ClearView, tabAssetId);
}
qobject_cast<AzQtComponents::TabWidget*>(parent())->removeTab(index);
}
}
@@ -271,8 +261,6 @@ namespace ScriptCanvasEditor
{
Q_EMIT TabCloseNoButton(i);
}
MemoryAssetNotificationBus::MultiHandler::BusDisconnect();
}
void GraphTabBar::OnContextMenu(const QPoint& point)
@@ -289,8 +277,6 @@ namespace ScriptCanvasEditor
auto tabAssetId = tabdata.value<GraphTabMetadata>();
Tracker::ScriptCanvasFileState fileState = Tracker::ScriptCanvasFileState::INVALID;
//AssetTrackerRequestBus::BroadcastResult(fileState , &AssetTrackerRequests::GetFileState, tabAssetId);
isModified = fileState == Tracker::ScriptCanvasFileState::NEW || fileState == Tracker::ScriptCanvasFileState::MODIFIED;
}
@@ -362,22 +348,6 @@ namespace ScriptCanvasEditor
AzQtComponents::TabBar::mouseReleaseEvent(event);
}
void GraphTabBar::OnFileStateChanged(Tracker::ScriptCanvasFileState )
{
// #sc_editor_asset
// const AZ::Data::AssetId* fileAssetId = MemoryAssetNotificationBus::GetCurrentBusId();
// if (fileAssetId)
// {
// SetFileState((*fileAssetId), fileState);
//
// if (FindTab((*fileAssetId)) == currentIndex())
// {
// Q_EMIT OnActiveFileStateChanged();
// }
// }
}
void GraphTabBar::SetTabText(int tabIndex, const QString& path, Tracker::ScriptCanvasFileState fileState)
{
if (tabIndex >= 0 && tabIndex < count())
@@ -42,7 +42,6 @@ namespace ScriptCanvasEditor
class GraphTabBar
: public AzQtComponents::TabBar
, public MemoryAssetNotificationBus::MultiHandler
{
Q_OBJECT
@@ -63,8 +62,6 @@ namespace ScriptCanvasEditor
int InsertGraphTab(int tabIndex, ScriptCanvasEditor::SourceHandle assetId, Tracker::ScriptCanvasFileState fileState);
bool SelectTab(ScriptCanvasEditor::SourceHandle assetId);
// void ConfigureTab(int tabIndex, ScriptCanvasEditor::SourceHandle fileAssetId, const AZStd::string& tabName);
int FindTab(ScriptCanvasEditor::SourceHandle assetId) const;
ScriptCanvasEditor::SourceHandle FindTabByPath(AZStd::string_view path) const;
ScriptCanvasEditor::SourceHandle FindAssetId(int tabIndex);
@@ -78,10 +75,6 @@ namespace ScriptCanvasEditor
void mouseReleaseEvent(QMouseEvent* event) override;
// MemoryAssetNotifications
void OnFileStateChanged(Tracker::ScriptCanvasFileState fileState) override;
////
// Updates the tab at the supplied index with the GraphTabMetadata
// The host widget field of the tabMetadata is not used and will not overwrite the tab data
void SetTabText(int tabIndex, const QString& path, Tracker::ScriptCanvasFileState fileState = Tracker::ScriptCanvasFileState::INVALID);
@@ -137,17 +137,6 @@ namespace ScriptCanvasEditor
m_additionTimer.start();
}
}
if (m_updatePolicy == UpdatePolicy::SingleTime)
{
// #sc_editor_asset
// treeItem = CreateChildNodeWithoutAddSignal<ExecutionLogTreeItem>(loggingDataId, nodeType, graphInfo, nodeId);
}
else
{
// #sc_editor_asset
// treeItem = CreateChildNode<ExecutionLogTreeItem>(loggingDataId, nodeType, graphInfo, nodeId);
}
return treeItem;
}
@@ -207,9 +196,6 @@ namespace ScriptCanvasEditor
AZ::NamedEntityId entityName;
// #sc_editor_asset restore this
//LoggingDataRequestBus::EventResult(entityName, m_loggingDataId, &LoggingDataRequests::FindNamedEntityId, m_graphInfo.m_runtimeEntity);
m_sourceEntityName = entityName.ToString().c_str();
m_displayName = nodeId.m_name.c_str();
@@ -514,7 +500,6 @@ namespace ScriptCanvasEditor
const ScriptCanvas::GraphIdentifier& ExecutionLogTreeItem::GetGraphIdentifier() const
{
// #sc_editor_asset
return m_graphIdentifier;
}
@@ -1665,42 +1665,6 @@ namespace ScriptCanvasEditor
return SaveAssetImpl(m_activeGraph, Save::As);
}
/*
bool MainWindow::SaveAssetImpl_OLD(const ScriptCanvasEditor::SourceHandle& assetId, const Callbacks::OnSave& saveCB)
{
if (!assetId.IsValid())
{
return false;
}
// TODO: Set graph read-only to prevent edits during save
bool saveSuccessful = false;
Tracker::ScriptCanvasFileState fileState = GetAssetFileState(assetId);
if (fileState == Tracker::ScriptCanvasFileState::NEW)
{
saveSuccessful = SaveAssetImpl(assetId, saveCB);
}
else if (fileState == Tracker::ScriptCanvasFileState::MODIFIED
|| fileState == Tracker::ScriptCanvasFileState::SOURCE_REMOVED)
{
SaveAs(assetId.Path(), assetId, saveCB);
saveSuccessful = true;
}
return saveSuccessful;
}
*/
// 1. SaveAssetImpl
// 2. SaveAs
// // 3. OnSaveCallback
// SaveAsEnd
// SaveAssetImpl end
bool MainWindow::SaveAssetImpl(const ScriptCanvasEditor::SourceHandle& inMemoryAssetId, Save save)
{
if (!inMemoryAssetId.IsGraphValid())
@@ -1768,11 +1732,6 @@ namespace ScriptCanvasEditor
AZ::IO::FileIOBase::GetInstance()->ResolvePath("@engroot@", assetRootChar.data(), assetRootChar.size());
assetRoot = assetRootChar.data();
// if (!AZ::StringFunc::StartsWith(filePath, assetRoot))
// {
// QMessageBox::information(this, "Unable to Save", AZStd::string::format("You must select a path within the current project\n\n%s", assetRoot.c_str()).c_str());
// }
// else
if (AzFramework::StringFunc::Path::GetFileName(filePath.c_str(), fileName))
{
isValidFileName = !(fileName.empty());
@@ -1924,14 +1883,6 @@ namespace ScriptCanvasEditor
{
m_tabBar->setCurrentIndex(saveTabIndex);
}
else
{
// // Something weird happens with our saving. Where we are relying on these scene changes being called.
// ScriptCanvasEditor::SourceHandle previousAssetId = m_activeGraph;
//
// OnChangeActiveGraphTab(ScriptCanvasEditor::SourceHandle());
// OnChangeActiveGraphTab(previousAssetId);
}
UpdateAssignToSelectionState();
@@ -2365,6 +2316,7 @@ namespace ScriptCanvasEditor
GraphCanvas::ViewRequestBus::Event(viewId, &GraphCanvas::ViewRequests::CenterOnEndOfChain);
}
// #sc_editor_asset
void MainWindow::UpdateWorkspaceStatus(const ScriptCanvasMemoryAsset& /*memoryAsset*/)
{
// only occurs on file open, do it there, if necessary
@@ -2656,16 +2608,6 @@ namespace ScriptCanvasEditor
void MainWindow::Clear()
{
m_tabBar->CloseAllTabs();
// #sc_editor_asset
//
// AssetTrackerRequests::AssetList assets;
// AssetTrackerRequestBus::BroadcastResult(assets, &AssetTrackerRequests::GetAssets);
//
// for (auto asset : assets)
// {
// RemoveScriptCanvasAsset(asset->GetAsset().GetId());
// }
SetActiveAsset({});
}
@@ -4093,32 +4035,6 @@ namespace ScriptCanvasEditor
void MainWindow::PrepareAssetForSave(const ScriptCanvasEditor::SourceHandle& /*assetId*/)
{
/*
ScriptCanvasMemoryAsset::pointer memoryAsset;
AssetTrackerRequestBus::BroadcastResult(memoryAsset, &AssetTrackerRequests::GetAsset, assetId);
if (memoryAsset)
{
AZ::EntityId graphId = memoryAsset->GetGraphId();
AZ::EntityId scriptCanvasId = memoryAsset->GetScriptCanvasId();
AZ::Entity* entity = nullptr;
GraphRequestBus::EventResult(entity, scriptCanvasId, &GraphRequests::GetGraphEntity);
if (entity)
{
GraphCanvas::GraphModelRequestBus::Event(graphId, &GraphCanvas::GraphModelRequests::OnSaveDataDirtied, entity->GetId());
}
GraphCanvas::GraphModelRequestBus::Event(graphId, &GraphCanvas::GraphModelRequests::OnSaveDataDirtied, graphId);
ScriptCanvasEditor::Graph* graph = AZ::EntityUtils::FindFirstDerivedComponent<ScriptCanvasEditor::Graph>(entity);
if (graph)
{
graph->MarkVersion();
}
}
*/
}
void MainWindow::RestartAutoTimerSave(bool forceTimer)
@@ -323,13 +323,7 @@ namespace ScriptCanvasEditor
m_view->tableWidget->setCellWidget(rowIndex, static_cast<int>(ColumnAction), upgradeButton);
}
char resolvedBuffer[AZ_MAX_PATH_LEN] = { 0 };
AZStd::string path = AZStd::string::format("@devroot@/%s", assetInfo.Path().c_str());
AZ::IO::FileIOBase::GetInstance()->ResolvePath(path.c_str(), resolvedBuffer, AZ_MAX_PATH_LEN);
AZ::StringFunc::Path::GetFullPath(resolvedBuffer, path);
AZ::StringFunc::Path::Normalize(path);
bool result = false;
AZ::Data::AssetInfo info;
AZStd::string watchFolder;
@@ -72,19 +72,16 @@ namespace ScriptCanvas
componentElementNode.AddElementWithData(context, "m_assetType", azrtti_typeid<RuntimeAsset>());
}
if (componentElementNode.GetVersion() <= GraphCpp::GraphVersion::RemoveFunctionGraphMarker)
if (auto subElement = componentElementNode.FindElement(AZ_CRC_CE("isFunctionGraph")); subElement > 0)
{
componentElementNode.RemoveElementByName(AZ_CRC_CE("isFunctionGraph"));
componentElementNode.RemoveElement(subElement);
}
if (componentElementNode.GetVersion() < GraphCpp::GraphVersion::FixupVersionDataTypeId)
if (auto subElement = componentElementNode.FindSubElement(AZ_CRC_CE("versionData")))
{
if (auto subElement = componentElementNode.FindSubElement(AZ_CRC_CE("versionData")))
if (subElement->GetId() == azrtti_typeid<SlotId>())
{
if (subElement->GetId() == azrtti_typeid<SlotId>())
{
componentElementNode.RemoveElementByName(AZ_CRC_CE("versionData"));
}
componentElementNode.RemoveElementByName(AZ_CRC_CE("versionData"));
}
}
@@ -22,16 +22,12 @@ namespace ScriptCanvas
Nodeable::Nodeable()
: m_noOpFunctor(&NodeableOutCpp::NoOp)
{
AZ_TracePrintf("SCDB", "How many times does this get called? Because it should....NOT GET CALLED!");
}
{}
Nodeable::Nodeable(ExecutionStateWeakPtr executionState)
: m_noOpFunctor(&NodeableOutCpp::NoOp)
, m_executionState(executionState)
{
AZ_TracePrintf("SCDB", "How many times does this get called 2?");
}
{}
#if !defined(RELEASE)
void Nodeable::CallOut(size_t index, AZ::BehaviorValueParameter* resultBVP, AZ::BehaviorValueParameter* argsBVPs, int numArguments) const
@@ -68,9 +68,7 @@ namespace ExecutionInterpretedAPICpp
{
if (lua_isstring(lua, -1))
{
AZStd::string errorResult = lua_tostring(lua, -1);
AZ_TracePrintf("ScriptCanvas", errorResult.c_str());
AZ::ScriptContext::FromNativeContext(lua)->Error(AZ::ScriptContext::ErrorType::Error, true, "%s", lua_tostring(lua, -1));
AZ::ScriptContext::FromNativeContext(lua)->Error(AZ::ScriptContext::ErrorType::Error, true, lua_tostring(lua, -1));
}
else
{
@@ -403,51 +401,7 @@ namespace ScriptCanvas
// \note: the the object is being constructed, and is assumed to never leave or re-enter Lua again
AZ_Assert(lua_isuserdata(lua, -2) && !lua_islightuserdata(lua, -2), "Error in compiled lua file, 1st argument to OverrideNodeableMetatable is not userdata (Nodeable)");
AZ_Assert(lua_istable(lua, -1), "Error in compiled lua file, 2nd argument to OverrideNodeableMetatable is not a Lua table");
/* table is in the stack at index 't' */
if (lua_istable(lua, -1))
{
lua_getfield(lua, -1, "__index");
if (lua_istable(lua, -1))
{
int t = -2;
AZStd::string tableGuts;
lua_pushnil(lua);
/* first key */
while (lua_next(lua, t) != 0)
{
/* uses 'key' (at index -2) and 'value' (at index -1) */
if (lua_type(lua, -2) == LUA_TSTRING)
{
size_t len;
tableGuts += AZStd::string::format("%s - %s\n",
lua_tolstring(lua, -2, &len),
lua_typename(lua, lua_type(lua, -1)));
}
else if (lua_type(lua, -2) == LUA_TNUMBER)
{
tableGuts += AZStd::string::format("%f - %s\n",
lua_tonumber(lua, -2),
lua_typename(lua, lua_type(lua, -1)));
}
else
{
tableGuts += AZStd::string::format("%s - %s\n",
lua_typename(lua, lua_type(lua, -2)),
lua_typename(lua, lua_type(lua, -1)));
}
/* removes 'value'; keeps 'key' for next iteration */
lua_pop(lua, 1);
}
AZ_TracePrintf("SCDB", tableGuts.c_str());
}
lua_pop(lua, 1);
}
[[maybe_unused]] auto userData = reinterpret_cast<AZ::LuaUserData*>(lua_touserdata(lua, -2));
AZ_Assert(userData && userData->magicData == AZ_CRC_CE("AZLuaUserData"), "this isn't user data");
// Lua: LuaUserData::nodeable, class_mt
@@ -111,75 +111,13 @@ namespace ScriptCanvas
auto& lua = m_luaState;
// Lua:
lua_rawgeti(lua, LUA_REGISTRYINDEX, registryIndex);
if (!lua_isuserdata(lua, -1))
{
AZ_TracePrintf("SCDB", "No light userdata");
}
// Lua: instance
lua_getmetatable(lua, -1);
if (!lua_istable(lua, -1))
{
AZ_TracePrintf("SCDB", "no metatable");
}
/* table is in the stack at index 't' */
if (lua_istable(lua, -1))
{
int t = -2;
AZStd::string tableGuts;
lua_pushnil(lua);
/* first key */
while (lua_next(lua, t) != 0)
{
/* uses 'key' (at index -2) and 'value' (at index -1) */
if (lua_type(lua, -2) == LUA_TSTRING)
{
size_t len;
tableGuts += AZStd::string::format("%s - %s\n",
lua_tolstring(lua, -2, &len),
lua_typename(lua, lua_type(lua, -1)));
}
else if (lua_type(lua, -2) == LUA_TNUMBER)
{
tableGuts += AZStd::string::format("%f - %s\n",
lua_tonumber(lua, -2),
lua_typename(lua, lua_type(lua, -1)));
}
else
{
tableGuts += AZStd::string::format("%s - %s\n",
lua_typename(lua, lua_type(lua, -2)),
lua_typename(lua, lua_type(lua, -1)));
}
/* removes 'value'; keeps 'key' for next iteration */
lua_pop(lua, 1);
}
AZ_TracePrintf("SCDB", tableGuts.c_str());
}
// Lua: instance, instance_mt
lua_pop (lua, 1);
// Lua: instance
lua_getfield(lua, -1, Grammar::k_OnGraphStartFunctionName);
// Lua: instance, graph_VM.k_OnGraphStartFunctionName
if (!lua_isfunction(lua, -1))
{
AZ_TracePrintf("SCDB", "No function");
}
lua_pushvalue(lua, -2);
if (!lua_isuserdata(lua, -1))
{
AZ_TracePrintf("SCDB", "No light userdata");
}
// Lua: instance, graph_VM.k_OnGraphStartFunctionName, instance
const int result = Execution::InterpretedSafeCall(lua, 1, 0);
// Lua: instance ?
// Lua: instance, ?
if (result == LUA_OK)
{
// Lua: instance
@@ -25,126 +25,6 @@ using namespace ScriptCanvasTests;
using namespace TestNodes;
using namespace ScriptCanvas::Execution;
// TODO: This fails to compile on Linux only
//ScriptCanvas::Grammar::SubgraphInterface* CreateExecutionMap(AZ::BehaviorContext& behaviorContext)
//{
// using namespace ScriptCanvas;
// using namespace ScriptCanvas::Grammar;
//
// auto ins = CreateInsFromBehaviorContextMethods("TestNodeableObject", behaviorContext, { "Branch" } );
// auto branchOutVoidTrue = CreateOut<Data::BooleanType, const Data::StringType&>("BranchTrue", { "condition", "message" });
// auto branchOutVoidFalse = CreateOut<Data::BooleanType, const Data::StringType&, const Data::Vector3Type&>("BranchFalse", { "condition", "message", "vector" });
//
// auto branchOut = FindInByName("Branch", ins);
//
// EXPECT_NE(branchOut, nullptr);
// if (branchOut)
// {
// branchOut->outs.emplace_back(AZStd::move(branchOutVoidTrue));
// branchOut->outs.emplace_back(AZStd::move(branchOutVoidFalse));
// }
//
// return aznew SubgraphInterface(AZStd::move(ins));
//}
TEST_F(ScriptCanvasTestFixture, TestLuaObjectOrientation)
{
using namespace ScriptCanvas;
using namespace ScriptCanvas::Grammar;
AZ::ScriptContext sc;
sc.BindTo(m_behaviorContext);
RegisterAPI(sc.NativeContext());
EXPECT_TRUE(sc.Execute(
R"LUA(
assert(Nodeable ~= nil, 'Nodeable was nill')
assert(Nodeable.__call ~= nil, 'Nodeable.__call was nil')
assert(type(Nodeable.__call) == 'function', 'Nodeable.__call was not a function')
local nodeable = Nodeable()
assert(nodeable ~= nil, 'nodeable was nil')
assert(type(nodeable) == "userdata", 'nodeable not userdata')
local SubGraph = {}
SubGraph.s_name = "SubGraphery"
SubGraph.s_createdCount = 0
function SubGraph:IncrementCreated()
SubGraph.s_createdCount = 1 + SubGraph.s_createdCount
end
setmetatable(SubGraph, { __index = Nodeable }) -- exposed through BehaviorContext
local SubGraphInstanceMetatable = { __index = SubGraph }
assert(getmetatable(SubGraph).__index == Nodeable, 'getmetatable(SubGraph).__index = Nodeable')
assert(type(getmetatable(SubGraph).__index) == 'table', "type(getmetatable(SubGraph).__index) ~= 'table'")
function SubGraph.new() -- Add executionState input here and to Nodeable()
-- now individual instance values can be initialized
local instance = OverrideNodeableMetatable(Nodeable(), SubGraphInstanceMetatable)
assert(type(instance.s_createdCount) == 'number', 'subgraph.s_createdCount was not a number')
instance:IncrementCreated()
instance.name = 'SubGraph '..tostring(instance.s_createdCount)
return instance
end
function SubGraph.newTable() -- Add executionState input here and to Nodeable()
-- now individual instance values can be initialized
local instance = setmetatable({}, SubGraphInstanceMetatable)
-- assert(getmetatable(instance) == SubGraphInstanceMetatable, "subgraphT")
assert(type(instance.s_createdCount) == 'number', 'subgraphT.s_createdCount was not a number')
instance:IncrementCreated()
instance.name = 'SubGraph '..tostring(instance.s_createdCount)
return instance
end
function SubGraph:Foo()
return "I, " .. tostring(self.name) .. ", am a user function"
end
local subgraphT = SubGraph.newTable()
assert(subgraphT ~= nil, "subgraphT was nil")
assert(type(subgraphT) == 'table', 'subgraphT was not a table')
assert(type(subgraphT.IsActive)== 'function', "subgraphT IsActive was not a function")
assert(type(subgraphT.Foo) == 'function', 'subgraphT was not a function')
local subgraphTResult = subgraphT:Foo()
assert(subgraphTResult == "I, SubGraph 1, am a user function", 'subgraphT did not return the right results:' .. tostring(subgraphTResult))
assert(subgraphT.s_createdCount == 1, "subgraphT created count was not one: ".. tostring(subgraphT.s_createdCount))
subgraphT = SubGraph.newTable()
assert(subgraphT.s_createdCount == 2, "subgraphT created count was not two: ".. tostring(subgraphT.s_createdCount))
local subgraph = SubGraph.new()
assert(subgraph ~= nil, "subgraph was nil")
assert(type(subgraph) == 'userdata', 'was not userdata')
assert(type(subgraph.IsActive)== 'function', "IsActive was not a function")
assert(not subgraph.IsActive(subgraph), "did not inherit properly")
assert(not subgraph:IsActive(), "did not inherit properly")
assert(type(subgraph.Foo) == 'function', 'was not a function')
local subgraphResult = subgraph:Foo()
assert(subgraphResult == "I, SubGraph 3, am a user function", 'subgraph:Foo() did not return the right results: ' .. tostring(subgraphResult))
assert(subgraph.s_createdCount == 3, "created count was not three: "..tostring(subgraph.s_createdCount))
local subgraph2 = SubGraph.new()
assert(subgraph2 ~= nil, "subgraph2 was nil")
assert(type(subgraph2) == 'userdata', 'subgraph2 was not userdata')
assert(type(subgraph2.IsActive)== 'function', "subgraph2 IsActive was not a function")
assert(not subgraph2.IsActive(subgraph2), "subgraph2 did not inherit properly")
assert(not subgraph2:IsActive(), "subgraph2 did not inherit properly")
assert(type(subgraph2.Foo) == 'function', 'subgraph2 was not a function')
local subgraph2Result = subgraph2:Foo()
assert(subgraph2Result == "I, SubGraph 4, am a user function", 'subgraph2:Foo() did not return the right results: ' .. tostring(subgraph2Result))
assert(subgraph2.s_createdCount == 4, "created count was not three: "..tostring(subgraph2.s_createdCount))
return SubGraph
)LUA"
));
}
//
// TEST_F(ScriptCanvasTestFixture, NativeNodeableStack)
// {
// TestNodeableObject nodeable;