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:
+26
-18
@@ -91,17 +91,19 @@ namespace GraphCanvas
|
||||
|
||||
}
|
||||
|
||||
void GeneralNodeTitleComponent::SetTitle(const AZStd::string& title)
|
||||
void GeneralNodeTitleComponent::SetDetails(const AZStd::string& title, const AZStd::string& subtitle)
|
||||
{
|
||||
m_title.SetFallback(title);
|
||||
m_title = title;
|
||||
m_subTitle = subtitle;
|
||||
|
||||
if (m_generalNodeTitleWidget)
|
||||
{
|
||||
m_generalNodeTitleWidget->SetTitle(title);
|
||||
m_generalNodeTitleWidget->SetDetails(title, subtitle);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void GeneralNodeTitleComponent::SetTranslationKeyedTitle(const TranslationKeyedString& title)
|
||||
void GeneralNodeTitleComponent::SetTitle(const AZStd::string& title)
|
||||
{
|
||||
m_title = title;
|
||||
|
||||
@@ -113,20 +115,10 @@ namespace GraphCanvas
|
||||
|
||||
AZStd::string GeneralNodeTitleComponent::GetTitle() const
|
||||
{
|
||||
return m_title.GetDisplayString();
|
||||
return m_title;
|
||||
}
|
||||
|
||||
void GeneralNodeTitleComponent::SetSubTitle(const AZStd::string& subtitle)
|
||||
{
|
||||
m_subTitle.SetFallback(subtitle);
|
||||
|
||||
if (m_generalNodeTitleWidget)
|
||||
{
|
||||
m_generalNodeTitleWidget->SetSubTitle(subtitle);
|
||||
}
|
||||
}
|
||||
|
||||
void GeneralNodeTitleComponent::SetTranslationKeyedSubTitle(const TranslationKeyedString& subtitle)
|
||||
{
|
||||
m_subTitle = subtitle;
|
||||
|
||||
@@ -138,7 +130,7 @@ namespace GraphCanvas
|
||||
|
||||
AZStd::string GeneralNodeTitleComponent::GetSubTitle() const
|
||||
{
|
||||
return m_subTitle.GetDisplayString();
|
||||
return m_subTitle;
|
||||
}
|
||||
|
||||
QGraphicsWidget* GeneralNodeTitleComponent::GetGraphicsWidget()
|
||||
@@ -270,7 +262,23 @@ namespace GraphCanvas
|
||||
SceneNotificationBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
void GeneralNodeTitleGraphicsWidget::SetTitle(const TranslationKeyedString& title)
|
||||
void GeneralNodeTitleGraphicsWidget::SetDetails(const AZStd::string& title, const AZStd::string& subtitle)
|
||||
{
|
||||
bool updateLayout = false;
|
||||
if (m_titleWidget)
|
||||
{
|
||||
m_titleWidget->SetLabel(title);
|
||||
updateLayout = true;
|
||||
}
|
||||
|
||||
if (m_subTitleWidget)
|
||||
{
|
||||
m_subTitleWidget->SetLabel(subtitle);
|
||||
updateLayout = true;
|
||||
}
|
||||
}
|
||||
|
||||
void GeneralNodeTitleGraphicsWidget::SetTitle(const AZStd::string& title)
|
||||
{
|
||||
if (m_titleWidget)
|
||||
{
|
||||
@@ -279,7 +287,7 @@ namespace GraphCanvas
|
||||
}
|
||||
}
|
||||
|
||||
void GeneralNodeTitleGraphicsWidget::SetSubTitle(const TranslationKeyedString& subtitle)
|
||||
void GeneralNodeTitleGraphicsWidget::SetSubTitle(const AZStd::string& subtitle)
|
||||
{
|
||||
if (m_subTitleWidget)
|
||||
{
|
||||
|
||||
@@ -68,12 +68,11 @@ namespace GraphCanvas
|
||||
////
|
||||
|
||||
// NodeTitleRequestBus
|
||||
void SetDetails(const AZStd::string& title, const AZStd::string& subtitle) override;
|
||||
void SetTitle(const AZStd::string& title) override;
|
||||
void SetTranslationKeyedTitle(const TranslationKeyedString& title) override;
|
||||
AZStd::string GetTitle() const override;
|
||||
|
||||
void SetSubTitle(const AZStd::string& subtitle) override;
|
||||
void SetTranslationKeyedSubTitle(const TranslationKeyedString& subtitle) override;
|
||||
AZStd::string GetSubTitle() const override;
|
||||
|
||||
QGraphicsWidget* GetGraphicsWidget() override;
|
||||
@@ -96,8 +95,8 @@ namespace GraphCanvas
|
||||
private:
|
||||
GeneralNodeTitleComponent(const GeneralNodeTitleComponent&) = delete;
|
||||
|
||||
TranslationKeyedString m_title;
|
||||
TranslationKeyedString m_subTitle;
|
||||
AZStd::string m_title;
|
||||
AZStd::string m_subTitle;
|
||||
|
||||
AZStd::string m_basePalette;
|
||||
|
||||
@@ -123,9 +122,10 @@ namespace GraphCanvas
|
||||
|
||||
void Activate();
|
||||
void Deactivate();
|
||||
|
||||
void SetTitle(const TranslationKeyedString& title);
|
||||
void SetSubTitle(const TranslationKeyedString& subtitle);
|
||||
|
||||
void SetDetails(const AZStd::string& title, const AZStd::string& subtitle);
|
||||
void SetTitle(const AZStd::string& title);
|
||||
void SetSubTitle(const AZStd::string& subtitle);
|
||||
|
||||
void SetPaletteOverride(AZStd::string_view paletteOverride);
|
||||
void SetPaletteOverride(const AZ::Uuid& uuid);
|
||||
|
||||
@@ -1007,20 +1007,16 @@ namespace GraphCanvas
|
||||
{
|
||||
if (!configuration.m_name.empty())
|
||||
{
|
||||
cloneConfiguration->m_name.Clear();
|
||||
cloneConfiguration->m_name.SetFallback(configuration.m_name);
|
||||
cloneConfiguration->m_name = configuration.m_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
AZStd::string nodeTitle;
|
||||
NodeTitleRequestBus::EventResult(nodeTitle, configuration.m_targetEndpoint.GetNodeId(), &NodeTitleRequests::GetTitle);
|
||||
|
||||
AZStd::string displayName = AZStd::string::format("%s:%s", nodeTitle.c_str(), cloneConfiguration->m_name.GetDisplayString().c_str());
|
||||
AZStd::string displayName = AZStd::string::format("%s:%s", nodeTitle.c_str(), cloneConfiguration->m_name.c_str());
|
||||
|
||||
// Gain some context. Lost the ability to refresh the strings.
|
||||
// Should be fixable once we get an actual use case for this setup.
|
||||
cloneConfiguration->m_name.Clear();
|
||||
cloneConfiguration->m_name.SetFallback(displayName);
|
||||
cloneConfiguration->m_name = displayName;
|
||||
}
|
||||
|
||||
AZ::Entity* slotEntity = nullptr;
|
||||
|
||||
@@ -315,12 +315,6 @@ namespace GraphCanvas
|
||||
NodeNotificationBus::Event(GetEntityId(), &NodeNotifications::OnTooltipChanged, m_configuration.GetTooltip());
|
||||
}
|
||||
|
||||
void NodeComponent::SetTranslationKeyedTooltip(const TranslationKeyedString& tooltip)
|
||||
{
|
||||
m_configuration.SetTooltip(tooltip.GetDisplayString());
|
||||
NodeNotificationBus::Event(GetEntityId(), &NodeNotifications::OnTooltipChanged, m_configuration.GetTooltip());
|
||||
}
|
||||
|
||||
void NodeComponent::AddSlot(const AZ::EntityId& slotId)
|
||||
{
|
||||
AZ_Assert(slotId.IsValid(), "Slot entity (ID: %s) is not valid!", slotId.ToString().data());
|
||||
|
||||
@@ -106,7 +106,6 @@ namespace GraphCanvas
|
||||
|
||||
// NodeRequestBus
|
||||
void SetTooltip(const AZStd::string& tooltip) override;
|
||||
void SetTranslationKeyedTooltip(const TranslationKeyedString& tooltip) override;
|
||||
const AZStd::string GetTooltip() const override { return m_configuration.GetTooltip(); }
|
||||
|
||||
void SetShowInOutliner(bool showInOutliner) override { m_configuration.SetShowInOutliner(showInOutliner); }
|
||||
|
||||
@@ -337,12 +337,9 @@ namespace GraphCanvas
|
||||
{
|
||||
m_connectionType = slotRequests->GetConnectionType();
|
||||
|
||||
TranslationKeyedString slotName = slotRequests->GetTranslationKeyedName();
|
||||
m_slotText->SetLabel(slotRequests->GetName());
|
||||
|
||||
m_slotText->SetLabel(slotName);
|
||||
|
||||
TranslationKeyedString toolTip = slotRequests->GetTranslationKeyedTooltip();
|
||||
OnTooltipChanged(toolTip);
|
||||
OnTooltipChanged(slotRequests->GetTooltip());
|
||||
|
||||
const SlotConfiguration& configuration = slotRequests->GetSlotConfiguration();
|
||||
|
||||
@@ -393,12 +390,12 @@ namespace GraphCanvas
|
||||
AZ::SystemTickBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
void DataSlotLayout::OnNameChanged(const TranslationKeyedString& name)
|
||||
void DataSlotLayout::OnNameChanged(const AZStd::string& name)
|
||||
{
|
||||
m_slotText->SetLabel(name);
|
||||
}
|
||||
|
||||
void DataSlotLayout::OnTooltipChanged(const TranslationKeyedString& tooltip)
|
||||
void DataSlotLayout::OnTooltipChanged(const AZStd::string& tooltip)
|
||||
{
|
||||
AZ::Uuid dataType;
|
||||
DataSlotRequestBus::EventResult(dataType, m_owner.GetEntityId(), &DataSlotRequests::GetDataTypeId);
|
||||
@@ -406,7 +403,7 @@ namespace GraphCanvas
|
||||
AZStd::string typeString;
|
||||
GraphModelRequestBus::EventResult(typeString, GetSceneId(), &GraphModelRequests::GetDataTypeString, dataType);
|
||||
|
||||
AZStd::string displayText = tooltip.GetDisplayString();
|
||||
AZStd::string displayText = tooltip;
|
||||
|
||||
if (!typeString.empty())
|
||||
{
|
||||
@@ -486,7 +483,7 @@ namespace GraphCanvas
|
||||
if (!iconPath.empty())
|
||||
{
|
||||
m_textDecoration = new GraphCanvasLabel();
|
||||
m_textDecoration->SetLabel(iconPath, "", "");
|
||||
m_textDecoration->SetLabel(iconPath);
|
||||
m_textDecoration->setToolTip(toolTip.c_str());
|
||||
|
||||
ApplyTextStyle(m_textDecoration);
|
||||
|
||||
@@ -120,8 +120,8 @@ namespace GraphCanvas
|
||||
// SlotNotificationBus
|
||||
void OnRegisteredToNode(const AZ::EntityId& nodeId) override;
|
||||
|
||||
void OnNameChanged(const TranslationKeyedString&) override;
|
||||
void OnTooltipChanged(const TranslationKeyedString&) override;
|
||||
void OnNameChanged(const AZStd::string&) override;
|
||||
void OnTooltipChanged(const AZStd::string&) override;
|
||||
////
|
||||
|
||||
// StyleNotificationBus
|
||||
|
||||
+7
-14
@@ -58,13 +58,8 @@ namespace GraphCanvas
|
||||
{
|
||||
m_connectionType = slotRequests->GetConnectionType();
|
||||
|
||||
TranslationKeyedString slotName = slotRequests->GetTranslationKeyedName();
|
||||
|
||||
m_slotText->SetLabel(slotName);
|
||||
|
||||
TranslationKeyedString toolTip = slotRequests->GetTranslationKeyedTooltip();
|
||||
|
||||
OnTooltipChanged(toolTip);
|
||||
m_slotText->SetLabel(slotRequests->GetName());
|
||||
OnTooltipChanged(slotRequests->GetTooltip());
|
||||
|
||||
const SlotConfiguration& configuration = slotRequests->GetSlotConfiguration();
|
||||
|
||||
@@ -88,17 +83,15 @@ namespace GraphCanvas
|
||||
OnStyleChanged();
|
||||
}
|
||||
|
||||
void ExecutionSlotLayout::OnNameChanged(const TranslationKeyedString& name)
|
||||
void ExecutionSlotLayout::OnNameChanged(const AZStd::string& name)
|
||||
{
|
||||
m_slotText->SetLabel(name);
|
||||
}
|
||||
|
||||
void ExecutionSlotLayout::OnTooltipChanged(const TranslationKeyedString& tooltip)
|
||||
void ExecutionSlotLayout::OnTooltipChanged(const AZStd::string& tooltip)
|
||||
{
|
||||
AZStd::string displayText = tooltip.GetDisplayString();
|
||||
|
||||
m_slotConnectionPin->setToolTip(displayText.c_str());
|
||||
m_slotText->setToolTip(displayText.c_str());
|
||||
m_slotConnectionPin->setToolTip(tooltip.c_str());
|
||||
m_slotText->setToolTip(tooltip.c_str());
|
||||
}
|
||||
|
||||
void ExecutionSlotLayout::OnStyleChanged()
|
||||
@@ -132,7 +125,7 @@ namespace GraphCanvas
|
||||
if (!textDecoration.empty())
|
||||
{
|
||||
m_textDecoration = new GraphCanvasLabel();
|
||||
m_textDecoration->SetLabel(textDecoration, "", "");
|
||||
m_textDecoration->SetLabel(textDecoration);
|
||||
m_textDecoration->setToolTip(toolTip.c_str());
|
||||
|
||||
ApplyTextStyle(m_textDecoration);
|
||||
|
||||
+2
-2
@@ -46,8 +46,8 @@ namespace GraphCanvas
|
||||
// SlotNotificationBus
|
||||
void OnRegisteredToNode(const AZ::EntityId& nodeId) override;
|
||||
|
||||
void OnNameChanged(const TranslationKeyedString& name) override;
|
||||
void OnTooltipChanged(const TranslationKeyedString& tooltip) override;
|
||||
void OnNameChanged(const AZStd::string& name) override;
|
||||
void OnTooltipChanged(const AZStd::string& tooltip) override;
|
||||
////
|
||||
|
||||
// StyleNotificationBus
|
||||
|
||||
+8
-10
@@ -119,13 +119,13 @@ namespace GraphCanvas
|
||||
{
|
||||
SlotRequestBus::EventResult(m_connectionType, m_owner.GetEntityId(), &SlotRequests::GetConnectionType);
|
||||
|
||||
TranslationKeyedString slotName;
|
||||
SlotRequestBus::EventResult(slotName, m_owner.GetEntityId(), &SlotRequests::GetTranslationKeyedName);
|
||||
AZStd::string slotName;
|
||||
SlotRequestBus::EventResult(slotName, m_owner.GetEntityId(), &SlotRequests::GetName);
|
||||
|
||||
m_slotText->SetLabel(slotName);
|
||||
|
||||
TranslationKeyedString toolTip;
|
||||
SlotRequestBus::EventResult(toolTip, m_owner.GetEntityId(), &SlotRequests::GetTranslationKeyedTooltip);
|
||||
AZStd::string toolTip;
|
||||
SlotRequestBus::EventResult(toolTip, m_owner.GetEntityId(), &SlotRequests::GetTooltip);
|
||||
|
||||
OnTooltipChanged(toolTip);
|
||||
|
||||
@@ -151,17 +151,15 @@ namespace GraphCanvas
|
||||
OnStyleChanged();
|
||||
}
|
||||
|
||||
void ExtenderSlotLayout::OnNameChanged(const TranslationKeyedString& name)
|
||||
void ExtenderSlotLayout::OnNameChanged(const AZStd::string& name)
|
||||
{
|
||||
m_slotText->SetLabel(name);
|
||||
}
|
||||
|
||||
void ExtenderSlotLayout::OnTooltipChanged(const TranslationKeyedString& tooltip)
|
||||
void ExtenderSlotLayout::OnTooltipChanged(const AZStd::string& tooltip)
|
||||
{
|
||||
AZStd::string displayText = tooltip.GetDisplayString();
|
||||
|
||||
m_slotConnectionPin->setToolTip(displayText.c_str());
|
||||
m_slotText->setToolTip(displayText.c_str());
|
||||
m_slotConnectionPin->setToolTip(tooltip.c_str());
|
||||
m_slotText->setToolTip(tooltip.c_str());
|
||||
}
|
||||
|
||||
void ExtenderSlotLayout::OnStyleChanged()
|
||||
|
||||
+2
-2
@@ -48,8 +48,8 @@ namespace GraphCanvas
|
||||
// SlotNotificationBus
|
||||
void OnRegisteredToNode(const AZ::EntityId& nodeId) override;
|
||||
|
||||
void OnNameChanged(const TranslationKeyedString& name) override;
|
||||
void OnTooltipChanged(const TranslationKeyedString& tooltip) override;
|
||||
void OnNameChanged(const AZStd::string& name) override;
|
||||
void OnTooltipChanged(const AZStd::string& tooltip) override;
|
||||
////
|
||||
|
||||
// StyleNotificationBus
|
||||
|
||||
+3
-3
@@ -90,10 +90,10 @@ namespace GraphCanvas
|
||||
TryAndSetupSlot();
|
||||
}
|
||||
|
||||
void PropertySlotLayout::OnTooltipChanged(const TranslationKeyedString& tooltip)
|
||||
void PropertySlotLayout::OnTooltipChanged(const AZStd::string& tooltip)
|
||||
{
|
||||
m_slotText->setToolTip(Tools::qStringFromUtf8(tooltip.GetDisplayString()));
|
||||
m_nodePropertyDisplay->setToolTip(Tools::qStringFromUtf8(tooltip.GetDisplayString()));
|
||||
m_slotText->setToolTip(Tools::qStringFromUtf8(tooltip));
|
||||
m_nodePropertyDisplay->setToolTip(Tools::qStringFromUtf8(tooltip));
|
||||
}
|
||||
|
||||
void PropertySlotLayout::OnStyleChanged()
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ namespace GraphCanvas
|
||||
// SlotNotificationBus
|
||||
void OnRegisteredToNode(const AZ::EntityId& nodeId) override;
|
||||
|
||||
void OnTooltipChanged(const TranslationKeyedString& tooltip) override;
|
||||
void OnTooltipChanged(const AZStd::string& tooltip) override;
|
||||
////
|
||||
|
||||
// StyleNotificationBus
|
||||
|
||||
@@ -91,14 +91,6 @@ namespace GraphCanvas
|
||||
|
||||
void SlotComponent::Activate()
|
||||
{
|
||||
SetTranslationKeyedName(m_slotConfiguration.m_name);
|
||||
|
||||
// Default tooltip.
|
||||
if (m_slotConfiguration.m_tooltip.empty())
|
||||
{
|
||||
SetTranslationKeyedTooltip(m_slotConfiguration.m_name);
|
||||
}
|
||||
|
||||
SlotRequestBus::Handler::BusConnect(GetEntityId());
|
||||
SceneMemberRequestBus::Handler::BusConnect(GetEntityId());
|
||||
}
|
||||
@@ -171,24 +163,6 @@ namespace GraphCanvas
|
||||
}
|
||||
|
||||
void SlotComponent::SetName(const AZStd::string& name)
|
||||
{
|
||||
if (name == m_slotConfiguration.m_name.GetDisplayString())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_slotConfiguration.m_name.SetFallback(name);
|
||||
|
||||
// Default tooltip.
|
||||
if (m_slotConfiguration.m_tooltip.empty())
|
||||
{
|
||||
m_slotConfiguration.m_tooltip = m_slotConfiguration.m_name;
|
||||
}
|
||||
|
||||
SlotNotificationBus::Event(GetEntityId(), &SlotNotifications::OnNameChanged, m_slotConfiguration.m_name);
|
||||
}
|
||||
|
||||
void SlotComponent::SetTranslationKeyedName(const TranslationKeyedString& name)
|
||||
{
|
||||
if (name == m_slotConfiguration.m_name)
|
||||
{
|
||||
@@ -206,25 +180,22 @@ namespace GraphCanvas
|
||||
SlotNotificationBus::Event(GetEntityId(), &SlotNotifications::OnNameChanged, m_slotConfiguration.m_name);
|
||||
}
|
||||
|
||||
void SlotComponent::SetTooltip(const AZStd::string& tooltip)
|
||||
void SlotComponent::SetDetails(const AZStd::string& name, const AZStd::string& tooltip)
|
||||
{
|
||||
if (tooltip == m_slotConfiguration.m_tooltip.GetDisplayString())
|
||||
if (name != m_slotConfiguration.m_name)
|
||||
{
|
||||
return;
|
||||
m_slotConfiguration.m_name = name;
|
||||
SlotNotificationBus::Event(GetEntityId(), &SlotNotifications::OnNameChanged, m_slotConfiguration.m_name);
|
||||
}
|
||||
|
||||
m_slotConfiguration.m_tooltip.SetFallback(tooltip);
|
||||
|
||||
// Default tooltip.
|
||||
if (m_slotConfiguration.m_tooltip.empty())
|
||||
if (tooltip != m_slotConfiguration.m_tooltip)
|
||||
{
|
||||
m_slotConfiguration.m_tooltip = m_slotConfiguration.m_name;
|
||||
m_slotConfiguration.m_tooltip = tooltip;
|
||||
SlotNotificationBus::Event(GetEntityId(), &SlotNotifications::OnTooltipChanged, m_slotConfiguration.m_tooltip);
|
||||
}
|
||||
|
||||
SlotNotificationBus::Event(GetEntityId(), &SlotNotifications::OnTooltipChanged, m_slotConfiguration.m_tooltip);
|
||||
}
|
||||
|
||||
void SlotComponent::SetTranslationKeyedTooltip(const TranslationKeyedString& tooltip)
|
||||
void SlotComponent::SetTooltip(const AZStd::string& tooltip)
|
||||
{
|
||||
if (tooltip == m_slotConfiguration.m_tooltip)
|
||||
{
|
||||
@@ -521,8 +492,8 @@ namespace GraphCanvas
|
||||
{
|
||||
slotConfiguration.m_connectionType = GetConnectionType();
|
||||
|
||||
slotConfiguration.m_name = GetTranslationKeyedName();
|
||||
slotConfiguration.m_tooltip = GetTranslationKeyedTooltip();
|
||||
slotConfiguration.m_name = m_slotConfiguration.m_name;
|
||||
slotConfiguration.m_tooltip = m_slotConfiguration.m_tooltip;
|
||||
|
||||
slotConfiguration.m_slotGroup = GetSlotGroup();
|
||||
}
|
||||
|
||||
@@ -74,18 +74,14 @@ namespace GraphCanvas
|
||||
|
||||
Endpoint GetEndpoint() const override;
|
||||
|
||||
const AZStd::string GetName() const override { return m_slotConfiguration.m_name.GetDisplayString(); }
|
||||
const AZStd::string GetName() const override { return m_slotConfiguration.m_name; }
|
||||
void SetName(const AZStd::string& name) override;
|
||||
|
||||
TranslationKeyedString GetTranslationKeyedName() const override { return m_slotConfiguration.m_name; }
|
||||
void SetTranslationKeyedName(const TranslationKeyedString&) override;
|
||||
void SetDetails(const AZStd::string& name, const AZStd::string& tooltip) override;
|
||||
|
||||
const AZStd::string GetTooltip() const override { return m_slotConfiguration.m_tooltip.GetDisplayString(); }
|
||||
const AZStd::string GetTooltip() const override { return m_slotConfiguration.m_tooltip; }
|
||||
void SetTooltip(const AZStd::string& tooltip) override;
|
||||
|
||||
TranslationKeyedString GetTranslationKeyedTooltip() const override { return m_slotConfiguration.m_tooltip; }
|
||||
void SetTranslationKeyedTooltip(const TranslationKeyedString&) override;
|
||||
|
||||
void DisplayProposedConnection(const AZ::EntityId& connectionId, const Endpoint& endpoint) override;
|
||||
void RemoveProposedConnection(const AZ::EntityId& connectionId, const Endpoint& endpoint) override;
|
||||
|
||||
|
||||
@@ -140,7 +140,6 @@ namespace GraphCanvas
|
||||
Styling::DefaultSelector::Reflect(serializeContext);
|
||||
Styling::CompoundSelector::Reflect(serializeContext);
|
||||
Styling::NestedSelector::Reflect(serializeContext);
|
||||
TranslationKeyedString::Reflect(serializeContext);
|
||||
Styling::Style::Reflect(serializeContext);
|
||||
AssetEditorUserSettings::Reflect(serializeContext);
|
||||
}
|
||||
@@ -218,6 +217,9 @@ namespace GraphCanvas
|
||||
|
||||
AzToolsFramework::ToolsAssetSystemBus::Broadcast(&AzToolsFramework::ToolsAssetSystemRequests::RegisterSourceAssetType, azrtti_typeid<TranslationAsset>(), TranslationAsset::GetFileFilter());
|
||||
m_translationAssetWorker.Activate();
|
||||
|
||||
m_assetHandler = AZStd::make_unique<TranslationAssetHandler>();
|
||||
m_assetHandler->Register();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -376,8 +378,7 @@ namespace GraphCanvas
|
||||
// Find any TranslationAsset files that may have translation database key/values
|
||||
AZ::Data::AssetCatalogRequests::AssetEnumerationCB collectAssetsCb = [this](const AZ::Data::AssetId assetId, const AZ::Data::AssetInfo& assetInfo)
|
||||
{
|
||||
const auto assetType = azrtti_typeid<TranslationAsset>();
|
||||
if (assetInfo.m_assetType == assetType)
|
||||
if (AZ::StringFunc::EndsWith(assetInfo.m_relativePath, ".names", false))
|
||||
{
|
||||
m_translationAssets.push_back(assetId);
|
||||
}
|
||||
@@ -405,7 +406,7 @@ namespace GraphCanvas
|
||||
for (const AZ::Data::AssetId& assetId : m_translationAssets)
|
||||
{
|
||||
AZ::Data::AssetBus::MultiHandler::BusConnect(assetId);
|
||||
AZ::Data::AssetManager::Instance().GetAsset<TranslationAsset>(assetId, AZ::Data::AssetLoadBehavior::Default);
|
||||
AZ::Data::AssetManager::Instance().GetAsset<TranslationAsset>(assetId, AZ::Data::AssetLoadBehavior::Default);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,10 @@
|
||||
|
||||
#include "TranslationAsset.h"
|
||||
|
||||
#include <AzCore/std/string/conversions.h>
|
||||
#include <AzCore/StringFunc/StringFunc.h>
|
||||
|
||||
|
||||
namespace GraphCanvas
|
||||
{
|
||||
namespace Translation
|
||||
@@ -88,10 +90,16 @@ namespace GraphCanvas
|
||||
static AZStd::string Sanitize(const AZStd::string& text)
|
||||
{
|
||||
AZStd::string result = text;
|
||||
AZ::StringFunc::Replace(result, "*", "x");
|
||||
AZ::StringFunc::Replace(result, "(", "_");
|
||||
AZ::StringFunc::Replace(result, ")", "_");
|
||||
AZ::StringFunc::Replace(result, "{", "_");
|
||||
AZ::StringFunc::Replace(result, "}", "_");
|
||||
AZ::StringFunc::Replace(result, ":", "_");
|
||||
AZ::StringFunc::Replace(result, "<", "_");
|
||||
AZ::StringFunc::Replace(result, ",", "_");
|
||||
AZ::StringFunc::Replace(result, ">", " ");
|
||||
AZ::StringFunc::Replace(result, "/", "");
|
||||
AZ::StringFunc::Strip(result, " ");
|
||||
AZ::StringFunc::Path::Normalize(result);
|
||||
return result;
|
||||
@@ -117,32 +125,32 @@ namespace GraphCanvas
|
||||
virtual bool HasKey(const AZStd::string& /*key*/) { return false; }
|
||||
|
||||
//! Returns the text value for a given key
|
||||
virtual const char* Get(const AZStd::string& /*key*/) { return nullptr; }
|
||||
virtual bool Get(const AZStd::string& /*key*/, AZStd::string& /*value*/) { return false; }
|
||||
|
||||
struct Details
|
||||
{
|
||||
AZStd::string Name;
|
||||
AZStd::string Tooltip;
|
||||
AZStd::string Category;
|
||||
AZStd::string Subtitle;
|
||||
AZStd::string m_name;
|
||||
AZStd::string m_tooltip;
|
||||
AZStd::string m_category;
|
||||
AZStd::string m_subtitle;
|
||||
|
||||
bool Valid = false;
|
||||
bool m_valid = false;
|
||||
|
||||
Details() = default;
|
||||
|
||||
Details(const Details& rhs)
|
||||
{
|
||||
Name = rhs.Name;
|
||||
Tooltip = rhs.Tooltip;
|
||||
Subtitle = rhs.Subtitle;
|
||||
Category = rhs.Category;
|
||||
Valid = rhs.Valid;
|
||||
m_name = rhs.m_name;
|
||||
m_tooltip = rhs.m_tooltip;
|
||||
m_category = rhs.m_category;
|
||||
m_subtitle = rhs.m_subtitle;
|
||||
m_valid = rhs.m_valid;
|
||||
}
|
||||
|
||||
Details(const char* name, const char* tooltip, const char* subtitle, const char* category)
|
||||
: Name(name), Tooltip(tooltip), Subtitle(subtitle), Category(category)
|
||||
: m_name(name), m_tooltip(tooltip), m_subtitle(subtitle), m_category(category)
|
||||
{
|
||||
Valid = !Name.empty();
|
||||
m_valid = !m_name.empty();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -150,7 +158,7 @@ namespace GraphCanvas
|
||||
virtual bool Add(const TranslationFormat& /*translationFormat*/) { return false; }
|
||||
|
||||
//! Get the details associated with a given key (assumes they are within a "details" object)
|
||||
virtual Details GetDetails(const AZStd::string& /*key*/) { return Details(); }
|
||||
virtual Details GetDetails(const AZStd::string& /*key*/, const Details& /*fallbackDetails*/) { return Details(); }
|
||||
|
||||
//! Generates the source JSON assets for all reflected elements
|
||||
virtual void GenerateSourceAssets() {}
|
||||
|
||||
@@ -104,35 +104,49 @@ namespace GraphCanvas
|
||||
return m_database.find(key) != m_database.end();
|
||||
}
|
||||
|
||||
GraphCanvas::TranslationRequests::Details TranslationDatabase::GetDetails(const AZStd::string& key)
|
||||
GraphCanvas::TranslationRequests::Details TranslationDatabase::GetDetails(const AZStd::string& key, const Details& fallbackDetails)
|
||||
{
|
||||
const char* name = Get(key + ".name");
|
||||
const char* tooltip = Get(key + ".tooltip");
|
||||
const char* subtitle = Get(key + ".subtitle");
|
||||
const char* category = Get(key + ".category");
|
||||
|
||||
static bool s_traceMissingItems = true;
|
||||
if (s_traceMissingItems)
|
||||
Details details;
|
||||
if (!Get(key + ".name", details.m_name))
|
||||
{
|
||||
AZ_TracePrintf("GraphCanvas", AZStd::string::format("Value (name) not found for key: %s", key.c_str()).c_str());
|
||||
AZ_TracePrintf("GraphCanvas", AZStd::string::format("Value (tooltip) not found for key: %s", key.c_str()).c_str());
|
||||
AZ_TracePrintf("GraphCanvas", AZStd::string::format("Value (subtitle) not found for key: %s", key.c_str()).c_str());
|
||||
AZ_TracePrintf("GraphCanvas", AZStd::string::format("Value (category) not found for key: %s", key.c_str()).c_str());
|
||||
details.m_name = fallbackDetails.m_name;
|
||||
}
|
||||
|
||||
return Details(name ? name : "", tooltip ? tooltip : "", subtitle ? subtitle : "", category ? category : "");
|
||||
if (!Get(key + ".tooltip", details.m_tooltip))
|
||||
{
|
||||
details.m_tooltip = fallbackDetails.m_tooltip;
|
||||
}
|
||||
|
||||
if (!Get(key + ".subtitle", details.m_subtitle))
|
||||
{
|
||||
details.m_subtitle = fallbackDetails.m_subtitle;
|
||||
}
|
||||
|
||||
if (!Get(key + ".category", details.m_category))
|
||||
{
|
||||
details.m_category = fallbackDetails.m_category;
|
||||
}
|
||||
|
||||
return details;
|
||||
}
|
||||
|
||||
const char* TranslationDatabase::Get(const AZStd::string& key)
|
||||
bool TranslationDatabase::Get(const AZStd::string& key, AZStd::string& value)
|
||||
{
|
||||
AZStd::lock_guard<AZStd::recursive_mutex> lock(m_mutex);
|
||||
|
||||
if (m_database.find(key) != m_database.end())
|
||||
{
|
||||
return m_database[key].c_str();
|
||||
value = m_database[key];
|
||||
return true;
|
||||
}
|
||||
|
||||
return "";
|
||||
static bool s_traceMissingItems = false;
|
||||
if (s_traceMissingItems)
|
||||
{
|
||||
AZ_TracePrintf("GraphCanvas", AZStd::string::format("Value not found for key: %s", key.c_str()).c_str());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TranslationDatabase::Add(const TranslationFormat& format)
|
||||
|
||||
@@ -43,9 +43,9 @@ namespace GraphCanvas
|
||||
|
||||
bool HasKey(const AZStd::string& key) override;
|
||||
|
||||
TranslationRequests::Details GetDetails(const AZStd::string& key) override;
|
||||
TranslationRequests::Details GetDetails(const AZStd::string& key, const Details& value) override;
|
||||
|
||||
const char* Get(const AZStd::string& key) override;
|
||||
bool Get(const AZStd::string& key, AZStd::string& value) override;
|
||||
|
||||
bool Add(const TranslationFormat& format) override;
|
||||
|
||||
|
||||
@@ -35,8 +35,10 @@ namespace GraphCanvas
|
||||
}
|
||||
else
|
||||
{
|
||||
AZStd::string existingValue = translationFormat->m_database[finalKey.c_str()];
|
||||
|
||||
// There is a name collision
|
||||
AZStd::string error = AZStd::string::format("Unable to store key: %s with value: %s because that key already exists", finalKey.c_str(), it.GetString());
|
||||
AZStd::string error = AZStd::string::format("Unable to store key: %s with value: %s because that key already exists with value: %s (proposed: %s)", finalKey.c_str(), it.GetString(), existingValue.c_str(), it.GetString());
|
||||
AZ_Error("TranslationSerializer", false, error.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <GraphCanvas/Editor/GraphCanvasProfiler.h>
|
||||
#include <GraphCanvas/tools.h>
|
||||
#include <GraphCanvas/Styling/StyleHelper.h>
|
||||
#include <Translation/TranslationBus.h>
|
||||
|
||||
namespace GraphCanvas
|
||||
{
|
||||
@@ -76,19 +77,11 @@ namespace GraphCanvas
|
||||
m_hasBorderOverride = false;
|
||||
}
|
||||
|
||||
void GraphCanvasLabel::SetLabel(const AZStd::string& label, const AZStd::string& translationContext, const AZStd::string& translationKey)
|
||||
void GraphCanvasLabel::SetLabel(const AZStd::string& value)
|
||||
{
|
||||
TranslationKeyedString keyedString(label, translationContext, translationKey);
|
||||
SetLabel(keyedString);
|
||||
}
|
||||
|
||||
void GraphCanvasLabel::SetLabel(const TranslationKeyedString& value)
|
||||
{
|
||||
AZStd::string displayString = value.GetDisplayString();
|
||||
|
||||
if (m_labelText.compare(QString(displayString.c_str())))
|
||||
if (m_labelText.compare(QString(value.c_str())))
|
||||
{
|
||||
m_labelText = Tools::qStringFromUtf8(displayString);
|
||||
m_labelText = Tools::qStringFromUtf8(value);
|
||||
|
||||
UpdateDisplayText();
|
||||
RefreshDisplay();
|
||||
|
||||
@@ -51,9 +51,8 @@ namespace GraphCanvas
|
||||
const QBrush& GetBorderColorOverride() const;
|
||||
void ClearBorderColorOverride();
|
||||
|
||||
void SetLabel(const AZStd::string& label, const AZStd::string& translationContext = AZStd::string(), const AZStd::string& translationKey = AZStd::string());
|
||||
void SetLabel(const TranslationKeyedString& value);
|
||||
AZStd::string GetLabel() const { return AZStd::string(m_labelText.toStdString().c_str()); }
|
||||
void SetLabel(const AZStd::string& value);
|
||||
AZStd::string GetLabel() const { return AZStd::string(m_labelText.toUtf8().data()); }
|
||||
|
||||
void SetSceneStyle(const AZ::EntityId& sceneId, const char* style);
|
||||
void SetStyle(const AZ::EntityId& entityId, const char* styleElement);
|
||||
|
||||
Reference in New Issue
Block a user