2019-12-26 15:33:43 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
#include "SPropertyEditorLevelPackage.h"
|
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340)
#lockdown Nick.Penwarden
#rb none
==========================
MAJOR FEATURES + CHANGES
==========================
Change 3209340 on 2016/11/23 by Ben.Marsh
Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h.
Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms.
* Every header now includes everything it needs to compile.
* There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first.
* There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h.
* Every .cpp file includes its matching .h file first.
* This helps validate that each header is including everything it needs to compile.
* No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more.
* You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there.
* There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible.
* No engine code explicitly includes a precompiled header any more.
* We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies.
* PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files.
Tool used to generate this transform is at Engine\Source\Programs\IncludeTool.
[CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
|
|
|
#include "Misc/TextFilter.h"
|
|
|
|
|
#include "GenericPlatform/GenericPlatformFile.h"
|
2020-05-06 17:58:18 -04:00
|
|
|
#include "HAL/PlatformFileManager.h"
|
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340)
#lockdown Nick.Penwarden
#rb none
==========================
MAJOR FEATURES + CHANGES
==========================
Change 3209340 on 2016/11/23 by Ben.Marsh
Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h.
Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms.
* Every header now includes everything it needs to compile.
* There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first.
* There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h.
* Every .cpp file includes its matching .h file first.
* This helps validate that each header is including everything it needs to compile.
* No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more.
* You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there.
* There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible.
* No engine code explicitly includes a precompiled header any more.
* We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies.
* PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files.
Tool used to generate this transform is at Engine\Source\Programs\IncludeTool.
[CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
|
|
|
#include "Widgets/Views/SListView.h"
|
|
|
|
|
#include "DetailLayoutBuilder.h"
|
|
|
|
|
#include "Widgets/Input/SSearchBox.h"
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
#define LOCTEXT_NAMESPACE "WorldBrowser"
|
|
|
|
|
|
|
|
|
|
void SPropertyEditorLevelPackage::Construct(const FArguments& InArgs, const TSharedPtr<IPropertyHandle>& InPropertyHandle)
|
|
|
|
|
{
|
|
|
|
|
PropertyHandle = InPropertyHandle;
|
|
|
|
|
RootPath = InArgs._RootPath;
|
|
|
|
|
bSortAlphabetically = InArgs._SortAlphabetically;
|
|
|
|
|
OnShouldFilterPackage = InArgs._OnShouldFilterPackage;
|
|
|
|
|
|
|
|
|
|
// Setup packages text filter
|
|
|
|
|
SearchBoxLevelPackageFilter = MakeShareable(
|
|
|
|
|
new LevelPackageTextFilter(LevelPackageTextFilter::FItemToStringArray::CreateSP(this, &SPropertyEditorLevelPackage::TransformPackageItemToString))
|
|
|
|
|
);
|
|
|
|
|
SearchBoxLevelPackageFilter->OnChanged().AddSP(this, &SPropertyEditorLevelPackage::OnTextFilterChanged);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ChildSlot
|
|
|
|
|
[
|
|
|
|
|
SAssignNew(PropertyMainWidget, SComboButton)
|
2022-05-09 13:12:28 -04:00
|
|
|
.ButtonStyle(FAppStyle::Get(), "PropertyEditor.AssetComboStyle")
|
|
|
|
|
.ForegroundColor(FAppStyle::GetColor("PropertyEditor.AssetName.ColorAndOpacity"))
|
2014-03-14 14:13:41 -04:00
|
|
|
.OnGetMenuContent( this, &SPropertyEditorLevelPackage::GetMenuContent )
|
|
|
|
|
.ContentPadding(2.0f)
|
|
|
|
|
.ButtonContent()
|
|
|
|
|
[
|
|
|
|
|
// Show the name of the asset or actor
|
|
|
|
|
SNew(STextBlock)
|
2022-05-09 13:12:28 -04:00
|
|
|
.TextStyle(FAppStyle::Get(), "PropertyEditor.AssetClass")
|
2014-03-14 14:13:41 -04:00
|
|
|
.Font(IDetailLayoutBuilder::GetDetailFont())
|
|
|
|
|
.Text(this, &SPropertyEditorLevelPackage::GetDisplayPackageName)
|
|
|
|
|
]
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FText SPropertyEditorLevelPackage::GetDisplayPackageName() const
|
|
|
|
|
{
|
|
|
|
|
FName PropertyValue;
|
|
|
|
|
if (PropertyHandle->GetValue(PropertyValue) == FPropertyAccess::MultipleValues)
|
|
|
|
|
{
|
|
|
|
|
return LOCTEXT("MultipleValues", "Multiple Values");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (PropertyValue != NAME_None)
|
|
|
|
|
{
|
|
|
|
|
FString LongPackageName = PropertyValue.ToString();
|
|
|
|
|
if (LongPackageName.StartsWith(RootPath))
|
|
|
|
|
{
|
2019-11-19 13:27:07 -05:00
|
|
|
LongPackageName.RightChopInline(RootPath.Len()-1, false); // do not chop front '/' from display name
|
2014-03-14 14:13:41 -04:00
|
|
|
return FText::FromString(LongPackageName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FText::FromName(PropertyValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FString SPropertyEditorLevelPackage::GetPropertyValue() const
|
|
|
|
|
{
|
|
|
|
|
FName PropertyValue; PropertyHandle->GetValue(PropertyValue);
|
|
|
|
|
if (PropertyValue != NAME_None)
|
|
|
|
|
{
|
|
|
|
|
return PropertyValue.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SPropertyEditorLevelPackage::OnSelectionChanged(const TSharedPtr<FLevelPackageItem> Item, ESelectInfo::Type SelectInfo)
|
|
|
|
|
{
|
|
|
|
|
if (Item.IsValid())
|
|
|
|
|
{
|
|
|
|
|
if (GetPropertyValue() == Item->LongPackageName)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PropertyHandle->SetValue(FName(*Item->LongPackageName));
|
|
|
|
|
PropertyMainWidget->SetIsOpen(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TSharedRef<SWidget> SPropertyEditorLevelPackage::GetMenuContent()
|
|
|
|
|
{
|
|
|
|
|
PopulatePackages();
|
|
|
|
|
return MakePickerWidget();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TSharedRef<SWidget> SPropertyEditorLevelPackage::MakePickerWidget()
|
|
|
|
|
{
|
|
|
|
|
TSharedPtr<SLevelPackageListView> PikerListView;
|
|
|
|
|
TSharedRef<SWidget> PikerWidget =
|
|
|
|
|
|
|
|
|
|
SNew(SBox)
|
|
|
|
|
.WidthOverride(300)
|
|
|
|
|
.HeightOverride(300)
|
|
|
|
|
[
|
|
|
|
|
SNew(SVerticalBox)
|
|
|
|
|
|
|
|
|
|
+SVerticalBox::Slot()
|
|
|
|
|
.AutoHeight()
|
|
|
|
|
[
|
|
|
|
|
SNew( SSearchBox )
|
2015-01-07 09:52:40 -05:00
|
|
|
.ToolTipText(LOCTEXT("LevelPackage_FilterTooltip", "Type here to search levels"))
|
2014-03-14 14:13:41 -04:00
|
|
|
.HintText(LOCTEXT( "LevelPackage_FilterHint", "Search Levels" ))
|
|
|
|
|
.OnTextChanged(SearchBoxLevelPackageFilter.Get(), &LevelPackageTextFilter::SetRawFilterText)
|
|
|
|
|
]
|
|
|
|
|
+SVerticalBox::Slot()
|
|
|
|
|
.FillHeight(1.f)
|
|
|
|
|
[
|
|
|
|
|
SAssignNew(PikerListView, SListView<TSharedPtr<FLevelPackageItem>>)
|
|
|
|
|
.ListItemsSource(&FilteredLevelPackages)
|
|
|
|
|
.SelectionMode(ESelectionMode::Single)
|
|
|
|
|
.OnGenerateRow(this, &SPropertyEditorLevelPackage::MakeListRowWidget)
|
|
|
|
|
.OnSelectionChanged(this, &SPropertyEditorLevelPackage::OnSelectionChanged)
|
|
|
|
|
]
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Set current property value as selected in list widget
|
|
|
|
|
TSharedPtr<FLevelPackageItem> CurrentItem = FindPackageItem(GetPropertyValue());
|
|
|
|
|
if (CurrentItem.IsValid())
|
|
|
|
|
{
|
|
|
|
|
PikerListView->SetSelection(CurrentItem);
|
|
|
|
|
PikerListView->RequestScrollIntoView(CurrentItem);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// store a weak pointer to a ListView to be able refresh it on filter changes
|
|
|
|
|
PickerListWidget = PikerListView;
|
|
|
|
|
|
|
|
|
|
return PikerWidget;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TSharedRef<ITableRow> SPropertyEditorLevelPackage::MakeListRowWidget(TSharedPtr<FLevelPackageItem> InPackageItem,
|
|
|
|
|
const TSharedRef<STableViewBase>& OwnerTable) const
|
|
|
|
|
{
|
|
|
|
|
return SNew(STableRow<TSharedPtr<FString>>, OwnerTable)
|
|
|
|
|
[
|
|
|
|
|
SNew(SBorder)
|
|
|
|
|
.Padding(5)
|
2022-05-09 13:12:28 -04:00
|
|
|
.BorderImage(FAppStyle::GetBrush("NoBrush"))
|
2014-03-14 14:13:41 -04:00
|
|
|
[
|
|
|
|
|
SNew(STextBlock)
|
2015-01-07 09:52:40 -05:00
|
|
|
.ToolTipText(FText::FromString(InPackageItem->LongPackageName))
|
|
|
|
|
.Text(FText::FromString(InPackageItem->DisplayName))
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
]
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SPropertyEditorLevelPackage::OnTextFilterChanged()
|
|
|
|
|
{
|
|
|
|
|
PopulateFilteredPackages();
|
|
|
|
|
|
|
|
|
|
// Refresh picker list
|
|
|
|
|
auto Picker = PickerListWidget.Pin();
|
|
|
|
|
if (Picker.IsValid())
|
|
|
|
|
{
|
|
|
|
|
Picker->RequestListRefresh();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FLevelPackageItem SPropertyEditorLevelPackage::PackageNameToItem(const FString& PackageName) const
|
|
|
|
|
{
|
|
|
|
|
FLevelPackageItem Item;
|
|
|
|
|
|
|
|
|
|
Item.LongPackageName = PackageName;
|
|
|
|
|
|
|
|
|
|
// DisplayString for a package should be just pacakage name without path
|
|
|
|
|
Item.DisplayName = FPackageName::GetShortName(Item.LongPackageName);
|
|
|
|
|
|
|
|
|
|
return Item;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TSharedPtr<FLevelPackageItem> SPropertyEditorLevelPackage::FindPackageItem(const FString& PackageName)
|
|
|
|
|
{
|
|
|
|
|
for (auto It = LevelPackages.CreateConstIterator(); It; ++It)
|
|
|
|
|
{
|
|
|
|
|
if ((*It)->LongPackageName == PackageName)
|
|
|
|
|
{
|
|
|
|
|
return (*It);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TSharedPtr<FLevelPackageItem>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SPropertyEditorLevelPackage::PopulatePackages()
|
|
|
|
|
{
|
|
|
|
|
struct FWorldRootVisitor
|
|
|
|
|
: public IPlatformFile::FDirectoryVisitor
|
|
|
|
|
{
|
|
|
|
|
const SPropertyEditorLevelPackage& Owner;
|
|
|
|
|
TArray<TSharedPtr<FLevelPackageItem>>& Output;
|
|
|
|
|
|
|
|
|
|
FWorldRootVisitor(const SPropertyEditorLevelPackage& InOwner, TArray<TSharedPtr<FLevelPackageItem>>& InOutput)
|
|
|
|
|
: Owner(InOwner)
|
|
|
|
|
, Output(InOutput)
|
|
|
|
|
{}
|
|
|
|
|
|
2014-06-13 06:14:46 -04:00
|
|
|
virtual bool Visit(const TCHAR* FilenameOrDirectory, bool bIsDirectory) override
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
FString FullPath = FilenameOrDirectory;
|
|
|
|
|
|
|
|
|
|
// for all packages
|
|
|
|
|
if (!bIsDirectory && FPaths::GetExtension(FullPath, true) == FPackageName::GetMapPackageExtension())
|
|
|
|
|
{
|
|
|
|
|
FLevelPackageItem Item = Owner.PackageNameToItem(FPackageName::FilenameToLongPackageName(FilenameOrDirectory));
|
|
|
|
|
Output.Add(MakeShareable(new FLevelPackageItem(Item)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
LevelPackages.Empty();
|
|
|
|
|
FWorldRootVisitor Visitor(*this, LevelPackages);
|
|
|
|
|
FPlatformFileManager::Get().GetPlatformFile().IterateDirectoryRecursively(*FPackageName::LongPackageNameToFilename(RootPath), Visitor);
|
|
|
|
|
|
|
|
|
|
// populate items array according to current filter settings
|
|
|
|
|
PopulateFilteredPackages();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SPropertyEditorLevelPackage::PopulateFilteredPackages()
|
|
|
|
|
{
|
|
|
|
|
FilteredLevelPackages.Empty(LevelPackages.Num());
|
|
|
|
|
|
|
|
|
|
for (auto It = LevelPackages.CreateConstIterator(); It; ++It)
|
|
|
|
|
{
|
|
|
|
|
if (!OnShouldFilterPackage.IsBound() || !OnShouldFilterPackage.Execute((*It)->LongPackageName))
|
|
|
|
|
{
|
|
|
|
|
if (SearchBoxLevelPackageFilter->PassesFilter((*It)))
|
|
|
|
|
{
|
|
|
|
|
FilteredLevelPackages.Add((*It));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Sort filtered packages if client wants to
|
|
|
|
|
if (bSortAlphabetically)
|
|
|
|
|
{
|
|
|
|
|
struct FSortPredicate
|
|
|
|
|
{
|
|
|
|
|
bool operator()(const TSharedPtr<FLevelPackageItem>& A, const TSharedPtr<FLevelPackageItem>& B) const
|
|
|
|
|
{
|
|
|
|
|
return A->DisplayName < B->DisplayName;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
FilteredLevelPackages.Sort(FSortPredicate());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SPropertyEditorLevelPackage::TransformPackageItemToString(const TSharedPtr<FLevelPackageItem>& Item, TArray<FString>& OutSearchStrings) const
|
|
|
|
|
{
|
|
|
|
|
if (Item.IsValid())
|
|
|
|
|
{
|
|
|
|
|
OutSearchStrings.Add(Item->DisplayName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#undef LOCTEXT_NAMESPACE
|