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
@@ -15,6 +15,63 @@
#include <ScriptCanvas/Core/Slot.h>
#include <GraphCanvas/Types/TranslationTypes.h>
#include <Source/Translation/TranslationBus.h>
#include <AzFramework/Gem/GemInfo.h>
#include <AzCore/Settings/SettingsRegistry.h>
namespace Translation
{
namespace GlobalKeys
{
static constexpr const char* EBusSenderIDKey = "Globals.EBusSenderBusId";
static constexpr const char* EBusHandlerIDKey = "Globals.EBusHandlerBusId";
static constexpr const char* MissingFunctionKey = "Globals.MissingFunction";
static constexpr const char* EBusHandlerOutSlot = "Globals.EBusHandler.OutSlot";
}
static inline bool GetValue(const AZStd::string key, AZStd::string& value)
{
GraphCanvas::TranslationKey tkey;
tkey = key;
bool result = false;
GraphCanvas::TranslationRequestBus::BroadcastResult(result, &GraphCanvas::TranslationRequests::Get, key, value);
return result;
}
}
namespace GraphCanvasAttributeHelper
{
template <typename T>
AZStd::string GetStringAttribute(const T* source, const AZ::Crc32& attribute)
{
AZStd::string attributeValue = "";
if (auto attributeItem = azrtti_cast<AZ::AttributeData<AZStd::string>*>(AZ::FindAttribute(attribute, source->m_attributes)))
{
attributeValue = attributeItem->Get(nullptr);
}
return attributeValue;
}
inline AZStd::string ReadStringAttribute(const AZ::AttributeArray& attributes, const AZ::Crc32& attribute)
{
AZStd::string attributeValue = "";
if (auto attributeItem = azrtti_cast<AZ::AttributeData<AZStd::string>*>(AZ::FindAttribute(attribute, attributes)))
{
attributeValue = attributeItem->Get(nullptr);
return attributeValue;
}
if (auto attributeItem = azrtti_cast<AZ::AttributeData<const char*>*>(AZ::FindAttribute(attribute, attributes)))
{
attributeValue = attributeItem->Get(nullptr);
return attributeValue;
}
return {};
}
}
namespace ScriptCanvasEditor
{
@@ -47,6 +104,20 @@ namespace ScriptCanvasEditor
Invalid
};
namespace TranslationKeyParts
{
const char* const handler = "HANDLER_";
const char* const name = "NAME";
const char* const tooltip = "TOOLTIP";
const char* const category = "CATEGORY";
const char* const in = "IN";
const char* const out = "OUT";
const char* const param = "PARAM";
const char* const output = "OUTPUT";
const char* const busid = "BUSID";
}
namespace TranslationContextGroupParts
{
const char* const ebusSender = "EBus";
@@ -55,19 +126,6 @@ namespace ScriptCanvasEditor
constexpr const char* const globalMethod = "GlobalMethod";
};
namespace TranslationKeyParts
{
const char* const handler = "HANDLER_";
const char* const name = "NAME";
const char* const tooltip = "TOOLTIP";
const char* const category = "CATEGORY";
const char* const in = "IN";
const char* const out = "OUT";
const char* const param = "PARAM";
const char* const output = "OUTPUT";
const char* const busid = "BUSID";
}
// The context name and keys generated by TranslationHelper should match the keys
// being exported by the TSGenerateAction.cpp in the ScriptCanvasDeveloper Gem.
class TranslationHelper
@@ -109,47 +167,10 @@ namespace ScriptCanvasEditor
}
// UserDefined
static AZStd::string GetUserDefinedContext(AZStd::string_view contextName)
{
return GetContextName(TranslationContextGroup::ClassMethod, contextName);
}
static AZStd::string GetUserDefinedKey(AZStd::string_view contextName, TranslationKeyId keyId)
{
return GetClassKey(TranslationContextGroup::ClassMethod, contextName, keyId);
}
static AZStd::string GetUserDefinedNodeKey(AZStd::string_view contextName, AZStd::string_view nodeName, TranslationKeyId keyId)
{
return GetKey(TranslationContextGroup::ClassMethod, contextName, nodeName, TranslationItemType::Node, keyId);
}
static AZStd::string GetUserDefinedNodeSlotKey(AZStd::string_view contextName, AZStd::string_view nodeName, TranslationItemType itemType, TranslationKeyId keyId, int slotIndex)
{
return GetKey(TranslationContextGroup::ClassMethod, contextName, nodeName, itemType, keyId, slotIndex);
}
////
// EBusEvent
static AZStd::string GetEbusHandlerContext(AZStd::string_view busName)
{
return GetContextName(TranslationContextGroup::EbusHandler, busName);
}
static AZStd::string GetEbusHandlerKey(AZStd::string_view busName, TranslationKeyId keyId)
{
return GetClassKey(TranslationContextGroup::EbusHandler, busName, keyId);
}
static AZStd::string GetEbusHandlerEventKey(AZStd::string_view busName, AZStd::string_view eventName, TranslationKeyId keyId)
{
return GetKey(TranslationContextGroup::EbusHandler, busName, eventName, TranslationItemType::Node, keyId);
}
static AZStd::string GetEBusHandlerSlotKey(AZStd::string_view busName, AZStd::string_view eventName, TranslationItemType type, TranslationKeyId keyId, int paramIndex)
{
return GetKey(TranslationContextGroup::EbusHandler, busName, eventName, type, keyId, paramIndex);
}
////
static AZStd::string GetKey(TranslationContextGroup group, AZStd::string_view keyBase, AZStd::string_view keyName, TranslationItemType type, TranslationKeyId keyId, int paramIndex = 0)
@@ -436,72 +457,6 @@ namespace ScriptCanvasEditor
return translated;
}
static GraphCanvas::TranslationKeyedString GetEBusHandlerBusIdNameKey()
{
GraphCanvas::TranslationKeyedString keyedString;
keyedString.m_context = "Globals";
keyedString.m_key = "DEFAULTS_EBUSHANDLER_BUSID_NAME";
keyedString.SetFallback("BusId");
return keyedString;
}
static GraphCanvas::TranslationKeyedString GetEBusHandlerBusIdTooltipKey()
{
GraphCanvas::TranslationKeyedString keyedString;
keyedString.m_context = "Globals";
keyedString.m_key = "DEFAULTS_EBUSHANDLER_BUSID_TOOLTIP";
keyedString.SetFallback("BusId");
return keyedString;
}
static GraphCanvas::TranslationKeyedString GetEBusHandlerOnEventTriggeredNameKey()
{
GraphCanvas::TranslationKeyedString keyedString;
keyedString.m_context = "Globals";
keyedString.m_key = "DEFAULTS_EBUSHANDLER_ONTRIGGERED_NAME";
keyedString.SetFallback("Out");
return keyedString;
}
static GraphCanvas::TranslationKeyedString GetEBusHandlerOnEventTriggeredTooltipKey()
{
GraphCanvas::TranslationKeyedString keyedString;
keyedString.m_context = "Globals";
keyedString.m_key = "DEFAULTS_EBUSHANDLER_ONTRIGGERED_TOOLTIP";
keyedString.SetFallback("Out");
return keyedString;
}
static GraphCanvas::TranslationKeyedString GetEBusSenderBusIdNameKey()
{
GraphCanvas::TranslationKeyedString keyedString;
keyedString.m_context = "Globals";
keyedString.m_key = "DEFAULTS_EBUSSENDER_BUSID_NAME";
keyedString.SetFallback("BusId");
return keyedString;
}
static GraphCanvas::TranslationKeyedString GetEBusSenderBusIdTooltipKey()
{
GraphCanvas::TranslationKeyedString keyedString;
keyedString.m_context = "Globals";
keyedString.m_key = "DEFAULTS_EBUSSENDER_BUSID_TOOLTIP";
keyedString.SetFallback("BusId");
return keyedString;
}
// Use the StackedString to index the translation keys as a Json Pointer
static constexpr AZStd::string_view GetAzEventHandlerContextKey()
{
return { "AzEventHandler" };
}
// Use the StackedString to index the translation keys as a Json Pointer
static AZ::StackedString GetAzEventHandlerRootPointer(AZStd::string_view eventName)
{
@@ -510,5 +465,10 @@ namespace ScriptCanvasEditor
return path;
}
};
}