Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated to UE 5.0 #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion BlueprintSorting.uplugin
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
[
{
"Name" : "BlueprintSorting",
"Type" : "Developer",
"Type" : "DeveloperTool",
"LoadingPhase" : "PreDefault"
}
]
Expand Down
27 changes: 2 additions & 25 deletions Source/BlueprintSorting/BlueprintSorting.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,16 @@

public class BlueprintSorting : ModuleRules
{
public BlueprintSorting(TargetInfo Target)
public BlueprintSorting(ReadOnlyTargetRules Target) : base(Target)
{
PublicIncludePaths.AddRange(
new string[] {
"BlueprintSorting/Public",
// ... add public include paths required here ...
}
);

PrivateIncludePaths.AddRange(
new string[] {
"BlueprintSorting/Private",
// ... add other private include paths required here ...
}
);
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;

PublicDependencyModuleNames.AddRange(
new string[]
{
"Core",
"CoreUObject",
"Engine",
// ... add other public dependencies that you statically link with here ...
}
);

Expand All @@ -38,17 +25,7 @@ public BlueprintSorting(TargetInfo Target)
"GraphEditor",
"UnrealEd",
"Kismet",
// ... add private dependencies that you statically link with here ...
}
);

DynamicallyLoadedModuleNames.AddRange(
new string[]
{
// ... add any modules that your module loads dynamically here ...
}
);

bEnforceIWYU = false;
}
}
4 changes: 2 additions & 2 deletions Source/BlueprintSorting/Private/BPCHandler_BaseSortArray.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "CoreMinimal.h"

#include "BPCHandler_BaseSortArray.h"
#include "BPNode_BaseSortArray.h"
#include "BlueprintSortingHelperLibrary.h"

#include "CoreMinimal.h"
#include "Engine/Blueprint.h"
#include "Engine/MemberReference.h"
#include "BlueprintActionDatabaseRegistrar.h"
Expand Down
10 changes: 5 additions & 5 deletions Source/BlueprintSorting/Private/BPCHandler_BubbleSortArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ void BPCHandler_BubbleSortArray::CompileSort(FKismetFunctionContext& Context, UE
UEdGraphPin* ExecTriggeringPin = Context.FindRequiredPinByName(ArrayNode, UEdGraphSchema_K2::PN_Execute, EGPD_Input);
if ((ExecTriggeringPin == NULL) || !Context.ValidatePinType(ExecTriggeringPin, ExpectedExecPinType))
{
CompilerContext.MessageLog.Error(*FString::Printf(*LOCTEXT("NoValidExecutionPinForSortArray_Error", "@@ must have a valid execution pin @@").ToString()), ArrayNode, ExecTriggeringPin);
CompilerContext.MessageLog.Error(*LOCTEXT("NoValidExecutionPinForSortArray_Error", "@@ must have a valid execution pin @@").ToString(), ArrayNode, ExecTriggeringPin);
return;
}

UFunction* OrderingFunction = FindFunction(Context, Node);
FBPTerminal* OrderingFunctionContext = FindFunctionContext(Context, Node);
if(!OrderingFunction)
{
CompilerContext.MessageLog.Error(*FString::Printf(*LOCTEXT("NoValidFunctionForSortArray_Error", "Unable to find a vaild sort function to call for @@").ToString()), ArrayNode);
CompilerContext.MessageLog.Error(*LOCTEXT("NoValidFunctionForSortArray_Error", "Unable to find a valid sort function to call for @@").ToString(), ArrayNode);
return;
}

Expand Down Expand Up @@ -138,7 +138,7 @@ void BPCHandler_BubbleSortArray::CompileSort(FKismetFunctionContext& Context, UE
MainLoopPtr = &MainLoop;
}

// Assign inital no swaps monitor variable to true
// Assign initial no swaps monitor variable to true
{
FBPTerminal* LiteralTerm = Context.CreateLocalTerminal(ETerminalSpecification::TS_Literal);
LiteralTerm->bIsLiteral = true;
Expand Down Expand Up @@ -235,7 +235,7 @@ void BPCHandler_BubbleSortArray::CompileSort(FKismetFunctionContext& Context, UE
Statement.RHS.Add(*DirectionTerm);
}

// If if the first item should go after the second item then we will swap the elements and mark that a swap has been made
// If the first item should go after the second item then we will swap the elements and mark that a swap has been made
// Otherwise jump this
{
FBlueprintCompiledStatement& JumpOverSwap = Context.AppendStatementForNode(Node);
Expand Down Expand Up @@ -318,7 +318,7 @@ void BPCHandler_BubbleSortArray::CompileSort(FKismetFunctionContext& Context, UE
JumpInnerLoopStart.TargetLabel = InnerLoopPtr;
}

// If any swaps occured then jump back and check orderings of all adjacent pairs
// If any swaps occurred then jump back and check orderings of all adjacent pairs
{
FBlueprintCompiledStatement& JumpInnerLoopStart = Context.AppendStatementForNode(Node);
JumpInnerLoopStart.Type = KCST_GotoIfNot;
Expand Down
72 changes: 40 additions & 32 deletions Source/BlueprintSorting/Private/BPNode_BaseSortArray.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "CoreMinimal.h"
#include "BPNode_BaseSortArray.h"
#include "CoreMinimal.h"
#include "BPCHandler_BubbleSortArray.h"
#include "Engine/Blueprint.h"
#include "Engine/MemberReference.h"
Expand All @@ -22,13 +22,13 @@

struct FBPNode_BaseSortArrayHelper
{
static FString DelegatePinName;
static FString ArrayPinName;
static FString SortDirectionPinName;
static FName DelegatePinName;
static FName ArrayPinName;
static FName SortDirectionPinName;
};
FString FBPNode_BaseSortArrayHelper::DelegatePinName(TEXT("Delegate"));
FString FBPNode_BaseSortArrayHelper::ArrayPinName(TEXT("Array"));
FString FBPNode_BaseSortArrayHelper::SortDirectionPinName(TEXT("Sort Direction"));
FName FBPNode_BaseSortArrayHelper::DelegatePinName(TEXT("Delegate"));
FName FBPNode_BaseSortArrayHelper::ArrayPinName(TEXT("Array"));
FName FBPNode_BaseSortArrayHelper::SortDirectionPinName(TEXT("Sort Direction"));

UBPNode_BaseSortArray::UBPNode_BaseSortArray(const FObjectInitializer &ObjectInitializer)
: Super(ObjectInitializer)
Expand Down Expand Up @@ -56,7 +56,7 @@ void UBPNode_BaseSortArray::ValidateNodeDuringCompilation(class FCompilerResults

if(ArrayPin->PinType.PinCategory == K2Schema->PC_Wildcard)
{
MessageLog.Error(*FString::Printf(*NSLOCTEXT("K2Node", "BaseSortArrayNotAssignable", "Array input must have a type. Connect it to something. @@").ToString()), this);
MessageLog.Error(*NSLOCTEXT("K2Node", "BaseSortArrayNotAssignable", "Array input must have a type. Connect it to something. @@").ToString(), this);
}
else
{
Expand All @@ -74,14 +74,14 @@ void UBPNode_BaseSortArray::ValidateNodeDuringCompilation(class FCompilerResults
}
else
{
TypeToSort = ArrayPin->PinType.PinCategory;
TypeToSort = ArrayPin->PinType.PinCategory.ToString();
}
}
else
{
TypeToSort = ArrayPin->PinType.PinCategory;
TypeToSort = ArrayPin->PinType.PinCategory.ToString();
}
MessageLog.Error(*FString::Printf(*NSLOCTEXT("K2Node", "BaseSortArray_MissingSignature", "Signature is missing. Create a (dummy) event dispatcher with a signature of %s, %s, OrderingResult. @@").ToString(), *TypeToSort, *TypeToSort), this);
MessageLog.Error(*FString::Format(*NSLOCTEXT("K2Node", "BaseSortArray_MissingSignature", "Signature is missing. Create a (dummy) event dispatcher with a signature of {0}, {1}, OrderingResult. @@").ToString(), { *TypeToSort, *TypeToSort }), this);
}
}

Expand All @@ -105,7 +105,7 @@ UK2Node::ERedirectType UBPNode_BaseSortArray::DoPinsMatchForReconstruction(const
{
if ((OldPin->PinType.PinCategory == K2Schema->PC_Delegate) &&
(NewPin->PinType.PinCategory == K2Schema->PC_Delegate) &&
(FCString::Stricmp(*(NewPin->PinName), *(OldPin->PinName)) == 0))
(NewPin->PinName == OldPin->PinName))
{
return ERedirectType_Name;
}
Expand All @@ -119,14 +119,16 @@ void UBPNode_BaseSortArray::AllocateDefaultPins()

const UEdGraphSchema_K2* K2Schema = GetDefault<UEdGraphSchema_K2>();

CreatePin(EGPD_Input, K2Schema->PC_Exec, TEXT(""), NULL, false, false, K2Schema->PN_Execute);
CreatePin(EGPD_Output, K2Schema->PC_Exec, TEXT(""), NULL, false, false, K2Schema->PN_Then);
CreatePin(EGPD_Input, K2Schema->PC_Exec, TEXT(""), nullptr, K2Schema->PN_Execute);
CreatePin(EGPD_Output, K2Schema->PC_Exec, TEXT(""), nullptr, K2Schema->PN_Then);

UEnum* EnumPtr = FindObject<UEnum>(ANY_PACKAGE, TEXT("ESortDirection"), true);
CreatePin(EGPD_Input, K2Schema->PC_Byte, TEXT(""), EnumPtr, false, false, FBPNode_BaseSortArrayHelper::SortDirectionPinName);
CreatePin(EGPD_Input, K2Schema->PC_Byte, TEXT(""), EnumPtr, FBPNode_BaseSortArrayHelper::SortDirectionPinName);
GetSortDirectionPin()->DefaultValue = "Ascending";

CreatePin(EGPD_Input, UEdGraphSchema_K2::PC_Wildcard, TEXT(""), NULL, true, false, FBPNode_BaseSortArrayHelper::ArrayPinName);
FCreatePinParams PinParams;
PinParams.ContainerType = EPinContainerType::Array;
CreatePin(EGPD_Input, UEdGraphSchema_K2::PC_Wildcard, FName(TEXT("")), nullptr, FBPNode_BaseSortArrayHelper::ArrayPinName, PinParams);
}

void UBPNode_BaseSortArray::ReallocatePinsDuringReconstruction(TArray<UEdGraphPin*>& OldPins)
Expand All @@ -150,7 +152,10 @@ void UBPNode_BaseSortArray::ReallocatePinsDuringReconstruction(TArray<UEdGraphPi
{
const UEdGraphSchema_K2* K2Schema = GetDefault<UEdGraphSchema_K2>();

auto DelegatePin = CreatePin(EGPD_Input, K2Schema->PC_Delegate, TEXT(""), NULL, false, true, FBPNode_BaseSortArrayHelper::DelegatePinName, true);
FCreatePinParams PinParams;
PinParams.bIsReference = true;
PinParams.bIsConst = true;
auto DelegatePin = CreatePin(EGPD_Input, K2Schema->PC_Delegate, TEXT(""), nullptr, FBPNode_BaseSortArrayHelper::DelegatePinName, PinParams);
if (DelegatePin)
{
UFunction* SignatureFunction = GetSignatureFunction(ArrayPin->PinType);
Expand Down Expand Up @@ -213,9 +218,9 @@ UFunction* UBPNode_BaseSortArray::GetSignatureFunction(FEdGraphPinType& PinType,
return nullptr;
}

for (TFieldIterator<UMulticastDelegateProperty> It(ClassToSearch); It; ++It)
for (TFieldIterator<FMulticastDelegateProperty> It(ClassToSearch); It; ++It)
{
UMulticastDelegateProperty* DelProp = *It;
FMulticastDelegateProperty* DelProp = *It;
if(!DelProp)
{
continue;
Expand All @@ -235,7 +240,7 @@ UFunction* UBPNode_BaseSortArray::GetSignatureFunction(FEdGraphPinType& PinType,
bool Relevant = true;

int32 PropertyIndex = 0;
for (TFieldIterator<UProperty> PIt(Func); PIt; ++PIt, ++PropertyIndex)
for (TFieldIterator<FProperty> PIt(Func); PIt; ++PIt, ++PropertyIndex)
{
if (PIt->PropertyFlags & CPF_OutParm)
{
Expand All @@ -254,7 +259,7 @@ UFunction* UBPNode_BaseSortArray::GetSignatureFunction(FEdGraphPinType& PinType,

if (PropertyIndex < 2)
{
if (PropType.bIsArray || PropType.bIsMap || PropType.bIsSet)
if (PropType.ContainerType != EPinContainerType::None)
{
Relevant = false;
break;
Expand All @@ -281,7 +286,7 @@ UFunction* UBPNode_BaseSortArray::GetSignatureFunction(FEdGraphPinType& PinType,

if (PropertyIndex == 2)
{
if (PropType.bIsArray || PropType.bIsMap || PropType.bIsSet)
if (PropType.ContainerType != EPinContainerType::None)
{
Relevant = false;
break;
Expand Down Expand Up @@ -383,14 +388,14 @@ UFunction* UBPNode_BaseSortArray::GetFunction(FEdGraphPinType& PinType) const
bool Relevant = true;

int32 PropertyIndex = 0;
for (TFieldIterator<UProperty> PIt(*It); PIt; ++PIt, ++PropertyIndex)
for (TFieldIterator<FProperty> PIt(*It); PIt; ++PIt, ++PropertyIndex)
{
FEdGraphPinType PropType;
K2Schema->ConvertPropertyToPinType(*PIt, PropType);

if (PropertyIndex < 2)
{
if (PropType.bIsArray || PropType.bIsMap || PropType.bIsSet)
if (PropType.ContainerType != EPinContainerType::None)
{
Relevant = false;
break;
Expand All @@ -414,7 +419,7 @@ UFunction* UBPNode_BaseSortArray::GetFunction(FEdGraphPinType& PinType) const

if (PropertyIndex == 2)
{
if (PropType.bIsArray || PropType.bIsMap || PropType.bIsSet)
if (PropType.ContainerType != EPinContainerType::None)
{
Relevant = false;
break;
Expand Down Expand Up @@ -449,7 +454,7 @@ bool UBPNode_BaseSortArray::AreSameSignatures(const UEdGraphSchema_K2* K2Schema,
return false;
}

for (TFieldIterator<UProperty> ItA(SigA), ItB(SigB); ItA, ItB; ++ItA, ++ItB)
for (TFieldIterator<FProperty> ItA(SigA), ItB(SigB); ItA, ItB; ++ItA, ++ItB)
{
FEdGraphPinType PropTypeA;
FEdGraphPinType PropTypeB;
Expand Down Expand Up @@ -482,7 +487,7 @@ void UBPNode_BaseSortArray::OnArrayPinChanged()
FEdGraphPinType PinType = ArrayPin->LinkedTo[0]->PinType;

ArrayPin->PinType = PinType;
ArrayPin->PinType.bIsArray = true;
ArrayPin->PinType.ContainerType = EPinContainerType::Array;
ArrayPin->PinType.bIsReference = false;

UBlueprint* Blueprint = GetBlueprint();
Expand Down Expand Up @@ -512,12 +517,15 @@ void UBPNode_BaseSortArray::OnArrayPinChanged()
{
if (DelegatePin)
{
DelegatePin->MarkPendingKill();
DelegatePin->MarkAsGarbage();
Pins.Remove(DelegatePin);
OldClassPins.Add(DelegatePin);
}

DelegatePin = CreatePin(EGPD_Input, K2Schema->PC_Delegate, TEXT(""), NULL, false, true, FBPNode_BaseSortArrayHelper::DelegatePinName, true);
FCreatePinParams PinParams;
PinParams.bIsConst = true;
PinParams.bIsReference = true;
DelegatePin = CreatePin(EGPD_Input, K2Schema->PC_Delegate, TEXT(""), nullptr, FBPNode_BaseSortArrayHelper::DelegatePinName, PinParams);
if (DelegatePin)
{
FMemberReference::FillSimpleMemberReference<UFunction>(SignatureFunction, DelegatePin->PinType.PinSubCategoryMemberReference);
Expand All @@ -531,7 +539,7 @@ void UBPNode_BaseSortArray::OnArrayPinChanged()

if (DelegatePin)
{
DelegatePin->MarkPendingKill();
DelegatePin->MarkAsGarbage();
Pins.Remove(DelegatePin);
OldClassPins.Add(DelegatePin);
}
Expand All @@ -541,13 +549,13 @@ void UBPNode_BaseSortArray::OnArrayPinChanged()
{
if (DelegatePin)
{
DelegatePin->MarkPendingKill();
DelegatePin->MarkAsGarbage();
Pins.Remove(DelegatePin);
OldClassPins.Add(DelegatePin);
}
}

RewireOldPinsToNewPins(OldClassPins, NewClassPins);
RewireOldPinsToNewPins(OldClassPins, NewClassPins, nullptr);

// Destroy the old pins
DestroyPinList(OldClassPins);
Expand Down
5 changes: 3 additions & 2 deletions Source/BlueprintSorting/Private/BPNode_SortArray.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#include "CoreMinimal.h"

#include "BPNode_SortArray.h"
#include "BPCHandler_BubbleSortArray.h"

#include "CoreMinimal.h"


#define LOCTEXT_NAMESPACE "BlueprintSorting"

UBPNode_SortArray::UBPNode_SortArray(const FObjectInitializer &ObjectInitializer)
Expand Down
4 changes: 2 additions & 2 deletions Source/BlueprintSorting/Private/BlueprintSorting.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "CoreMinimal.h"
#include "BlueprintSorting.h"

#include "CoreMinimal.h"
#include "Modules/ModuleManager.h"
#include "BlueprintSorting.h"


void BlueprintSorting::StartupModule()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "CoreMinimal.h"

#include "BlueprintSortingHelperLibrary.h"

void UBlueprintSortingHelperLibrary::SwapItems_Impl(void* TargetArray, const UArrayProperty* ArrayProp, int32 Index1, int32 Index2)
#include "CoreMinimal.h"

void UBlueprintSortingHelperLibrary::SwapItems_Impl(void* TargetArray, const FArrayProperty* ArrayProp, int32 Index1, int32 Index2)
{
if (TargetArray)
{
Expand All @@ -12,7 +12,7 @@ void UBlueprintSortingHelperLibrary::SwapItems_Impl(void* TargetArray, const UAr
}
}

bool UBlueprintSortingHelperLibrary::GreaterThanOrEqualArrayLength_Impl(void* TargetArray, const UArrayProperty* ArrayProp, int32 Index)
bool UBlueprintSortingHelperLibrary::GreaterThanOrEqualArrayLength_Impl(void* TargetArray, const FArrayProperty* ArrayProp, int32 Index)
{
if (TargetArray)
{
Expand All @@ -25,7 +25,7 @@ bool UBlueprintSortingHelperLibrary::GreaterThanOrEqualArrayLength_Impl(void* Ta
return false;
}

bool UBlueprintSortingHelperLibrary::LessThanOrEqualArrayLength_Impl(void* TargetArray, const UArrayProperty* ArrayProp, int32 Index)
bool UBlueprintSortingHelperLibrary::LessThanOrEqualArrayLength_Impl(void* TargetArray, const FArrayProperty* ArrayProp, int32 Index)
{
if (TargetArray)
{
Expand Down
Loading