Script Canvas, replace the text replacement system to a JSON file based one (#5228)

It is now possible to right click on nodes on the node palette to navigate to the file that holds the text data for any given node, this way it is easy to update and improve the naming of titles, subtitles, categories, tool tips and slots.
This commit is contained in:
Luis Sempé
2021-11-11 11:53:51 -08:00
committed by GitHub
parent 9d93282e42
commit 9e2a3226fd
1382 changed files with 209123 additions and 1515 deletions
@@ -63,6 +63,7 @@
#include <ScriptCanvas/Libraries/Libraries.h>
#include <ScriptCanvas/Utils/NodeUtils.h>
#include <ScriptEvents/ScriptEventsAsset.h>
#include "AzQtComponents/Utilities/DesktopUtilities.h"
namespace ScriptCanvasEditor
{
@@ -99,7 +100,7 @@ namespace ScriptCanvasEditor
if (auto customModelInformation = azrtti_cast<const CustomNodeModelInformation*>(modelInformation))
{
createdItem = parentItem->CreateChildNode<CustomNodePaletteTreeItem>(customModelInformation->m_typeId, customModelInformation->m_displayName);
createdItem = parentItem->CreateChildNode<CustomNodePaletteTreeItem>(*customModelInformation);
createdItem->SetToolTip(QString(customModelInformation->m_toolTip.c_str()));
}
else if (auto methodNodeModelInformation = azrtti_cast<const MethodNodeModelInformation*>(modelInformation))
@@ -660,6 +661,11 @@ namespace ScriptCanvasEditor
, m_previousCycleAction(nullptr)
, m_ignoreSelectionChanged(false)
{
GraphCanvas::NodePaletteTreeView* treeView = GetTreeView();
treeView->setContextMenuPolicy(Qt::ContextMenuPolicy::ActionsContextMenu);
if (!paletteConfig.m_isInContextMenu)
{
QMenu* creationMenu = new QMenu();
@@ -677,10 +683,11 @@ namespace ScriptCanvasEditor
AddSearchCustomizationWidget(m_newCustomEvent);
GraphCanvas::NodePaletteTreeView* treeView = GetTreeView();
{
m_nextCycleAction = new QAction(treeView);
m_nextCycleAction->setText(tr("Next Instance in Graph"));
m_nextCycleAction->setShortcut(QKeySequence(Qt::Key_F8));
treeView->addAction(m_nextCycleAction);
@@ -690,6 +697,7 @@ namespace ScriptCanvasEditor
{
m_previousCycleAction = new QAction(treeView);
m_previousCycleAction->setText(tr("Previous Instance in Graph"));
m_previousCycleAction->setShortcut(QKeySequence(Qt::Key_F7));
treeView->addAction(m_previousCycleAction);
@@ -699,6 +707,23 @@ namespace ScriptCanvasEditor
QObject::connect(treeView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &NodePaletteDockWidget::OnTreeSelectionChanged);
QObject::connect(treeView, &GraphCanvas::NodePaletteTreeView::OnTreeItemDoubleClicked, this, &NodePaletteDockWidget::HandleTreeItemDoubleClicked);
{
m_openTranslationData = new QAction(treeView);
m_openTranslationData->setText("Open Translation Data");
treeView->addAction(m_openTranslationData);
QObject::connect(m_openTranslationData, &QAction::triggered, this, &NodePaletteDockWidget::OpenTranslationData);
}
{
m_generateTranslation = new QAction(treeView);
m_generateTranslation->setText("Generate Translation");
treeView->addAction(m_generateTranslation);
QObject::connect(m_generateTranslation, &QAction::triggered, this, &NodePaletteDockWidget::GenerateTranslation);
}
}
ConfigureSearchCustomizationMargins(QMargins(0, 0, 0, 0), 0);
@@ -781,6 +806,7 @@ namespace ScriptCanvasEditor
{
m_nextCycleAction->setEnabled(true);
m_previousCycleAction->setEnabled(true);
m_openTranslationData->setEnabled(true);
}
}
@@ -793,6 +819,7 @@ namespace ScriptCanvasEditor
{
m_nextCycleAction->setEnabled(false);
m_previousCycleAction->setEnabled(false);
m_openTranslationData->setEnabled(false);
}
}
@@ -816,6 +843,84 @@ namespace ScriptCanvasEditor
CycleToNextNode();
}
static AZStd::string GetGemPath(const AZStd::string& gemName)
{
if (auto settingsRegistry = AZ::Interface<AZ::SettingsRegistryInterface>::Get(); settingsRegistry != nullptr)
{
AZ::IO::Path gemSourceAssetDirectories;
AZStd::vector<AzFramework::GemInfo> gemInfos;
if (AzFramework::GetGemsInfo(gemInfos, *settingsRegistry))
{
auto FindGemByName = [gemName](const AzFramework::GemInfo& gemInfo)
{
return gemInfo.m_gemName == gemName;
};
// Gather unique list of Gem Paths from the Settings Registry
auto foundIt = AZStd::find_if(gemInfos.begin(), gemInfos.end(), FindGemByName);
if (foundIt != gemInfos.end())
{
const AzFramework::GemInfo& gemInfo = *foundIt;
for (const AZ::IO::Path& absoluteSourcePath : gemInfo.m_absoluteSourcePaths)
{
gemSourceAssetDirectories = (absoluteSourcePath / gemInfo.GetGemAssetFolder());
}
return gemSourceAssetDirectories.c_str();
}
}
}
return "";
}
void NodePaletteDockWidget::GenerateTranslation()
{
QModelIndexList indexList = GetTreeView()->selectionModel()->selectedRows();
if (indexList.size() == 1)
{
QSortFilterProxyModel* filterModel = static_cast<QSortFilterProxyModel*>(GetTreeView()->model());
for (const QModelIndex& index : indexList)
{
QModelIndex sourceIndex = filterModel->mapToSource(index);
GraphCanvas::NodePaletteTreeItem* nodePaletteItem = static_cast<GraphCanvas::NodePaletteTreeItem*>(sourceIndex.internalPointer());
nodePaletteItem->GenerateTranslationData();
}
}
}
void NodePaletteDockWidget::OpenTranslationData()
{
QModelIndexList indexList = GetTreeView()->selectionModel()->selectedRows();
if (indexList.size() == 1)
{
QSortFilterProxyModel* filterModel = static_cast<QSortFilterProxyModel*>(GetTreeView()->model());
for (const QModelIndex& index : indexList)
{
QModelIndex sourceIndex = filterModel->mapToSource(index);
GraphCanvas::NodePaletteTreeItem* nodePaletteItem = static_cast<GraphCanvas::NodePaletteTreeItem*>(sourceIndex.internalPointer());
if (nodePaletteItem)
{
AZ::IO::Path gemPath = GetGemPath("ScriptCanvas.Editor");
gemPath = gemPath / AZ::IO::Path("TranslationAssets");
gemPath = gemPath / nodePaletteItem->GetTranslationDataPath();
gemPath.ReplaceExtension(".names");
AZ::IO::FileIOBase* fileIO = AZ::IO::FileIOBase::GetInstance();
if (fileIO->Exists(gemPath.c_str()))
{
AzQtComponents::ShowFileOnDesktop(gemPath.c_str());
}
}
}
}
}
void NodePaletteDockWidget::ConfigureHelper()
{
if (!m_cyclingHelper.IsConfigured() && !m_cyclingIdentifiers.empty())