Initial commit

This commit is contained in:
alexpete
2021-03-05 11:26:34 -08:00
commit a10351f38d
27091 changed files with 5521199 additions and 0 deletions
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<ScriptCanvas Include="Include/ScriptCanvas/Libraries/String/Contains.h" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Class Name="Contains"
QualifiedName="ScriptCanvas::Nodes::String::Contains"
PreferredClassName="Contains String"
Uuid="{8481E892-DE37-4CCF-86AA-E4770DE90643}"
Base="ScriptCanvas::Node"
Category="String"
Version="0"
GeneratePropertyFriend="True"
Description="Checks if a string contains an instance of a specified string, if true, it returns the index to the first instance matched.">
<In Name="In" Description="Input signal"/>
<Property Name="Source"
Description="The string to search in."
Type="AZStd::string"
IsInput="True"
IsOutput="False" />
<Property Name="Pattern"
Description="The substring to search for."
Type="AZStd::string"
IsInput="True"
IsOutput="False" />
<Property Name="Search From End"
Description="Start the match checking from the end of a string."
Type="bool"
IsInput="True"
IsOutput="False" />
<Property Name="Case Sensitive"
Description="Take into account the case of the string when searching."
Type="bool"
DefaultValue="true"
IsInput="True"
IsOutput="False" />
<Out Name="True" Description="The string contains the provided pattern."/>
<Out Name="False" Description="The string did not contain the provided pattern."/>
<Property Name="Index"
Description="The first index at which the substring was found."
Type="int"
IsInput="False"
IsOutput="True" />
</Class>
</ScriptCanvas>
@@ -0,0 +1,51 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "Contains.h"
#include <AzFramework/StringFunc/StringFunc.h>
namespace ScriptCanvas
{
namespace Nodes
{
namespace String
{
void Contains::OnInputSignal(const SlotId&)
{
AZ_PROFILE_SCOPE(AZ::Debug::ProfileCategory::ScriptCanvas, "ScriptCanvas::Contains::OnInputSignal");
AZStd::string sourceString = ContainsProperty::GetSource(this);
AZStd::string patternString = ContainsProperty::GetPattern(this);
bool caseSensitive = ContainsProperty::GetCaseSensitive(this);
bool searchFromEnd = ContainsProperty::GetSearchFromEnd(this);
auto index = AzFramework::StringFunc::Find(sourceString.c_str(), patternString.c_str(), 0, searchFromEnd, caseSensitive);
if (index != AZStd::string::npos)
{
const SlotId outputIndexSlotId = ContainsProperty::GetIndexSlotId(this);
if (auto* indexSlot = GetSlot(outputIndexSlotId))
{
Datum outputIndex(index);
PushOutput(outputIndex, *indexSlot);
}
SignalOutput(GetSlotId("True"));
return;
}
SignalOutput(GetSlotId("False"));
}
}
}
}
@@ -0,0 +1,80 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <ScriptCanvas/CodeGen/CodeGen.h>
#include <ScriptCanvas/Core/Node.h>
#include <ScriptCanvas/Internal/Nodes/StringFormatted.h>
#include <Include/ScriptCanvas/Libraries/String/Contains.generated.h>
namespace ScriptCanvas
{
namespace Nodes
{
namespace String
{
//! Checks if the specified substring exists in the provided string
class Contains
: public Node
{
public:
ScriptCanvas_Node(Contains,
ScriptCanvas_Node::Name("Contains String", "Checks if a string contains an instance of a specified string, if true, it returns the index to the first instance matched.")
ScriptCanvas_Node::Uuid("{8481E892-DE37-4CCF-86AA-E4770DE90643}")
ScriptCanvas_Node::Category("String")
ScriptCanvas_Node::Version(0)
);
protected:
// Inputs
ScriptCanvas_In(ScriptCanvas_In::Name("In", "Input signal"));
ScriptCanvas_Property(AZStd::string,
ScriptCanvas_Property::Name("Source", "The string to search in.")
ScriptCanvas_Property::Input
);
ScriptCanvas_Property(AZStd::string,
ScriptCanvas_Property::Name("Pattern", "The substring to search for.")
ScriptCanvas_Property::Input
);
ScriptCanvas_Property(bool,
ScriptCanvas_Property::Name("Search From End", "Start the match checking from the end of a string.")
ScriptCanvas_Property::Input
);
ScriptCanvas_PropertyWithDefaults(bool, true,
ScriptCanvas_Property::Name("Case Sensitive", "Take into account the case of the string when searching.")
ScriptCanvas_Property::Input
);
ScriptCanvas_Out(ScriptCanvas_Out::Name("True", "The string contains the provided pattern."));
ScriptCanvas_Out(ScriptCanvas_Out::Name("False", "The string did not contain the provided pattern."));
ScriptCanvas_Property(int,
ScriptCanvas_Property::Name("Index", "The first index at which the substring was found.")
ScriptCanvas_Property::Output,
ScriptCanvas_Property::OutputStorageSpec
);
void OnInputSignal(const SlotId& slotId) override;
};
}
}
}
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<ScriptCanvas Include="Include/ScriptCanvas/Libraries/String/Format.h" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Class Name="Format"
QualifiedName="ScriptCanvas::Nodes::String::Format"
PreferredClassName="Build String"
Uuid="{B16259BA-9CF6-4143-B09B-5A0F3B4585E6}"
Base="ScriptCanvas::Nodes::Internal::StringFormatted"
Category="String"
Version="0"
DynamicSlotOrdering="True"
GeneratePropertyFriend="True"
Description="Formats and creates a string from the provided text.\nAny word within {} will create a data pin on this node.">
<Property Name="String"
Description="The resulting string."
Type="AZStd::string"
DisplayGroup="PrintDisplayGroup"
IsInput="False"
IsOutput="True" />
</Class>
</ScriptCanvas>
@@ -0,0 +1,37 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "Format.h"
namespace ScriptCanvas
{
namespace Nodes
{
namespace String
{
void Format::OnInputSignal(const SlotId&)
{
AZ_PROFILE_SCOPE(AZ::Debug::ProfileCategory::ScriptCanvas, "ScriptCanvas::Format::OnInputSignal");
Datum output = Datum(ProcessFormat());
const SlotId outputTextSlotId = FormatProperty::GetStringSlotId(this);
if (auto* slot = GetSlot(outputTextSlotId))
{
PushOutput(output, *slot);
}
SignalOutput(GetSlotId("Out"));
}
}
}
}
@@ -0,0 +1,55 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <ScriptCanvas/CodeGen/CodeGen.h>
#include <ScriptCanvas/Core/Node.h>
#include <ScriptCanvas/Internal/Nodes/StringFormatted.h>
#include <Include/ScriptCanvas/Libraries/String/Format.generated.h>
namespace ScriptCanvas
{
namespace Nodes
{
namespace String
{
//! A String formatting class that produces a data output based on the specified string format and
//! input values.
class Format
: public Internal::StringFormatted
{
public:
ScriptCanvas_Node(Format,
ScriptCanvas_Node::Name("Build String", "Formats and creates a string from the provided text.\nAny word within {} will create a data pin on this node.")
ScriptCanvas_Node::Uuid("{B16259BA-9CF6-4143-B09B-5A0F3B4585E6}")
ScriptCanvas_Node::Category("String")
ScriptCanvas_Node::DynamicSlotOrdering(true)
ScriptCanvas_Node::Version(0)
);
protected:
ScriptCanvas_Property(AZStd::string,
ScriptCanvas_Property::Name("String", "The resulting string.")
ScriptCanvas_Property::Output
ScriptCanvas_Property::OutputStorageSpec
ScriptCanvas_Property::DisplayGroup("PrintDisplayGroup")
);
void OnInputSignal(const SlotId& slotId) override;
};
}
}
}
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<ScriptCanvas Include="Include/ScriptCanvas/Libraries/String/Print.h" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Class Name="Print"
QualifiedName="ScriptCanvas::Nodes::String::Print"
PreferredClassName="Print"
Uuid="{E1940FB4-83FE-4594-9AFF-375FF7603338}"
Base="ScriptCanvas::Nodes::Internal::StringFormatted"
Category="Utilities/Debug"
Version="0"
DynamicSlotOrdering="True"
EditAttributes="AZ::Edit::Attributes::CategoryStyle@.string;ScriptCanvas::Attributes::Node::TitlePaletteOverride@StringNodeTitlePalette"
Description="Formats and prints the provided text in the debug console.\nAny word within {} will create a data pin on this node.">
</Class>
</ScriptCanvas>
@@ -0,0 +1,44 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "Print.h"
#include <ScriptCanvas/Execution/RuntimeBus.h>
#include <ScriptCanvas/Execution/ExecutionBus.h>
namespace ScriptCanvas
{
namespace Nodes
{
namespace String
{
void Print::OnInputSignal([[maybe_unused]] const SlotId& slotId)
{
#if !defined(PERFORMANCE_BUILD) && !defined(_RELEASE)
AZ_PROFILE_SCOPE(AZ::Debug::ProfileCategory::ScriptCanvas, "ScriptCanvas::Print::OnInputSignal");
AZStd::string text = ProcessFormat();
AZ_TracePrintf("Script Canvas", "%s\n", text.c_str());
LogNotificationBus::Event(GetOwningScriptCanvasId(), &LogNotifications::LogMessage, text);
AZ::EntityId assetNodeId{};
ScriptCanvas::RuntimeRequestBus::EventResult(assetNodeId, GetOwningScriptCanvasId(), &ScriptCanvas::RuntimeRequests::FindAssetNodeIdByRuntimeNodeId, GetEntityId());
SC_EXECUTION_TRACE_ANNOTATE_NODE((*this), (AnnotateNodeSignal(CreateGraphInfo(GetOwningScriptCanvasId(), GetGraphIdentifier()), AnnotateNodeSignal::AnnotationLevel::Info, text, AZ::NamedEntityId(assetNodeId, GetNodeName()))));
#endif
SignalOutput(GetSlotId("Out"));
}
}
}
}
@@ -0,0 +1,50 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <ScriptCanvas/CodeGen/CodeGen.h>
#include <ScriptCanvas/Core/Node.h>
#include <ScriptCanvas/Internal/Nodes/StringFormatted.h>
#include <Include/ScriptCanvas/Libraries/String/Print.generated.h>
namespace ScriptCanvas
{
namespace Nodes
{
namespace String
{
//! Prints a formatted string into the console.
class Print
: public Internal::StringFormatted
{
public:
ScriptCanvas_Node(Print,
ScriptCanvas_Node::Name("Print", "Formats and prints the provided text in the debug console.\nAny word within {} will create a data pin on this node.")
ScriptCanvas_Node::Uuid("{E1940FB4-83FE-4594-9AFF-375FF7603338}")
ScriptCanvas_Node::Category("Utilities/Debug")
ScriptCanvas_Node::EditAttributes(AZ::Edit::Attributes::CategoryStyle(".string"), ScriptCanvas::Attributes::Node::TitlePaletteOverride("StringNodeTitlePalette"))
ScriptCanvas_Node::DynamicSlotOrdering(true)
ScriptCanvas_Node::Version(0)
);
protected:
void OnInputSignal(const SlotId&) override;
};
}
}
}
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<ScriptCanvas Include="Include/ScriptCanvas/Libraries/String/Replace.h" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Class Name="Replace"
QualifiedName="ScriptCanvas::Nodes::String::Replace"
PreferredClassName="Replace String"
Uuid="{197D0BAA-FCAF-4922-872B-3A95BEA574B2}"
Base="ScriptCanvas::Node"
Category="String"
Version="0"
GeneratePropertyFriend="True"
Description="Allows replacing a substring from a given string.">
<In Name="In" Description="Input signal"/>
<Out Name="Out" Description=""/>
<Property Name="Source"
Description="The string to search in."
Type="AZStd::string"
IsInput="True"
IsOutput="False" />
<Property Name="Replace"
Description="The substring to search for."
Type="AZStd::string"
IsInput="True"
IsOutput="False" />
<Property Name="With"
Description="The string to replace the substring with."
Type="AZStd::string"
IsInput="True"
IsOutput="False" />
<Property Name="Case Sensitive"
Description="Take into account the case of the string when searching."
Type="bool"
DefaultValue="true"
IsInput="True"
IsOutput="False" />
<Property Name="Result"
Description="The resulting string."
Type="AZStd::string"
IsInput="False"
IsOutput="True" />
</Class>
</ScriptCanvas>
@@ -0,0 +1,47 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "Replace.h"
#include <AzFramework/StringFunc/StringFunc.h>
namespace ScriptCanvas
{
namespace Nodes
{
namespace String
{
void Replace::OnInputSignal(const SlotId&)
{
AZ_PROFILE_SCOPE(AZ::Debug::ProfileCategory::ScriptCanvas, "ScriptCanvas::Replace::OnInputSignal");
AZStd::string sourceString = ReplaceProperty::GetSource(this);
AZStd::string replaceString = ReplaceProperty::GetReplace(this);
AZStd::string withString = ReplaceProperty::GetWith(this);
bool caseSensitive = ReplaceProperty::GetCaseSensitive(this);
AzFramework::StringFunc::Replace(sourceString, replaceString.c_str(), withString.c_str(), caseSensitive);
const SlotId outputResultSlotId = ReplaceProperty::GetResultSlotId(this);
ScriptCanvas::Datum output(sourceString);
if (auto* outputSlot = GetSlot(outputResultSlotId))
{
PushOutput(output, *outputSlot);
}
SignalOutput(GetSlotId("Out"));
}
}
}
}
@@ -0,0 +1,80 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <ScriptCanvas/CodeGen/CodeGen.h>
#include <ScriptCanvas/Core/Node.h>
#include <ScriptCanvas/Internal/Nodes/StringFormatted.h>
#include <Include/ScriptCanvas/Libraries/String/Replace.generated.h>
namespace ScriptCanvas
{
namespace Nodes
{
namespace String
{
//! A String formatting class that produces a data output based on the specified string format and
//! input values.
class Replace
: public Node
{
public:
ScriptCanvas_Node(Replace,
ScriptCanvas_Node::Name("Replace String", "Allows replacing a substring from a given string.")
ScriptCanvas_Node::Uuid("{197D0BAA-FCAF-4922-872B-3A95BEA574B2}")
ScriptCanvas_Node::Category("String")
ScriptCanvas_Node::Version(0)
);
protected:
// Inputs
ScriptCanvas_In(ScriptCanvas_In::Name("In", "Input signal"));
// Outputs
ScriptCanvas_Out(ScriptCanvas_Out::Name("Out", ""));
ScriptCanvas_Property(AZStd::string,
ScriptCanvas_Property::Name("Source", "The string to search in.")
ScriptCanvas_Property::Input
);
ScriptCanvas_Property(AZStd::string,
ScriptCanvas_Property::Name("Replace", "The substring to search for.")
ScriptCanvas_Property::Input
);
ScriptCanvas_Property(AZStd::string,
ScriptCanvas_Property::Name("With", "The string to replace the substring with.")
ScriptCanvas_Property::Input
);
ScriptCanvas_PropertyWithDefaults(bool, true,
ScriptCanvas_Property::Name("Case Sensitive", "Take into account the case of the string when searching.")
ScriptCanvas_Property::Input
);
ScriptCanvas_Property(AZStd::string,
ScriptCanvas_Property::Name("Result", "The resulting string.")
ScriptCanvas_Property::Output
ScriptCanvas_Property::OutputStorageSpec
);
void OnInputSignal(const SlotId& slotId) override;
};
}
}
}
@@ -0,0 +1,80 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <ScriptCanvas/Internal/Nodes/StringFormatted.h>
#include <ScriptCanvas/Libraries/Libraries.h>
#include <ScriptCanvas/Core/Attributes.h>
#include "String.h"
namespace ScriptCanvas
{
namespace Library
{
void String::Reflect(AZ::ReflectContext* reflection)
{
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(reflection);
if (serializeContext)
{
serializeContext->Class<String, LibraryDefinition>()
->Version(0)
;
AZ::EditContext* editContext = serializeContext->GetEditContext();
if (editContext)
{
editContext->Class<String>("String", "")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::Icon, "Editor/Icons/ScriptCanvas/Libraries/String.png")
->Attribute(AZ::Edit::Attributes::CategoryStyle, ".string")
->Attribute(ScriptCanvas::Attributes::Node::TitlePaletteOverride, "StringNodeTitlePalette")
;
}
}
Nodes::Internal::StringFormatted::Reflect(reflection);
}
void String::InitNodeRegistry(NodeRegistry& nodeRegistry)
{
using namespace ScriptCanvas::Nodes::String;
AddNodeToRegistry<String, Format>(nodeRegistry);
AddNodeToRegistry<String, Print>(nodeRegistry);
AddNodeToRegistry<String, Replace>(nodeRegistry);
AddNodeToRegistry<String, Contains>(nodeRegistry);
AddNodeToRegistry<String, StartsWith>(nodeRegistry);
AddNodeToRegistry<String, EndsWith>(nodeRegistry);
AddNodeToRegistry<String, Split>(nodeRegistry);
AddNodeToRegistry<String, Join>(nodeRegistry);
StringNodes::Registrar::AddToRegistry<String>(nodeRegistry);
}
AZStd::vector<AZ::ComponentDescriptor*> String::GetComponentDescriptors()
{
AZStd::vector<AZ::ComponentDescriptor*> descriptors = {
ScriptCanvas::Nodes::String::Format::CreateDescriptor(),
ScriptCanvas::Nodes::String::Print::CreateDescriptor(),
ScriptCanvas::Nodes::String::Replace::CreateDescriptor(),
ScriptCanvas::Nodes::String::Contains::CreateDescriptor(),
ScriptCanvas::Nodes::String::StartsWith::CreateDescriptor(),
ScriptCanvas::Nodes::String::EndsWith::CreateDescriptor(),
ScriptCanvas::Nodes::String::Split::CreateDescriptor(),
ScriptCanvas::Nodes::String::Join::CreateDescriptor()
};
StringNodes::Registrar::AddDescriptors(descriptors);
return descriptors;
}
}
}
@@ -0,0 +1,23 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
// This header is only meant to include the nodes and should not contain
// shared code
#include "Format.h"
#include "Print.h"
#include "Replace.h"
#include "Contains.h"
#include "Utilities.h"
#include "StringGenerics.h"
@@ -0,0 +1,55 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <ScriptCanvas/Core/NodeFunctionGeneric.h>
#include <AzFramework/StringFunc/StringFunc.h>
#include <AzCore/Math/MathUtils.h>
namespace ScriptCanvas
{
namespace StringNodes
{
AZ_INLINE Data::StringType ToLower(Data::StringType sourceString)
{
AZStd::to_lower(sourceString.begin(), sourceString.end());
return sourceString;
}
SCRIPT_CANVAS_GENERIC_FUNCTION_NODE(ToLower, "String", "{FC5FA07E-C65D-470A-BEFA-714EF8103866}", "Makes all the characters in the string lower case", "Source");
AZ_INLINE Data::StringType ToUpper(Data::StringType sourceString)
{
AZStd::to_upper(sourceString.begin(), sourceString.end());
return sourceString;
}
SCRIPT_CANVAS_GENERIC_FUNCTION_NODE(ToUpper, "String", "{323951D4-9BB1-47C9-BD2C-2DD2B750217F}", "Makes all the characters in the string upper case", "Source");
AZ_INLINE Data::StringType Substring(Data::StringType sourceString, AZ::u32 index, AZ::u32 length)
{
length = AZ::GetClamp<AZ::u32>(length, 0, aznumeric_cast<AZ::u32>(sourceString.size()));
if (length == 0 || index < 0 || index >= sourceString.size())
{
return {};
}
return sourceString.substr(index, length);
}
SCRIPT_CANVAS_GENERIC_FUNCTION_NODE(Substring, "String", "{031BCDFC-5DA4-4EA0-A310-1FA9165E5BE5}", "Returns a sub string from a given string", "Source", "From", "Length");
using Registrar = RegistrarGeneric
<
ToLowerNode,
ToUpperNode,
SubstringNode
>;
}
}
@@ -0,0 +1,118 @@
<?xml version="1.0" encoding="utf-8"?>
<ScriptCanvas Include="Include/ScriptCanvas/Libraries/String/Utilities.h" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Class Name="StartsWith"
QualifiedName="ScriptCanvas::Nodes::String::StartsWith"
PreferredClassName="Starts With"
Uuid="{60EB479A-CF31-4734-B2E5-422828A54A46}"
Base="ScriptCanvas::Node"
Category="String"
Version="0"
GeneratePropertyFriend="True"
Description=".">
<In Name="In" Description="Input signal"/>
<Out Name="True" Description=""/>
<Out Name="False" Description=""/>
<Property Name="Source"
Description="The string to search in."
Type="AZStd::string"
IsInput="True"
IsOutput="False" />
<Property Name="Pattern"
Description="The pattern to evaluate."
Type="AZStd::string"
IsInput="True"
IsOutput="False" />
<Property Name="Case Sensitive"
Description="Take into account the case of the string when searching."
Type="bool"
DefaultValue="false"
IsInput="True"
IsOutput="False" />
</Class>
<Class Name="EndsWith"
QualifiedName="ScriptCanvas::Nodes::String::EndsWith"
PreferredClassName="Ends With"
Uuid="{6C1CECA6-C155-4ED5-96BC-1D4F11C7A0FE}"
Base="ScriptCanvas::Node"
Category="String"
Version="0"
GeneratePropertyFriend="True"
Description=".">
<In Name="In" Description="Input signal"/>
<Out Name="True" Description=""/>
<Out Name="False" Description=""/>
<Property Name="Source"
Description="The string to search in."
Type="AZStd::string"
IsInput="True"
IsOutput="False" />
<Property Name="Pattern"
Description="The pattern to evaulate."
Type="AZStd::string"
IsInput="True"
IsOutput="False" />
<Property Name="Case Sensitive"
Description="Take into account the case of the string when searching."
Type="bool"
DefaultValue="false"
IsInput="True"
IsOutput="False" />
</Class>
<Class Name="Split"
QualifiedName="ScriptCanvas::Nodes::String::Split"
PreferredClassName="Split"
Uuid="{327EFC0F-F71E-4028-BAF9-C4223B933FB6}"
Base="ScriptCanvas::Node"
Category="String"
Version="0"
GeneratePropertyFriend="True"
Description=".">
<In Name="In" Description="Input signal"/>
<Out Name="Out" Description=""/>
<Property Name="Source"
Description="The string to search in."
Type="AZStd::string"
IsInput="True"
IsOutput="False" />
<Property Name="Delimiters"
Description="The characters that can be used as delimiters."
Type="AZStd::string"
DefaultValue="k_defaultDelimiter"
IsInput="True"
IsOutput="False" />
<Property Name="String Array"
Description="A container of all the strings."
Type="AZStd::vector&lt;AZStd::string&gt;"
IsInput="False"
IsOutput="True" />
</Class>
<Class Name="Join"
QualifiedName="ScriptCanvas::Nodes::String::Join"
PreferredClassName="Join"
Uuid="{121E5B89-5A8A-4477-A3B7-078B0F1B36FD}"
Base="ScriptCanvas::Node"
Category="String"
Version="0"
GeneratePropertyFriend="True"
Description=".">
<In Name="In" Description="Input signal"/>
<Out Name="Out" Description=""/>
<Property Name="String Array"
Description="The array of strings to join."
Type="AZStd::vector&lt;AZStd::string&gt;"
IsInput="True"
IsOutput="False" />
<Property Name="Separator"
Description="Will use this string when concatenating the strings from the array."
Type="AZStd::string"
DefaultValue="k_defaultSeparator"
IsInput="True"
IsOutput="False" />
<Property Name="String"
Description="The joined string."
Type="AZStd::string"
IsInput="False"
IsOutput="True" />
</Class>
</ScriptCanvas>
@@ -0,0 +1,120 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "Utilities.h"
#include <AzFramework/StringFunc/StringFunc.h>
namespace ScriptCanvas
{
namespace Nodes
{
namespace String
{
const char* Split::k_defaultDelimiter = " ";
const char* Join::k_defaultSeparator = " ";
void StartsWith::OnInputSignal(const SlotId&)
{
AZ_PROFILE_SCOPE(AZ::Debug::ProfileCategory::ScriptCanvas, "ScriptCanvas::StartsWith::OnInputSignal");
AZStd::string sourceString = StartsWithProperty::GetSource(this);
AZStd::string patternString = StartsWithProperty::GetPattern(this);
bool caseSensitive = StartsWithProperty::GetCaseSensitive(this);
if (AzFramework::StringFunc::StartsWith(sourceString.c_str(), patternString.c_str(), caseSensitive))
{
SignalOutput(GetSlotId("True"));
}
else
{
SignalOutput(GetSlotId("False"));
}
}
void EndsWith::OnInputSignal(const SlotId&)
{
AZ_PROFILE_SCOPE(AZ::Debug::ProfileCategory::ScriptCanvas, "ScriptCanvas::EndssWith::OnInputSignal");
AZStd::string sourceString = EndsWithProperty::GetSource(this);
AZStd::string patternString = EndsWithProperty::GetPattern(this);
bool caseSensitive = EndsWithProperty::GetCaseSensitive(this);
if (AzFramework::StringFunc::EndsWith(sourceString.c_str(), patternString.c_str(), caseSensitive))
{
SignalOutput(GetSlotId("True"));
}
else
{
SignalOutput(GetSlotId("False"));
}
}
void Split::OnInputSignal([[maybe_unused]] const SlotId& slotId)
{
AZ_PROFILE_SCOPE(AZ::Debug::ProfileCategory::ScriptCanvas, "ScriptCanvas::Split::OnInputSignal");
AZStd::string sourceString = SplitProperty::GetSource(this);
AZStd::string delimiterString = SplitProperty::GetDelimiters(this);
AZStd::vector<AZStd::string> stringArray;
AzFramework::StringFunc::Tokenize(sourceString.c_str(), stringArray, delimiterString.c_str(), false, false);
const SlotId outputResultSlotId = SplitProperty::GetStringArraySlotId(this);
if (auto* outputSlot = GetSlot(outputResultSlotId))
{
ScriptCanvas::Datum output(ScriptCanvas::Data::FromAZType(azrtti_typeid<AZStd::vector<AZStd::string>>()), ScriptCanvas::Datum::eOriginality::Original, &stringArray, azrtti_typeid<AZStd::vector<AZStd::string>>());
PushOutput(output, *outputSlot);
}
SignalOutput(GetSlotId("Out"));
}
void Join::OnInputSignal([[maybe_unused]] const SlotId& slotId)
{
AZ_PROFILE_SCOPE(AZ::Debug::ProfileCategory::ScriptCanvas, "ScriptCanvas::Join::OnInputSignal");
AZStd::vector<AZStd::string> sourceArray = JoinProperty::GetStringArray(this);
AZStd::string separatorString = JoinProperty::GetSeparator(this);
AZStd::string result;
size_t index = 0;
const size_t length = sourceArray.size();
for (auto string : sourceArray)
{
if (index < length - 1)
{
result.append(AZStd::string::format("%s%s", string.c_str(), separatorString.c_str()));
}
else
{
result.append(string);
}
++index;
}
const SlotId outputResultSlotId = JoinProperty::GetStringSlotId(this);
if (auto* outputSlot = GetSlot(outputResultSlotId))
{
ScriptCanvas::Datum output(result);
PushOutput(output, *outputSlot);
}
SignalOutput(GetSlotId("Out"));
}
}
}
}
@@ -0,0 +1,193 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <ScriptCanvas/CodeGen/CodeGen.h>
#include <ScriptCanvas/Core/Node.h>
#include <ScriptCanvas/Internal/Nodes/StringFormatted.h>
#include <Include/ScriptCanvas/Libraries/String/Utilities.generated.h>
namespace ScriptCanvas
{
namespace Nodes
{
namespace String
{
//! Checks if a string starts with a given string, outputs True or False
class StartsWith
: public Node
{
public:
ScriptCanvas_Node(StartsWith,
ScriptCanvas_Node::Name("Starts With", ".")
ScriptCanvas_Node::Uuid("{60EB479A-CF31-4734-B2E5-422828A54A46}")
ScriptCanvas_Node::Category("String")
ScriptCanvas_Node::Version(0)
);
protected:
// Inputs
ScriptCanvas_In(ScriptCanvas_In::Name("In", "Input signal"));
// Outputs
ScriptCanvas_Out(ScriptCanvas_Out::Name("True", ""));
ScriptCanvas_Out(ScriptCanvas_Out::Name("False", ""));
ScriptCanvas_Property(AZStd::string,
ScriptCanvas_Property::Name("Source", "The string to search in.")
ScriptCanvas_Property::Input
);
ScriptCanvas_Property(AZStd::string,
ScriptCanvas_Property::Name("Pattern", "The pattern to evaluate.")
ScriptCanvas_Property::Input
);
ScriptCanvas_PropertyWithDefaults(bool, false,
ScriptCanvas_Property::Name("Case Sensitive", "Take into account the case of the string when searching.")
ScriptCanvas_Property::Input
);
void OnInputSignal(const SlotId& slotId) override;
};
//! Checks if a string starts with a given string, outputs True or False
class EndsWith
: public Node
{
public:
ScriptCanvas_Node(EndsWith,
ScriptCanvas_Node::Name("Ends With", ".")
ScriptCanvas_Node::Uuid("{6C1CECA6-C155-4ED5-96BC-1D4F11C7A0FE}")
ScriptCanvas_Node::Category("String")
ScriptCanvas_Node::Version(0)
);
protected:
// Inputs
ScriptCanvas_In(ScriptCanvas_In::Name("In", "Input signal"));
// Outputs
ScriptCanvas_Out(ScriptCanvas_Out::Name("True", ""));
ScriptCanvas_Out(ScriptCanvas_Out::Name("False", ""));
ScriptCanvas_Property(AZStd::string,
ScriptCanvas_Property::Name("Source", "The string to search in.")
ScriptCanvas_Property::Input
);
ScriptCanvas_Property(AZStd::string,
ScriptCanvas_Property::Name("Pattern", "The pattern to evaulate.")
ScriptCanvas_Property::Input
);
ScriptCanvas_PropertyWithDefaults(bool, false,
ScriptCanvas_Property::Name("Case Sensitive", "Take into account the case of the string when searching.")
ScriptCanvas_Property::Input
);
void OnInputSignal(const SlotId& slotId) override;
};
//! Splits a string into an array of strings using the specified delimiter (empty space by default).
//! Returns an array of strings always, if the string cannot be split, the string will be the first
//! element of the returned array
class Split
: public Node
{
public:
ScriptCanvas_Node(Split,
ScriptCanvas_Node::Name("Split", ".")
ScriptCanvas_Node::Uuid("{327EFC0F-F71E-4028-BAF9-C4223B933FB6}")
ScriptCanvas_Node::Category("String")
ScriptCanvas_Node::Version(0)
);
protected:
// Inputs
ScriptCanvas_In(ScriptCanvas_In::Name("In", "Input signal"));
// Outputs
ScriptCanvas_Out(ScriptCanvas_Out::Name("Out", ""));
ScriptCanvas_Property(AZStd::string,
ScriptCanvas_Property::Name("Source", "The string to search in.")
ScriptCanvas_Property::Input
);
static const char* k_defaultDelimiter;
ScriptCanvas_PropertyWithDefaults(AZStd::string, k_defaultDelimiter,
ScriptCanvas_Property::Name("Delimiters", "The characters that can be used as delimiters.")
ScriptCanvas_Property::Input
);
ScriptCanvas_Property(AZStd::vector<AZStd::string>,
ScriptCanvas_Property::Name("String Array", "A container of all the strings.")
ScriptCanvas_Property::Output
ScriptCanvas_Property::OutputStorageSpec
);
void OnInputSignal(const SlotId& slotId) override;
};
//! Given an array of strings, this will join the elements in the array and return a single string
class Join
: public Node
{
public:
ScriptCanvas_Node(Join,
ScriptCanvas_Node::Name("Join", ".")
ScriptCanvas_Node::Uuid("{121E5B89-5A8A-4477-A3B7-078B0F1B36FD}")
ScriptCanvas_Node::Category("String")
ScriptCanvas_Node::Version(0)
);
protected:
// Inputs
ScriptCanvas_In(ScriptCanvas_In::Name("In", "Input signal"));
// Outputs
ScriptCanvas_Out(ScriptCanvas_Out::Name("Out", ""));
ScriptCanvas_Property(AZStd::vector<AZStd::string>,
ScriptCanvas_Property::Name("String Array", "The array of strings to join.")
ScriptCanvas_Property::Input
);
static const char* k_defaultSeparator;
ScriptCanvas_PropertyWithDefaults(AZStd::string, k_defaultSeparator,
ScriptCanvas_Property::Name("Separator", "Will use this string when concatenating the strings from the array.")
ScriptCanvas_Property::Input
);
ScriptCanvas_Property(AZStd::string,
ScriptCanvas_Property::Name("String", "The joined string.")
ScriptCanvas_Property::Output
ScriptCanvas_Property::OutputStorageSpec
);
void OnInputSignal(const SlotId& slotId) override;
};
}
}
}