clean up open pipeline to render graph
Signed-off-by: chcurran <82187351+carlitosan@users.noreply.github.com>
This commit is contained in:
@@ -58,111 +58,111 @@ namespace ScriptCanvasEditor
|
||||
SaveAs(assetId, {}, onSaveCallback);
|
||||
}
|
||||
|
||||
void AssetTracker::SaveAs(AZ::Data::AssetId assetId, const AZStd::string& path, Callbacks::OnSave onSaveCallback)
|
||||
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");
|
||||
}
|
||||
// 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)
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace ScriptCanvasEditor
|
||||
namespace Callbacks
|
||||
{
|
||||
//! Callback used to know when a save operation failed or succeeded
|
||||
using OnSave = AZStd::function<void(bool saveSuccess, AZ::Data::AssetPtr, AZ::Data::AssetId previousFileAssetId)>;
|
||||
using OnSave = AZStd::function<void(bool saveSuccess, const SourceHandle& attempt, const SourceHandle& previous)>;
|
||||
|
||||
using OnAssetReadyCallback = AZStd::function<void(ScriptCanvasMemoryAsset&)>;
|
||||
using OnAssetCreatedCallback = OnAssetReadyCallback;
|
||||
|
||||
@@ -124,6 +124,12 @@ namespace ScriptCanvasEditor
|
||||
}
|
||||
}
|
||||
|
||||
if (auto entity = scriptCanvasData->GetScriptCanvasEntity())
|
||||
{
|
||||
entity->Init();
|
||||
entity->Activate();
|
||||
}
|
||||
|
||||
return AZ::Success(ScriptCanvasEditor::SourceHandle(scriptCanvasData, {}, path));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,10 +283,11 @@ namespace ScriptCanvasEditor
|
||||
m_undoHelper = AZStd::make_unique<UndoHelper>(*this);
|
||||
}
|
||||
|
||||
ScriptCanvasEditor::Widget::CanvasWidget* ScriptCanvasMemoryAsset::CreateView(QWidget* parent)
|
||||
ScriptCanvasEditor::Widget::CanvasWidget* ScriptCanvasMemoryAsset::CreateView(QWidget* /*parent*/)
|
||||
{
|
||||
m_canvasWidget = new Widget::CanvasWidget(m_fileAssetId, parent);
|
||||
return m_canvasWidget;
|
||||
//m_canvasWidget = new Widget::CanvasWidget(m_fileAssetId, parent);
|
||||
//return m_canvasWidget;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ScriptCanvasMemoryAsset::ClearView()
|
||||
@@ -430,68 +431,68 @@ namespace ScriptCanvasEditor
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptCanvasMemoryAsset::SourceFileFailed(AZStd::string relativePath, AZStd::string scanFolder, AZ::Uuid)
|
||||
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);
|
||||
}
|
||||
// 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)
|
||||
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;
|
||||
}
|
||||
}
|
||||
// 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)
|
||||
@@ -525,14 +526,14 @@ namespace ScriptCanvasEditor
|
||||
UndoNotificationBus::Broadcast(&UndoNotifications::OnCanRedoChanged, m_undoState->m_undoStack->CanRedo());
|
||||
}
|
||||
|
||||
void ScriptCanvasMemoryAsset::SetFileAssetId(const AZ::Data::AssetId& fileAssetId)
|
||||
void ScriptCanvasMemoryAsset::SetFileAssetId(const AZ::Data::AssetId& /*fileAssetId*/)
|
||||
{
|
||||
m_fileAssetId = fileAssetId;
|
||||
|
||||
if (m_canvasWidget)
|
||||
{
|
||||
m_canvasWidget->SetAssetId(fileAssetId);
|
||||
}
|
||||
// m_fileAssetId = fileAssetId;
|
||||
//
|
||||
// if (m_canvasWidget)
|
||||
// {
|
||||
// m_canvasWidget->SetAssetId(fileAssetId);
|
||||
// }
|
||||
}
|
||||
|
||||
void ScriptCanvasMemoryAsset::SignalFileStateChanged()
|
||||
@@ -604,27 +605,27 @@ namespace ScriptCanvasEditor
|
||||
// AssetSaveFinalizer
|
||||
//////////////////////////////////////
|
||||
|
||||
bool AssetSaveFinalizer::ValidateStatus(const AzToolsFramework::SourceControlFileInfo& fileInfo)
|
||||
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;
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ namespace ScriptCanvasEditor
|
||||
public:
|
||||
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
|
||||
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
|
||||
using BusIdType = AZ::Data::AssetId;
|
||||
using BusIdType = SourceHandle;
|
||||
|
||||
virtual void OnAssetVisualized() {};
|
||||
virtual void OnAssetUnloaded() {};
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace ScriptCanvasEditor
|
||||
{
|
||||
namespace Widget
|
||||
{
|
||||
CanvasWidget::CanvasWidget(const AZ::Data::AssetId& assetId, QWidget* parent)
|
||||
CanvasWidget::CanvasWidget(const ScriptCanvasEditor::SourceHandle& assetId, QWidget* parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::CanvasWidget())
|
||||
, m_attached(false)
|
||||
@@ -78,7 +78,7 @@ namespace ScriptCanvasEditor
|
||||
m_scriptCanvasId = scriptCanvasId;
|
||||
}
|
||||
|
||||
void CanvasWidget::SetAssetId(const AZ::Data::AssetId& assetId)
|
||||
void CanvasWidget::SetAssetId(const ScriptCanvasEditor::SourceHandle& assetId)
|
||||
{
|
||||
m_assetId = assetId;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ AZ_POP_DISABLE_WARNING
|
||||
#include <AzCore/Asset/AssetCommon.h>
|
||||
|
||||
#include <GraphCanvas/Components/ViewBus.h>
|
||||
#include <ScriptCanvas/Core/Core.h>
|
||||
#endif
|
||||
|
||||
class QVBoxLayout;
|
||||
@@ -46,13 +47,13 @@ namespace ScriptCanvasEditor
|
||||
Q_OBJECT
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(CanvasWidget, AZ::SystemAllocator, 0);
|
||||
CanvasWidget(const AZ::Data::AssetId& assetId, QWidget* parent = nullptr);
|
||||
CanvasWidget(const ScriptCanvasEditor::SourceHandle& assetId, QWidget* parent = nullptr);
|
||||
~CanvasWidget() override;
|
||||
|
||||
void SetDefaultBorderColor(AZ::Color defaultBorderColor);
|
||||
void ShowScene(const ScriptCanvas::ScriptCanvasId& scriptCanvasId);
|
||||
|
||||
void SetAssetId(const AZ::Data::AssetId& assetId);
|
||||
void SetAssetId(const ScriptCanvasEditor::SourceHandle& assetId);
|
||||
|
||||
const GraphCanvas::ViewId& GetViewId() const;
|
||||
|
||||
@@ -69,7 +70,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
void SetupGraphicsView();
|
||||
|
||||
AZ::Data::AssetId m_assetId;
|
||||
ScriptCanvasEditor::SourceHandle m_assetId;
|
||||
|
||||
AZStd::unique_ptr<Ui::CanvasWidget> ui;
|
||||
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
|
||||
#include <ScriptCanvas/Asset/AssetDescription.h>
|
||||
|
||||
#include <Editor/Include/ScriptCanvas/Components/EditorGraph.h>
|
||||
|
||||
namespace ScriptCanvasEditor
|
||||
{
|
||||
namespace Widget
|
||||
@@ -31,7 +33,7 @@ namespace ScriptCanvasEditor
|
||||
// GraphTabBar
|
||||
////////////////
|
||||
|
||||
GraphTabBar::GraphTabBar(QWidget* parent /*= nullptr*/)
|
||||
GraphTabBar::GraphTabBar(QWidget* parent)
|
||||
: AzQtComponents::TabBar(parent)
|
||||
{
|
||||
setTabsClosable(true);
|
||||
@@ -49,40 +51,81 @@ namespace ScriptCanvasEditor
|
||||
InsertGraphTab(count(), assetId);
|
||||
}
|
||||
|
||||
int GraphTabBar::InsertGraphTab([[maybe_unused]] int tabIndex, [[maybe_unused]] ScriptCanvasEditor::SourceHandle assetId)
|
||||
void GraphTabBar::ClearTabView(int tabIndex)
|
||||
{
|
||||
// #sc_editor_asset
|
||||
// if (!SelectTab(assetId))
|
||||
// {
|
||||
// AZStd::shared_ptr<ScriptCanvasMemoryAsset> memoryAsset;
|
||||
// AssetTrackerRequestBus::BroadcastResult(memoryAsset, &AssetTrackerRequests::GetAsset, assetId);
|
||||
//
|
||||
// if (memoryAsset)
|
||||
// {
|
||||
// ScriptCanvas::AssetDescription assetDescription = memoryAsset->GetAsset().Get()->GetAssetDescription();
|
||||
//
|
||||
// QIcon tabIcon = QIcon(assetDescription.GetIconPathImpl());
|
||||
// int newTabIndex = qobject_cast<AzQtComponents::TabWidget*>(parent())->insertTab(tabIndex, new QWidget(), tabIcon, "");
|
||||
//
|
||||
// CanvasWidget* canvasWidget = memoryAsset->CreateView(this);
|
||||
//
|
||||
// canvasWidget->SetDefaultBorderColor(assetDescription.GetDisplayColorImpl());
|
||||
//
|
||||
// AZStd::string tabName;
|
||||
// AzFramework::StringFunc::Path::GetFileName(memoryAsset->GetAbsolutePath().c_str(), tabName);
|
||||
//
|
||||
// ConfigureTab(newTabIndex, assetId, tabName);
|
||||
//
|
||||
// // new graphs will need to use their in-memory assetid which we'll need to update
|
||||
// // upon saving the asset
|
||||
// if (!memoryAsset->GetFileAssetId().IsValid())
|
||||
// {
|
||||
// setTabData(newTabIndex, QVariant::fromValue(memoryAsset->GetId()));
|
||||
// }
|
||||
//
|
||||
// return newTabIndex;
|
||||
// }
|
||||
// }
|
||||
if (tabIndex < count())
|
||||
{
|
||||
if (QVariant tabDataVariant = tabData(tabIndex); tabDataVariant.isValid())
|
||||
{
|
||||
GraphTabMetadata replacement = tabDataVariant.value<GraphTabMetadata>();
|
||||
if (replacement.m_canvasWidget)
|
||||
{
|
||||
delete replacement.m_canvasWidget;
|
||||
replacement.m_canvasWidget = nullptr;
|
||||
tabDataVariant.setValue(replacement);
|
||||
setTabData(tabIndex, tabDataVariant);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CanvasWidget* GraphTabBar::ModOrCreateTabView(int tabIndex)
|
||||
{
|
||||
if (tabIndex < count())
|
||||
{
|
||||
if (QVariant tabDataVariant = tabData(tabIndex); tabDataVariant.isValid())
|
||||
{
|
||||
if (!tabDataVariant.value<GraphTabMetadata>().m_canvasWidget)
|
||||
{
|
||||
CanvasWidget* canvasWidget = new CanvasWidget(tabDataVariant.value<GraphTabMetadata>().m_assetId, this);
|
||||
canvasWidget->SetDefaultBorderColor(ScriptCanvasAssetDescription().GetDisplayColorImpl());
|
||||
GraphTabMetadata replacement = tabDataVariant.value<GraphTabMetadata>();
|
||||
replacement.m_canvasWidget = canvasWidget;
|
||||
tabDataVariant.setValue(replacement);
|
||||
setTabData(tabIndex, tabDataVariant);
|
||||
}
|
||||
|
||||
return tabDataVariant.value<GraphTabMetadata>().m_canvasWidget;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CanvasWidget* GraphTabBar::ModTabView(int tabIndex)
|
||||
{
|
||||
if (tabIndex < count())
|
||||
{
|
||||
if (QVariant tabDataVariant = tabData(tabIndex); tabDataVariant.isValid())
|
||||
{
|
||||
return tabDataVariant.value<GraphTabMetadata>().m_canvasWidget;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int GraphTabBar::InsertGraphTab(int tabIndex, ScriptCanvasEditor::SourceHandle assetId)
|
||||
{
|
||||
if (!SelectTab(assetId))
|
||||
{
|
||||
QIcon tabIcon = QIcon(ScriptCanvasAssetDescription().GetIconPathImpl());
|
||||
tabIndex = qobject_cast<AzQtComponents::TabWidget*>(parent())->insertTab(tabIndex, new QWidget(), tabIcon, "");
|
||||
GraphTabMetadata metaData;
|
||||
CanvasWidget* canvasWidget = new CanvasWidget(assetId, this);
|
||||
canvasWidget->SetDefaultBorderColor(ScriptCanvasAssetDescription().GetDisplayColorImpl());
|
||||
metaData.m_canvasWidget = canvasWidget;
|
||||
|
||||
AZStd::string tabName;
|
||||
AzFramework::StringFunc::Path::GetFileName(assetId.Path().c_str(), tabName);
|
||||
|
||||
// #sc_editor_asset filestate
|
||||
Tracker::ScriptCanvasFileState fileState = Tracker::ScriptCanvasFileState::INVALID;
|
||||
// AssetTrackerRequestBus::BroadcastResult(fileState, &AssetTrackerRequests::GetFileState, fileAssetId);
|
||||
SetTabText(tabIndex, tabName.c_str(), fileState);
|
||||
setTabData(tabIndex, QVariant::fromValue(metaData));
|
||||
return tabIndex;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
@@ -98,31 +141,10 @@ namespace ScriptCanvasEditor
|
||||
return false;
|
||||
}
|
||||
|
||||
void GraphTabBar::ConfigureTab(int tabIndex, ScriptCanvasEditor::SourceHandle fileAssetId, const AZStd::string& tabName)
|
||||
{
|
||||
if (fileAssetId.IsValid())
|
||||
{
|
||||
QVariant tabDataVariant = tabData(tabIndex);
|
||||
|
||||
if (tabDataVariant.isValid())
|
||||
{
|
||||
// #se_editor_asset
|
||||
// auto tabAssetId = tabDataVariant.value<AZ::Data::AssetId>();
|
||||
// MemoryAssetNotificationBus::MultiHandler::BusDisconnect(tabAssetId);
|
||||
}
|
||||
|
||||
setTabData(tabIndex, QVariant::fromValue(fileAssetId));
|
||||
|
||||
// #se_editor_asset
|
||||
// MemoryAssetNotificationBus::MultiHandler::BusConnect(fileAssetId);
|
||||
}
|
||||
|
||||
// #se_editor_asset
|
||||
Tracker::ScriptCanvasFileState fileState = Tracker::ScriptCanvasFileState::INVALID;
|
||||
// AssetTrackerRequestBus::BroadcastResult(fileState, &AssetTrackerRequests::GetFileState, fileAssetId);
|
||||
|
||||
SetTabText(tabIndex, tabName.c_str(), fileState);
|
||||
}
|
||||
// void GraphTabBar::ConfigureTab(int /*tabIndex*/, ScriptCanvasEditor::SourceHandle fileAssetId, const AZStd::string& tabName)
|
||||
// {
|
||||
//
|
||||
// }
|
||||
|
||||
int GraphTabBar::FindTab(ScriptCanvasEditor::SourceHandle assetId) const
|
||||
{
|
||||
@@ -131,8 +153,8 @@ namespace ScriptCanvasEditor
|
||||
QVariant tabDataVariant = tabData(tabIndex);
|
||||
if (tabDataVariant.isValid())
|
||||
{
|
||||
auto tabAssetId = tabDataVariant.value<ScriptCanvasEditor::SourceHandle>();
|
||||
if (tabAssetId == assetId)
|
||||
auto tabAssetId = tabDataVariant.value<GraphTabMetadata>();
|
||||
if (tabAssetId.m_assetId == assetId)
|
||||
{
|
||||
return tabIndex;
|
||||
}
|
||||
@@ -141,18 +163,56 @@ namespace ScriptCanvasEditor
|
||||
return -1;
|
||||
}
|
||||
|
||||
ScriptCanvasEditor::SourceHandle GraphTabBar::FindTabByPath(AZStd::string_view path) const
|
||||
{
|
||||
ScriptCanvasEditor::SourceHandle candidate(nullptr, {}, path);
|
||||
|
||||
for (int index = 0; index < count(); ++index)
|
||||
{
|
||||
QVariant tabdata = tabData(index);
|
||||
if (tabdata.isValid())
|
||||
{
|
||||
auto tabAssetId = tabdata.value<GraphTabMetadata>();
|
||||
if (tabAssetId.m_assetId.AnyEquals(candidate))
|
||||
{
|
||||
return tabAssetId.m_assetId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
ScriptCanvasEditor::SourceHandle GraphTabBar::FindAssetId(int tabIndex)
|
||||
{
|
||||
QVariant dataVariant = tabData(tabIndex);
|
||||
if (dataVariant.isValid())
|
||||
{
|
||||
auto tabAssetId = dataVariant.value<ScriptCanvasEditor::SourceHandle>();
|
||||
return tabAssetId;
|
||||
auto tabAssetId = dataVariant.value<GraphTabMetadata>();
|
||||
return tabAssetId.m_assetId;
|
||||
}
|
||||
|
||||
return ScriptCanvasEditor::SourceHandle();
|
||||
}
|
||||
|
||||
ScriptCanvas::ScriptCanvasId GraphTabBar::FindScriptCanvasIdFromGraphCanvasId(const GraphCanvas::GraphId& graphCanvasGraphId) const
|
||||
{
|
||||
for (int index = 0; index < count(); ++index)
|
||||
{
|
||||
QVariant tabdata = tabData(index);
|
||||
if (tabdata.isValid())
|
||||
{
|
||||
auto tabAssetId = tabdata.value<GraphTabMetadata>();
|
||||
if (tabAssetId.m_assetId && tabAssetId.m_assetId.Get()->GetGraphCanvasGraphId() == graphCanvasGraphId)
|
||||
{
|
||||
return tabAssetId.m_assetId.Get()->GetScriptCanvasId();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ScriptCanvas::ScriptCanvasId{};
|
||||
}
|
||||
|
||||
void GraphTabBar::CloseTab(int index)
|
||||
{
|
||||
if (index >= 0 && index < count())
|
||||
@@ -160,10 +220,11 @@ namespace ScriptCanvasEditor
|
||||
QVariant tabdata = tabData(index);
|
||||
if (tabdata.isValid())
|
||||
{
|
||||
auto tabAssetId = tabdata.value<AZ::Data::AssetId>();
|
||||
// #sc_editor_asset fix tabData
|
||||
auto tabAssetId = tabdata.value<GraphTabMetadata>();
|
||||
|
||||
MemoryAssetNotificationBus::MultiHandler::BusDisconnect(tabAssetId);
|
||||
AssetTrackerRequestBus::Broadcast(&AssetTrackerRequests::ClearView, tabAssetId);
|
||||
//MemoryAssetNotificationBus::MultiHandler::BusDisconnect(tabAssetId);
|
||||
//AssetTrackerRequestBus::Broadcast(&AssetTrackerRequests::ClearView, tabAssetId);
|
||||
}
|
||||
|
||||
qobject_cast<AzQtComponents::TabWidget*>(parent())->removeTab(index);
|
||||
@@ -191,10 +252,10 @@ namespace ScriptCanvasEditor
|
||||
QVariant tabdata = tabData(tabIndex);
|
||||
if (tabdata.isValid())
|
||||
{
|
||||
auto tabAssetId = tabdata.value<AZ::Data::AssetId>();
|
||||
auto tabAssetId = tabdata.value<GraphTabMetadata>();
|
||||
|
||||
Tracker::ScriptCanvasFileState fileState;
|
||||
AssetTrackerRequestBus::BroadcastResult(fileState , &AssetTrackerRequests::GetFileState, tabAssetId);
|
||||
Tracker::ScriptCanvasFileState fileState = Tracker::ScriptCanvasFileState::INVALID;
|
||||
//AssetTrackerRequestBus::BroadcastResult(fileState , &AssetTrackerRequests::GetFileState, tabAssetId);
|
||||
|
||||
isModified = fileState == Tracker::ScriptCanvasFileState::NEW || fileState == Tracker::ScriptCanvasFileState::MODIFIED;
|
||||
}
|
||||
@@ -269,7 +330,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
void GraphTabBar::OnFileStateChanged(Tracker::ScriptCanvasFileState )
|
||||
{
|
||||
// #se_editor_asset
|
||||
// #sc_editor_asset
|
||||
// const AZ::Data::AssetId* fileAssetId = MemoryAssetNotificationBus::GetCurrentBusId();
|
||||
|
||||
// if (fileAssetId)
|
||||
@@ -332,7 +393,7 @@ namespace ScriptCanvasEditor
|
||||
return;
|
||||
}
|
||||
|
||||
auto assetId = tabdata.value<AZ::Data::AssetId>();
|
||||
auto assetId = tabdata.value<GraphTabMetadata>();
|
||||
|
||||
// #sc_editor_asset
|
||||
// ScriptCanvasEditor::GeneralRequestBus::Broadcast(&ScriptCanvasEditor::GeneralRequests::OnChangeActiveGraphTab, assetId);
|
||||
@@ -346,7 +407,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
void GraphTabBar::SetFileState(ScriptCanvasEditor::SourceHandle, Tracker::ScriptCanvasFileState )
|
||||
{
|
||||
// #se_editor_asset
|
||||
// #sc_editor_asset
|
||||
// int index = FindTab(assetId);
|
||||
|
||||
// if (index >= 0 && index < count())
|
||||
@@ -354,7 +415,7 @@ namespace ScriptCanvasEditor
|
||||
// QVariant tabdata = tabData(index);
|
||||
// if (tabdata.isValid())
|
||||
// {
|
||||
// auto tabAssetId = tabdata.value<AZ::Data::AssetId>();
|
||||
// auto tabAssetId = tabdata.value<GraphTabMetadata>();
|
||||
//
|
||||
// AZStd::string tabName;
|
||||
// AssetTrackerRequestBus::BroadcastResult(tabName, &AssetTrackerRequests::GetTabName, tabAssetId);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <AzCore/Component/EntityId.h>
|
||||
#include <AzCore/Asset/AssetCommon.h>
|
||||
|
||||
#include <ScriptCanvas/Core/Core.h>
|
||||
#include <Editor/Assets/ScriptCanvasAssetTracker.h>
|
||||
#endif
|
||||
|
||||
@@ -26,11 +27,13 @@ namespace ScriptCanvasEditor
|
||||
{
|
||||
namespace Widget
|
||||
{
|
||||
class CanvasWidget;
|
||||
|
||||
struct GraphTabMetadata
|
||||
{
|
||||
AZ::Data::AssetId m_assetId;
|
||||
SourceHandle m_assetId;
|
||||
QWidget* m_hostWidget = nullptr;
|
||||
QString m_tabName;
|
||||
CanvasWidget* m_canvasWidget = nullptr;
|
||||
Tracker::ScriptCanvasFileState m_fileState = Tracker::ScriptCanvasFileState::INVALID;
|
||||
};
|
||||
|
||||
@@ -46,16 +49,22 @@ namespace ScriptCanvasEditor
|
||||
~GraphTabBar() override = default;
|
||||
|
||||
void AddGraphTab(ScriptCanvasEditor::SourceHandle assetId);
|
||||
void CloseTab(int index);
|
||||
void CloseAllTabs();
|
||||
|
||||
int InsertGraphTab(int tabIndex, ScriptCanvasEditor::SourceHandle assetId);
|
||||
bool SelectTab(ScriptCanvasEditor::SourceHandle assetId);
|
||||
|
||||
void ConfigureTab(int tabIndex, ScriptCanvasEditor::SourceHandle fileAssetId, const AZStd::string& tabName);
|
||||
// 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);
|
||||
ScriptCanvas::ScriptCanvasId FindScriptCanvasIdFromGraphCanvasId(const GraphCanvas::GraphId& graphCanvasGraphId) const;
|
||||
|
||||
void CloseTab(int index);
|
||||
void CloseAllTabs();
|
||||
void ClearTabView(int tabIndex);
|
||||
CanvasWidget* ModOrCreateTabView(int tabIndex);
|
||||
CanvasWidget* ModTabView(int tabIndex);
|
||||
|
||||
void OnContextMenu(const QPoint& point);
|
||||
|
||||
|
||||
@@ -122,7 +122,11 @@ namespace ScriptCanvasEditor
|
||||
{
|
||||
}
|
||||
|
||||
ExecutionLogTreeItem* DebugLogRootItem::CreateExecutionItem(const LoggingDataId& loggingDataId, const ScriptCanvas::NodeTypeIdentifier& nodeType, const ScriptCanvas::GraphInfo& graphInfo, const ScriptCanvas::NamedNodeId& nodeId)
|
||||
ExecutionLogTreeItem* DebugLogRootItem::CreateExecutionItem
|
||||
( [[maybe_unused]] const LoggingDataId& loggingDataId
|
||||
, [[maybe_unused]] const ScriptCanvas::NodeTypeIdentifier& nodeType
|
||||
, [[maybe_unused]] const ScriptCanvas::GraphInfo& graphInfo
|
||||
, [[maybe_unused]] const ScriptCanvas::NamedNodeId& nodeId)
|
||||
{
|
||||
ExecutionLogTreeItem* treeItem = nullptr;
|
||||
|
||||
@@ -136,11 +140,13 @@ namespace ScriptCanvasEditor
|
||||
|
||||
if (m_updatePolicy == UpdatePolicy::SingleTime)
|
||||
{
|
||||
treeItem = CreateChildNodeWithoutAddSignal<ExecutionLogTreeItem>(loggingDataId, nodeType, graphInfo, nodeId);
|
||||
// #sc_editor_asset
|
||||
// treeItem = CreateChildNodeWithoutAddSignal<ExecutionLogTreeItem>(loggingDataId, nodeType, graphInfo, nodeId);
|
||||
}
|
||||
else
|
||||
{
|
||||
treeItem = CreateChildNode<ExecutionLogTreeItem>(loggingDataId, nodeType, graphInfo, nodeId);
|
||||
// #sc_editor_asset
|
||||
// treeItem = CreateChildNode<ExecutionLogTreeItem>(loggingDataId, nodeType, graphInfo, nodeId);
|
||||
}
|
||||
|
||||
return treeItem;
|
||||
@@ -185,7 +191,11 @@ namespace ScriptCanvasEditor
|
||||
// ExecutionLogTreeItem
|
||||
/////////////////////////
|
||||
|
||||
ExecutionLogTreeItem::ExecutionLogTreeItem(const LoggingDataId& loggingDataId, const ScriptCanvas::NodeTypeIdentifier& nodeType, const ScriptCanvas::GraphInfo& graphInfo, const ScriptCanvas::NamedNodeId& nodeId)
|
||||
ExecutionLogTreeItem::ExecutionLogTreeItem
|
||||
( const LoggingDataId& loggingDataId
|
||||
, const ScriptCanvas::NodeTypeIdentifier& nodeType
|
||||
, const SourceHandle& graphInfo
|
||||
, const ScriptCanvas::NamedNodeId& nodeId)
|
||||
: m_loggingDataId(loggingDataId)
|
||||
, m_nodeType(nodeType)
|
||||
, m_graphInfo(graphInfo)
|
||||
@@ -196,7 +206,9 @@ namespace ScriptCanvasEditor
|
||||
m_paletteConfiguration.SetColorPalette("MethodNodeTitlePalette");
|
||||
|
||||
AZ::NamedEntityId entityName;
|
||||
LoggingDataRequestBus::EventResult(entityName, m_loggingDataId, &LoggingDataRequests::FindNamedEntityId, m_graphInfo.m_runtimeEntity);
|
||||
|
||||
// #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();
|
||||
@@ -207,7 +219,7 @@ namespace ScriptCanvasEditor
|
||||
m_inputName = "---";
|
||||
m_outputName = "---";
|
||||
|
||||
GeneralAssetNotificationBus::Handler::BusConnect(GetAssetId());
|
||||
GeneralAssetNotificationBus::Handler::BusConnect(graphInfo);
|
||||
}
|
||||
|
||||
QVariant ExecutionLogTreeItem::Data(const QModelIndex& index, int role) const
|
||||
@@ -502,12 +514,13 @@ namespace ScriptCanvasEditor
|
||||
|
||||
const ScriptCanvas::GraphIdentifier& ExecutionLogTreeItem::GetGraphIdentifier() const
|
||||
{
|
||||
return m_graphInfo.m_graphIdentifier;
|
||||
// #sc_editor_asset
|
||||
return m_graphIdentifier;
|
||||
}
|
||||
|
||||
const AZ::Data::AssetId& ExecutionLogTreeItem::GetAssetId() const
|
||||
AZ::Data::AssetId ExecutionLogTreeItem::GetAssetId() const
|
||||
{
|
||||
return m_graphInfo.m_graphIdentifier.m_assetId;
|
||||
return m_graphInfo.Id();
|
||||
}
|
||||
|
||||
AZ::EntityId ExecutionLogTreeItem::GetScriptCanvasAssetNodeId() const
|
||||
|
||||
@@ -131,7 +131,12 @@ namespace ScriptCanvasEditor
|
||||
AZ_CLASS_ALLOCATOR(ExecutionLogTreeItem, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(ExecutionLogTreeItem, "{71139142-A30C-4A16-81CC-D51314AEAF7D}", DebugLogTreeItem);
|
||||
|
||||
ExecutionLogTreeItem(const LoggingDataId& loggingDataId, const ScriptCanvas::NodeTypeIdentifier& nodeType, const ScriptCanvas::GraphInfo& graphInfo, const ScriptCanvas::NamedNodeId& nodeId);
|
||||
ExecutionLogTreeItem
|
||||
( const LoggingDataId& loggingDataId
|
||||
, const ScriptCanvas::NodeTypeIdentifier& nodeType
|
||||
, const SourceHandle& graphInfo
|
||||
, const ScriptCanvas::NamedNodeId& nodeId);
|
||||
|
||||
~ExecutionLogTreeItem() override = default;
|
||||
|
||||
QVariant Data(const QModelIndex& index, int role) const override final;
|
||||
@@ -163,7 +168,7 @@ namespace ScriptCanvasEditor
|
||||
////
|
||||
|
||||
const ScriptCanvas::GraphIdentifier& GetGraphIdentifier() const;
|
||||
const AZ::Data::AssetId& GetAssetId() const;
|
||||
AZ::Data::AssetId GetAssetId() const;
|
||||
|
||||
AZ::EntityId GetScriptCanvasAssetNodeId() const;
|
||||
GraphCanvas::NodeId GetGraphCanvasNodeId() const;
|
||||
@@ -184,7 +189,8 @@ namespace ScriptCanvasEditor
|
||||
|
||||
LoggingDataId m_loggingDataId;
|
||||
ScriptCanvas::NodeTypeIdentifier m_nodeType;
|
||||
ScriptCanvas::GraphInfo m_graphInfo;
|
||||
SourceHandle m_graphInfo;
|
||||
ScriptCanvas::GraphIdentifier m_graphIdentifier;
|
||||
QString m_sourceEntityName;
|
||||
QString m_graphName;
|
||||
QString m_relativeGraphPath;
|
||||
|
||||
@@ -819,16 +819,10 @@ namespace ScriptCanvasEditor
|
||||
|
||||
void MainWindow::SignalActiveSceneChanged(ScriptCanvasEditor::SourceHandle assetId)
|
||||
{
|
||||
// #se_editor_asset
|
||||
/*
|
||||
ScriptCanvasMemoryAsset::pointer memoryAsset;
|
||||
AssetTrackerRequestBus::BroadcastResult(memoryAsset, &AssetTrackerRequests::GetAsset, assetId);
|
||||
|
||||
AZ::EntityId graphId;
|
||||
|
||||
if (memoryAsset)
|
||||
if (assetId)
|
||||
{
|
||||
graphId = memoryAsset->GetGraphId();
|
||||
EditorGraphRequestBus::EventResult(graphId, assetId.Get()->GetScriptCanvasId(), &EditorGraphRequests::GetGraphCanvasGraphId);
|
||||
}
|
||||
|
||||
m_autoSaveTimer.stop();
|
||||
@@ -847,18 +841,20 @@ namespace ScriptCanvasEditor
|
||||
GraphCanvas::ViewId viewId;
|
||||
GraphCanvas::SceneRequestBus::EventResult(viewId, graphId, &GraphCanvas::SceneRequests::GetViewId);
|
||||
|
||||
AZ_Assert(viewId.IsValid(), "SceneRequest must return a valid ViewId");
|
||||
if (viewId.IsValid())
|
||||
{
|
||||
GraphCanvas::ViewNotificationBus::Handler::BusDisconnect();
|
||||
GraphCanvas::ViewNotificationBus::Handler::BusConnect(viewId);
|
||||
|
||||
enabled = memoryAsset->GetScriptCanvasId().IsValid();
|
||||
enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Error("ScriptCanvasEditor", viewId.IsValid(), "SceneRequest must return a valid ViewId");
|
||||
}
|
||||
}
|
||||
|
||||
UpdateMenuState(enabled);
|
||||
*/
|
||||
}
|
||||
|
||||
void MainWindow::UpdateRecentMenu()
|
||||
@@ -938,7 +934,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
if (shouldSaveResults == UnsavedChangesOptions::SAVE)
|
||||
{
|
||||
// #se_editor_asset
|
||||
// #sc_editor_asset
|
||||
// Callbacks::OnSave saveCB = [this](bool isSuccessful, AZ::Data::AssetPtr, ScriptCanvasEditor::SourceHandle)
|
||||
// {
|
||||
// if (isSuccessful)
|
||||
@@ -1138,7 +1134,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
void MainWindow::MarkAssetModified(const ScriptCanvasEditor::SourceHandle& /*assetId*/)
|
||||
{
|
||||
// #se_editor_asset if (!assetId.IsValid())
|
||||
// #sc_editor_asset if (!assetId.IsValid())
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
@@ -1159,7 +1155,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
void MainWindow::RefreshScriptCanvasAsset(const AZ::Data::Asset<ScriptCanvas::ScriptCanvasAssetBase>& /*asset*/)
|
||||
{
|
||||
// #se_editor_asset
|
||||
// #sc_editor_asset
|
||||
/*
|
||||
ScriptCanvasMemoryAsset::pointer memoryAsset;
|
||||
AssetTrackerRequestBus::BroadcastResult(memoryAsset, &AssetTrackerRequests::GetAsset, asset.GetId());
|
||||
@@ -1192,12 +1188,9 @@ namespace ScriptCanvasEditor
|
||||
*/
|
||||
}
|
||||
|
||||
AZ::Outcome<int, AZStd::string> MainWindow::OpenScriptCanvasAssetId(const ScriptCanvasEditor::SourceHandle& /*fileAssetId*/)
|
||||
AZ::Outcome<int, AZStd::string> MainWindow::OpenScriptCanvasAssetId(const ScriptCanvasEditor::SourceHandle& fileAssetId)
|
||||
{
|
||||
// #se_editor_asset
|
||||
return AZ::Failure(AZStd::string("rewrite MainWindow::OpenScriptCanvasAssetId"));
|
||||
/*
|
||||
if (!fileAssetId.IsValid())
|
||||
if (fileAssetId.Id().IsNull())
|
||||
{
|
||||
return AZ::Failure(AZStd::string("Unable to open asset with invalid asset id"));
|
||||
}
|
||||
@@ -1210,79 +1203,47 @@ namespace ScriptCanvasEditor
|
||||
return AZ::Success(outTabIndex);
|
||||
}
|
||||
|
||||
AZ::Data::AssetInfo assetInfo;
|
||||
AZ::Data::AssetCatalogRequestBus::BroadcastResult(assetInfo, &AZ::Data::AssetCatalogRequests::GetAssetInfoById, fileAssetId);
|
||||
outTabIndex = CreateAssetTab(fileAssetId);
|
||||
|
||||
if (assetInfo.m_relativePath.empty())
|
||||
if (!m_isRestoringWorkspace)
|
||||
{
|
||||
return AZ::Failure(AZStd::string("Unknown AssetId"));
|
||||
SetActiveAsset(fileAssetId);
|
||||
}
|
||||
|
||||
if (assetInfo.m_assetType != azrtti_typeid<ScriptCanvasAsset>())
|
||||
{
|
||||
return AZ::Failure(AZStd::string("Invalid AssetId provided, it's not a Script Canvas supported type"));
|
||||
}
|
||||
|
||||
AssetTrackerRequests::OnAssetReadyCallback onAssetReady = [this, fileAssetId, &outTabIndex](ScriptCanvasMemoryAsset& asset)
|
||||
{
|
||||
if (!asset.IsSourceInError())
|
||||
{
|
||||
outTabIndex = CreateAssetTab(asset.GetFileAssetId());
|
||||
|
||||
if (!m_isRestoringWorkspace)
|
||||
{
|
||||
SetActiveAsset(fileAssetId);
|
||||
}
|
||||
|
||||
UpdateWorkspaceStatus(asset);
|
||||
}
|
||||
else
|
||||
{
|
||||
outTabIndex = -1;
|
||||
m_loadingAssets.erase(fileAssetId);
|
||||
}
|
||||
};
|
||||
|
||||
m_loadingAssets.insert(fileAssetId);
|
||||
|
||||
AssetTrackerRequestBus::Broadcast(&AssetTrackerRequests::Load, fileAssetId, assetInfo.m_assetType, onAssetReady);
|
||||
|
||||
if (outTabIndex >= 0)
|
||||
{
|
||||
AddRecentFile(fileAssetId.Path().c_str());
|
||||
OpenScriptCanvasAssetImplementation(fileAssetId);
|
||||
return AZ::Success(outTabIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
return AZ::Failure(AZStd::string("Specified asset is in an error state and cannot be properly displayed."));
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
AZ::Outcome<int, AZStd::string> MainWindow::OpenScriptCanvasAsset(const ScriptCanvasMemoryAsset& /*scriptCanvasAsset*/, int /*tabIndex*/ /*= -1*/)
|
||||
AZ::Outcome<int, AZStd::string> MainWindow::OpenScriptCanvasAssetImplementation(const SourceHandle& scriptCanvasAsset, int tabIndex)
|
||||
{
|
||||
// #se_editor_asset
|
||||
return AZ::Failure(AZStd::string("rewrite MainWindow::OpenScriptCanvasAsset"));
|
||||
/*
|
||||
const ScriptCanvasEditor::SourceHandle& fileAssetId = scriptCanvasAsset.GetFileAssetId();
|
||||
const ScriptCanvasEditor::SourceHandle& fileAssetId = scriptCanvasAsset;
|
||||
if (!fileAssetId.IsValid())
|
||||
{
|
||||
return AZ::Failure(AZStd::string("Unable to open asset with invalid asset id"));
|
||||
}
|
||||
|
||||
if (scriptCanvasAsset.IsSourceInError())
|
||||
if (!scriptCanvasAsset.IsValid())
|
||||
{
|
||||
if (!m_isRestoringWorkspace)
|
||||
{
|
||||
AZStd::string errorPath = scriptCanvasAsset.GetAbsolutePath();
|
||||
AZStd::string errorPath = scriptCanvasAsset.Path();
|
||||
|
||||
if (errorPath.empty())
|
||||
{
|
||||
errorPath = m_errorFilePath;
|
||||
}
|
||||
|
||||
if (m_queuedFocusOverride == fileAssetId)
|
||||
if (m_queuedFocusOverride.AnyEquals(fileAssetId))
|
||||
{
|
||||
m_queuedFocusOverride.SetInvalid();
|
||||
m_queuedFocusOverride = fileAssetId;
|
||||
}
|
||||
|
||||
QMessageBox::warning(this, "Unable to open source file", QString("Source File(%1) is in error and cannot be opened").arg(errorPath.c_str()), QMessageBox::StandardButton::Ok);
|
||||
@@ -1307,18 +1268,14 @@ namespace ScriptCanvasEditor
|
||||
|
||||
if (outTabIndex == -1)
|
||||
{
|
||||
return AZ::Failure(AZStd::string::format("Unable to open existing Script Canvas Asset with id %s in the Script Canvas Editor", AssetHelpers::AssetIdToString(fileAssetId).c_str()));
|
||||
return AZ::Failure(AZStd::string::format("Unable to open existing Script Canvas Asset with id %s in the Script Canvas Editor"
|
||||
, fileAssetId.ToString().c_str()));
|
||||
}
|
||||
|
||||
AZStd::string assetPath = scriptCanvasAsset.GetAbsolutePath();
|
||||
AZStd::string assetPath = scriptCanvasAsset.Path();
|
||||
if (!assetPath.empty() && !m_loadingNewlySavedFile)
|
||||
{
|
||||
const size_t eraseCount = m_loadingWorkspaceAssets.erase(fileAssetId);
|
||||
|
||||
if (eraseCount == 0)
|
||||
{
|
||||
AddRecentFile(assetPath.c_str());
|
||||
}
|
||||
AddRecentFile(assetPath.c_str());
|
||||
}
|
||||
|
||||
if (!m_isRestoringWorkspace)
|
||||
@@ -1326,47 +1283,34 @@ namespace ScriptCanvasEditor
|
||||
SetActiveAsset(fileAssetId);
|
||||
}
|
||||
|
||||
GraphCanvas::GraphId graphCanvasGraphId = GetGraphCanvasGraphId(scriptCanvasAsset.GetScriptCanvasId());
|
||||
GraphCanvas::GraphId graphCanvasGraphId = GetGraphCanvasGraphId(scriptCanvasAsset.Get()->GetScriptCanvasId());
|
||||
GraphCanvas::AssetEditorNotificationBus::Event(ScriptCanvasEditor::AssetEditorId, &GraphCanvas::AssetEditorNotifications::OnGraphLoaded, graphCanvasGraphId);
|
||||
|
||||
GeneralAssetNotificationBus::Event(fileAssetId, &GeneralAssetNotifications::OnAssetVisualized);
|
||||
|
||||
AssetTrackerNotificationBus::MultiHandler::BusConnect(fileAssetId);
|
||||
|
||||
return AZ::Success(outTabIndex);
|
||||
*/
|
||||
}
|
||||
|
||||
AZ::Outcome<int, AZStd::string> MainWindow::OpenScriptCanvasAsset(ScriptCanvasEditor::SourceHandle /*scriptCanvasAssetId*/, int /*tabIndex*/ /*= -1*/)
|
||||
AZ::Outcome<int, AZStd::string> MainWindow::OpenScriptCanvasAsset(ScriptCanvasEditor::SourceHandle scriptCanvasAssetId, int tabIndex)
|
||||
{
|
||||
// #se_editor_asset
|
||||
return AZ::Failure(AZStd::string("rewrite MainWindow::OpenScriptCanvasAsset"));
|
||||
/*
|
||||
ScriptCanvasMemoryAsset::pointer memoryAsset;
|
||||
AssetTrackerRequestBus::BroadcastResult(memoryAsset, &AssetTrackerRequests::GetAsset, scriptCanvasAssetId);
|
||||
|
||||
// If the asset is already tracked we can go directly to opening it.
|
||||
if (memoryAsset)
|
||||
if (scriptCanvasAssetId)
|
||||
{
|
||||
return OpenScriptCanvasAsset(*memoryAsset, tabIndex);
|
||||
return OpenScriptCanvasAssetImplementation(scriptCanvasAssetId, tabIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
return OpenScriptCanvasAssetId(scriptCanvasAssetId);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
int MainWindow::CreateAssetTab(const ScriptCanvasEditor::SourceHandle& /*assetId*/, int /*tabIndex*/)
|
||||
int MainWindow::CreateAssetTab(const ScriptCanvasEditor::SourceHandle& assetId, int tabIndex)
|
||||
{
|
||||
// #se_editor_asset
|
||||
return -1;
|
||||
// return m_tabBar->InsertGraphTab(tabIndex, assetId);
|
||||
return m_tabBar->InsertGraphTab(tabIndex, assetId);
|
||||
}
|
||||
|
||||
AZ::Outcome<int, AZStd::string> MainWindow::UpdateScriptCanvasAsset(const AZ::Data::Asset<ScriptCanvas::ScriptCanvasAssetBase>& /*scriptCanvasAsset*/)
|
||||
{
|
||||
// #se_editor_asset
|
||||
// #sc_editor_asset
|
||||
return AZ::Failure(AZStd::string("rewrite MainWindow::UpdateScriptCanvasAsset"));
|
||||
|
||||
/*
|
||||
@@ -1391,7 +1335,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
void MainWindow::RemoveScriptCanvasAsset(const ScriptCanvasEditor::SourceHandle& /*assetId*/)
|
||||
{
|
||||
// #se_editor_asset move what is necessary to the widget
|
||||
// #sc_editor_asset move what is necessary to the widget
|
||||
/*
|
||||
AssetHelpers::PrintInfo("RemoveScriptCanvasAsset : %s", AssetHelpers::AssetIdToString(assetId).c_str());
|
||||
|
||||
@@ -1417,7 +1361,7 @@ namespace ScriptCanvasEditor
|
||||
QVariant tabdata = m_tabBar->tabData(tabIndex);
|
||||
if (tabdata.isValid())
|
||||
{
|
||||
auto tabAssetId = tabdata.value<ScriptCanvasEditor::SourceHandle>();
|
||||
auto tabAssetId = tabdata.value<Widget::GraphTabMetadata>();
|
||||
SetActiveAsset(tabAssetId);
|
||||
}
|
||||
*/
|
||||
@@ -1465,7 +1409,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
bool MainWindow::IsScriptCanvasAssetOpen(const ScriptCanvasEditor::SourceHandle& /*assetId*/) const
|
||||
{
|
||||
// #se_editor_asset
|
||||
// #sc_editor_asset
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1481,7 +1425,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
void MainWindow::GetSuggestedFullFilenameToSaveAs(const ScriptCanvasEditor::SourceHandle& /*assetId*/, AZStd::string& /*filePath*/, AZStd::string& /*fileFilter*/)
|
||||
{
|
||||
// #se_editor_asset
|
||||
// #sc_editor_asset
|
||||
/*
|
||||
ScriptCanvasMemoryAsset::pointer memoryAsset;
|
||||
AssetTrackerRequestBus::BroadcastResult(memoryAsset, &AssetTrackerRequests::GetAsset, assetId);
|
||||
@@ -1528,18 +1472,50 @@ namespace ScriptCanvasEditor
|
||||
|
||||
void MainWindow::OpenFile(const char* fullPath)
|
||||
{
|
||||
AZ::Outcome<ScriptCanvasEditor::SourceHandle, AZStd::string> outcome = LoadFromFile(fullPath);
|
||||
|
||||
if (!outcome.IsSuccess())
|
||||
auto tabIndex = m_tabBar->FindTabByPath(fullPath);
|
||||
if (tabIndex.IsValid())
|
||||
{
|
||||
SetActiveAsset(tabIndex);
|
||||
return;
|
||||
}
|
||||
|
||||
AZStd::string watchFolder;
|
||||
AZ::Data::AssetInfo assetInfo;
|
||||
bool sourceInfoFound{};
|
||||
AzToolsFramework::AssetSystemRequestBus::BroadcastResult
|
||||
( sourceInfoFound
|
||||
, &AzToolsFramework::AssetSystemRequestBus::Events::GetSourceInfoBySourcePath, fullPath, assetInfo, watchFolder);
|
||||
|
||||
if (!sourceInfoFound)
|
||||
{
|
||||
QMessageBox::warning(this, "Invalid Source Asset", QString("'%1' is not a valid asset path.").arg(fullPath), QMessageBox::Ok);
|
||||
m_errorFilePath = fullPath;
|
||||
AZ_Warning("ScriptCanvas", false, "Unable to open file as a ScriptCanvas graph: %s", fullPath);
|
||||
return;
|
||||
}
|
||||
|
||||
AZ::Outcome<ScriptCanvasEditor::SourceHandle, AZStd::string> outcome = LoadFromFile(fullPath);
|
||||
if (!outcome.IsSuccess())
|
||||
{
|
||||
QMessageBox::warning(this, "Invalid Source File", QString("'%1' is not a valid file path.").arg(fullPath), QMessageBox::Ok);
|
||||
m_errorFilePath = fullPath;
|
||||
AZ_Warning("ScriptCanvas", false, "Unable to open file as a ScriptCanvas graph: %s", fullPath);
|
||||
return;
|
||||
}
|
||||
|
||||
m_errorFilePath.clear();
|
||||
m_activeGraph = ScriptCanvasEditor::SourceHandle(outcome.TakeValue(), assetInfo.m_assetId.m_guid, fullPath);
|
||||
|
||||
auto openOutcome = OpenScriptCanvasAsset(m_activeGraph);
|
||||
if (openOutcome)
|
||||
{
|
||||
RunGraphValidation(false);
|
||||
SetRecentAssetId(m_activeGraph);
|
||||
SetActiveAsset(m_activeGraph);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_errorFilePath.clear();
|
||||
m_activeGraph = outcome.TakeValue();
|
||||
return;
|
||||
AZ_Warning("Script Canvas", openOutcome, "%s", openOutcome.GetError().data());
|
||||
}
|
||||
|
||||
#if defined(EDITOR_ASSET_SUPPORT_ENABLED)
|
||||
@@ -1770,7 +1746,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
bool MainWindow::OnFileSave(const Callbacks::OnSave& saveCB)
|
||||
{
|
||||
return SaveAssetImpl(m_activeGraph, saveCB);
|
||||
return SaveAssetAsImpl(m_activeGraph, saveCB);
|
||||
}
|
||||
|
||||
bool MainWindow::OnFileSaveAs(const Callbacks::OnSave& saveCB)
|
||||
@@ -1798,7 +1774,7 @@ namespace ScriptCanvasEditor
|
||||
else if (fileState == Tracker::ScriptCanvasFileState::MODIFIED
|
||||
|| fileState == Tracker::ScriptCanvasFileState::SOURCE_REMOVED)
|
||||
{
|
||||
SaveAsset(assetId, saveCB);
|
||||
SaveAs(assetId.Path(), assetId, saveCB);
|
||||
saveSuccessful = true;
|
||||
}
|
||||
|
||||
@@ -1878,7 +1854,7 @@ namespace ScriptCanvasEditor
|
||||
return false;
|
||||
}
|
||||
|
||||
SaveNewAsset(internalStringFile, inMemoryAssetId, saveCB);
|
||||
SaveAs(internalStringFile, inMemoryAssetId, saveCB);
|
||||
|
||||
m_newlySavedFile = internalStringFile;
|
||||
|
||||
@@ -1893,7 +1869,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
void MainWindow::OnSaveCallback(bool /*saveSuccess*/, AZ::Data::AssetPtr /*fileAsset*/, ScriptCanvasEditor::SourceHandle /*previousFileAssetId*/)
|
||||
{
|
||||
// #se_editor_asset yikes...just save the thing...move to ::SaveAsset maybe
|
||||
// #sc_editor_asset yikes...just save the thing...move to ::SaveAsset maybe
|
||||
|
||||
/*
|
||||
ScriptCanvasMemoryAsset::pointer memoryAsset;
|
||||
@@ -1915,7 +1891,7 @@ namespace ScriptCanvasEditor
|
||||
if (saveTabIndex != m_tabBar->currentIndex())
|
||||
{
|
||||
// Invalidate the file asset id so we don't delete trigger the asset flow.
|
||||
m_tabBar->setTabData(saveTabIndex, QVariant::fromValue(ScriptCanvasEditor::SourceHandle()));
|
||||
m_tabBar->setTabData(saveTabIndex, QVariant::fromValue(GraphTabMetaData));
|
||||
|
||||
m_tabBar->CloseTab(saveTabIndex);
|
||||
saveTabIndex = -1;
|
||||
@@ -1936,6 +1912,7 @@ namespace ScriptCanvasEditor
|
||||
AzFramework::StringFunc::Path::GetFileName(memoryAsset->GetAbsolutePath().c_str(), tabName);
|
||||
|
||||
// Update the tab's assetId to the file asset Id (necessary when saving a new asset)
|
||||
// used to be configure tab...sets the name and file state
|
||||
m_tabBar->ConfigureTab(saveTabIndex, fileAssetId, tabName);
|
||||
|
||||
GeneralAssetNotificationBus::Event(memoryAsset->GetId(), &GeneralAssetNotifications::OnAssetVisualized);
|
||||
@@ -2027,53 +2004,11 @@ namespace ScriptCanvasEditor
|
||||
return OnFileSave(saveCB);
|
||||
}
|
||||
|
||||
void MainWindow::SaveAsset(ScriptCanvasEditor::SourceHandle /*assetId*/, const Callbacks::OnSave& /*onSave*/)
|
||||
{
|
||||
/*
|
||||
PrepareAssetForSave(assetId);
|
||||
|
||||
auto onSaveCallback = [this, onSave](bool saveSuccess, AZ::Data::AssetPtr asset, ScriptCanvasEditor::SourceHandle previousAssetId)
|
||||
{
|
||||
OnSaveCallback(saveSuccess, asset, previousAssetId);
|
||||
if (onSave)
|
||||
{
|
||||
AZStd::invoke(onSave, saveSuccess, asset, previousAssetId);
|
||||
}
|
||||
};
|
||||
|
||||
AssetTrackerRequestBus::Broadcast(&AssetTrackerRequests::Save, assetId, onSaveCallback);
|
||||
UpdateSaveState();
|
||||
|
||||
ScriptCanvasMemoryAsset::pointer memoryAsset;
|
||||
AssetTrackerRequestBus::BroadcastResult(memoryAsset, &AssetTrackerRequests::GetAsset, m_activeGraph);
|
||||
|
||||
// Disable the current view if we are saving.
|
||||
if (memoryAsset)
|
||||
{
|
||||
DisableAssetView(memoryAsset);
|
||||
}
|
||||
|
||||
BlockCloseRequests();
|
||||
*/
|
||||
}
|
||||
|
||||
void MainWindow::SaveNewAsset(AZStd::string_view /*path*/, ScriptCanvasEditor::SourceHandle /*inMemoryAssetId*/, const Callbacks::OnSave& /*onSave*/)
|
||||
void MainWindow::SaveAs(AZStd::string_view /*path*/, ScriptCanvasEditor::SourceHandle /*inMemoryAssetId*/, const Callbacks::OnSave& /*onSave*/)
|
||||
{
|
||||
/*
|
||||
PrepareAssetForSave(inMemoryAssetId);
|
||||
|
||||
auto onSaveCallback = [this, onSave](bool saveSuccess, AZ::Data::AssetPtr asset, ScriptCanvasEditor::SourceHandle previousAssetId)
|
||||
{
|
||||
OnSaveCallback(saveSuccess, asset, previousAssetId);
|
||||
if (onSave)
|
||||
{
|
||||
AZStd::invoke(onSave, saveSuccess, asset, previousAssetId);
|
||||
}
|
||||
};
|
||||
AssetTrackerRequestBus::Broadcast(&AssetTrackerRequests::SaveAs, inMemoryAssetId, path, onSaveCallback);
|
||||
|
||||
UpdateSaveState();
|
||||
|
||||
ScriptCanvasMemoryAsset::pointer memoryAsset;
|
||||
AssetTrackerRequestBus::BroadcastResult(memoryAsset, &AssetTrackerRequests::GetAsset, inMemoryAssetId);
|
||||
|
||||
@@ -2083,6 +2018,44 @@ namespace ScriptCanvasEditor
|
||||
DisableAssetView(memoryAsset);
|
||||
}
|
||||
|
||||
auto onSaveCallback = [this, onSave](bool saveSuccess, AZ::Data::AssetPtr asset, ScriptCanvasEditor::SourceHandle previousAssetId)
|
||||
{
|
||||
OnSaveCallback(saveSuccess, asset, previousAssetId);
|
||||
if (onSave)
|
||||
{
|
||||
AZStd::invoke(onSave, saveSuccess, asset, previousAssetId);
|
||||
}
|
||||
};
|
||||
|
||||
AZ::Data::AssetStreamInfo streamInfo;
|
||||
streamInfo.m_streamFlags = AZ::IO::OpenMode::ModeWrite;
|
||||
streamInfo.m_streamName = m_saveAsPath;
|
||||
|
||||
if (!streamInfo.IsValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bool sourceControlActive = false;
|
||||
AzToolsFramework::SourceControlConnectionRequestBus::BroadcastResult(sourceControlActive, &AzToolsFramework::SourceControlConnectionRequests::IsActive);
|
||||
// If Source Control is active then use it to check out the file before saving otherwise query the file info and save only if the file is not read-only
|
||||
if (sourceControlActive)
|
||||
{
|
||||
AzToolsFramework::SourceControlCommandBus::Broadcast(&AzToolsFramework::SourceControlCommandBus::Events::RequestEdit,
|
||||
streamInfo.m_streamName.c_str(),
|
||||
true,
|
||||
[this, streamInfo, onSaveCallback](bool success, AzToolsFramework::SourceControlFileInfo info) { FinalizeAssetSave(success, info, streamInfo, onSaveCallback); }
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
AzToolsFramework::SourceControlCommandBus::Broadcast(&AzToolsFramework::SourceControlCommandBus::Events::GetFileInfo,
|
||||
streamInfo.m_streamName.c_str(),
|
||||
[this, streamInfo, onSaveCallback](bool success, AzToolsFramework::SourceControlFileInfo info) { FinalizeAssetSave(success, info, streamInfo, onSaveCallback); }
|
||||
);
|
||||
}
|
||||
|
||||
UpdateSaveState();
|
||||
BlockCloseRequests();
|
||||
*/
|
||||
}
|
||||
@@ -2503,7 +2476,6 @@ namespace ScriptCanvasEditor
|
||||
if (eraseCount == 0)
|
||||
{
|
||||
AZStd::string fullPath = AZStd::string::format("%s/%s", rootFilePath.c_str(), assetInfo.m_relativePath.c_str());
|
||||
AddRecentFile(fullPath.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2566,69 +2538,55 @@ namespace ScriptCanvasEditor
|
||||
|
||||
AZ::EntityId MainWindow::GetActiveGraphCanvasGraphId() const
|
||||
{
|
||||
// #se_editor_asset
|
||||
AZ::EntityId graphId{};
|
||||
|
||||
// AZ::EntityId graphId;
|
||||
// AssetTrackerRequestBus::BroadcastResult(graphId, &AssetTrackerRequests::GetGraphId, m_activeGraph);
|
||||
/*
|
||||
* Falls through to this, which falls through to editor graph, move to canvas widget
|
||||
AZ::EntityId ScriptCanvasMemoryAsset::GetGraphId()
|
||||
{
|
||||
if (!m_graphId.IsValid())
|
||||
if (m_activeGraph)
|
||||
{
|
||||
EditorGraphRequestBus::EventResult(m_graphId, m_scriptCanvasId, &EditorGraphRequests::GetGraphCanvasGraphId);
|
||||
EditorGraphRequestBus::EventResult
|
||||
( graphId, m_activeGraph.Get()->GetScriptCanvasId(), &EditorGraphRequests::GetGraphCanvasGraphId);
|
||||
}
|
||||
|
||||
return m_graphId;
|
||||
}
|
||||
*/
|
||||
return AZ::EntityId{};
|
||||
return graphId;
|
||||
}
|
||||
|
||||
ScriptCanvas::ScriptCanvasId MainWindow::GetActiveScriptCanvasId() const
|
||||
{
|
||||
// ScriptCanvas::ScriptCanvasId sceneId;
|
||||
// AssetTrackerRequestBus::BroadcastResult(sceneId, &AssetTrackerRequests::GetScriptCanvasId, m_activeGraph);
|
||||
// #se_editor_asset
|
||||
return ScriptCanvas::ScriptCanvasId{};
|
||||
return FindScriptCanvasIdByAssetId(m_activeGraph);
|
||||
}
|
||||
|
||||
GraphCanvas::GraphId MainWindow::GetGraphCanvasGraphId(const ScriptCanvas::ScriptCanvasId& /*scriptCanvasId*/) const
|
||||
GraphCanvas::GraphId MainWindow::GetGraphCanvasGraphId(const ScriptCanvas::ScriptCanvasId& scriptCanvasId) const
|
||||
{
|
||||
// #se_editor_asset
|
||||
// AZ::EntityId graphCanvasId;
|
||||
// AssetTrackerRequestBus::BroadcastResult(graphCanvasId, &AssetTrackerRequests::GetGraphCanvasId, scriptCanvasId);
|
||||
// move to widget
|
||||
return AZ::EntityId{};
|
||||
AZ::EntityId graphId{};
|
||||
EditorGraphRequestBus::EventResult(graphId, scriptCanvasId, &EditorGraphRequests::GetGraphCanvasGraphId);
|
||||
return graphId;
|
||||
}
|
||||
|
||||
GraphCanvas::GraphId MainWindow::FindGraphCanvasGraphIdByAssetId(const ScriptCanvasEditor::SourceHandle& /*assetId*/) const
|
||||
GraphCanvas::GraphId MainWindow::FindGraphCanvasGraphIdByAssetId(const ScriptCanvasEditor::SourceHandle& assetId) const
|
||||
{
|
||||
// #se_editor_asset
|
||||
// AZ::EntityId graphId;
|
||||
// AssetTrackerRequestBus::BroadcastResult(graphId, &AssetTrackerRequests::GetGraphId, assetId);
|
||||
return AZ::EntityId{};
|
||||
AZ::EntityId graphId{};
|
||||
|
||||
if (assetId)
|
||||
{
|
||||
EditorGraphRequestBus::EventResult
|
||||
( graphId, assetId.Get()->GetScriptCanvasId(), &EditorGraphRequests::GetGraphCanvasGraphId);
|
||||
}
|
||||
|
||||
return graphId;
|
||||
}
|
||||
|
||||
ScriptCanvas::ScriptCanvasId MainWindow::FindScriptCanvasIdByAssetId(const ScriptCanvasEditor::SourceHandle& /*assetId*/) const
|
||||
ScriptCanvas::ScriptCanvasId MainWindow::FindScriptCanvasIdByAssetId(const ScriptCanvasEditor::SourceHandle& assetId) const
|
||||
{
|
||||
// #se_editor_asset
|
||||
// ScriptCanvas::ScriptCanvasId scriptCanvasId;
|
||||
// AssetTrackerRequestBus::BroadcastResult(scriptCanvasId, &AssetTrackerRequests::GetScriptCanvasId, assetId);
|
||||
return ScriptCanvas::ScriptCanvasId{};
|
||||
return assetId ? assetId.Get()->GetScriptCanvasId() : ScriptCanvas::ScriptCanvasId{};
|
||||
}
|
||||
|
||||
ScriptCanvas::ScriptCanvasId MainWindow::GetScriptCanvasId(const GraphCanvas::GraphId& /*graphCanvasGraphId*/) const
|
||||
ScriptCanvas::ScriptCanvasId MainWindow::GetScriptCanvasId(const GraphCanvas::GraphId& graphCanvasGraphId) const
|
||||
{
|
||||
// #se_editor_asset
|
||||
// ScriptCanvas::ScriptCanvasId scriptCanvasId;
|
||||
// AssetTrackerRequestBus::BroadcastResult(scriptCanvasId, &AssetTrackerRequests::GetScriptCanvasIdFromGraphId, graphCanvasGraphId);
|
||||
return ScriptCanvas::ScriptCanvasId{};
|
||||
return m_tabBar->FindScriptCanvasIdFromGraphCanvasId(graphCanvasGraphId);
|
||||
}
|
||||
|
||||
bool MainWindow::IsInUndoRedo(const AZ::EntityId& graphCanvasGraphId) const
|
||||
{
|
||||
// #se_editor_asset
|
||||
// #sc_editor_asset
|
||||
bool isActive = false;
|
||||
UndoRequestBus::EventResult(isActive, GetScriptCanvasId(graphCanvasGraphId), &UndoRequests::IsActive);
|
||||
return isActive;
|
||||
@@ -2660,8 +2618,8 @@ namespace ScriptCanvasEditor
|
||||
QVariant tabdata = m_tabBar->tabData(tabIndex);
|
||||
if (tabdata.isValid())
|
||||
{
|
||||
auto tabAssetId = tabdata.value<ScriptCanvasEditor::SourceHandle>();
|
||||
if (tabAssetId == assetId)
|
||||
auto tabAssetId = tabdata.value<Widget::GraphTabMetadata>();
|
||||
if (tabAssetId.m_assetId == assetId)
|
||||
{
|
||||
return tabdata;
|
||||
}
|
||||
@@ -2681,21 +2639,15 @@ namespace ScriptCanvasEditor
|
||||
return false;
|
||||
}
|
||||
|
||||
void MainWindow::ReconnectSceneBuses(ScriptCanvasEditor::SourceHandle /*previousAssetId*/, ScriptCanvasEditor::SourceHandle /*nextAssetId*/)
|
||||
void MainWindow::ReconnectSceneBuses(ScriptCanvasEditor::SourceHandle previousAsset, ScriptCanvasEditor::SourceHandle nextAsset)
|
||||
{
|
||||
// #se_editor_asset
|
||||
/*
|
||||
ScriptCanvasMemoryAsset::pointer previousAsset;
|
||||
AssetTrackerRequestBus::BroadcastResult(previousAsset, &AssetTrackerRequests::GetAsset, previousAssetId);
|
||||
|
||||
ScriptCanvasMemoryAsset::pointer nextAsset;
|
||||
AssetTrackerRequestBus::BroadcastResult(nextAsset, &AssetTrackerRequests::GetAsset, nextAssetId);
|
||||
|
||||
// #sc_editor_asset
|
||||
|
||||
// Disconnect previous asset
|
||||
AZ::EntityId previousScriptCanvasSceneId;
|
||||
if (previousAsset)
|
||||
{
|
||||
previousScriptCanvasSceneId = previousAsset->GetScriptCanvasId();
|
||||
previousScriptCanvasSceneId = previousAsset.Get()->GetScriptCanvasId();
|
||||
GraphCanvas::SceneNotificationBus::MultiHandler::BusDisconnect(previousScriptCanvasSceneId);
|
||||
}
|
||||
|
||||
@@ -2703,7 +2655,8 @@ namespace ScriptCanvasEditor
|
||||
if (nextAsset)
|
||||
{
|
||||
// Connect the next asset
|
||||
nextAssetGraphCanvasId = nextAsset->GetGraphId();
|
||||
EditorGraphRequestBus::EventResult(nextAssetGraphCanvasId, nextAsset.Get()->GetScriptCanvasId(), &EditorGraphRequests::GetGraphCanvasGraphId);
|
||||
|
||||
if (nextAssetGraphCanvasId.IsValid())
|
||||
{
|
||||
GraphCanvas::SceneNotificationBus::MultiHandler::BusConnect(nextAssetGraphCanvasId);
|
||||
@@ -2716,13 +2669,12 @@ namespace ScriptCanvasEditor
|
||||
|
||||
// Notify about the graph refresh
|
||||
GraphCanvas::AssetEditorNotificationBus::Event(ScriptCanvasEditor::AssetEditorId, &GraphCanvas::AssetEditorNotifications::OnGraphRefreshed, previousScriptCanvasSceneId, nextAssetGraphCanvasId);
|
||||
*/
|
||||
}
|
||||
|
||||
void MainWindow::SetActiveAsset(const ScriptCanvasEditor::SourceHandle& /*fileAssetId*/)
|
||||
void MainWindow::SetActiveAsset(const ScriptCanvasEditor::SourceHandle& fileAssetId)
|
||||
{
|
||||
// #se_editor_asset
|
||||
/*
|
||||
// #sc_editor_asset
|
||||
|
||||
if (m_activeGraph == fileAssetId)
|
||||
{
|
||||
return;
|
||||
@@ -2745,98 +2697,61 @@ namespace ScriptCanvasEditor
|
||||
|
||||
if (m_activeGraph.IsValid())
|
||||
{
|
||||
ScriptCanvasMemoryAsset::pointer memoryAsset;
|
||||
AssetTrackerRequestBus::BroadcastResult(memoryAsset, &AssetTrackerRequests::GetAsset, m_activeGraph);
|
||||
|
||||
// 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
|
||||
if (memoryAsset && memoryAsset->GetView())
|
||||
auto oldTab = m_tabBar->FindTab(m_activeGraph);
|
||||
if (auto view = m_tabBar->ModTabView(oldTab))
|
||||
{
|
||||
memoryAsset->GetView()->hide();
|
||||
m_layout->removeWidget(memoryAsset->GetView());
|
||||
view->hide();
|
||||
m_layout->removeWidget(view);
|
||||
m_tabBar->ClearTabView(oldTab);
|
||||
}
|
||||
}
|
||||
|
||||
if (fileAssetId.IsValid())
|
||||
{
|
||||
ScriptCanvasEditor::SourceHandle previousAssetId = m_activeGraph;
|
||||
|
||||
m_activeGraph = fileAssetId;
|
||||
RefreshActiveAsset();
|
||||
|
||||
ReconnectSceneBuses(previousAssetId, m_activeGraph);
|
||||
}
|
||||
else
|
||||
{
|
||||
ScriptCanvasEditor::SourceHandle previousAssetId = m_activeGraph;
|
||||
|
||||
m_activeGraph.Clear();
|
||||
m_emptyCanvas->show();
|
||||
|
||||
ReconnectSceneBuses(previousAssetId, m_activeGraph);
|
||||
|
||||
SignalActiveSceneChanged(ScriptCanvasEditor::SourceHandle());
|
||||
}
|
||||
|
||||
UpdateUndoCache(fileAssetId);
|
||||
|
||||
RefreshSelection();
|
||||
*/
|
||||
RefreshSelection();
|
||||
}
|
||||
|
||||
void MainWindow::RefreshActiveAsset()
|
||||
{
|
||||
// #se_editor_asset
|
||||
/*
|
||||
if (m_activeGraph.IsValid())
|
||||
{
|
||||
AssetHelpers::PrintInfo("RefreshActiveAsset : m_activeGraph (%s)", m_activeGraph.ToString().c_str());
|
||||
|
||||
ScriptCanvasMemoryAsset::pointer memoryAsset;
|
||||
AssetTrackerRequestBus::BroadcastResult(memoryAsset, &AssetTrackerRequests::GetAsset, m_activeGraph);
|
||||
|
||||
if (memoryAsset)
|
||||
if (auto view = m_tabBar->ModOrCreateTabView(m_tabBar->FindTab(m_activeGraph)))
|
||||
{
|
||||
AZ::EntityId sceneEntityId = memoryAsset->GetScriptCanvasId();
|
||||
|
||||
const auto& scriptCanvasAsset = memoryAsset->GetAsset();
|
||||
|
||||
if (scriptCanvasAsset.IsReady() && scriptCanvasAsset.Get()->GetScriptCanvasEntity()->GetState() == AZ::Entity::State::Active)
|
||||
{
|
||||
if (!memoryAsset->GetView())
|
||||
{
|
||||
memoryAsset->CreateView(m_tabBar);
|
||||
}
|
||||
|
||||
auto view = memoryAsset->GetView();
|
||||
AZ_Assert(view, "Asset should have a view");
|
||||
if (view)
|
||||
{
|
||||
AssetHelpers::PrintInfo("RefreshActiveAsset : m_activeGraph (%s)", m_activeGraph.ToString().c_str());
|
||||
|
||||
view->ShowScene(sceneEntityId);
|
||||
m_layout->addWidget(view);
|
||||
view->show();
|
||||
|
||||
m_emptyCanvas->hide();
|
||||
}
|
||||
|
||||
SignalActiveSceneChanged(m_activeGraph);
|
||||
}
|
||||
view->ShowScene(m_activeGraph.Get()->GetScriptCanvasId());
|
||||
m_layout->addWidget(view);
|
||||
view->show();
|
||||
m_emptyCanvas->hide();
|
||||
SignalActiveSceneChanged(m_activeGraph);
|
||||
}
|
||||
else
|
||||
{
|
||||
// If we couldn't load a memory asset for our active asset. Just set ourselves to invalid.
|
||||
SetActiveAsset({});
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void MainWindow::Clear()
|
||||
{
|
||||
m_tabBar->CloseAllTabs();
|
||||
// #se_editor_asset
|
||||
// #sc_editor_asset
|
||||
//
|
||||
// AssetTrackerRequests::AssetList assets;
|
||||
// AssetTrackerRequestBus::BroadcastResult(assets, &AssetTrackerRequests::GetAssets);
|
||||
@@ -2855,12 +2770,12 @@ namespace ScriptCanvasEditor
|
||||
QVariant tabdata = m_tabBar->tabData(index);
|
||||
if (tabdata.isValid())
|
||||
{
|
||||
auto fileAssetId = tabdata.value<ScriptCanvasEditor::SourceHandle>();
|
||||
auto fileAssetId = tabdata.value<Widget::GraphTabMetadata>();
|
||||
|
||||
Tracker::ScriptCanvasFileState fileState = Tracker::ScriptCanvasFileState::NEW;
|
||||
bool isSaving = false;
|
||||
|
||||
// #se_editor_asset Get from widgets
|
||||
// #sc_editor_asset Get from widgets
|
||||
/*
|
||||
AssetTrackerRequestBus::BroadcastResult(fileState, &AssetTrackerRequests::GetFileState, fileAssetId);
|
||||
AssetTrackerRequestBus::BroadcastResult(isSaving, &AssetTrackerRequests::IsSaving, fileAssetId);
|
||||
@@ -2874,9 +2789,9 @@ namespace ScriptCanvasEditor
|
||||
UnsavedChangesOptions saveDialogResults = UnsavedChangesOptions::CONTINUE_WITHOUT_SAVING;
|
||||
if (!isSaving && (fileState == Tracker::ScriptCanvasFileState::NEW || fileState == Tracker::ScriptCanvasFileState::MODIFIED || fileState == Tracker::ScriptCanvasFileState::SOURCE_REMOVED))
|
||||
{
|
||||
SetActiveAsset(fileAssetId);
|
||||
SetActiveAsset(fileAssetId.m_assetId);
|
||||
|
||||
// #se_editor_asset
|
||||
// #sc_editor_asset
|
||||
AZStd::string tabName = "Get from widget";
|
||||
// AssetTrackerRequestBus::BroadcastResult(tabName, &AssetTrackerRequests::GetTabName, fileAssetId);
|
||||
|
||||
@@ -2885,7 +2800,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
if (saveDialogResults == UnsavedChangesOptions::SAVE)
|
||||
{
|
||||
// #se_editor_asset
|
||||
// #sc_editor_asset
|
||||
// auto saveCB = [this](bool isSuccessful, AZ::Data::AssetPtr asset, ScriptCanvasEditor::SourceHandle)
|
||||
// {
|
||||
// if (isSuccessful)
|
||||
@@ -2927,10 +2842,9 @@ namespace ScriptCanvasEditor
|
||||
QVariant tabdata = m_tabBar->tabData(index);
|
||||
if (tabdata.isValid())
|
||||
{
|
||||
auto assetId = tabdata.value<ScriptCanvasEditor::SourceHandle>();
|
||||
SaveAssetImpl(assetId, nullptr);
|
||||
auto assetId = tabdata.value<Widget::GraphTabMetadata>();
|
||||
SaveAssetAsImpl(assetId.m_assetId, nullptr);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::CloseAllTabs()
|
||||
@@ -2946,7 +2860,7 @@ namespace ScriptCanvasEditor
|
||||
QVariant tabdata = m_tabBar->tabData(index);
|
||||
if (tabdata.isValid())
|
||||
{
|
||||
auto assetId = tabdata.value<ScriptCanvasEditor::SourceHandle>();
|
||||
auto assetId = tabdata.value<Widget::GraphTabMetadata>().m_assetId;
|
||||
|
||||
m_isClosingTabs = true;
|
||||
m_skipTabOnClose = assetId;
|
||||
@@ -2956,7 +2870,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
void MainWindow::CopyPathToClipboard(int /*index*/)
|
||||
{
|
||||
// #se_editor_asset
|
||||
// #sc_editor_asset
|
||||
/*
|
||||
QVariant tabdata = m_tabBar->tabData(index);
|
||||
|
||||
@@ -2964,7 +2878,7 @@ namespace ScriptCanvasEditor
|
||||
{
|
||||
QClipboard* clipBoard = QGuiApplication::clipboard();
|
||||
|
||||
auto assetId = tabdata.value<ScriptCanvasEditor::SourceHandle>();
|
||||
auto assetId = tabdata.value<Widget::GraphTabMetadata>();
|
||||
|
||||
ScriptCanvasMemoryAsset::pointer memoryAsset;
|
||||
AssetTrackerRequestBus::BroadcastResult(memoryAsset, &AssetTrackerRequests::GetAsset, assetId);
|
||||
@@ -3006,9 +2920,9 @@ namespace ScriptCanvasEditor
|
||||
QVariant tabdata = m_tabBar->tabData(tab);
|
||||
if (tabdata.isValid())
|
||||
{
|
||||
auto assetId = tabdata.value<ScriptCanvasEditor::SourceHandle>();
|
||||
auto assetId = tabdata.value<Widget::GraphTabMetadata>();
|
||||
|
||||
if (assetId != m_skipTabOnClose)
|
||||
if (assetId.m_assetId != m_skipTabOnClose)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -3027,7 +2941,7 @@ namespace ScriptCanvasEditor
|
||||
QVariant tabdata = m_tabBar->tabData(index);
|
||||
if (tabdata.isValid())
|
||||
{
|
||||
auto tabAssetId = tabdata.value<ScriptCanvasEditor::SourceHandle>();
|
||||
auto tabAssetId = tabdata.value<Widget::GraphTabMetadata>();
|
||||
|
||||
if (tabAssetId == m_activeGraph)
|
||||
{
|
||||
@@ -3694,7 +3608,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
void MainWindow::UpdateSaveState()
|
||||
{
|
||||
// #se_editor_asset todo, consider making blocking
|
||||
// #sc_editor_asset todo, consider making blocking
|
||||
// bool enabled = m_activeGraph.IsValid();
|
||||
// bool isSaving = false;
|
||||
// bool hasModifications = false;
|
||||
@@ -3910,7 +3824,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
AZ::EntityId MainWindow::FindEditorNodeIdByAssetNodeId(const ScriptCanvasEditor::SourceHandle& /*assetId*/, AZ::EntityId /*assetNodeId*/) const
|
||||
{
|
||||
// #se_editor_asset
|
||||
// #sc_editor_asset
|
||||
return AZ::EntityId{};
|
||||
// AZ::EntityId editorEntityId;
|
||||
// AssetTrackerRequestBus::BroadcastResult(editorEntityId, &AssetTrackerRequests::GetEditorEntityIdFromSceneEntityId, assetId, assetNodeId);
|
||||
@@ -3919,7 +3833,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
AZ::EntityId MainWindow::FindAssetNodeIdByEditorNodeId(const ScriptCanvasEditor::SourceHandle& /*assetId*/, AZ::EntityId /*editorNodeId*/) const
|
||||
{
|
||||
// #se_editor_asset
|
||||
// #sc_editor_asset
|
||||
return AZ::EntityId{};
|
||||
// AZ::EntityId sceneEntityId;
|
||||
// AssetTrackerRequestBus::BroadcastResult(sceneEntityId, &AssetTrackerRequests::GetSceneEntityIdFromEditorEntityId, assetId, editorNodeId);
|
||||
@@ -4413,7 +4327,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
void MainWindow::OnAssignToSelectedEntities()
|
||||
{
|
||||
// #se_editor_asset consider cutting
|
||||
// #sc_editor_asset consider cutting
|
||||
// Tracker::ScriptCanvasFileState fileState;
|
||||
// AssetTrackerRequestBus::BroadcastResult(fileState, &AssetTrackerRequests::GetFileState, m_activeGraph);
|
||||
//
|
||||
@@ -4487,7 +4401,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
ScriptCanvasEditor::Tracker::ScriptCanvasFileState MainWindow::GetAssetFileState(ScriptCanvasEditor::SourceHandle /*assetId*/) const
|
||||
{
|
||||
// #se_editor_asset
|
||||
// #sc_editor_asset
|
||||
return Tracker::ScriptCanvasFileState::INVALID;
|
||||
// Tracker::ScriptCanvasFileState fileState = Tracker::ScriptCanvasFileState::INVALID;
|
||||
// AssetTrackerRequestBus::BroadcastResult(fileState, &AssetTrackerRequests::GetFileState, assetId);
|
||||
@@ -4540,7 +4454,7 @@ namespace ScriptCanvasEditor
|
||||
if (usableRequestBus)
|
||||
{
|
||||
ScriptCanvasMemoryAsset::pointer memoryAsset;
|
||||
// #se_editor_asset
|
||||
// #sc_editor_asset
|
||||
// AssetTrackerRequestBus::BroadcastResult(memoryAsset, &AssetTrackerRequests::GetAsset, m_activeGraph);
|
||||
|
||||
if (memoryAsset)
|
||||
@@ -4597,6 +4511,7 @@ namespace ScriptCanvasEditor
|
||||
m_filesToOpen.pop_front();
|
||||
|
||||
OpenFile(nextFile.toUtf8().data());
|
||||
OpenNextFile();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -230,7 +230,7 @@ namespace ScriptCanvasEditor
|
||||
, private VariablePaletteRequestBus::Handler
|
||||
, private ScriptCanvas::BatchOperationNotificationBus::Handler
|
||||
, private AssetGraphSceneBus::Handler
|
||||
, private AssetTrackerNotificationBus::MultiHandler
|
||||
//, private AssetTrackerNotificationBus::MultiHandler
|
||||
#if SCRIPTCANVAS_EDITOR
|
||||
//, public IEditorNotifyListener
|
||||
#endif
|
||||
@@ -421,7 +421,7 @@ namespace ScriptCanvasEditor
|
||||
//! GeneralRequestBus
|
||||
AZ::Outcome<int, AZStd::string> OpenScriptCanvasAssetId(const SourceHandle& assetId) override;
|
||||
AZ::Outcome<int, AZStd::string> OpenScriptCanvasAsset(SourceHandle scriptCanvasAssetId, int tabIndex = -1) override;
|
||||
AZ::Outcome<int, AZStd::string> OpenScriptCanvasAsset(const ScriptCanvasMemoryAsset& scriptCanvasAsset, int tabIndex = -1);
|
||||
AZ::Outcome<int, AZStd::string> OpenScriptCanvasAssetImplementation(const SourceHandle& sourceHandle, int tabIndex = -1);
|
||||
int CloseScriptCanvasAsset(const SourceHandle& assetId) override;
|
||||
bool CreateScriptCanvasAssetFor(const TypeDefs::EntityComponentId& requestingEntityId) override;
|
||||
|
||||
@@ -556,8 +556,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
bool ActivateAndSaveAsset(const ScriptCanvasEditor::SourceHandle& unsavedAssetId, const Callbacks::OnSave& onSave);
|
||||
|
||||
void SaveNewAsset(AZStd::string_view path, ScriptCanvasEditor::SourceHandle assetId, const Callbacks::OnSave& onSave);
|
||||
void SaveAsset(ScriptCanvasEditor::SourceHandle assetId, const Callbacks::OnSave& onSave);
|
||||
void SaveAs(AZStd::string_view path, ScriptCanvasEditor::SourceHandle assetId, const Callbacks::OnSave& onSave);
|
||||
|
||||
void OpenFile(const char* fullPath);
|
||||
void CreateMenus();
|
||||
|
||||
@@ -190,12 +190,27 @@ namespace ScriptCanvas
|
||||
|
||||
namespace ScriptCanvasEditor
|
||||
{
|
||||
SourceHandle::SourceHandle(const SourceHandle& data, const AZ::Uuid& id, AZStd::string_view path)
|
||||
: m_data(data.m_data)
|
||||
, m_id(id)
|
||||
, m_path(path)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
SourceHandle::SourceHandle(ScriptCanvas::DataPtr graph, const AZ::Uuid& id, AZStd::string_view path)
|
||||
: m_data(graph)
|
||||
, m_id(id)
|
||||
, m_path(path)
|
||||
{}
|
||||
|
||||
bool SourceHandle::AnyEquals(const SourceHandle& other) const
|
||||
{
|
||||
return m_data == other.m_data
|
||||
|| m_id == other.m_id
|
||||
|| m_path == other.m_path;
|
||||
}
|
||||
|
||||
void SourceHandle::Clear()
|
||||
{
|
||||
m_data = nullptr;
|
||||
|
||||
@@ -326,8 +326,12 @@ namespace ScriptCanvasEditor
|
||||
|
||||
SourceHandle() = default;
|
||||
|
||||
SourceHandle(const SourceHandle& data, const AZ::Uuid& id, AZStd::string_view path);
|
||||
|
||||
SourceHandle(ScriptCanvas::DataPtr graph, const AZ::Uuid& id, AZStd::string_view path);
|
||||
|
||||
bool AnyEquals(const SourceHandle& other) const;
|
||||
|
||||
void Clear();
|
||||
|
||||
GraphPtrConst Get() const;
|
||||
@@ -391,11 +395,28 @@ namespace AZStd
|
||||
{
|
||||
using argument_type = ScriptCanvas::SlotId;
|
||||
using result_type = AZStd::size_t;
|
||||
AZ_FORCE_INLINE size_t operator()(const argument_type& ref) const
|
||||
|
||||
inline size_t operator()(const argument_type& ref) const
|
||||
{
|
||||
return AZStd::hash<AZ::Uuid>()(ref.m_id);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct hash<ScriptCanvasEditor::SourceHandle>
|
||||
{
|
||||
using argument_type = ScriptCanvasEditor::SourceHandle;
|
||||
using result_type = AZStd::size_t;
|
||||
|
||||
inline size_t operator()(const argument_type& handle) const
|
||||
{
|
||||
size_t h = 0;
|
||||
hash_combine(h, handle.Id());
|
||||
hash_combine(h, handle.Path());
|
||||
hash_combine(h, handle.Get());
|
||||
return h;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#define SCRIPT_CANVAS_INFINITE_LOOP_DETECTION_COUNT (2000000)
|
||||
|
||||
Reference in New Issue
Block a user