|
@@ -819,16 +819,10 @@ namespace ScriptCanvasEditor
|
|
|
|
|
|
void MainWindow::SignalActiveSceneChanged(ScriptCanvasEditor::SourceHandle assetId)
|
|
void MainWindow::SignalActiveSceneChanged(ScriptCanvasEditor::SourceHandle assetId)
|
|
{
|
|
{
|
|
- // #se_editor_asset
|
|
|
|
- /*
|
|
|
|
- ScriptCanvasMemoryAsset::pointer memoryAsset;
|
|
|
|
- AssetTrackerRequestBus::BroadcastResult(memoryAsset, &AssetTrackerRequests::GetAsset, assetId);
|
|
|
|
-
|
|
|
|
AZ::EntityId graphId;
|
|
AZ::EntityId graphId;
|
|
-
|
|
|
|
- if (memoryAsset)
|
|
|
|
|
|
+ if (assetId)
|
|
{
|
|
{
|
|
- graphId = memoryAsset->GetGraphId();
|
|
|
|
|
|
+ EditorGraphRequestBus::EventResult(graphId, assetId.Get()->GetScriptCanvasId(), &EditorGraphRequests::GetGraphCanvasGraphId);
|
|
}
|
|
}
|
|
|
|
|
|
m_autoSaveTimer.stop();
|
|
m_autoSaveTimer.stop();
|
|
@@ -847,18 +841,20 @@ namespace ScriptCanvasEditor
|
|
GraphCanvas::ViewId viewId;
|
|
GraphCanvas::ViewId viewId;
|
|
GraphCanvas::SceneRequestBus::EventResult(viewId, graphId, &GraphCanvas::SceneRequests::GetViewId);
|
|
GraphCanvas::SceneRequestBus::EventResult(viewId, graphId, &GraphCanvas::SceneRequests::GetViewId);
|
|
|
|
|
|
- AZ_Assert(viewId.IsValid(), "SceneRequest must return a valid ViewId");
|
|
|
|
if (viewId.IsValid())
|
|
if (viewId.IsValid())
|
|
{
|
|
{
|
|
GraphCanvas::ViewNotificationBus::Handler::BusDisconnect();
|
|
GraphCanvas::ViewNotificationBus::Handler::BusDisconnect();
|
|
GraphCanvas::ViewNotificationBus::Handler::BusConnect(viewId);
|
|
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);
|
|
UpdateMenuState(enabled);
|
|
- */
|
|
|
|
}
|
|
}
|
|
|
|
|
|
void MainWindow::UpdateRecentMenu()
|
|
void MainWindow::UpdateRecentMenu()
|
|
@@ -938,7 +934,7 @@ namespace ScriptCanvasEditor
|
|
|
|
|
|
if (shouldSaveResults == UnsavedChangesOptions::SAVE)
|
|
if (shouldSaveResults == UnsavedChangesOptions::SAVE)
|
|
{
|
|
{
|
|
- // #se_editor_asset
|
|
|
|
|
|
+ // #sc_editor_asset
|
|
// Callbacks::OnSave saveCB = [this](bool isSuccessful, AZ::Data::AssetPtr, ScriptCanvasEditor::SourceHandle)
|
|
// Callbacks::OnSave saveCB = [this](bool isSuccessful, AZ::Data::AssetPtr, ScriptCanvasEditor::SourceHandle)
|
|
// {
|
|
// {
|
|
// if (isSuccessful)
|
|
// if (isSuccessful)
|
|
@@ -1138,7 +1134,7 @@ namespace ScriptCanvasEditor
|
|
|
|
|
|
void MainWindow::MarkAssetModified(const ScriptCanvasEditor::SourceHandle& /*assetId*/)
|
|
void MainWindow::MarkAssetModified(const ScriptCanvasEditor::SourceHandle& /*assetId*/)
|
|
{
|
|
{
|
|
-// #se_editor_asset if (!assetId.IsValid())
|
|
|
|
|
|
+// #sc_editor_asset if (!assetId.IsValid())
|
|
// {
|
|
// {
|
|
// return;
|
|
// return;
|
|
// }
|
|
// }
|
|
@@ -1159,7 +1155,7 @@ namespace ScriptCanvasEditor
|
|
|
|
|
|
void MainWindow::RefreshScriptCanvasAsset(const AZ::Data::Asset<ScriptCanvas::ScriptCanvasAssetBase>& /*asset*/)
|
|
void MainWindow::RefreshScriptCanvasAsset(const AZ::Data::Asset<ScriptCanvas::ScriptCanvasAssetBase>& /*asset*/)
|
|
{
|
|
{
|
|
- // #se_editor_asset
|
|
|
|
|
|
+ // #sc_editor_asset
|
|
/*
|
|
/*
|
|
ScriptCanvasMemoryAsset::pointer memoryAsset;
|
|
ScriptCanvasMemoryAsset::pointer memoryAsset;
|
|
AssetTrackerRequestBus::BroadcastResult(memoryAsset, &AssetTrackerRequests::GetAsset, asset.GetId());
|
|
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"));
|
|
return AZ::Failure(AZStd::string("Unable to open asset with invalid asset id"));
|
|
}
|
|
}
|
|
@@ -1210,79 +1203,47 @@ namespace ScriptCanvasEditor
|
|
return AZ::Success(outTabIndex);
|
|
return AZ::Success(outTabIndex);
|
|
}
|
|
}
|
|
|
|
|
|
- AZ::Data::AssetInfo assetInfo;
|
|
|
|
- AZ::Data::AssetCatalogRequestBus::BroadcastResult(assetInfo, &AZ::Data::AssetCatalogRequests::GetAssetInfoById, fileAssetId);
|
|
|
|
-
|
|
|
|
- if (assetInfo.m_relativePath.empty())
|
|
|
|
- {
|
|
|
|
- return AZ::Failure(AZStd::string("Unknown AssetId"));
|
|
|
|
- }
|
|
|
|
|
|
+ outTabIndex = CreateAssetTab(fileAssetId);
|
|
|
|
|
|
- if (assetInfo.m_assetType != azrtti_typeid<ScriptCanvasAsset>())
|
|
|
|
|
|
+ if (!m_isRestoringWorkspace)
|
|
{
|
|
{
|
|
- return AZ::Failure(AZStd::string("Invalid AssetId provided, it's not a Script Canvas supported type"));
|
|
|
|
|
|
+ SetActiveAsset(fileAssetId);
|
|
}
|
|
}
|
|
|
|
|
|
- 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)
|
|
if (outTabIndex >= 0)
|
|
{
|
|
{
|
|
|
|
+ AddRecentFile(fileAssetId.Path().c_str());
|
|
|
|
+ OpenScriptCanvasAssetImplementation(fileAssetId);
|
|
return AZ::Success(outTabIndex);
|
|
return AZ::Success(outTabIndex);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
return AZ::Failure(AZStd::string("Specified asset is in an error state and cannot be properly displayed."));
|
|
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())
|
|
if (!fileAssetId.IsValid())
|
|
{
|
|
{
|
|
return AZ::Failure(AZStd::string("Unable to open asset with invalid asset id"));
|
|
return AZ::Failure(AZStd::string("Unable to open asset with invalid asset id"));
|
|
}
|
|
}
|
|
|
|
|
|
- if (scriptCanvasAsset.IsSourceInError())
|
|
|
|
|
|
+ if (!scriptCanvasAsset.IsValid())
|
|
{
|
|
{
|
|
if (!m_isRestoringWorkspace)
|
|
if (!m_isRestoringWorkspace)
|
|
{
|
|
{
|
|
- AZStd::string errorPath = scriptCanvasAsset.GetAbsolutePath();
|
|
|
|
|
|
+ AZStd::string errorPath = scriptCanvasAsset.Path();
|
|
|
|
|
|
if (errorPath.empty())
|
|
if (errorPath.empty())
|
|
{
|
|
{
|
|
errorPath = m_errorFilePath;
|
|
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);
|
|
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)
|
|
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)
|
|
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)
|
|
if (!m_isRestoringWorkspace)
|
|
@@ -1326,47 +1283,34 @@ namespace ScriptCanvasEditor
|
|
SetActiveAsset(fileAssetId);
|
|
SetActiveAsset(fileAssetId);
|
|
}
|
|
}
|
|
|
|
|
|
- GraphCanvas::GraphId graphCanvasGraphId = GetGraphCanvasGraphId(scriptCanvasAsset.GetScriptCanvasId());
|
|
|
|
|
|
+ GraphCanvas::GraphId graphCanvasGraphId = GetGraphCanvasGraphId(scriptCanvasAsset.Get()->GetScriptCanvasId());
|
|
GraphCanvas::AssetEditorNotificationBus::Event(ScriptCanvasEditor::AssetEditorId, &GraphCanvas::AssetEditorNotifications::OnGraphLoaded, graphCanvasGraphId);
|
|
GraphCanvas::AssetEditorNotificationBus::Event(ScriptCanvasEditor::AssetEditorId, &GraphCanvas::AssetEditorNotifications::OnGraphLoaded, graphCanvasGraphId);
|
|
|
|
|
|
GeneralAssetNotificationBus::Event(fileAssetId, &GeneralAssetNotifications::OnAssetVisualized);
|
|
GeneralAssetNotificationBus::Event(fileAssetId, &GeneralAssetNotifications::OnAssetVisualized);
|
|
|
|
|
|
- AssetTrackerNotificationBus::MultiHandler::BusConnect(fileAssetId);
|
|
|
|
-
|
|
|
|
return AZ::Success(outTabIndex);
|
|
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
|
|
else
|
|
{
|
|
{
|
|
return OpenScriptCanvasAssetId(scriptCanvasAssetId);
|
|
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*/)
|
|
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"));
|
|
return AZ::Failure(AZStd::string("rewrite MainWindow::UpdateScriptCanvasAsset"));
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -1391,7 +1335,7 @@ namespace ScriptCanvasEditor
|
|
|
|
|
|
void MainWindow::RemoveScriptCanvasAsset(const ScriptCanvasEditor::SourceHandle& /*assetId*/)
|
|
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());
|
|
AssetHelpers::PrintInfo("RemoveScriptCanvasAsset : %s", AssetHelpers::AssetIdToString(assetId).c_str());
|
|
|
|
|
|
@@ -1417,7 +1361,7 @@ namespace ScriptCanvasEditor
|
|
QVariant tabdata = m_tabBar->tabData(tabIndex);
|
|
QVariant tabdata = m_tabBar->tabData(tabIndex);
|
|
if (tabdata.isValid())
|
|
if (tabdata.isValid())
|
|
{
|
|
{
|
|
- auto tabAssetId = tabdata.value<ScriptCanvasEditor::SourceHandle>();
|
|
|
|
|
|
+ auto tabAssetId = tabdata.value<Widget::GraphTabMetadata>();
|
|
SetActiveAsset(tabAssetId);
|
|
SetActiveAsset(tabAssetId);
|
|
}
|
|
}
|
|
*/
|
|
*/
|
|
@@ -1465,7 +1409,7 @@ namespace ScriptCanvasEditor
|
|
|
|
|
|
bool MainWindow::IsScriptCanvasAssetOpen(const ScriptCanvasEditor::SourceHandle& /*assetId*/) const
|
|
bool MainWindow::IsScriptCanvasAssetOpen(const ScriptCanvasEditor::SourceHandle& /*assetId*/) const
|
|
{
|
|
{
|
|
- // #se_editor_asset
|
|
|
|
|
|
+ // #sc_editor_asset
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1481,7 +1425,7 @@ namespace ScriptCanvasEditor
|
|
|
|
|
|
void MainWindow::GetSuggestedFullFilenameToSaveAs(const ScriptCanvasEditor::SourceHandle& /*assetId*/, AZStd::string& /*filePath*/, AZStd::string& /*fileFilter*/)
|
|
void MainWindow::GetSuggestedFullFilenameToSaveAs(const ScriptCanvasEditor::SourceHandle& /*assetId*/, AZStd::string& /*filePath*/, AZStd::string& /*fileFilter*/)
|
|
{
|
|
{
|
|
- // #se_editor_asset
|
|
|
|
|
|
+ // #sc_editor_asset
|
|
/*
|
|
/*
|
|
ScriptCanvasMemoryAsset::pointer memoryAsset;
|
|
ScriptCanvasMemoryAsset::pointer memoryAsset;
|
|
AssetTrackerRequestBus::BroadcastResult(memoryAsset, &AssetTrackerRequests::GetAsset, assetId);
|
|
AssetTrackerRequestBus::BroadcastResult(memoryAsset, &AssetTrackerRequests::GetAsset, assetId);
|
|
@@ -1528,18 +1472,50 @@ namespace ScriptCanvasEditor
|
|
|
|
|
|
void MainWindow::OpenFile(const char* fullPath)
|
|
void MainWindow::OpenFile(const char* fullPath)
|
|
{
|
|
{
|
|
- AZ::Outcome<ScriptCanvasEditor::SourceHandle, AZStd::string> outcome = LoadFromFile(fullPath);
|
|
|
|
|
|
+ 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())
|
|
if (!outcome.IsSuccess())
|
|
{
|
|
{
|
|
|
|
+ QMessageBox::warning(this, "Invalid Source File", QString("'%1' is not a valid file path.").arg(fullPath), QMessageBox::Ok);
|
|
m_errorFilePath = fullPath;
|
|
m_errorFilePath = fullPath;
|
|
AZ_Warning("ScriptCanvas", false, "Unable to open file as a ScriptCanvas graph: %s", 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
|
|
else
|
|
{
|
|
{
|
|
- m_errorFilePath.clear();
|
|
|
|
- m_activeGraph = outcome.TakeValue();
|
|
|
|
- return;
|
|
|
|
|
|
+ AZ_Warning("Script Canvas", openOutcome, "%s", openOutcome.GetError().data());
|
|
}
|
|
}
|
|
|
|
|
|
#if defined(EDITOR_ASSET_SUPPORT_ENABLED)
|
|
#if defined(EDITOR_ASSET_SUPPORT_ENABLED)
|
|
@@ -1770,7 +1746,7 @@ namespace ScriptCanvasEditor
|
|
|
|
|
|
bool MainWindow::OnFileSave(const Callbacks::OnSave& saveCB)
|
|
bool MainWindow::OnFileSave(const Callbacks::OnSave& saveCB)
|
|
{
|
|
{
|
|
- return SaveAssetImpl(m_activeGraph, saveCB);
|
|
|
|
|
|
+ return SaveAssetAsImpl(m_activeGraph, saveCB);
|
|
}
|
|
}
|
|
|
|
|
|
bool MainWindow::OnFileSaveAs(const Callbacks::OnSave& saveCB)
|
|
bool MainWindow::OnFileSaveAs(const Callbacks::OnSave& saveCB)
|
|
@@ -1798,7 +1774,7 @@ namespace ScriptCanvasEditor
|
|
else if (fileState == Tracker::ScriptCanvasFileState::MODIFIED
|
|
else if (fileState == Tracker::ScriptCanvasFileState::MODIFIED
|
|
|| fileState == Tracker::ScriptCanvasFileState::SOURCE_REMOVED)
|
|
|| fileState == Tracker::ScriptCanvasFileState::SOURCE_REMOVED)
|
|
{
|
|
{
|
|
- SaveAsset(assetId, saveCB);
|
|
|
|
|
|
+ SaveAs(assetId.Path(), assetId, saveCB);
|
|
saveSuccessful = true;
|
|
saveSuccessful = true;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1878,7 +1854,7 @@ namespace ScriptCanvasEditor
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
- SaveNewAsset(internalStringFile, inMemoryAssetId, saveCB);
|
|
|
|
|
|
+ SaveAs(internalStringFile, inMemoryAssetId, saveCB);
|
|
|
|
|
|
m_newlySavedFile = internalStringFile;
|
|
m_newlySavedFile = internalStringFile;
|
|
|
|
|
|
@@ -1893,7 +1869,7 @@ namespace ScriptCanvasEditor
|
|
|
|
|
|
void MainWindow::OnSaveCallback(bool /*saveSuccess*/, AZ::Data::AssetPtr /*fileAsset*/, ScriptCanvasEditor::SourceHandle /*previousFileAssetId*/)
|
|
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;
|
|
ScriptCanvasMemoryAsset::pointer memoryAsset;
|
|
@@ -1915,7 +1891,7 @@ namespace ScriptCanvasEditor
|
|
if (saveTabIndex != m_tabBar->currentIndex())
|
|
if (saveTabIndex != m_tabBar->currentIndex())
|
|
{
|
|
{
|
|
// Invalidate the file asset id so we don't delete trigger the asset flow.
|
|
// 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);
|
|
m_tabBar->CloseTab(saveTabIndex);
|
|
saveTabIndex = -1;
|
|
saveTabIndex = -1;
|
|
@@ -1936,6 +1912,7 @@ namespace ScriptCanvasEditor
|
|
AzFramework::StringFunc::Path::GetFileName(memoryAsset->GetAbsolutePath().c_str(), tabName);
|
|
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)
|
|
// 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);
|
|
m_tabBar->ConfigureTab(saveTabIndex, fileAssetId, tabName);
|
|
|
|
|
|
GeneralAssetNotificationBus::Event(memoryAsset->GetId(), &GeneralAssetNotifications::OnAssetVisualized);
|
|
GeneralAssetNotificationBus::Event(memoryAsset->GetId(), &GeneralAssetNotifications::OnAssetVisualized);
|
|
@@ -2027,25 +2004,13 @@ namespace ScriptCanvasEditor
|
|
return OnFileSave(saveCB);
|
|
return OnFileSave(saveCB);
|
|
}
|
|
}
|
|
|
|
|
|
- void MainWindow::SaveAsset(ScriptCanvasEditor::SourceHandle /*assetId*/, const Callbacks::OnSave& /*onSave*/)
|
|
|
|
|
|
+ void MainWindow::SaveAs(AZStd::string_view /*path*/, ScriptCanvasEditor::SourceHandle /*inMemoryAssetId*/, 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();
|
|
|
|
|
|
+ PrepareAssetForSave(inMemoryAssetId);
|
|
|
|
|
|
ScriptCanvasMemoryAsset::pointer memoryAsset;
|
|
ScriptCanvasMemoryAsset::pointer memoryAsset;
|
|
- AssetTrackerRequestBus::BroadcastResult(memoryAsset, &AssetTrackerRequests::GetAsset, m_activeGraph);
|
|
|
|
|
|
+ AssetTrackerRequestBus::BroadcastResult(memoryAsset, &AssetTrackerRequests::GetAsset, inMemoryAssetId);
|
|
|
|
|
|
// Disable the current view if we are saving.
|
|
// Disable the current view if we are saving.
|
|
if (memoryAsset)
|
|
if (memoryAsset)
|
|
@@ -2053,15 +2018,6 @@ namespace ScriptCanvasEditor
|
|
DisableAssetView(memoryAsset);
|
|
DisableAssetView(memoryAsset);
|
|
}
|
|
}
|
|
|
|
|
|
- BlockCloseRequests();
|
|
|
|
- */
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- void MainWindow::SaveNewAsset(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)
|
|
auto onSaveCallback = [this, onSave](bool saveSuccess, AZ::Data::AssetPtr asset, ScriptCanvasEditor::SourceHandle previousAssetId)
|
|
{
|
|
{
|
|
OnSaveCallback(saveSuccess, asset, previousAssetId);
|
|
OnSaveCallback(saveSuccess, asset, previousAssetId);
|
|
@@ -2070,19 +2026,36 @@ namespace ScriptCanvasEditor
|
|
AZStd::invoke(onSave, saveSuccess, asset, previousAssetId);
|
|
AZStd::invoke(onSave, saveSuccess, asset, previousAssetId);
|
|
}
|
|
}
|
|
};
|
|
};
|
|
- AssetTrackerRequestBus::Broadcast(&AssetTrackerRequests::SaveAs, inMemoryAssetId, path, onSaveCallback);
|
|
|
|
|
|
|
|
- UpdateSaveState();
|
|
|
|
|
|
+ AZ::Data::AssetStreamInfo streamInfo;
|
|
|
|
+ streamInfo.m_streamFlags = AZ::IO::OpenMode::ModeWrite;
|
|
|
|
+ streamInfo.m_streamName = m_saveAsPath;
|
|
|
|
|
|
- ScriptCanvasMemoryAsset::pointer memoryAsset;
|
|
|
|
- AssetTrackerRequestBus::BroadcastResult(memoryAsset, &AssetTrackerRequests::GetAsset, inMemoryAssetId);
|
|
|
|
|
|
+ if (!streamInfo.IsValid())
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
|
|
- // Disable the current view if we are saving.
|
|
|
|
- if (memoryAsset)
|
|
|
|
|
|
+ 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)
|
|
{
|
|
{
|
|
- DisableAssetView(memoryAsset);
|
|
|
|
|
|
+ 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();
|
|
BlockCloseRequests();
|
|
*/
|
|
*/
|
|
}
|
|
}
|
|
@@ -2503,7 +2476,6 @@ namespace ScriptCanvasEditor
|
|
if (eraseCount == 0)
|
|
if (eraseCount == 0)
|
|
{
|
|
{
|
|
AZStd::string fullPath = AZStd::string::format("%s/%s", rootFilePath.c_str(), assetInfo.m_relativePath.c_str());
|
|
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
|
|
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 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
|
|
bool MainWindow::IsInUndoRedo(const AZ::EntityId& graphCanvasGraphId) const
|
|
{
|
|
{
|
|
- // #se_editor_asset
|
|
|
|
|
|
+ // #sc_editor_asset
|
|
bool isActive = false;
|
|
bool isActive = false;
|
|
UndoRequestBus::EventResult(isActive, GetScriptCanvasId(graphCanvasGraphId), &UndoRequests::IsActive);
|
|
UndoRequestBus::EventResult(isActive, GetScriptCanvasId(graphCanvasGraphId), &UndoRequests::IsActive);
|
|
return isActive;
|
|
return isActive;
|
|
@@ -2660,8 +2618,8 @@ namespace ScriptCanvasEditor
|
|
QVariant tabdata = m_tabBar->tabData(tabIndex);
|
|
QVariant tabdata = m_tabBar->tabData(tabIndex);
|
|
if (tabdata.isValid())
|
|
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;
|
|
return tabdata;
|
|
}
|
|
}
|
|
@@ -2681,21 +2639,15 @@ namespace ScriptCanvasEditor
|
|
return false;
|
|
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
|
|
// Disconnect previous asset
|
|
AZ::EntityId previousScriptCanvasSceneId;
|
|
AZ::EntityId previousScriptCanvasSceneId;
|
|
if (previousAsset)
|
|
if (previousAsset)
|
|
{
|
|
{
|
|
- previousScriptCanvasSceneId = previousAsset->GetScriptCanvasId();
|
|
|
|
|
|
+ previousScriptCanvasSceneId = previousAsset.Get()->GetScriptCanvasId();
|
|
GraphCanvas::SceneNotificationBus::MultiHandler::BusDisconnect(previousScriptCanvasSceneId);
|
|
GraphCanvas::SceneNotificationBus::MultiHandler::BusDisconnect(previousScriptCanvasSceneId);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2703,7 +2655,8 @@ namespace ScriptCanvasEditor
|
|
if (nextAsset)
|
|
if (nextAsset)
|
|
{
|
|
{
|
|
// Connect the next asset
|
|
// Connect the next asset
|
|
- nextAssetGraphCanvasId = nextAsset->GetGraphId();
|
|
|
|
|
|
+ EditorGraphRequestBus::EventResult(nextAssetGraphCanvasId, nextAsset.Get()->GetScriptCanvasId(), &EditorGraphRequests::GetGraphCanvasGraphId);
|
|
|
|
+
|
|
if (nextAssetGraphCanvasId.IsValid())
|
|
if (nextAssetGraphCanvasId.IsValid())
|
|
{
|
|
{
|
|
GraphCanvas::SceneNotificationBus::MultiHandler::BusConnect(nextAssetGraphCanvasId);
|
|
GraphCanvas::SceneNotificationBus::MultiHandler::BusConnect(nextAssetGraphCanvasId);
|
|
@@ -2716,13 +2669,12 @@ namespace ScriptCanvasEditor
|
|
|
|
|
|
// Notify about the graph refresh
|
|
// Notify about the graph refresh
|
|
GraphCanvas::AssetEditorNotificationBus::Event(ScriptCanvasEditor::AssetEditorId, &GraphCanvas::AssetEditorNotifications::OnGraphRefreshed, previousScriptCanvasSceneId, nextAssetGraphCanvasId);
|
|
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)
|
|
if (m_activeGraph == fileAssetId)
|
|
{
|
|
{
|
|
return;
|
|
return;
|
|
@@ -2745,98 +2697,61 @@ namespace ScriptCanvasEditor
|
|
|
|
|
|
if (m_activeGraph.IsValid())
|
|
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,
|
|
// 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
|
|
// 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())
|
|
if (fileAssetId.IsValid())
|
|
{
|
|
{
|
|
ScriptCanvasEditor::SourceHandle previousAssetId = m_activeGraph;
|
|
ScriptCanvasEditor::SourceHandle previousAssetId = m_activeGraph;
|
|
-
|
|
|
|
m_activeGraph = fileAssetId;
|
|
m_activeGraph = fileAssetId;
|
|
RefreshActiveAsset();
|
|
RefreshActiveAsset();
|
|
-
|
|
|
|
ReconnectSceneBuses(previousAssetId, m_activeGraph);
|
|
ReconnectSceneBuses(previousAssetId, m_activeGraph);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
ScriptCanvasEditor::SourceHandle previousAssetId = m_activeGraph;
|
|
ScriptCanvasEditor::SourceHandle previousAssetId = m_activeGraph;
|
|
-
|
|
|
|
m_activeGraph.Clear();
|
|
m_activeGraph.Clear();
|
|
m_emptyCanvas->show();
|
|
m_emptyCanvas->show();
|
|
-
|
|
|
|
ReconnectSceneBuses(previousAssetId, m_activeGraph);
|
|
ReconnectSceneBuses(previousAssetId, m_activeGraph);
|
|
-
|
|
|
|
SignalActiveSceneChanged(ScriptCanvasEditor::SourceHandle());
|
|
SignalActiveSceneChanged(ScriptCanvasEditor::SourceHandle());
|
|
}
|
|
}
|
|
|
|
|
|
UpdateUndoCache(fileAssetId);
|
|
UpdateUndoCache(fileAssetId);
|
|
-
|
|
|
|
- RefreshSelection();
|
|
|
|
- */
|
|
|
|
|
|
+ RefreshSelection();
|
|
}
|
|
}
|
|
|
|
|
|
void MainWindow::RefreshActiveAsset()
|
|
void MainWindow::RefreshActiveAsset()
|
|
{
|
|
{
|
|
- // #se_editor_asset
|
|
|
|
- /*
|
|
|
|
if (m_activeGraph.IsValid())
|
|
if (m_activeGraph.IsValid())
|
|
{
|
|
{
|
|
AssetHelpers::PrintInfo("RefreshActiveAsset : m_activeGraph (%s)", m_activeGraph.ToString().c_str());
|
|
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
|
|
else
|
|
{
|
|
{
|
|
- // If we couldn't load a memory asset for our active asset. Just set ourselves to invalid.
|
|
|
|
SetActiveAsset({});
|
|
SetActiveAsset({});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- */
|
|
|
|
}
|
|
}
|
|
|
|
|
|
void MainWindow::Clear()
|
|
void MainWindow::Clear()
|
|
{
|
|
{
|
|
m_tabBar->CloseAllTabs();
|
|
m_tabBar->CloseAllTabs();
|
|
- // #se_editor_asset
|
|
|
|
|
|
+ // #sc_editor_asset
|
|
//
|
|
//
|
|
// AssetTrackerRequests::AssetList assets;
|
|
// AssetTrackerRequests::AssetList assets;
|
|
// AssetTrackerRequestBus::BroadcastResult(assets, &AssetTrackerRequests::GetAssets);
|
|
// AssetTrackerRequestBus::BroadcastResult(assets, &AssetTrackerRequests::GetAssets);
|
|
@@ -2855,12 +2770,12 @@ namespace ScriptCanvasEditor
|
|
QVariant tabdata = m_tabBar->tabData(index);
|
|
QVariant tabdata = m_tabBar->tabData(index);
|
|
if (tabdata.isValid())
|
|
if (tabdata.isValid())
|
|
{
|
|
{
|
|
- auto fileAssetId = tabdata.value<ScriptCanvasEditor::SourceHandle>();
|
|
|
|
|
|
+ auto fileAssetId = tabdata.value<Widget::GraphTabMetadata>();
|
|
|
|
|
|
Tracker::ScriptCanvasFileState fileState = Tracker::ScriptCanvasFileState::NEW;
|
|
Tracker::ScriptCanvasFileState fileState = Tracker::ScriptCanvasFileState::NEW;
|
|
bool isSaving = false;
|
|
bool isSaving = false;
|
|
|
|
|
|
- // #se_editor_asset Get from widgets
|
|
|
|
|
|
+ // #sc_editor_asset Get from widgets
|
|
/*
|
|
/*
|
|
AssetTrackerRequestBus::BroadcastResult(fileState, &AssetTrackerRequests::GetFileState, fileAssetId);
|
|
AssetTrackerRequestBus::BroadcastResult(fileState, &AssetTrackerRequests::GetFileState, fileAssetId);
|
|
AssetTrackerRequestBus::BroadcastResult(isSaving, &AssetTrackerRequests::IsSaving, fileAssetId);
|
|
AssetTrackerRequestBus::BroadcastResult(isSaving, &AssetTrackerRequests::IsSaving, fileAssetId);
|
|
@@ -2874,9 +2789,9 @@ namespace ScriptCanvasEditor
|
|
UnsavedChangesOptions saveDialogResults = UnsavedChangesOptions::CONTINUE_WITHOUT_SAVING;
|
|
UnsavedChangesOptions saveDialogResults = UnsavedChangesOptions::CONTINUE_WITHOUT_SAVING;
|
|
if (!isSaving && (fileState == Tracker::ScriptCanvasFileState::NEW || fileState == Tracker::ScriptCanvasFileState::MODIFIED || fileState == Tracker::ScriptCanvasFileState::SOURCE_REMOVED))
|
|
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";
|
|
AZStd::string tabName = "Get from widget";
|
|
// AssetTrackerRequestBus::BroadcastResult(tabName, &AssetTrackerRequests::GetTabName, fileAssetId);
|
|
// AssetTrackerRequestBus::BroadcastResult(tabName, &AssetTrackerRequests::GetTabName, fileAssetId);
|
|
|
|
|
|
@@ -2885,7 +2800,7 @@ namespace ScriptCanvasEditor
|
|
|
|
|
|
if (saveDialogResults == UnsavedChangesOptions::SAVE)
|
|
if (saveDialogResults == UnsavedChangesOptions::SAVE)
|
|
{
|
|
{
|
|
- // #se_editor_asset
|
|
|
|
|
|
+ // #sc_editor_asset
|
|
// auto saveCB = [this](bool isSuccessful, AZ::Data::AssetPtr asset, ScriptCanvasEditor::SourceHandle)
|
|
// auto saveCB = [this](bool isSuccessful, AZ::Data::AssetPtr asset, ScriptCanvasEditor::SourceHandle)
|
|
// {
|
|
// {
|
|
// if (isSuccessful)
|
|
// if (isSuccessful)
|
|
@@ -2927,10 +2842,9 @@ namespace ScriptCanvasEditor
|
|
QVariant tabdata = m_tabBar->tabData(index);
|
|
QVariant tabdata = m_tabBar->tabData(index);
|
|
if (tabdata.isValid())
|
|
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()
|
|
void MainWindow::CloseAllTabs()
|
|
@@ -2946,7 +2860,7 @@ namespace ScriptCanvasEditor
|
|
QVariant tabdata = m_tabBar->tabData(index);
|
|
QVariant tabdata = m_tabBar->tabData(index);
|
|
if (tabdata.isValid())
|
|
if (tabdata.isValid())
|
|
{
|
|
{
|
|
- auto assetId = tabdata.value<ScriptCanvasEditor::SourceHandle>();
|
|
|
|
|
|
+ auto assetId = tabdata.value<Widget::GraphTabMetadata>().m_assetId;
|
|
|
|
|
|
m_isClosingTabs = true;
|
|
m_isClosingTabs = true;
|
|
m_skipTabOnClose = assetId;
|
|
m_skipTabOnClose = assetId;
|
|
@@ -2956,7 +2870,7 @@ namespace ScriptCanvasEditor
|
|
|
|
|
|
void MainWindow::CopyPathToClipboard(int /*index*/)
|
|
void MainWindow::CopyPathToClipboard(int /*index*/)
|
|
{
|
|
{
|
|
- // #se_editor_asset
|
|
|
|
|
|
+ // #sc_editor_asset
|
|
/*
|
|
/*
|
|
QVariant tabdata = m_tabBar->tabData(index);
|
|
QVariant tabdata = m_tabBar->tabData(index);
|
|
|
|
|
|
@@ -2964,7 +2878,7 @@ namespace ScriptCanvasEditor
|
|
{
|
|
{
|
|
QClipboard* clipBoard = QGuiApplication::clipboard();
|
|
QClipboard* clipBoard = QGuiApplication::clipboard();
|
|
|
|
|
|
- auto assetId = tabdata.value<ScriptCanvasEditor::SourceHandle>();
|
|
|
|
|
|
+ auto assetId = tabdata.value<Widget::GraphTabMetadata>();
|
|
|
|
|
|
ScriptCanvasMemoryAsset::pointer memoryAsset;
|
|
ScriptCanvasMemoryAsset::pointer memoryAsset;
|
|
AssetTrackerRequestBus::BroadcastResult(memoryAsset, &AssetTrackerRequests::GetAsset, assetId);
|
|
AssetTrackerRequestBus::BroadcastResult(memoryAsset, &AssetTrackerRequests::GetAsset, assetId);
|
|
@@ -3006,9 +2920,9 @@ namespace ScriptCanvasEditor
|
|
QVariant tabdata = m_tabBar->tabData(tab);
|
|
QVariant tabdata = m_tabBar->tabData(tab);
|
|
if (tabdata.isValid())
|
|
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;
|
|
break;
|
|
}
|
|
}
|
|
@@ -3027,7 +2941,7 @@ namespace ScriptCanvasEditor
|
|
QVariant tabdata = m_tabBar->tabData(index);
|
|
QVariant tabdata = m_tabBar->tabData(index);
|
|
if (tabdata.isValid())
|
|
if (tabdata.isValid())
|
|
{
|
|
{
|
|
- auto tabAssetId = tabdata.value<ScriptCanvasEditor::SourceHandle>();
|
|
|
|
|
|
+ auto tabAssetId = tabdata.value<Widget::GraphTabMetadata>();
|
|
|
|
|
|
if (tabAssetId == m_activeGraph)
|
|
if (tabAssetId == m_activeGraph)
|
|
{
|
|
{
|
|
@@ -3694,7 +3608,7 @@ namespace ScriptCanvasEditor
|
|
|
|
|
|
void MainWindow::UpdateSaveState()
|
|
void MainWindow::UpdateSaveState()
|
|
{
|
|
{
|
|
- // #se_editor_asset todo, consider making blocking
|
|
|
|
|
|
+ // #sc_editor_asset todo, consider making blocking
|
|
// bool enabled = m_activeGraph.IsValid();
|
|
// bool enabled = m_activeGraph.IsValid();
|
|
// bool isSaving = false;
|
|
// bool isSaving = false;
|
|
// bool hasModifications = false;
|
|
// bool hasModifications = false;
|
|
@@ -3910,7 +3824,7 @@ namespace ScriptCanvasEditor
|
|
|
|
|
|
AZ::EntityId MainWindow::FindEditorNodeIdByAssetNodeId(const ScriptCanvasEditor::SourceHandle& /*assetId*/, AZ::EntityId /*assetNodeId*/) const
|
|
AZ::EntityId MainWindow::FindEditorNodeIdByAssetNodeId(const ScriptCanvasEditor::SourceHandle& /*assetId*/, AZ::EntityId /*assetNodeId*/) const
|
|
{
|
|
{
|
|
- // #se_editor_asset
|
|
|
|
|
|
+ // #sc_editor_asset
|
|
return AZ::EntityId{};
|
|
return AZ::EntityId{};
|
|
// AZ::EntityId editorEntityId;
|
|
// AZ::EntityId editorEntityId;
|
|
// AssetTrackerRequestBus::BroadcastResult(editorEntityId, &AssetTrackerRequests::GetEditorEntityIdFromSceneEntityId, assetId, assetNodeId);
|
|
// 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
|
|
AZ::EntityId MainWindow::FindAssetNodeIdByEditorNodeId(const ScriptCanvasEditor::SourceHandle& /*assetId*/, AZ::EntityId /*editorNodeId*/) const
|
|
{
|
|
{
|
|
- // #se_editor_asset
|
|
|
|
|
|
+ // #sc_editor_asset
|
|
return AZ::EntityId{};
|
|
return AZ::EntityId{};
|
|
// AZ::EntityId sceneEntityId;
|
|
// AZ::EntityId sceneEntityId;
|
|
// AssetTrackerRequestBus::BroadcastResult(sceneEntityId, &AssetTrackerRequests::GetSceneEntityIdFromEditorEntityId, assetId, editorNodeId);
|
|
// AssetTrackerRequestBus::BroadcastResult(sceneEntityId, &AssetTrackerRequests::GetSceneEntityIdFromEditorEntityId, assetId, editorNodeId);
|
|
@@ -4413,7 +4327,7 @@ namespace ScriptCanvasEditor
|
|
|
|
|
|
void MainWindow::OnAssignToSelectedEntities()
|
|
void MainWindow::OnAssignToSelectedEntities()
|
|
{
|
|
{
|
|
- // #se_editor_asset consider cutting
|
|
|
|
|
|
+ // #sc_editor_asset consider cutting
|
|
// Tracker::ScriptCanvasFileState fileState;
|
|
// Tracker::ScriptCanvasFileState fileState;
|
|
// AssetTrackerRequestBus::BroadcastResult(fileState, &AssetTrackerRequests::GetFileState, m_activeGraph);
|
|
// AssetTrackerRequestBus::BroadcastResult(fileState, &AssetTrackerRequests::GetFileState, m_activeGraph);
|
|
//
|
|
//
|
|
@@ -4487,7 +4401,7 @@ namespace ScriptCanvasEditor
|
|
|
|
|
|
ScriptCanvasEditor::Tracker::ScriptCanvasFileState MainWindow::GetAssetFileState(ScriptCanvasEditor::SourceHandle /*assetId*/) const
|
|
ScriptCanvasEditor::Tracker::ScriptCanvasFileState MainWindow::GetAssetFileState(ScriptCanvasEditor::SourceHandle /*assetId*/) const
|
|
{
|
|
{
|
|
- // #se_editor_asset
|
|
|
|
|
|
+ // #sc_editor_asset
|
|
return Tracker::ScriptCanvasFileState::INVALID;
|
|
return Tracker::ScriptCanvasFileState::INVALID;
|
|
// Tracker::ScriptCanvasFileState fileState = Tracker::ScriptCanvasFileState::INVALID;
|
|
// Tracker::ScriptCanvasFileState fileState = Tracker::ScriptCanvasFileState::INVALID;
|
|
// AssetTrackerRequestBus::BroadcastResult(fileState, &AssetTrackerRequests::GetFileState, assetId);
|
|
// AssetTrackerRequestBus::BroadcastResult(fileState, &AssetTrackerRequests::GetFileState, assetId);
|
|
@@ -4540,7 +4454,7 @@ namespace ScriptCanvasEditor
|
|
if (usableRequestBus)
|
|
if (usableRequestBus)
|
|
{
|
|
{
|
|
ScriptCanvasMemoryAsset::pointer memoryAsset;
|
|
ScriptCanvasMemoryAsset::pointer memoryAsset;
|
|
- // #se_editor_asset
|
|
|
|
|
|
+ // #sc_editor_asset
|
|
// AssetTrackerRequestBus::BroadcastResult(memoryAsset, &AssetTrackerRequests::GetAsset, m_activeGraph);
|
|
// AssetTrackerRequestBus::BroadcastResult(memoryAsset, &AssetTrackerRequests::GetAsset, m_activeGraph);
|
|
|
|
|
|
if (memoryAsset)
|
|
if (memoryAsset)
|
|
@@ -4597,6 +4511,7 @@ namespace ScriptCanvasEditor
|
|
m_filesToOpen.pop_front();
|
|
m_filesToOpen.pop_front();
|
|
|
|
|
|
OpenFile(nextFile.toUtf8().data());
|
|
OpenFile(nextFile.toUtf8().data());
|
|
|
|
+ OpenNextFile();
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|