Skip to content

Commit 9cd808e

Browse files
committed
IsValid now requires all the data to be valid, added ToDisplayString
1 parent 42c4434 commit 9cd808e

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

Source/FunctionPicker/Private/FunctionPickerData/FunctionPicker.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ UFunction* FFunctionPicker::GetFunction() const
2929
return nullptr;
3030
}
3131

32+
// Returns string in text format: Class::Function
33+
FString FFunctionPicker::ToDisplayString() const
34+
{
35+
return IsValid() ? FString::Printf(TEXT("%s::%s"), *FunctionClass->GetName(), *FunctionName.ToString()) : FString();
36+
}
37+
3238
// Creates a hash value
3339
uint32 GetTypeHash(const FFunctionPicker& Other)
3440
{

Source/FunctionPicker/Public/FunctionPickerData/FunctionPicker.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,22 @@ struct FUNCTIONPICKER_API FFunctionPicker
3838
FFunctionPicker(UClass* InFunctionClass, FName InFunctionName);
3939

4040
/** The class where function can be found. */
41-
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, meta = (DisplayName = "Class"))
41+
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, meta = (DisplayName = "Class", ShowOnlyInnerProperties))
4242
TObjectPtr<UClass> FunctionClass = nullptr;
4343

4444
/** The function name to choose for specified class.*/
45-
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, meta = (DisplayName = "Function"))
45+
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, meta = (DisplayName = "Function", ShowOnlyInnerProperties))
4646
FName FunctionName = NAME_None;
4747

4848
/** Returns true if is valid. */
49-
FORCEINLINE bool IsValid() const { return !(*this == Empty); }
49+
FORCEINLINE bool IsValid() const { return FunctionClass && !FunctionName.IsNone(); }
5050

5151
/** Returns the function pointer based on set data to this structure. */
5252
UFunction* GetFunction() const;
5353

54+
/** Returns string in text format: Class::Function. */
55+
FString ToDisplayString() const;
56+
5457
/** Compares for equality.
5558
* @param Other The other object being compared. */
5659
FORCEINLINE bool operator==(const FFunctionPicker& Other) const { return GetTypeHash(*this) == GetTypeHash(Other); }

0 commit comments

Comments
 (0)