You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
The code in DetailLayoutBuilderImpl.cpp that is attempting to create a new category is relying on a value from a FProperty that is not necessarily initialized and should not be relied upon. Instead, use information from the UObject to initialize the Category and it's UProperty #jira UE-196166 #rb JeanMichel.Dignard [CL 28259427 by karen jirak in ue5-main branch]
135 lines
4.0 KiB
C++
135 lines
4.0 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "DetailsDisplayManager.h"
|
|
|
|
#include "DetailsViewStyle.h"
|
|
#include "SDetailsView.h"
|
|
#include "DetailLayoutBuilderImpl.h"
|
|
#include "DetailCategoryBuilderImpl.h"
|
|
#include "ObjectEditorUtils.h"
|
|
#include "ObjectPropertyNode.h"
|
|
|
|
|
|
static TAutoConsoleVariable<bool> CVarForceShowComponentEditor(
|
|
TEXT("CoreEntity.UI.ForceShowComponentEditor"),
|
|
true,
|
|
TEXT("Force the component editor to show in the main details tab."));
|
|
|
|
|
|
FDetailsDisplayManager::FDetailsDisplayManager(): bIsOuterCategory(false)
|
|
{
|
|
PrimaryStyleKey = SDetailsView::GetPrimaryDetailsViewStyleKey();
|
|
}
|
|
|
|
FDetailsDisplayManager::~FDetailsDisplayManager()
|
|
{
|
|
OnDetailsNeedsUpdate.Unbind();
|
|
}
|
|
|
|
bool FDetailsDisplayManager::ShouldHideComponentEditor()
|
|
{
|
|
return !GetForceShowSubObjectEditor();
|
|
}
|
|
|
|
bool FDetailsDisplayManager::ShouldShowCategoryMenu()
|
|
{
|
|
return false;
|
|
}
|
|
|
|
void FDetailsDisplayManager::SetCategoryObjectName(FName InCategoryObjectName)
|
|
{
|
|
CategoryObjectName = InCategoryObjectName;
|
|
}
|
|
|
|
TSharedPtr<SWidget> FDetailsDisplayManager::GetCategoryMenu(FName InCategoryObjectName)
|
|
{
|
|
return nullptr;
|
|
}
|
|
|
|
void FDetailsDisplayManager::UpdateView() const
|
|
{
|
|
OnDetailsNeedsUpdate.ExecuteIfBound();
|
|
}
|
|
|
|
const FDetailsViewStyleKey& FDetailsDisplayManager::GetDetailsViewStyleKey() const
|
|
{
|
|
return PrimaryStyleKey;
|
|
}
|
|
|
|
void FDetailsDisplayManager::SetIsOuterCategory(bool bInIsOuterCategory)
|
|
{
|
|
bIsOuterCategory = bInIsOuterCategory;
|
|
}
|
|
|
|
const FDetailsViewStyle* FDetailsDisplayManager::GetDetailsViewStyle() const
|
|
{
|
|
const FDetailsViewStyle* ViewStyle = FDetailsViewStyle::GetStyle(GetDetailsViewStyleKey());
|
|
return ViewStyle;
|
|
}
|
|
|
|
FMargin FDetailsDisplayManager::GetTablePadding() const
|
|
{
|
|
const FDetailsViewStyle* Style = GetDetailsViewStyle();
|
|
return Style ? Style->GetTablePadding(bIsScrollBarNeeded) : 0;
|
|
}
|
|
|
|
bool FDetailsDisplayManager::ShowEmptyCategoryIfRootUObjectHasNoPropertyData(UObject* InNode) const
|
|
{
|
|
return false;
|
|
}
|
|
|
|
bool FDetailsDisplayManager::AddEmptyCategoryToDetailLayoutIfNeeded(TSharedRef<FComplexPropertyNode> Node,
|
|
TSharedRef<FDetailLayoutBuilderImpl> DetailLayoutBuilder)
|
|
{
|
|
if (FObjectPropertyNode* ObjectPropertyNode = Node->AsObjectNode())
|
|
{
|
|
/* a pointer to the UObject for this Category, if we have one */
|
|
UObject* UObjectForCategory = nullptr;
|
|
|
|
const bool bPropertyNodeHasOneUObject = ObjectPropertyNode && ObjectPropertyNode->GetNumObjects() == 1;
|
|
if ( bPropertyNodeHasOneUObject )
|
|
{
|
|
UObjectForCategory = ObjectPropertyNode->GetUObject(0);
|
|
}
|
|
|
|
if (UObjectForCategory &&
|
|
/* we're supposed to show an empty category for this particular object if it has no UProperties */
|
|
ShowEmptyCategoryIfRootUObjectHasNoPropertyData(UObjectForCategory) &&
|
|
UObjectForCategory->GetClass())
|
|
{
|
|
/* Base empty category display text off the display text of the UObject class */
|
|
const FText UObjectClassNameDisplayText = UObjectForCategory->GetClass()->GetDisplayNameText();
|
|
|
|
/* Base empty category name off the name of the UObject class */
|
|
const FName UObjectClassName = UObjectForCategory->GetClass()->GetFName();
|
|
|
|
FDetailCategoryImpl& EmptyCategory = DetailLayoutBuilder->DefaultCategory( UObjectClassName );
|
|
EmptyCategory.SetDisplayName(UObjectClassName, UObjectClassNameDisplayText);
|
|
|
|
/* property node for now will always show empty ~ eventually we will want to add hooks to optionally show
|
|
* a "No properties here" or "This empty component does XYZ" string of some kind that can be overridden
|
|
* based on object type and usage */
|
|
EmptyCategory.AddPropertyNode(Node, UObjectClassName);
|
|
EmptyCategory.SetIsEmpty(true);
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool FDetailsDisplayManager::GetIsScrollBarNeeded() const
|
|
{
|
|
return bIsScrollBarNeeded;
|
|
}
|
|
|
|
void FDetailsDisplayManager::SetIsScrollBarNeeded(bool bInIsScrollBarNeeded)
|
|
{
|
|
bIsScrollBarNeeded = bInIsScrollBarNeeded;
|
|
}
|
|
|
|
bool FDetailsDisplayManager::GetForceShowSubObjectEditor()
|
|
{
|
|
return CVarForceShowComponentEditor.GetValueOnAnyThread();
|
|
}
|
|
|