// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "CoreMinimal.h" #include "AssetRegistry/AssetData.h" #include "Modules/ModuleInterface.h" #include "ContentBrowserDelegates.h" class IContentBrowserSingleton; struct FARFilter; class FMainMRUFavoritesList; class FContentBrowserPluginFilter; /** Extra state generator that adds an icon and a corresponding legend entry on an asset. */ class FAssetViewExtraStateGenerator { public: FAssetViewExtraStateGenerator(FOnGenerateAssetViewExtraStateIndicators InIconGenerator, FOnGenerateAssetViewExtraStateIndicators InToolTipGenerator) : IconGenerator(MoveTemp(InIconGenerator)) , ToolTipGenerator(MoveTemp(InToolTipGenerator)) , Handle(FDelegateHandle::GenerateNewHandle) {} /** Delegate called to generate an extra icon on an asset view. */ FOnGenerateAssetViewExtraStateIndicators IconGenerator; /** Delegate called to generate an extra tooltip on an asset view. */ FOnGenerateAssetViewExtraStateIndicators ToolTipGenerator; private: /** The handle to this extra state generator. */ FDelegateHandle Handle; friend class FContentBrowserModule; }; /** * Content browser module */ class FContentBrowserModule : public IModuleInterface { public: /** */ DECLARE_MULTICAST_DELEGATE_TwoParams( FOnFilterChanged, const FARFilter& /*NewFilter*/, bool /*bIsPrimaryBrowser*/ ); /** */ DECLARE_MULTICAST_DELEGATE_TwoParams( FOnSearchBoxChanged, const FText& /*InSearchText*/, bool /*bIsPrimaryBrowser*/ ); /** */ DECLARE_MULTICAST_DELEGATE_TwoParams( FOnAssetSelectionChanged, const TArray& /*NewSelectedAssets*/, bool /*bIsPrimaryBrowser*/ ); /** */ DECLARE_MULTICAST_DELEGATE_OneParam( FOnSourcesViewChanged, bool /*bExpanded*/ ); /** */ DECLARE_MULTICAST_DELEGATE_OneParam( FOnAssetPathChanged, const FString& /*NewPath*/ ); /** */ DECLARE_DELEGATE_OneParam( FAddPathViewPluginFilters, TArray>& /*Filters*/ ); /** */ DECLARE_MULTICAST_DELEGATE_OneParam( FOnContentBrowserSettingChanged, FName /*PropertyName*/); /** */ DECLARE_DELEGATE_OneParam( FDefaultSelectedPathsDelegate, TArray& /*VirtualPaths*/ ); /** */ DECLARE_DELEGATE_OneParam( FDefaultPathsToExpandDelegate, TArray& /*VirtualPaths*/ ); /** * Called right after the plugin DLL has been loaded and the plugin object has been created */ virtual void StartupModule(); /** * Called before the plugin is unloaded, right before the plugin object is destroyed. */ virtual void ShutdownModule(); /** Gets the content browser singleton */ virtual IContentBrowserSingleton& Get() const; /** * Add a generator to add extra state functionality to the content browser's assets. * @param Generator the delegates that add functionality. * @return FDelegateHandle the handle to the extra state generator. */ virtual FDelegateHandle AddAssetViewExtraStateGenerator(const FAssetViewExtraStateGenerator& Generator); /** * Remove an asset view extra state generator. * @param GeneratorHandle the extra state generator's handle. */ virtual void RemoveAssetViewExtraStateGenerator(const FDelegateHandle& GeneratorHandle); /** Delegates to be called to extend the content browser menus */ virtual TArray& GetAllAssetContextMenuExtenders() {return AssetContextMenuExtenders;} virtual TArray& GetAllPathViewContextMenuExtenders() {return PathViewContextMenuExtenders;} virtual TArray& GetAllCollectionListContextMenuExtenders() {return CollectionListContextMenuExtenders;} virtual TArray& GetAllCollectionViewContextMenuExtenders() {return CollectionViewContextMenuExtenders;} virtual TArray& GetAllAssetViewContextMenuExtenders() {return AssetViewContextMenuExtenders;} virtual TArray& GetAllAssetViewViewMenuExtenders() {return AssetViewViewMenuExtenders;} /** Delegates to call to extend the command/keybinds for content browser */ virtual TArray& GetAllContentBrowserCommandExtenders() { return ContentBrowserCommandExtenders; } /** Delegates to be called to add extra state indicators on the asset view */ virtual const TArray& GetAllAssetViewExtraStateGenerators() { return AssetViewExtraStateGenerators; } /** Delegates to be called to extend the drag-and-drop support of the asset view */ virtual TArray& GetAssetViewDragAndDropExtenders() { return AssetViewDragAndDropExtenders; } /** Delegates to be called to extend list of content browser Plugin Filters*/ virtual TArray& GetAddPathViewPluginFilters() { return PathViewPluginFilters; } /** Delegate accessors */ FOnFilterChanged& GetOnFilterChanged() { return OnFilterChanged; } FOnSearchBoxChanged& GetOnSearchBoxChanged() { return OnSearchBoxChanged; } FOnAssetSelectionChanged& GetOnAssetSelectionChanged() { return OnAssetSelectionChanged; } FOnSourcesViewChanged& GetOnSourcesViewChanged() { return OnSourcesViewChanged; } FOnAssetPathChanged& GetOnAssetPathChanged() { return OnAssetPathChanged; } FOnContentBrowserSettingChanged& GetOnContentBrowserSettingChanged() { return OnContentBrowserSettingChanged; } /** Override list of paths to select by default */ FDefaultSelectedPathsDelegate& GetDefaultSelectedPathsDelegate() { return DefaultSelectedPathsDelegate; } /** Override list of paths to expand by default */ FDefaultPathsToExpandDelegate& GetDefaultPathsToExpandDelegate() { return DefaultPathsToExpandDelegate; } FMainMRUFavoritesList* GetRecentlyOpenedAssets() const { return RecentlyOpenedAssets.Get(); }; static const FName NumberOfRecentAssetsName; void AddDynamicTagAssetClass(const FName& InName) { AssetClassesRequiringDynamicTags.AddUnique(InName); } void RemoveDynamicTagAssetClass(const FName& InName) { AssetClassesRequiringDynamicTags.Remove(InName); } bool IsDynamicTagAssetClass(const FName& InName) { return AssetClassesRequiringDynamicTags.Contains(InName); } private: /** Handle changes to content browser settings */ void ContentBrowserSettingChanged(FName InName); /** List of asset classes whose tags are dynamic and therefore we should union all asset's tags rather than grabbing the first available. */ TArray AssetClassesRequiringDynamicTags; private: IContentBrowserSingleton* ContentBrowserSingleton; TSharedPtr ContentBrowserSpawner; /** All extender delegates for the content browser menus */ TArray AssetContextMenuExtenders; TArray PathViewContextMenuExtenders; TArray CollectionListContextMenuExtenders; TArray CollectionViewContextMenuExtenders; TArray AssetViewContextMenuExtenders; TArray AssetViewViewMenuExtenders; TArray ContentBrowserCommandExtenders; /** All delegates generating extra state indicators */ TArray AssetViewExtraStateGenerators; /** All extender delegates for the drag-and-drop support of the asset view */ TArray AssetViewDragAndDropExtenders; /** All delegates that extend available path view plugin filters */ TArray PathViewPluginFilters; TUniquePtr RecentlyOpenedAssets; FOnFilterChanged OnFilterChanged; FOnSearchBoxChanged OnSearchBoxChanged; FOnAssetSelectionChanged OnAssetSelectionChanged; FOnSourcesViewChanged OnSourcesViewChanged; FOnAssetPathChanged OnAssetPathChanged; FOnContentBrowserSettingChanged OnContentBrowserSettingChanged; FDefaultSelectedPathsDelegate DefaultSelectedPathsDelegate; FDefaultPathsToExpandDelegate DefaultPathsToExpandDelegate; };