Renamed 'key' to 'base' to avoid future problems with secrets patterns, cleanup and improvements

Signed-off-by: lsemp3d <58790905+lsemp3d@users.noreply.github.com>
monroegm-disable-blank-issue-2
lsemp3d 4 years ago
parent 9e6e83ff7f
commit 2da3ab42fd

@ -19,7 +19,6 @@
#include <GraphCanvas/Components/StyleBus.h>
#include <GraphCanvas/Components/VisualBus.h>
#include <GraphCanvas/Types/EntitySaveData.h>
#include <GraphCanvas/Types/TranslationTypes.h>
#include <Widgets/GraphCanvasLabel.h>
namespace GraphCanvas

@ -58,7 +58,6 @@
#include <GraphCanvas/Types/ConstructPresets.h>
#include <GraphCanvas/Types/EntitySaveData.h>
#include <GraphCanvas/Types/TranslationTypes.h>
#include <GraphCanvas/Widgets/GraphCanvasEditor/GraphCanvasAssetEditorMainWindow.h>
#include <GraphCanvas/Widgets/GraphCanvasMimeEvent.h>

@ -59,14 +59,14 @@ namespace GraphCanvas
//!
//! Requirements:
//! - Must have a top level array called "entries"
//! - Must provide a "key" element for any entry added
//! - Must provide a "base" element for any entry added
//!
//! Example:
//!
//! {
//! "entries": [
//! {
//! "key": "Globals",
//! "base": "Globals",
//! "details": {
//! "name": "My Name",
//! "tooltip": "My Tooltip"
@ -90,21 +90,21 @@ namespace GraphCanvas
//! Globals.details.somearray.0.name
//! Globals.details.somearray.1.name
//!
//! There is one important aspect however, if an element in an array has a "key" value, the value of this key
//! There is one important aspect however, if an element in an array has a "base" value, the value of this key
//! will replace the index. This is useful when the index and/or ordering of an entry is not relevant or may
//! change.
//!
//! "somearray": [ {
//! "name": "First one"
//! "key": "a_key"
//! "base": "a_key"
//! }, {
//! "name": "Second one",
//! "key": "b_key"
//! "base": "b_key"
//! } ]
//!
//! Globals.details.somearray.0.key == "a_key"
//! Globals.details.somearray.0.base == "a_key"
//! Globals.details.somearray.0.name == "First one"
//! Globals.details.somearray.1.key == "b_key"
//! Globals.details.somearray.1.base == "b_key"
//! Globals.details.somearray.1.name == "Second one"
//!
class TranslationAssetHandler

@ -11,17 +11,6 @@
namespace GraphCanvas
{
namespace Schema
{
namespace Field
{
static constexpr char key[] = "key";
static constexpr char context[] = "context";
static constexpr char variant[] = "variant";
static constexpr char entries[] = "entries";
}
}
AZ_CLASS_ALLOCATOR_IMPL(TranslationFormatSerializer, AZ::SystemAllocator, 0);
void AddEntryToDatabase(const AZStd::string& baseKey, const AZStd::string& name, const rapidjson::Value& it, TranslationFormat* translationFormat)
@ -76,11 +65,15 @@ namespace GraphCanvas
const rapidjson::Value& array = it;
for (rapidjson::SizeType i = 0; i < array.Size(); ++i)
{
// so, here, I need to go in and if there is a "key" member within the object, then I need to use that,
// if there isn't, I can use the %d
// if there is a "base" member within the object, then use it, otherwise use the index
if (array[i].IsObject())
{
if (array[i].HasMember(Schema::Field::key))
if (array[i].HasMember(Schema::Field::deprecated_key))
{
AZStd::string innerKey = array[i].FindMember(Schema::Field::deprecated_key)->value.GetString();
itemKey.append(AZStd::string::format(".%s", innerKey.c_str()));
}
else if (array[i].HasMember(Schema::Field::key))
{
AZStd::string innerKey = array[i].FindMember(Schema::Field::key)->value.GetString();
itemKey.append(AZStd::string::format(".%s", innerKey.c_str()));
@ -133,7 +126,12 @@ namespace GraphCanvas
AZStd::string keyStr;
rapidjson::Value::ConstMemberIterator keyValue;
if (entry.HasMember(Schema::Field::key))
if (entry.HasMember(Schema::Field::deprecated_key))
{
keyValue = entry.FindMember(Schema::Field::deprecated_key);
keyStr = keyValue->value.GetString();
}
else if (entry.HasMember(Schema::Field::key))
{
keyValue = entry.FindMember(Schema::Field::key);
keyStr = keyValue->value.GetString();

@ -23,4 +23,17 @@ namespace GraphCanvas
AZ::JsonSerializationResult::Result Store(rapidjson::Value& outputValue, const void* inputValue,
const void* defaultValue, const AZ::Uuid& valueTypeId, AZ::JsonSerializerContext& context) override;
};
namespace Schema
{
namespace Field
{
// Moved away from "key" due to some strict filtering on secrets
static constexpr char deprecated_key[] = "key";
static constexpr char key[] = "base";
static constexpr char context[] = "context";
static constexpr char variant[] = "variant";
static constexpr char entries[] = "entries";
}
}
}

@ -16,7 +16,6 @@ AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option")
AZ_POP_DISABLE_WARNING
#include <GraphCanvas/Styling/StyleHelper.h>
#include <GraphCanvas/Types/TranslationTypes.h>
namespace GraphCanvas
{

@ -15,7 +15,6 @@
#include <GraphCanvas/Editor/EditorTypes.h>
#include <GraphCanvas/Types/EntitySaveData.h>
#include <GraphCanvas/Types/GraphCanvasGraphSerialization.h>
#include <GraphCanvas/Types/TranslationTypes.h>
#include <GraphCanvas/Components/Slots/SlotBus.h>

@ -11,7 +11,6 @@
#include <AzCore/EBus/EBus.h>
#include <AzCore/std/string/string.h>
#include <GraphCanvas/Types/TranslationTypes.h>
#include <GraphCanvas/Components/StyleBus.h>
#include <GraphCanvas/Types/SceneMemberComponentSaveData.h>

@ -16,7 +16,6 @@
#include <GraphCanvas/Types/Endpoint.h>
#include <GraphCanvas/Types/Types.h>
#include <GraphCanvas/Types/TranslationTypes.h>
class QGraphicsLayoutItem;

@ -1,116 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <QCoreApplication>
#include <AzCore/Serialization/SerializeContext.h>
namespace GraphCanvas
{
struct TranslationKeyedString
{
public:
AZ_TYPE_INFO(TranslationKeyedString, "{B796685C-0335-4E74-9EF8-A1933E8B2142}");
AZ_CLASS_ALLOCATOR(TranslationKeyedString, AZ::SystemAllocator, 0);
static void Reflect(AZ::ReflectContext* context)
{
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
if (!serializeContext)
{
return;
}
serializeContext->Class<TranslationKeyedString>()
->Version(1)
->Field("Fallback", &TranslationKeyedString::m_fallback)
->Field("Context", &TranslationKeyedString::m_context)
->Field("Key", &TranslationKeyedString::m_key)
;
}
TranslationKeyedString()
: m_dirtyText(true)
{
}
~TranslationKeyedString() = default;
TranslationKeyedString(const AZStd::string& fallback, const AZStd::string& context = AZStd::string(), const AZStd::string& key = AZStd::string())
: m_fallback(fallback)
, m_context(context)
, m_key(key)
, m_dirtyText(true)
{
}
const AZStd::string GetDisplayString() const
{
if (m_dirtyText)
{
const_cast<TranslationKeyedString*>(this)->TranslateString();
}
return m_display;
}
void TranslateString()
{
m_display = m_fallback;
if (!m_context.empty() && !m_key.empty())
{
AZStd::string translatedText = QCoreApplication::translate(m_context.c_str(), m_key.c_str()).toUtf8().data();
if (translatedText != m_key)
{
m_display = translatedText;
}
}
m_dirtyText = false;
}
bool empty() const
{
return m_fallback.empty() && (m_context.empty() || m_key.empty());
}
bool operator==(const TranslationKeyedString& other) const
{
return m_fallback == other.m_fallback
&& m_context == other.m_context
&& m_key == other.m_key
;
}
void Clear()
{
m_key.clear();
m_context.clear();
m_fallback.clear();
}
void SetFallback(const AZStd::string& fallback)
{
m_fallback = fallback;
m_dirtyText = true;
}
AZStd::string m_context;
AZStd::string m_key;
AZStd::string m_display;
private:
AZStd::string m_fallback;
bool m_dirtyText;
};
}

@ -102,8 +102,7 @@ set(FILES
StaticLib/GraphCanvas/Types/GraphCanvasGraphData.h
StaticLib/GraphCanvas/Types/GraphCanvasGraphSerialization.cpp
StaticLib/GraphCanvas/Types/GraphCanvasGraphSerialization.h
StaticLib/GraphCanvas/Types/SceneMemberComponentSaveData.h
StaticLib/GraphCanvas/Types/TranslationTypes.h
StaticLib/GraphCanvas/Types/SceneMemberComponentSaveData.h
StaticLib/GraphCanvas/Types/Types.h
StaticLib/GraphCanvas/Types/QtMetaTypes.h
StaticLib/GraphCanvas/Widgets/Resources/default_style.json

@ -12,7 +12,7 @@
{
"key": "Getmaterials",
"details": {
"name": "Getmaterials"
"name": "Get Materials"
},
"params": [
{
@ -27,7 +27,7 @@
{
"typeid": "{50F6716F-698B-5A6C-AACD-940597FDEC24}",
"details": {
"name": ""
"name": "Material Assignment Map"
}
}
]
@ -35,7 +35,7 @@
{
"key": "Setmaterials",
"details": {
"name": "Setmaterials"
"name": "Set Materials"
},
"params": [
{
@ -48,7 +48,7 @@
{
"typeid": "{50F6716F-698B-5A6C-AACD-940597FDEC24}",
"details": {
"name": ""
"name": "Material Assignment Map"
}
}
]

@ -1,7 +1,7 @@
{
"entries": [
{
"key": "AuthenticationProviderRequestBus",
"base": "AuthenticationProviderRequestBus",
"context": "EBusSender",
"variant": "",
"details": {

@ -335,7 +335,7 @@ namespace ScriptCanvasEditor::Nodes
AZStd::string updatedMethodName = methodName;
if (isAccessor)
{
if (methodNode->GetMethodType() == ScriptCanvas::MethodType::Getter)
if (methodNode->GetMethodType() == ScriptCanvas::MethodType::Getter || methodNode->GetMethodType() == ScriptCanvas::MethodType::Free)
{
updatedMethodName = "Get";
}
@ -351,7 +351,7 @@ namespace ScriptCanvasEditor::Nodes
if (methodDetails.m_subtitle.empty())
{
methodDetails.m_subtitle = details.m_name;
methodDetails.m_subtitle = details.m_category;
}
// Add to the tooltip the C++ class for reference

@ -14,7 +14,6 @@
#include <AzCore/std/string/conversions.h>
#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>

@ -16,7 +16,6 @@
#include <AzCore/Serialization/Utils.h>
#include <AzCore/UserSettings/UserSettings.h>
#include <GraphCanvas/Types/TranslationTypes.h>
#include <GraphCanvas/Components/SceneBus.h>
#include <GraphCanvas/Components/StyleBus.h>

@ -19,7 +19,6 @@
#include <AzToolsFramework/ToolsComponents/EditorComponentBase.h>
#include <GraphCanvas/Types/TranslationTypes.h>
#include <GraphCanvas/Components/SceneBus.h>
#include <GraphCanvas/Components/StyleBus.h>

@ -18,7 +18,6 @@
#include <AzToolsFramework/ToolsComponents/EditorComponentBase.h>
#include <GraphCanvas/Types/TranslationTypes.h>
#include <GraphCanvas/Components/SceneBus.h>
#include <GraphCanvas/Components/StyleBus.h>

@ -33,6 +33,7 @@
#include <AzFramework/StringFunc/StringFunc.h>
#include <AzQtComponents/Utilities/DesktopUtilities.h>
#include <Source/Translation/TranslationSerializer.h>
namespace ScriptCanvasEditorTools
{
@ -848,8 +849,9 @@ namespace ScriptCanvasEditorTools
Helpers::GetTypeNameAndDescription(parameter->m_typeId, argumentName, argumentDescription);
const AZStd::string* argName = behaviorMethod->GetArgumentName(argIndex);
argument.m_typeId = argumentKey;
argument.m_details.m_name = behaviorMethod->GetArgumentName(argIndex) ? *behaviorMethod->GetArgumentName(argIndex) : argumentName;
argument.m_details.m_name = argName ? *argName : argumentName;
argument.m_details.m_category = "";
argument.m_details.m_tooltip = argumentDescription;
@ -871,8 +873,9 @@ namespace ScriptCanvasEditorTools
Helpers::GetTypeNameAndDescription(resultParameter->m_typeId, resultName, resultDescription);
const AZStd::string* resName = behaviorMethod->GetArgumentName(0);
result.m_typeId = resultKey;
result.m_details.m_name = behaviorMethod->GetArgumentName(0) ? *behaviorMethod->GetArgumentName(0) : resultName;
result.m_details.m_name = resName ? *resName : resultName;
result.m_details.m_tooltip = resultDescription;
SplitCamelCase(result.m_details.m_name);
@ -1093,13 +1096,13 @@ namespace ScriptCanvasEditorTools
rapidjson_ly::Value value(rapidjson_ly::kStringType);
value.SetString(entrySource.m_key.c_str(), document.GetAllocator());
entry.AddMember("key", value, document.GetAllocator());
entry.AddMember(GraphCanvas::Schema::Field::key, value, document.GetAllocator());
value.SetString(entrySource.m_context.c_str(), document.GetAllocator());
entry.AddMember("context", value, document.GetAllocator());
entry.AddMember(GraphCanvas::Schema::Field::context, value, document.GetAllocator());
value.SetString(entrySource.m_variant.c_str(), document.GetAllocator());
entry.AddMember("variant", value, document.GetAllocator());
entry.AddMember(GraphCanvas::Schema::Field::variant, value, document.GetAllocator());
rapidjson_ly::Value details(rapidjson_ly::kObjectType);
value.SetString(entrySource.m_details.m_name.c_str(), document.GetAllocator());
@ -1120,12 +1123,12 @@ namespace ScriptCanvasEditorTools
rapidjson_ly::Value theMethod(rapidjson_ly::kObjectType);
value.SetString(methodSource.m_key.c_str(), document.GetAllocator());
theMethod.AddMember("key", value, document.GetAllocator());
theMethod.AddMember(GraphCanvas::Schema::Field::key, value, document.GetAllocator());
if (!methodSource.m_context.empty())
{
value.SetString(methodSource.m_context.c_str(), document.GetAllocator());
theMethod.AddMember("context", value, document.GetAllocator());
theMethod.AddMember(GraphCanvas::Schema::Field::context, value, document.GetAllocator());
}
if (!methodSource.m_entry.m_name.empty())
@ -1233,7 +1236,7 @@ namespace ScriptCanvasEditorTools
rapidjson_ly::Value theSlot(rapidjson_ly::kObjectType);
value.SetString(slotSource.m_key.c_str(), document.GetAllocator());
theSlot.AddMember("key", value, document.GetAllocator());
theSlot.AddMember(GraphCanvas::Schema::Field::key, value, document.GetAllocator());
rapidjson_ly::Value sloDetails(rapidjson_ly::kObjectType);
if (!slotSource.m_details.m_name.empty())

@ -1,13 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- These are examples on how to create different kinds of nodes, by default they do not show
on the Script Canvas node palette, to show them, remove the following attribute from the desired
node:
EditAttributes="AZ::Script::Attributes::ExcludeFrom@AZ::Script::Attributes::ExcludeFlags::All"
-->
<ScriptCanvas Include="Source/Nodes/Nodeables/ValuePointerReferenceExample.h" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Class Name="ReturnTypeExample"
QualifiedName="ScriptCanvasTesting::Nodeables::ReturnTypeExample"
PreferredClassName="Return Type Example"
Base="ScriptCanvas::Nodeable"
Icon="Icons/ScriptCanvas/Placeholder.png"
Category="Tests"
Category="Examples"
GeneratePropertyFriend="True"
Namespace="None"
EditAttributes="AZ::Script::Attributes::ExcludeFrom@AZ::Script::Attributes::ExcludeFlags::All"
Description="Example of returning by value, pointer and reference.">
<Input Name="Return By Value" >
<Return Name="Value" Type="AZStd::vector&lt;ScriptCanvas::Data::NumberType&gt;" />
@ -24,9 +33,10 @@
PreferredClassName="Branch Input Type Example"
Base="ScriptCanvas::Nodeable"
Icon="Icons/ScriptCanvas/Placeholder.png"
Category="Tests"
Category="Examples"
GeneratePropertyFriend="True"
Namespace="None"
EditAttributes="AZ::Script::Attributes::ExcludeFrom@AZ::Script::Attributes::ExcludeFlags::All"
Description="Example of branch passing as input by value, pointer and reference.">
<Input Name="Get Internal Vector" Description="">
<Return Name="Result" Type="AZStd::vector&lt;ScriptCanvas::Data::NumberType&gt;" />
@ -46,9 +56,10 @@
PreferredClassName="Input Type Example"
Base="ScriptCanvas::Nodeable"
Icon="Icons/ScriptCanvas/Placeholder.png"
Category="Tests"
Category="Examples"
GeneratePropertyFriend="True"
Namespace="None"
EditAttributes="AZ::Script::Attributes::ExcludeFrom@AZ::Script::Attributes::ExcludeFlags::All"
Description="Example of passing as input by value, pointer and reference.">
<Input Name="Clear By Value" Description="">
<Parameter Name="Value Input" Type="AZStd::vector&lt;ScriptCanvas::Data::NumberType&gt;"/>
@ -65,9 +76,10 @@
PreferredClassName="Property Example"
Base="ScriptCanvas::Nodeable"
Icon="Icons/ScriptCanvas/Placeholder.png"
Category="Tests"
Category="Examples"
GeneratePropertyFriend="True"
Namespace="None"
EditAttributes="AZ::Script::Attributes::ExcludeFrom@AZ::Script::Attributes::ExcludeFlags::All"
Description="Example of using properties.">
<Input Name="In" Description=""/>
<Property Name="Numbers" Type="AZStd::vector&lt;ScriptCanvas::Data::NumberType&gt;"/>

@ -26,9 +26,12 @@ namespace ScriptCanvasTesting
if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
{
behaviorContext->EnumProperty<(AZ::u32)TestEnum::Alpha>("ALPHA");
behaviorContext->EnumProperty<(AZ::u32)TestEnum::Bravo>("BRAVO");
behaviorContext->EnumProperty<(AZ::u32)TestEnum::Charlie>("CHARLIE");
behaviorContext->EnumProperty<(AZ::u32)TestEnum::Alpha>("ALPHA")
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All);
behaviorContext->EnumProperty<(AZ::u32)TestEnum::Bravo>("BRAVO")
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All);
behaviorContext->EnumProperty<(AZ::u32)TestEnum::Charlie>("CHARLIE")
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All);
}
}

Loading…
Cancel
Save