You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
123 lines
3.8 KiB
C++
123 lines
3.8 KiB
C++
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
#include "BlueprintGraphPrivatePCH.h"
|
|
#include "K2Node_SelectEnum.h"
|
|
#include "BlueprintNodeSpawner.h"
|
|
|
|
UDEPRECATED_K2Node_SelectEnum::UDEPRECATED_K2Node_SelectEnum(const class FPostConstructInitializeProperties& PCIP)
|
|
: Super(PCIP)
|
|
{
|
|
|
|
const UEdGraphSchema_K2* Schema = GetDefault<UEdGraphSchema_K2>();
|
|
IndexPinType.PinCategory = Schema->PC_Byte;
|
|
IndexPinType.PinSubCategory = TEXT("");
|
|
IndexPinType.PinSubCategoryObject = NULL;
|
|
}
|
|
|
|
void UDEPRECATED_K2Node_SelectEnum::AllocateDefaultPins()
|
|
{
|
|
const UEdGraphSchema_K2* Schema = GetDefault<UEdGraphSchema_K2>();
|
|
|
|
// to refresh, just in case if that changed
|
|
SetEnum(Enum);
|
|
|
|
NumOptionPins = EnumEntries.Num();
|
|
|
|
// Create the option pins
|
|
for (int32 Idx = 0; Idx < NumOptionPins; Idx++)
|
|
{
|
|
const FString PinName = FString::Printf(TEXT("%s"), *EnumEntries[Idx].ToString());
|
|
CreatePin(EGPD_Input, Schema->PC_Int, TEXT(""), NULL, false, false, PinName);
|
|
}
|
|
|
|
CreatePin(EGPD_Input, IndexPinType.PinCategory, IndexPinType.PinSubCategory, IndexPinType.PinSubCategoryObject.Get(), false, false, "Index");
|
|
|
|
// Create the return value
|
|
CreatePin(EGPD_Output, Schema->PC_Int, TEXT(""), NULL, false, false, Schema->PN_ReturnValue);
|
|
|
|
// skip select node
|
|
UK2Node::AllocateDefaultPins();
|
|
}
|
|
|
|
FString UDEPRECATED_K2Node_SelectEnum::GetTooltip() const
|
|
{
|
|
return TEXT("Return literal value set for each enum value");
|
|
}
|
|
|
|
FText UDEPRECATED_K2Node_SelectEnum::GetNodeTitle(ENodeTitleType::Type TitleType) const
|
|
{
|
|
FText EnumName = (Enum != NULL) ? FText::FromString(Enum->GetName()) : NSLOCTEXT("K2Node", "BadEnum", "(bad enum)");
|
|
|
|
FFormatNamedArguments Args;
|
|
Args.Add(TEXT("EnumName"), EnumName);
|
|
return FText::Format(NSLOCTEXT("K2Node", "SelectByEnum", "Select by {EnumName}"), Args);
|
|
}
|
|
|
|
/** Determine if any pins are connected, if so make all the other pins the same type, if not, make sure pins are switched back to wildcards */
|
|
void UDEPRECATED_K2Node_SelectEnum::NotifyPinConnectionListChanged(UEdGraphPin* Pin)
|
|
{
|
|
Super::NotifyPinConnectionListChanged(Pin);
|
|
|
|
// don't do anything
|
|
}
|
|
|
|
void UDEPRECATED_K2Node_SelectEnum::GetMenuActions(TArray<UBlueprintNodeSpawner*>& ActionListOut) const
|
|
{
|
|
for (TObjectIterator<UEnum> EnumIt; EnumIt; ++EnumIt)
|
|
{
|
|
UEnum const* Enum = (*EnumIt);
|
|
auto CustomizeEnumNodeLambda = [](UEdGraphNode* NewNode, bool bIsTemplateNode, TWeakObjectPtr<UEnum> EnumPtr)
|
|
{
|
|
UDEPRECATED_K2Node_SelectEnum* EnumNode = CastChecked<UDEPRECATED_K2Node_SelectEnum>(NewNode);
|
|
if (EnumPtr.IsValid())
|
|
{
|
|
EnumNode->Enum = EnumPtr.Get();
|
|
}
|
|
};
|
|
|
|
UBlueprintNodeSpawner* NodeSpawner = UBlueprintNodeSpawner::Create(GetClass());
|
|
check(NodeSpawner != nullptr);
|
|
ActionListOut.Add(NodeSpawner);
|
|
|
|
TWeakObjectPtr<UEnum> EnumPtr = Enum;
|
|
NodeSpawner->CustomizeNodeDelegate = UBlueprintNodeSpawner::FCustomizeNodeDelegate::CreateStatic(CustomizeEnumNodeLambda, EnumPtr);
|
|
}
|
|
}
|
|
|
|
void UDEPRECATED_K2Node_SelectEnum::GetOptionPins(TArray<UEdGraphPin*>& OptionPins) const
|
|
{
|
|
OptionPins.Empty();
|
|
|
|
for (auto It = Pins.CreateConstIterator(); It; It++)
|
|
{
|
|
UEdGraphPin* Pin = (*It);
|
|
if (EnumEntries.Contains(FName(*Pin->PinName)))
|
|
{
|
|
OptionPins.Add(Pin);
|
|
}
|
|
}
|
|
}
|
|
|
|
void UDEPRECATED_K2Node_SelectEnum::SetEnum(UEnum* InEnum)
|
|
{
|
|
Enum = InEnum;
|
|
|
|
// regenerate enum name list
|
|
EnumEntries.Empty();
|
|
|
|
for (int32 EnumIndex = 0; EnumIndex < Enum->NumEnums() - 1; ++EnumIndex)
|
|
{
|
|
//@TODO: Doesn't handle PinDisplayName metadata!
|
|
// This is commented out because it fails on the other end in the compiler
|
|
// Ideally we keep PinName as the enum name always, and use PinFriendlyName to show the metadataized version
|
|
//FString EnumValueName = CurrentEnum->GetDisplayNameText(EnumIndex).ToString();
|
|
//if (EnumValueName.Len() == 0)
|
|
FString EnumValueName;
|
|
{
|
|
EnumValueName = Enum->GetEnumName(EnumIndex);
|
|
}
|
|
EnumEntries.Add( FName(*EnumValueName) );
|
|
}
|
|
}
|