mirror of
https://github.com/Ed94/Cog.git
synced 2026-08-07 16:18:50 +00:00
CogEngine: Levels window: Remove the loading of assets by default.
This commit is contained in:
@@ -17,22 +17,16 @@ void FCogEngineWindow_Levels::Initialize()
|
|||||||
|
|
||||||
bHasMenu = true;
|
bHasMenu = true;
|
||||||
Config = GetConfig<UCogEngineWindowConfig_LevelLoader>();
|
Config = GetConfig<UCogEngineWindowConfig_LevelLoader>();
|
||||||
GetAllLevels(UnsortedLevels);
|
|
||||||
|
|
||||||
RefreshSorting();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
void FCogEngineWindow_Levels::GetAllLevels(TArray<FAssetData>& OutLevels)
|
void FCogEngineWindow_Levels::GetAllLevels(TArray<FAssetData>& OutLevels)
|
||||||
{
|
{
|
||||||
const FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>("AssetRegistry");
|
const FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>("AssetRegistry");
|
||||||
IAssetRegistry& AssetRegistry = AssetRegistryModule.Get();
|
const IAssetRegistry& AssetRegistry = AssetRegistryModule.Get();
|
||||||
|
|
||||||
AssetRegistry.SearchAllAssets(true);
|
|
||||||
|
|
||||||
FARFilter AssetFilter;
|
FARFilter AssetFilter;
|
||||||
AssetFilter.ClassPaths.Add(UWorld::StaticClass()->GetClassPathName());
|
AssetFilter.ClassPaths.Add(UWorld::StaticClass()->GetClassPathName());
|
||||||
AssetFilter.bRecursiveClasses = true;
|
|
||||||
|
|
||||||
AssetRegistry.GetAssets(AssetFilter, OutLevels);
|
AssetRegistry.GetAssets(AssetFilter, OutLevels);
|
||||||
|
|
||||||
@@ -48,11 +42,11 @@ void FCogEngineWindow_Levels::RefreshSorting()
|
|||||||
{
|
{
|
||||||
if (Config->ShowPath)
|
if (Config->ShowPath)
|
||||||
{
|
{
|
||||||
Levels.Sort([](const FAssetData& InA, const FAssetData& InB) { return InA.PackagePath.Compare(InB.PackagePath) < 0; });
|
Levels.Sort([](const auto& InA, const auto& InB) { return InA.PackagePath.Compare(InB.PackagePath) < 0; });
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Levels.Sort([](const FAssetData& InA, const FAssetData& InB) { return InA.AssetName.Compare(InB.AssetName) < 0; });
|
Levels.Sort([](const auto& InA, const auto& InB) { return InA.AssetName.Compare(InB.AssetName) < 0; });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -88,6 +82,13 @@ void FCogEngineWindow_Levels::RenderContent()
|
|||||||
{
|
{
|
||||||
Super::RenderContent();
|
Super::RenderContent();
|
||||||
|
|
||||||
|
if (HasGatheredLevels == false)
|
||||||
|
{
|
||||||
|
GetAllLevels(UnsortedLevels);
|
||||||
|
RefreshSorting();
|
||||||
|
HasGatheredLevels = true;
|
||||||
|
}
|
||||||
|
|
||||||
RenderMenu();
|
RenderMenu();
|
||||||
|
|
||||||
const float FooterHeight = ImGui::GetFrameHeightWithSpacing();
|
const float FooterHeight = ImGui::GetFrameHeightWithSpacing();
|
||||||
@@ -133,15 +134,7 @@ void FCogEngineWindow_Levels::RenderContent()
|
|||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
void FCogEngineWindow_Levels::RenderLevel(int32 InIndex, const FAssetData& InAsset)
|
void FCogEngineWindow_Levels::RenderLevel(int32 InIndex, const FAssetData& InAsset)
|
||||||
{
|
{
|
||||||
FString Label;
|
const FString Label = Config->ShowPath ? InAsset.PackageName.ToString() : InAsset.AssetName.ToString();
|
||||||
if (Config->ShowPath)
|
|
||||||
{
|
|
||||||
Label = InAsset.PackageName.ToString();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Label = InAsset.AssetName.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto LabelStr = StringCast<ANSICHAR>(*Label);
|
const auto LabelStr = StringCast<ANSICHAR>(*Label);
|
||||||
if (Filter.PassFilter(LabelStr.Get()) == false)
|
if (Filter.PassFilter(LabelStr.Get()) == false)
|
||||||
@@ -156,7 +149,7 @@ void FCogEngineWindow_Levels::RenderLevel(int32 InIndex, const FAssetData& InAss
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::SetItemTooltip(StringCast<ANSICHAR>(*InAsset.PackagePath.ToString()).Get());
|
ImGui::SetItemTooltip(StringCast<ANSICHAR>(*InAsset.PackageName.ToString()).Get());
|
||||||
|
|
||||||
RenderLevelContextMenu(InIndex, InAsset);
|
RenderLevelContextMenu(InIndex, InAsset);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ private:
|
|||||||
|
|
||||||
TArray<FAssetData> UnsortedLevels;
|
TArray<FAssetData> UnsortedLevels;
|
||||||
|
|
||||||
|
bool HasGatheredLevels = false;
|
||||||
|
|
||||||
int32 SelectedIndex = -1;
|
int32 SelectedIndex = -1;
|
||||||
|
|
||||||
TObjectPtr<UCogEngineWindowConfig_LevelLoader> Config = nullptr;
|
TObjectPtr<UCogEngineWindowConfig_LevelLoader> Config = nullptr;
|
||||||
|
|||||||
Reference in New Issue
Block a user