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
@@ -148,8 +148,6 @@ namespace ScriptCanvasEditor
AZ::Entity* entity = nullptr;
AZ::ComponentApplicationBus::BroadcastResult(entity, &AZ::ComponentApplicationBus::Events::FindEntity, scriptCanvasId);
AZStd::string ebusContextName = TranslationHelper::GetEbusHandlerContext(m_busName);
if (entity)
{
ScriptCanvas::Nodes::Core::EBusEventHandler* eventHandler = AZ::EntityUtils::FindFirstDerivedComponent<ScriptCanvas::Nodes::Core::EBusEventHandler>(entity);
@@ -190,52 +188,63 @@ namespace ScriptCanvasEditor
if (scriptCanvasSlot && scriptCanvasSlot->IsVisible())
{
AZ::EntityId slotId = Nodes::DisplayScriptCanvasSlot(GetEntityId(), (*scriptCanvasSlot));
auto graphCanvasSlotId = Nodes::DisplayScriptCanvasSlot(GetEntityId(), (*scriptCanvasSlot));
GraphCanvas::SlotRequestBus::Event(slotId, &GraphCanvas::SlotRequests::SetTranslationKeyedName, TranslationHelper::GetEBusHandlerOnEventTriggeredNameKey());
GraphCanvas::SlotRequestBus::Event(slotId, &GraphCanvas::SlotRequests::SetTranslationKeyedTooltip, TranslationHelper::GetEBusHandlerOnEventTriggeredTooltipKey());
GraphCanvas::TranslationKey key;
key << "EBusHandler" << eventHandler->GetEBusName() << "methods" << m_eventName;
if (scriptCanvasSlot->IsExecution() && scriptCanvasSlot->IsOutput())
{
key << "exit";
}
else
{
key << "details";
}
GraphCanvas::TranslationRequests::Details details;
GraphCanvas::TranslationRequestBus::BroadcastResult(details, &GraphCanvas::TranslationRequests::GetDetails, key, details);
GraphCanvas::SlotRequestBus::Event(graphCanvasSlotId, &GraphCanvas::SlotRequests::SetName, details.m_name);
GraphCanvas::SlotRequestBus::Event(graphCanvasSlotId, &GraphCanvas::SlotRequests::SetTooltip, details.m_tooltip);
}
//
// inputCount and outputCount work because the order of the slots is maintained from the BehaviorContext, if this changes
// in the future then we should consider storing the actual offset or key name at that time.
//
int inputCount = 0;
int outputCount = 0;
int paramIndex = 0;
int outputIndex = 0;
for (const auto& slotId : myEvent.m_parameterSlotIds)
{
scriptCanvasSlot = eventHandler->GetSlot(slotId);
if (scriptCanvasSlot && scriptCanvasSlot->IsVisible())
{
AZ::EntityId graphCanvasSlotId = Nodes::DisplayScriptCanvasSlot(GetEntityId(), (*scriptCanvasSlot));
auto graphCanvasSlotId = Nodes::DisplayScriptCanvasSlot(GetEntityId(), (*scriptCanvasSlot));
int& index = (scriptCanvasSlot->IsData() && scriptCanvasSlot->IsOutput()) ? paramIndex : outputIndex;
TranslationItemType itemType = TranslationHelper::GetItemType(scriptCanvasSlot->GetDescriptor());
GraphCanvas::TranslationRequests::Details details;
GraphCanvas::TranslationKeyedString slotNameKeyedString(scriptCanvasSlot->GetName());
slotNameKeyedString.m_context = ebusContextName;
if (scriptCanvasSlot->IsData())
{
GraphCanvas::TranslationKey key;
key = "EBusHandler";
key << eventHandler->GetEBusName() << "methods" << m_eventName << "params" << index << "details";
GraphCanvas::TranslationKeyedString slotTooltipKeyedString(scriptCanvasSlot->GetToolTip());
slotTooltipKeyedString.m_context = ebusContextName;
details.m_name = scriptCanvasSlot->GetName();
slotNameKeyedString.SetFallback(scriptCanvasSlot->GetName());
slotTooltipKeyedString.SetFallback(scriptCanvasSlot->GetToolTip());
GraphCanvas::TranslationRequestBus::BroadcastResult(details, &GraphCanvas::TranslationRequests::GetDetails, key, details);
GraphCanvas::SlotRequestBus::Event(graphCanvasSlotId, &GraphCanvas::SlotRequests::SetName, details.m_name);
GraphCanvas::SlotRequestBus::Event(graphCanvasSlotId, &GraphCanvas::SlotRequests::SetTooltip, details.m_tooltip);
}
if (scriptCanvasSlot->GetDescriptor() == ScriptCanvas::SlotDescriptors::DataOut())
{
slotNameKeyedString.m_key = TranslationHelper::GetEBusHandlerSlotKey(m_busName, m_eventName, itemType, TranslationKeyId::Name, outputCount);
slotTooltipKeyedString.m_key = TranslationHelper::GetEBusHandlerSlotKey(m_busName, m_eventName, itemType, TranslationKeyId::Tooltip, outputCount);
++outputCount;
++outputIndex;
}
else
{
slotNameKeyedString.m_key = TranslationHelper::GetEBusHandlerSlotKey(m_busName, m_eventName, itemType, TranslationKeyId::Name, inputCount);
slotTooltipKeyedString.m_key = TranslationHelper::GetEBusHandlerSlotKey(m_busName, m_eventName, itemType, TranslationKeyId::Tooltip, inputCount);
++inputCount;
++paramIndex;
}
GraphCanvas::SlotRequestBus::Event(graphCanvasSlotId, &GraphCanvas::SlotRequests::SetTranslationKeyedName, slotNameKeyedString);
GraphCanvas::SlotRequestBus::Event(graphCanvasSlotId, &GraphCanvas::SlotRequests::SetTranslationKeyedTooltip, slotTooltipKeyedString);
}
}
@@ -245,18 +254,7 @@ namespace ScriptCanvasEditor
if (scriptCanvasSlot && scriptCanvasSlot->IsVisible())
{
AZ::EntityId graphCanvasSlotId = Nodes::DisplayScriptCanvasSlot(GetEntityId(), (*scriptCanvasSlot));
TranslationItemType itemType = TranslationHelper::GetItemType(scriptCanvasSlot->GetDescriptor());
GraphCanvas::TranslationKeyedString slotNameKeyedString(scriptCanvasSlot->GetName(), ebusContextName);
slotNameKeyedString.m_key = slotNameKeyedString.m_key = TranslationHelper::GetKey(TranslationContextGroup::EbusHandler, m_busName, m_eventName, itemType, TranslationKeyId::Name);
GraphCanvas::TranslationKeyedString slotTooltipKeyedString(TranslationHelper::GetSafeTypeName(scriptCanvasSlot->GetDataType()), ebusContextName);
slotTooltipKeyedString.m_key = TranslationHelper::GetKey(TranslationContextGroup::EbusHandler, m_busName, m_eventName, itemType, TranslationKeyId::Tooltip);
GraphCanvas::SlotRequestBus::Event(graphCanvasSlotId, &GraphCanvas::SlotRequests::SetTranslationKeyedName, slotNameKeyedString);
GraphCanvas::SlotRequestBus::Event(graphCanvasSlotId, &GraphCanvas::SlotRequests::SetTranslationKeyedTooltip, slotTooltipKeyedString);
Nodes::DisplayScriptCanvasSlot(GetEntityId(), (*scriptCanvasSlot));
}
}
@@ -345,9 +343,6 @@ namespace ScriptCanvasEditor
if (connectionType == GraphCanvas::ConnectionType::CT_Output)
{
GraphCanvas::SlotRequestBus::Event(slotId, &GraphCanvas::SlotRequests::SetTranslationKeyedName, TranslationHelper::GetEBusHandlerOnEventTriggeredNameKey());
GraphCanvas::SlotRequestBus::Event(slotId, &GraphCanvas::SlotRequests::SetTranslationKeyedTooltip, TranslationHelper::GetEBusHandlerOnEventTriggeredTooltipKey());
break;
}
}
@@ -210,10 +210,10 @@ namespace ScriptCanvasEditor
{
if (m_eventTypeToId.find(eventId) == m_eventTypeToId.end())
{
AZStd::string eventName;
AZStd::string eventName;
for (const HandlerEventConfiguration& testEventConfiguration : eventConfigurations)
{
{
if (testEventConfiguration.m_eventId == eventId)
{
eventName = testEventConfiguration.m_eventName;
@@ -540,8 +540,11 @@ namespace ScriptCanvasEditor
if (slotType == GraphCanvas::SlotTypes::DataSlot)
{
GraphCanvas::SlotRequestBus::Event(testSlotId, &GraphCanvas::SlotRequests::SetTranslationKeyedName, TranslationHelper::GetEBusHandlerBusIdNameKey());
GraphCanvas::SlotRequestBus::Event(testSlotId, &GraphCanvas::SlotRequests::SetTranslationKeyedTooltip, TranslationHelper::GetEBusHandlerBusIdTooltipKey());
GraphCanvas::TranslationKey key;
key << Translation::GlobalKeys::EBusHandlerIDKey << ".details";
GraphCanvas::TranslationRequests::Details details;
GraphCanvas::TranslationRequestBus::BroadcastResult(details, &GraphCanvas::TranslationRequests::GetDetails, key, details);
GraphCanvas::SlotRequestBus::Event(testSlotId, &GraphCanvas::SlotRequests::SetDetails, details.m_name, details.m_tooltip);
break;
}
}
@@ -68,9 +68,6 @@ namespace ScriptCanvasEditor
if (currentSlotId == slotId)
{
GraphCanvas::SlotRequestBus::Event(graphCanvasId, &GraphCanvas::SlotRequests::SetTranslationKeyedName, TranslationHelper::GetEBusSenderBusIdNameKey());
GraphCanvas::SlotRequestBus::Event(graphCanvasId, &GraphCanvas::SlotRequests::SetTranslationKeyedTooltip, TranslationHelper::GetEBusSenderBusIdTooltipKey());
break;
}
}
@@ -142,8 +142,6 @@ namespace ScriptCanvasEditor
m_ebusWrapper.m_graphCanvasId = wrappingNode;
m_ebusWrapper.m_scriptCanvasId = scriptCanvasId;
AZStd::string ebusContextName = TranslationHelper::GetEbusHandlerContext(m_busName);
ScriptCanvas::Nodes::Core::ReceiveScriptEvent* eventHandler = AZ::EntityUtils::FindFirstDerivedComponent<ScriptCanvas::Nodes::Core::ReceiveScriptEvent>(scriptCanvasId);
if (eventHandler)
{
@@ -179,49 +177,20 @@ namespace ScriptCanvasEditor
if (scriptCanvasSlot && scriptCanvasSlot->IsVisible())
{
AZ::EntityId slotId = Nodes::DisplayScriptCanvasSlot(GetEntityId(), (*scriptCanvasSlot));
GraphCanvas::SlotRequestBus::Event(slotId, &GraphCanvas::SlotRequests::SetTranslationKeyedName, TranslationHelper::GetEBusHandlerOnEventTriggeredNameKey());
GraphCanvas::SlotRequestBus::Event(slotId, &GraphCanvas::SlotRequests::SetTranslationKeyedTooltip, TranslationHelper::GetEBusHandlerOnEventTriggeredTooltipKey());
Nodes::DisplayScriptCanvasSlot(GetEntityId(), (*scriptCanvasSlot));
}
//
// inputCount and outputCount work because the order of the slots is maintained from the BehaviorContext, if this changes
// in the future then we should consider storing the actual offset or key name at that time.
//
int inputCount = 0;
int outputCount = 0;
for (const auto& slotId : myEvent.m_parameterSlotIds)
{
scriptCanvasSlot = eventHandler->GetSlot(slotId);
if (scriptCanvasSlot && scriptCanvasSlot->IsVisible())
{
AZ::EntityId graphCanvasSlotId = Nodes::DisplayScriptCanvasSlot(GetEntityId(), (*scriptCanvasSlot));
TranslationItemType itemType = TranslationHelper::GetItemType(scriptCanvasSlot->GetDescriptor());
GraphCanvas::TranslationKeyedString slotNameKeyedString(scriptCanvasSlot->GetName());
slotNameKeyedString.m_context = ebusContextName;
GraphCanvas::TranslationKeyedString slotTooltipKeyedString(scriptCanvasSlot->GetToolTip());
slotTooltipKeyedString.m_context = ebusContextName;
if (scriptCanvasSlot->GetDescriptor() == ScriptCanvas::SlotDescriptors::DataOut())
{
slotNameKeyedString.m_key = TranslationHelper::GetEBusHandlerSlotKey(m_busName, m_eventName, itemType, TranslationKeyId::Name, outputCount);
slotTooltipKeyedString.m_key = TranslationHelper::GetEBusHandlerSlotKey(m_busName, m_eventName, itemType, TranslationKeyId::Tooltip, outputCount);
++outputCount;
}
else
{
slotNameKeyedString.m_key = TranslationHelper::GetEBusHandlerSlotKey(m_busName, m_eventName, itemType, TranslationKeyId::Name, inputCount);
slotTooltipKeyedString.m_key = TranslationHelper::GetEBusHandlerSlotKey(m_busName, m_eventName, itemType, TranslationKeyId::Tooltip, inputCount);
++inputCount;
}
GraphCanvas::SlotRequestBus::Event(graphCanvasSlotId, &GraphCanvas::SlotRequests::SetTranslationKeyedName, slotNameKeyedString);
GraphCanvas::SlotRequestBus::Event(graphCanvasSlotId, &GraphCanvas::SlotRequests::SetTranslationKeyedTooltip, slotTooltipKeyedString);
Nodes::DisplayScriptCanvasSlot(GetEntityId(), (*scriptCanvasSlot));
}
}
@@ -231,18 +200,7 @@ namespace ScriptCanvasEditor
if (scriptCanvasSlot && scriptCanvasSlot->IsVisible())
{
AZ::EntityId graphCanvasSlotId = Nodes::DisplayScriptCanvasSlot(GetEntityId(), (*scriptCanvasSlot));
TranslationItemType itemType = TranslationHelper::GetItemType(scriptCanvasSlot->GetDescriptor());
GraphCanvas::TranslationKeyedString slotNameKeyedString(scriptCanvasSlot->GetName(), ebusContextName);
slotNameKeyedString.m_key = slotNameKeyedString.m_key = TranslationHelper::GetKey(TranslationContextGroup::EbusHandler, m_busName, m_eventName, itemType, TranslationKeyId::Name);
GraphCanvas::TranslationKeyedString slotTooltipKeyedString(TranslationHelper::GetSafeTypeName(scriptCanvasSlot->GetDataType()), ebusContextName);
slotTooltipKeyedString.m_key = TranslationHelper::GetKey(TranslationContextGroup::EbusHandler, m_busName, m_eventName, itemType, TranslationKeyId::Tooltip);
GraphCanvas::SlotRequestBus::Event(graphCanvasSlotId, &GraphCanvas::SlotRequests::SetTranslationKeyedName, slotNameKeyedString);
GraphCanvas::SlotRequestBus::Event(graphCanvasSlotId, &GraphCanvas::SlotRequests::SetTranslationKeyedTooltip, slotTooltipKeyedString);
Nodes::DisplayScriptCanvasSlot(GetEntityId(), (*scriptCanvasSlot));
}
}
@@ -367,9 +325,6 @@ namespace ScriptCanvasEditor
if (connectionType == GraphCanvas::ConnectionType::CT_Output)
{
GraphCanvas::SlotRequestBus::Event(slotId, &GraphCanvas::SlotRequests::SetTranslationKeyedName, TranslationHelper::GetEBusHandlerOnEventTriggeredNameKey());
GraphCanvas::SlotRequestBus::Event(slotId, &GraphCanvas::SlotRequests::SetTranslationKeyedTooltip, TranslationHelper::GetEBusHandlerOnEventTriggeredTooltipKey());
break;
}
}
@@ -560,8 +560,11 @@ namespace ScriptCanvasEditor
if (slotType == GraphCanvas::SlotTypes::DataSlot)
{
GraphCanvas::SlotRequestBus::Event(testSlotId, &GraphCanvas::SlotRequests::SetTranslationKeyedName, TranslationHelper::GetEBusHandlerBusIdNameKey());
GraphCanvas::SlotRequestBus::Event(testSlotId, &GraphCanvas::SlotRequests::SetTranslationKeyedTooltip, TranslationHelper::GetEBusHandlerBusIdTooltipKey());
GraphCanvas::TranslationKey key;
key << Translation::GlobalKeys::EBusHandlerIDKey << "details";
GraphCanvas::TranslationRequests::Details details;
GraphCanvas::TranslationRequestBus::BroadcastResult(details, &GraphCanvas::TranslationRequests::GetDetails, key, details);
GraphCanvas::SlotRequestBus::Event(testSlotId, &GraphCanvas::SlotRequests::SetDetails, details.m_name, details.m_tooltip);
break;
}
}
@@ -118,9 +118,6 @@ namespace ScriptCanvasEditor
if (currentSlotId == slotId)
{
GraphCanvas::SlotRequestBus::Event(graphCanvasId, &GraphCanvas::SlotRequests::SetTranslationKeyedName, TranslationHelper::GetEBusSenderBusIdNameKey());
GraphCanvas::SlotRequestBus::Event(graphCanvasId, &GraphCanvas::SlotRequests::SetTranslationKeyedTooltip, TranslationHelper::GetEBusSenderBusIdTooltipKey());
break;
}
}