// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "Containers/Array.h" #include "Containers/UnrealString.h" #include "Delegates/Delegate.h" #include "Internationalization/Text.h" #include "Misc/PackageName.h" #include "Misc/Paths.h" #include "Templates/SharedPointer.h" #include "Templates/TypeHash.h" #include "Types/SlateEnums.h" #include "Widgets/DeclarativeSyntaxSupport.h" #include "Widgets/SCompoundWidget.h" class ITableRow; class STableViewBase; class SWidget; template class SListView; template< typename ItemType > class TTextFilter; ///////////////////////////////////////////////////// // FLevelPackageItem struct FLevelPackageItem { FString DisplayName; FString LongPackageName; }; typedef TTextFilter&> LevelPackageTextFilter; typedef SListView> SLevelPackageListView; ///////////////////////////////////////////////////// // SPropertyEditorLevelPackage // // Widget which plugs in to a details panel to edit FNames properties which represent a level package name // Looks kinda similar to a SPropertyEditorAsset, should be replaced with it when ContentBrowser will treat ULevel as an asset // class SPropertyEditorLevelPackage : public SCompoundWidget { public: DECLARE_DELEGATE_RetVal_OneParam(bool, FOnShouldFilterPackage, const FString&); DECLARE_DELEGATE_OneParam(FOnPackagePicked, const FString&); SLATE_BEGIN_ARGS( SPropertyEditorLevelPackage ) : _RootPath(FPackageName::FilenameToLongPackageName(FPaths::ProjectContentDir())) , _SortAlphabetically(false) {} /** Root folder path for gathering level packages */ SLATE_ARGUMENT( FString, RootPath ) /** Whether package list should be aaranged alphabetically */ SLATE_ARGUMENT( bool, SortAlphabetically ) /** Called to check if an item should be filtered out by external code */ SLATE_EVENT(FOnShouldFilterPackage, OnShouldFilterPackage) SLATE_END_ARGS() void Construct(const FArguments& InArgs, const TSharedPtr& InPropertyHandle); /**@return FLevelPackageItem initialized from a given PackageName */ FLevelPackageItem PackageNameToItem(const FString& PackageName) const; private: /**@return Display text for a property value */ FText GetDisplayPackageName() const; /**@return Picker widget with content to display combo box drop menu */ TSharedRef GetMenuContent(); /** Creates picker widget */ TSharedRef MakePickerWidget(); /** Creates a row for a piker widget */ TSharedRef MakeListRowWidget(TSharedPtr InPackageName, const TSharedRef& OwnerTable) const; /** Handles on OnSelectionChanged event from a picker widget */ void OnSelectionChanged(const TSharedPtr Item, ESelectInfo::Type SelectInfo); /** Populates internal array with levels packages found on disk under RootPath */ void PopulatePackages(); /** Populates internal array with packages previously found on disk according to current filter settings */ void PopulateFilteredPackages(); /** Transforms FLevelPackageItem to a search terms for a text filter */ void TransformPackageItemToString(const TSharedPtr& Item, TArray& OutSearchStrings) const; /** Handles text filter changes */ void OnTextFilterChanged(); /** Handles text filter changes */ TSharedPtr FindPackageItem(const FString& PackageName); /** @return Current property value as a string */ FString GetPropertyValue() const; private: /** */ FString RootPath; /** */ bool bSortAlphabetically; /** */ FOnShouldFilterPackage OnShouldFilterPackage; /** */ TSharedPtr PropertyHandle; /** */ TSharedPtr PropertyMainWidget; /** */ TWeakPtr PickerListWidget; /** */ TArray> LevelPackages; /** */ TArray> FilteredLevelPackages; /** */ TSharedPtr SearchBoxLevelPackageFilter; };