Skip to content

Push metadata changes to skeleton class as well as generated class #12

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

Open
wants to merge 4 commits into
base: main
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
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ namespace MDMDEFV_Private

const FString FMDMetaDataEditorFieldView::MultipleValues = TEXT("Multiple Values");

FMDMetaDataEditorFieldView::FMDMetaDataEditorFieldView(FProperty* InProperty, UBlueprint* InBlueprint)
FMDMetaDataEditorFieldView::FMDMetaDataEditorFieldView(FProperty* InProperty, FProperty* InSkelProperty, UBlueprint* InBlueprint)
: MetadataProperty(InProperty)
, MetadataSkeletonProperty(InSkelProperty)
, BlueprintPtr(InBlueprint)
{
if (InProperty != nullptr)
Expand Down Expand Up @@ -124,8 +125,9 @@ FMDMetaDataEditorFieldView::FMDMetaDataEditorFieldView(FProperty* InProperty, UU
{
}

FMDMetaDataEditorFieldView::FMDMetaDataEditorFieldView(FProperty* InProperty, UK2Node_EditablePinBase* InNode)
FMDMetaDataEditorFieldView::FMDMetaDataEditorFieldView(FProperty* InProperty, FProperty* InSkelProperty, UK2Node_EditablePinBase* InNode)
: MetadataProperty(InProperty)
, MetadataSkeletonProperty(InSkelProperty)
, BlueprintPtr(IsValid(InNode) ? InNode->GetBlueprint() : nullptr)
{
if (InProperty != nullptr)
Expand Down Expand Up @@ -863,6 +865,11 @@ void FMDMetaDataEditorFieldView::SetMetadataValue(const FName& Key, const FStrin
Property->SetMetaData(Key, FString(Value));
VariableDescription.SetMetaData(Key, Value);
bDidFindMetaData = true;

if (FProperty* SkeletonProperty = MetadataSkeletonProperty.Get())
{
SkeletonProperty->SetMetaData(Key, FString(Value));
}
}
}

Expand All @@ -878,6 +885,11 @@ void FMDMetaDataEditorFieldView::SetMetadataValue(const FName& Key, const FStrin
FuncNode->Modify();
Property->SetMetaData(Key, FString(Value));
VariableDescription.SetMetaData(Key, Value);

if (FProperty* SkeletonProperty = MetadataSkeletonProperty.Get())
{
SkeletonProperty->SetMetaData(Key, FString(Value));
}
}
}
}
Expand All @@ -892,6 +904,11 @@ void FMDMetaDataEditorFieldView::SetMetadataValue(const FName& Key, const FStrin
}

Property->SetMetaData(Key, FString(Value));

if (FProperty* SkeletonProperty = MetadataSkeletonProperty.Get())
{
SkeletonProperty->SetMetaData(Key, FString(Value));
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ enum class EMDMetaDataEditorFieldType : uint8
class MDMETADATAEDITOR_API FMDMetaDataEditorFieldView : public TSharedFromThis<FMDMetaDataEditorFieldView>
{
public:
FMDMetaDataEditorFieldView(FProperty* InProperty, UBlueprint* InBlueprint);
FMDMetaDataEditorFieldView(FProperty* InProperty, FProperty* InSkelProperty, UBlueprint* InBlueprint);
FMDMetaDataEditorFieldView(FProperty* InProperty, UUserDefinedStruct* InUserDefinedStruct);
FMDMetaDataEditorFieldView(FProperty* InProperty, UK2Node_EditablePinBase* InNode);
FMDMetaDataEditorFieldView(FProperty* InProperty, FProperty* InSkelProperty, UK2Node_EditablePinBase* InNode);
explicit FMDMetaDataEditorFieldView(UUserDefinedStruct* InUserDefinedStruct);
FMDMetaDataEditorFieldView(UK2Node_FunctionEntry* InFunctionEntry, UBlueprint* InBlueprint);
FMDMetaDataEditorFieldView(UK2Node_Tunnel* InTunnel, UBlueprint* InBlueprint);
Expand Down Expand Up @@ -109,6 +109,7 @@ class MDMETADATAEDITOR_API FMDMetaDataEditorFieldView : public TSharedFromThis<F
bool CanPasteMetadata(FName Key) const;

TWeakFieldPtr<FProperty> MetadataProperty;
TWeakFieldPtr<FProperty> MetadataSkeletonProperty;
TWeakObjectPtr<UUserDefinedStruct> MetadataStruct;
TWeakObjectPtr<UK2Node_FunctionEntry> MetadataFunctionEntry;
TWeakObjectPtr<UK2Node_Tunnel> MetadataTunnel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ namespace MDMDEFC_Private
return nullptr;
}

FProperty* FindNodeProperty(const UK2Node_EditablePinBase* Node, const TSharedPtr<FUserPinInfo>& PinInfo)
FProperty* FindNodeProperty(const UK2Node_EditablePinBase* Node, const TSharedPtr<FUserPinInfo>& PinInfo, bool bUseSkelClass)
{
// Specifically grab the generated class, not the skeleton class so that UMDMetaDataEditorBlueprintCompilerExtension can grab the meta data after the BP is compiled

const UBlueprint* Blueprint = IsValid(Node) ? Node->GetBlueprint() : nullptr;
const UClass* Class = IsValid(Blueprint) ? Blueprint->GeneratedClass : nullptr;
const UClass* Class = IsValid(Blueprint) ? (bUseSkelClass ? Blueprint->SkeletonGeneratedClass : Blueprint->GeneratedClass) : nullptr;
const UFunction* Function = nullptr;

if (const UK2Node_FunctionResult* ResultNode = Cast<UK2Node_FunctionResult>(Node))
Expand Down Expand Up @@ -178,13 +178,14 @@ void FMDMetaDataEditorFunctionCustomization::InitFieldViews(UObject* Obj)
{
for (const TSharedPtr<FUserPinInfo>& PinInfo : Node->UserDefinedPins)
{
FProperty* ParamProperty = MDMDEFC_Private::FindNodeProperty(Node, PinInfo);
FProperty* ParamProperty = MDMDEFC_Private::FindNodeProperty(Node, PinInfo, false);
if (ParamProperty == nullptr)
{
continue;
}
FProperty* SkeletonProperty = MDMDEFC_Private::FindNodeProperty(Node, PinInfo, true);

TSharedPtr<FMDMetaDataEditorFieldView> ParamFieldView = MakeShared<FMDMetaDataEditorFieldView>(ParamProperty, Node);
TSharedPtr<FMDMetaDataEditorFieldView> ParamFieldView = MakeShared<FMDMetaDataEditorFieldView>(ParamProperty, SkeletonProperty, Node);
ParamFieldView->RequestRefresh.BindSP(this, &FMDMetaDataEditorFunctionCustomization::RefreshDetails);
ParamFieldViews.Emplace(MoveTemp(ParamFieldView));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ void FMDMetaDataEditorVariableCustomization::CustomizeObject(IDetailLayoutBuilde
|| (!bIsLocalVariable && Config->bEnableMetaDataEditorForVariables);
if (bIsEnabled)
{
FProperty* SkeletonProperty = GetBlueprint()->SkeletonGeneratedClass->FindPropertyByName(Property->GetFName());

TMap<FName, IDetailGroup*> GroupMap;
VariableFieldView = MakeShared<FMDMetaDataEditorFieldView>(Property, GetBlueprint());
VariableFieldView = MakeShared<FMDMetaDataEditorFieldView>(Property, SkeletonProperty, GetBlueprint());
VariableFieldView->RequestRefresh.BindSP(this, &FMDMetaDataEditorVariableCustomization::RefreshDetails);
VariableFieldView->GenerateMetadataEditor(DetailLayout, GroupMap);
}
Expand Down