Ejemplo n.º 1
0
TSharedRef<SWidget> FGameplayTagCustomization::GetListContent()
{
	BuildEditableContainerList();
	
	FString Categories;
	if (StructPropertyHandle->GetProperty()->HasMetaData(TEXT("Categories")))
	{
		Categories = StructPropertyHandle->GetProperty()->GetMetaData(TEXT("Categories"));
	}

	bool bReadOnly = StructPropertyHandle->GetProperty()->HasAnyPropertyFlags(CPF_EditConst);

	return SNew(SVerticalBox)
		+ SVerticalBox::Slot()
		.AutoHeight()
		.MaxHeight(400)
		[
			SNew(SGameplayTagWidget, EditableContainers)
			.Filter(Categories)
			.ReadOnly(bReadOnly)
			.TagContainerName(StructPropertyHandle->GetPropertyDisplayName().ToString())
			.MultiSelect(false)
			.OnTagChanged(this, &FGameplayTagCustomization::OnTagChanged)
			.PropertyHandle(StructPropertyHandle)
		];
}
void FGameplayTagContainerCustomization::RefreshTagList()
{
	// Rebuild Editable Containers as container references can become unsafe
	BuildEditableContainerList();

	// Clear the list
	TagNames.Empty();

	// Add tags to list
	for (int32 ContainerIdx = 0; ContainerIdx < EditableContainers.Num(); ++ContainerIdx)
	{
		FGameplayTagContainer* Container = EditableContainers[ContainerIdx].TagContainer;
		if (Container)
		{
			for (auto It = Container->CreateConstIterator(); It; ++It)
			{
				TagNames.Add(MakeShareable(new FString(It->ToString())));
			}
		}
	}

	// Refresh the slate list
	if( TagListView.IsValid() )
	{
		TagListView->RequestListRefresh();
	}
}
void FGameplayTagContainerCustomization::CustomizeHeader(TSharedRef<class IPropertyHandle> InStructPropertyHandle, class FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& StructCustomizationUtils)
{
	StructPropertyHandle = InStructPropertyHandle;

	FSimpleDelegate OnTagContainerChanged = FSimpleDelegate::CreateSP(this, &FGameplayTagContainerCustomization::RefreshTagList);
	StructPropertyHandle->SetOnPropertyValueChanged(OnTagContainerChanged);

	BuildEditableContainerList();

	HeaderRow
		.NameContent()
		[
			StructPropertyHandle->CreatePropertyNameWidget()
		]
		.ValueContent()
		.MaxDesiredWidth(512)
		[
			SNew(SHorizontalBox)
		+ SHorizontalBox::Slot()
		.AutoWidth()
		.VAlign(VAlign_Center)
		[
			SNew(SVerticalBox)
			+ SVerticalBox::Slot()
			.AutoHeight()
			[
				SNew(SButton)
				.IsEnabled(!StructPropertyHandle->GetProperty()->HasAnyPropertyFlags(CPF_EditConst))
				.Text(LOCTEXT("GameplayTagContainerCustomization_Edit", "Edit..."))
				.OnClicked(this, &FGameplayTagContainerCustomization::OnEditButtonClicked)
			]
			+ SVerticalBox::Slot()
				.AutoHeight()
				[
					SNew(SButton)
					.IsEnabled(!StructPropertyHandle->GetProperty()->HasAnyPropertyFlags(CPF_EditConst))
					.Text(LOCTEXT("GameplayTagContainerCustomization_Clear", "Clear All"))
					.OnClicked(this, &FGameplayTagContainerCustomization::OnClearAllButtonClicked)
					.Visibility(this, &FGameplayTagContainerCustomization::GetClearAllVisibility)
				]
		]
	+ SHorizontalBox::Slot()
		.AutoWidth()
		[
			SNew(SBorder)
			.Padding(4.0f)
			.Visibility(this, &FGameplayTagContainerCustomization::GetTagsListVisibility)
			[
				ActiveTags()
			]
			]
		];

	GEditor->RegisterForUndo(this);
}
Ejemplo n.º 4
0
void FGameplayTagCustomization::CustomizeHeader(TSharedRef<class IPropertyHandle> InStructPropertyHandle, class FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& StructCustomizationUtils)
{
	TagContainer = MakeShareable(new FGameplayTagContainer);
	StructPropertyHandle = InStructPropertyHandle;

	FSimpleDelegate OnTagChanged = FSimpleDelegate::CreateSP(this, &FGameplayTagCustomization::OnPropertyValueChanged);
	StructPropertyHandle->SetOnPropertyValueChanged(OnTagChanged);

	BuildEditableContainerList();

	HeaderRow
	.NameContent()
	[
		StructPropertyHandle->CreatePropertyNameWidget()
	]
	.ValueContent()
	.MaxDesiredWidth(512)
	[
		SNew(SHorizontalBox)
		+ SHorizontalBox::Slot()
		.AutoWidth()
		[
			SAssignNew(ComboButton, SComboButton)
			.OnGetMenuContent(this, &FGameplayTagCustomization::GetListContent)
			.ContentPadding(FMargin(2.0f, 2.0f))
			.MenuPlacement(MenuPlacement_BelowAnchor)
			.ButtonContent()
			[
				SNew(STextBlock)
				.Text(LOCTEXT("GameplayTagCustomization_Edit", "Edit"))
			]
		]
		+ SHorizontalBox::Slot()
		.AutoWidth()
		[
			SNew(SBorder)
			.Padding(4.0f)
			[
				SNew(STextBlock)
				.Text(this, &FGameplayTagCustomization::SelectedTag)
			]
		]
	];

	GEditor->RegisterForUndo(this);
}
TSharedRef<SWidget> FGameplayTagCustomization::GetListContent()
{
	BuildEditableContainerList();
	
	FString Categories = UGameplayTagsManager::Get().GetCategoriesMetaFromPropertyHandle(StructPropertyHandle);

	bool bReadOnly = StructPropertyHandle->IsEditConst();

	return SNew(SVerticalBox)
		+ SVerticalBox::Slot()
		.AutoHeight()
		.MaxHeight(400)
		[
			SNew(SGameplayTagWidget, EditableContainers)
			.Filter(Categories)
			.ReadOnly(bReadOnly)
			.TagContainerName(StructPropertyHandle->GetPropertyDisplayName().ToString())
			.MultiSelect(false)
			.OnTagChanged(this, &FGameplayTagCustomization::OnTagChanged)
			.PropertyHandle(StructPropertyHandle)
		];
}