You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
203 lines
5.6 KiB
C++
203 lines
5.6 KiB
C++
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#define LOCTEXT_NAMESPACE "CollectionManager"
|
|
|
|
class FCollectionManagerConsoleCommands
|
|
{
|
|
public:
|
|
const FCollectionManagerModule& Module;
|
|
|
|
FAutoConsoleCommand CreateCommand;
|
|
FAutoConsoleCommand DestroyCommand;
|
|
FAutoConsoleCommand AddCommand;
|
|
FAutoConsoleCommand RemoveCommand;
|
|
|
|
FCollectionManagerConsoleCommands(const FCollectionManagerModule& InModule)
|
|
: Module(InModule)
|
|
, CreateCommand(
|
|
TEXT( "CollectionManager.Create" ),
|
|
*LOCTEXT("CommandText_Create", "Creates a collection of the specified name and type").ToString(),
|
|
FConsoleCommandWithArgsDelegate::CreateRaw( this, &FCollectionManagerConsoleCommands::Create ) )
|
|
, DestroyCommand(
|
|
TEXT( "CollectionManager.Destroy" ),
|
|
*LOCTEXT("CommandText_Destroy", "Deletes a collection of the specified name and type").ToString(),
|
|
FConsoleCommandWithArgsDelegate::CreateRaw( this, &FCollectionManagerConsoleCommands::Destroy ) )
|
|
, AddCommand(
|
|
TEXT( "CollectionManager.Add" ),
|
|
*LOCTEXT("CommandText_Add", "Adds the specified object path to the specified collection").ToString(),
|
|
FConsoleCommandWithArgsDelegate::CreateRaw( this, &FCollectionManagerConsoleCommands::Add ) )
|
|
, RemoveCommand(
|
|
TEXT( "CollectionManager.Remove" ),
|
|
*LOCTEXT("CommandText_Remove", "Removes the specified object path from the specified collection").ToString(),
|
|
FConsoleCommandWithArgsDelegate::CreateRaw( this, &FCollectionManagerConsoleCommands::Remove ) )
|
|
{}
|
|
|
|
void Create(const TArray<FString>& Args)
|
|
{
|
|
if ( Args.Num() < 2 )
|
|
{
|
|
UE_LOG(LogCollectionManager, Log, TEXT("Usage: CollectionManager.Create CollectionName CollectionType"));
|
|
return;
|
|
}
|
|
|
|
FName CollectionName = FName(*Args[0]);
|
|
FString ShareStr = Args[1];
|
|
ECollectionShareType::Type Type;
|
|
|
|
if ( ShareStr == TEXT("LOCAL") )
|
|
{
|
|
Type = ECollectionShareType::CST_Local;
|
|
}
|
|
else if ( ShareStr == TEXT("PRIVATE") )
|
|
{
|
|
Type = ECollectionShareType::CST_Private;
|
|
}
|
|
else if ( ShareStr == TEXT("SHARED") )
|
|
{
|
|
Type = ECollectionShareType::CST_Shared;
|
|
}
|
|
else
|
|
{
|
|
UE_LOG(LogCollectionManager, Warning, TEXT("Invalid collection share type: %s"), *ShareStr);
|
|
return;
|
|
}
|
|
|
|
if ( Module.Get().CreateCollection(CollectionName, Type) )
|
|
{
|
|
UE_LOG(LogCollectionManager, Log, TEXT("Collection created: %s"), *CollectionName.ToString());
|
|
}
|
|
else
|
|
{
|
|
UE_LOG(LogCollectionManager, Warning, TEXT("Failed to create collection: %s"), *CollectionName.ToString());
|
|
}
|
|
}
|
|
|
|
void Destroy(const TArray<FString>& Args)
|
|
{
|
|
if ( Args.Num() < 2 )
|
|
{
|
|
UE_LOG(LogCollectionManager, Log, TEXT("Usage: CollectionManager.Destroy CollectionName CollectionType"));
|
|
return;
|
|
}
|
|
|
|
FName CollectionName = FName(*Args[0]);
|
|
FString ShareStr = Args[1];
|
|
ECollectionShareType::Type Type;
|
|
|
|
if ( ShareStr == TEXT("LOCAL") )
|
|
{
|
|
Type = ECollectionShareType::CST_Local;
|
|
}
|
|
else if ( ShareStr == TEXT("PRIVATE") )
|
|
{
|
|
Type = ECollectionShareType::CST_Private;
|
|
}
|
|
else if ( ShareStr == TEXT("SHARED") )
|
|
{
|
|
Type = ECollectionShareType::CST_Shared;
|
|
}
|
|
else
|
|
{
|
|
UE_LOG(LogCollectionManager, Warning, TEXT("Invalid collection share type: %s"), *ShareStr);
|
|
return;
|
|
}
|
|
|
|
if ( Module.Get().DestroyCollection(CollectionName, Type) )
|
|
{
|
|
UE_LOG(LogCollectionManager, Log, TEXT("Collection destroyed: %s"), *CollectionName.ToString());
|
|
}
|
|
else
|
|
{
|
|
UE_LOG(LogCollectionManager, Warning, TEXT("Failed to destroyed collection: %s"), *CollectionName.ToString());
|
|
}
|
|
}
|
|
|
|
void Add(const TArray<FString>& Args)
|
|
{
|
|
if ( Args.Num() < 3 )
|
|
{
|
|
UE_LOG(LogCollectionManager, Log, TEXT("Usage: CollectionManager.Add CollectionName CollectionType ObjectPath"));
|
|
return;
|
|
}
|
|
|
|
FName CollectionName = FName(*Args[0]);
|
|
FString ShareStr = Args[1];
|
|
FName ObjectPath = FName(*Args[2]);
|
|
ECollectionShareType::Type Type;
|
|
|
|
if ( ShareStr == TEXT("LOCAL") )
|
|
{
|
|
Type = ECollectionShareType::CST_Local;
|
|
}
|
|
else if ( ShareStr == TEXT("PRIVATE") )
|
|
{
|
|
Type = ECollectionShareType::CST_Private;
|
|
}
|
|
else if ( ShareStr == TEXT("SHARED") )
|
|
{
|
|
Type = ECollectionShareType::CST_Shared;
|
|
}
|
|
else
|
|
{
|
|
UE_LOG(LogCollectionManager, Warning, TEXT("Invalid collection share type: %s"), *ShareStr);
|
|
return;
|
|
}
|
|
|
|
if ( Module.Get().AddToCollection(CollectionName, Type, ObjectPath) )
|
|
{
|
|
UE_LOG(LogCollectionManager, Log, TEXT("%s added to collection %s"), *ObjectPath.ToString(), *CollectionName.ToString());
|
|
}
|
|
else
|
|
{
|
|
UE_LOG(LogCollectionManager, Warning, TEXT("Failed to add %s to collection %s"), *ObjectPath.ToString(), *CollectionName.ToString());
|
|
}
|
|
}
|
|
|
|
void Remove(const TArray<FString>& Args)
|
|
{
|
|
if ( Args.Num() < 3 )
|
|
{
|
|
UE_LOG(LogCollectionManager, Log, TEXT("Usage: CollectionManager.Remove CollectionName CollectionType ObjectPath"));
|
|
return;
|
|
}
|
|
|
|
FName CollectionName = FName(*Args[0]);
|
|
FString ShareStr = Args[1];
|
|
FName ObjectPath = FName(*Args[2]);
|
|
|
|
ECollectionShareType::Type Type;
|
|
|
|
if ( ShareStr == TEXT("LOCAL") )
|
|
{
|
|
Type = ECollectionShareType::CST_Local;
|
|
}
|
|
else if ( ShareStr == TEXT("PRIVATE") )
|
|
{
|
|
Type = ECollectionShareType::CST_Private;
|
|
}
|
|
else if ( ShareStr == TEXT("SHARED") )
|
|
{
|
|
Type = ECollectionShareType::CST_Shared;
|
|
}
|
|
else
|
|
{
|
|
UE_LOG(LogCollectionManager, Warning, TEXT("Invalid collection share type: %s"), *ShareStr);
|
|
return;
|
|
}
|
|
|
|
if ( Module.Get().RemoveFromCollection(CollectionName, Type, ObjectPath) )
|
|
{
|
|
UE_LOG(LogCollectionManager, Log, TEXT("%s removed from collection %s"), *ObjectPath.ToString(), *CollectionName.ToString());
|
|
}
|
|
else
|
|
{
|
|
UE_LOG(LogCollectionManager, Warning, TEXT("Failed to remove %s from collection %s"), *ObjectPath.ToString(), *CollectionName.ToString());
|
|
}
|
|
}
|
|
};
|
|
|
|
|
|
#undef LOCTEXT_NAMESPACE
|