Files
UnrealEngineUWP/Engine/Source/Editor/ContentBrowser/Private/ContentBrowserModule.cpp
aurel cordonnier 50944fd712 Merge UE5/RES @ 16162155 to UE5/Main
This represents UE4/Main @ 16130047 and Dev-PerfTest @ 16126156

[CL 16163576 by aurel cordonnier in ue5-main branch]
2021-04-29 19:32:06 -04:00

74 lines
2.4 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "ContentBrowserModule.h"
#include "ContentBrowserLog.h"
#include "ContentBrowserSingleton.h"
#include "IContentBrowserDataModule.h"
#include "MRUFavoritesList.h"
#include "Settings/ContentBrowserSettings.h"
#include "ContentBrowserDataSubsystem.h"
IMPLEMENT_MODULE( FContentBrowserModule, ContentBrowser );
DEFINE_LOG_CATEGORY(LogContentBrowser);
const FName FContentBrowserModule::NumberOfRecentAssetsName(TEXT("NumObjectsInRecentList"));
void FContentBrowserModule::StartupModule()
{
// Ensure the data module is loaded
IContentBrowserDataModule::Get();
ContentBrowserSingleton = new FContentBrowserSingleton();
RecentlyOpenedAssets = MakeUnique<FMainMRUFavoritesList>(TEXT("ContentBrowserRecent"), GetDefault<UContentBrowserSettings>()->NumObjectsInRecentList);
RecentlyOpenedAssets->ReadFromINI();
UContentBrowserSettings::OnSettingChanged().AddRaw(this, &FContentBrowserModule::ContentBrowserSettingChanged);
}
void FContentBrowserModule::ShutdownModule()
{
if ( ContentBrowserSingleton )
{
delete ContentBrowserSingleton;
ContentBrowserSingleton = NULL;
}
UContentBrowserSettings::OnSettingChanged().RemoveAll(this);
RecentlyOpenedAssets.Reset();
}
IContentBrowserSingleton& FContentBrowserModule::Get() const
{
check(ContentBrowserSingleton);
return *ContentBrowserSingleton;
}
FDelegateHandle FContentBrowserModule::AddAssetViewExtraStateGenerator(const FAssetViewExtraStateGenerator& Generator)
{
AssetViewExtraStateGenerators.Add(Generator);
return Generator.Handle;
}
void FContentBrowserModule::RemoveAssetViewExtraStateGenerator(const FDelegateHandle& GeneratorHandle)
{
AssetViewExtraStateGenerators.RemoveAll([&GeneratorHandle](const FAssetViewExtraStateGenerator& Generator) { return Generator.Handle == GeneratorHandle; });
}
void FContentBrowserModule::ContentBrowserSettingChanged(FName InName)
{
if (UContentBrowserDataSubsystem* ContentBrowserData = IContentBrowserDataModule::Get().GetSubsystem())
{
ContentBrowserData->RefreshVirtualPathTreeIfNeeded();
}
// Resize the recently opened asset list
if (InName == NumberOfRecentAssetsName)
{
RecentlyOpenedAssets->WriteToINI();
RecentlyOpenedAssets = MakeUnique<FMainMRUFavoritesList>(TEXT("ContentBrowserRecent"), GetDefault<UContentBrowserSettings>()->NumObjectsInRecentList);
RecentlyOpenedAssets->ReadFromINI();
}
OnContentBrowserSettingChanged.Broadcast(InName);
}