Files
UnrealEngineUWP/Engine/Source/Editor/DetailCustomizations/Private/LandscapeProxyUIDetails.cpp
ryan durand 627baf970a Updating copyright for Engine Editor.
#rnx
#rb none


#ROBOMERGE-SOURCE: CL 10869241 via CL 10869527 via CL 10869904
#ROBOMERGE-BOT: (v613-10869866)

[CL 10870586 by ryan durand in Main branch]
2019-12-26 15:33:43 -05:00

138 lines
4.4 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "LandscapeProxyUIDetails.h"
#include "Widgets/DeclarativeSyntaxSupport.h"
#include "PropertyHandle.h"
#include "DetailLayoutBuilder.h"
#include "Runtime/Landscape/Classes/Landscape.h"
#include "Runtime/Landscape/Classes/LandscapeInfo.h"
#include "Settings/EditorExperimentalSettings.h"
#include "DetailCategoryBuilder.h"
#include "DetailWidgetRow.h"
#include "Widgets/Input/SButton.h"
#include "Widgets/Text/STextBlock.h"
#include "Widgets/Input/SCheckBox.h"
#include "Misc/MessageDialog.h"
#include "Editor.h"
#define LOCTEXT_NAMESPACE "FLandscapeProxyUIDetails"
FLandscapeProxyUIDetails::FLandscapeProxyUIDetails()
{
}
TSharedRef<IDetailCustomization> FLandscapeProxyUIDetails::MakeInstance()
{
return MakeShareable( new FLandscapeProxyUIDetails);
}
void FLandscapeProxyUIDetails::CustomizeDetails( IDetailLayoutBuilder& DetailBuilder )
{
TArray<TWeakObjectPtr<UObject>> EditingObjects;
DetailBuilder.GetObjectsBeingCustomized(EditingObjects);
auto GenerateTextWidget = [](const FText& InText, bool bInBold = false) -> TSharedRef<SWidget>
{
return SNew(STextBlock)
.Font(bInBold? IDetailLayoutBuilder::GetDetailFontBold() : IDetailLayoutBuilder::GetDetailFont())
.Text(InText);
};
if (EditingObjects.Num() == 1)
{
if (ALandscapeProxy* Proxy = Cast<ALandscapeProxy>(EditingObjects[0]))
{
if (ULandscapeInfo* LandscapeInfo = Proxy->GetLandscapeInfo())
{
IDetailCategoryBuilder& CategoryBuilder = DetailBuilder.EditCategory("Information", FText::GetEmpty(), ECategoryPriority::Important);
FText RowDisplayText = LOCTEXT("LandscapeComponentResolution", "Component Resolution (Verts)");
CategoryBuilder.AddCustomRow(RowDisplayText)
.NameContent()
[
GenerateTextWidget(RowDisplayText)
]
.ValueContent()
[
GenerateTextWidget(FText::Format(LOCTEXT("LandscapeComponentResolutionValue", "{0} x {0}"), Proxy->ComponentSizeQuads+1), true) // Verts
];
RowDisplayText = LOCTEXT("LandscapeComponentCount", "Component Count");
CategoryBuilder.AddCustomRow(RowDisplayText)
.NameContent()
[
GenerateTextWidget(RowDisplayText)
]
.ValueContent()
[
GenerateTextWidget(FText::Format(LOCTEXT("LandscapeComponentCountValue", "{0}"), Proxy->LandscapeComponents.Num()), true)
];
RowDisplayText = LOCTEXT("LandscapeComponentSubsections", "Component Subsections");
CategoryBuilder.AddCustomRow(RowDisplayText)
.NameContent()
[
GenerateTextWidget(RowDisplayText)
]
.ValueContent()
[
GenerateTextWidget(FText::Format(LOCTEXT("LandscapeComponentSubSectionsValue", "{0} x {0}"), Proxy->NumSubsections), true)
];
FIntRect Rect = Proxy->GetBoundingRect();
FIntPoint Size = Rect.Size();
RowDisplayText = LOCTEXT("LandscapeResolution", "Resolution (Verts)");
CategoryBuilder.AddCustomRow(RowDisplayText)
.NameContent()
[
GenerateTextWidget(RowDisplayText)
]
.ValueContent()
[
GenerateTextWidget(FText::Format(LOCTEXT("LandscapeResolutionValue", "{0} x {1}"), Size.X+1, Size.Y+1), true)
];
int32 LandscapeCount = LandscapeInfo->Proxies.Num() + (LandscapeInfo->LandscapeActor.Get() ? 1 : 0);
RowDisplayText = LOCTEXT("LandscapeCount", "Landscape Count");
CategoryBuilder.AddCustomRow(RowDisplayText)
.NameContent()
[
GenerateTextWidget(RowDisplayText)
]
.ValueContent()
[
GenerateTextWidget(FText::Format(LOCTEXT("LandscapeCountValue", "{0}"), LandscapeCount), true)
];
int32 TotalComponentCount = LandscapeInfo->XYtoComponentMap.Num();
RowDisplayText = LOCTEXT("TotalLandscapeComponentCount", "Total Component Count");
CategoryBuilder.AddCustomRow(RowDisplayText)
.NameContent()
[
GenerateTextWidget(RowDisplayText)
]
.ValueContent()
[
GenerateTextWidget(FText::Format(LOCTEXT("TotalLandscapeComponentCountValue", "{0}"), TotalComponentCount), true)
];
LandscapeInfo->GetLandscapeExtent(Rect.Min.X, Rect.Min.Y, Rect.Max.X, Rect.Max.Y);
Size = Rect.Size();
RowDisplayText = LOCTEXT("LandscapeOverallResolution", "Overall Resolution (Verts)");
CategoryBuilder.AddCustomRow(RowDisplayText)
.NameContent()
[
GenerateTextWidget(RowDisplayText)
]
.ValueContent()
[
GenerateTextWidget(FText::Format(LOCTEXT("LandscapeOveralResolutionValue", "{0} x {1}"), Size.X + 1, Size.Y + 1), true)
];
}
}
}
}
#undef LOCTEXT_NAMESPACE