示例#1
0
bool FCollectionManager::RenameCollection (FName CurrentCollectionName, ECollectionShareType::Type CurrentShareType, FName NewCollectionName, ECollectionShareType::Type NewShareType)
{
	if ( !ensure(CurrentShareType < ECollectionShareType::CST_All) || !ensure(NewShareType < ECollectionShareType::CST_All) )
	{
		// Bad share type
		LastError = LOCTEXT("Error_Internal", "There was an internal error.");
		return false;
	}

	// Get the object paths for the assets in the collection
	TArray<FName> ObjectPaths;
	if ( !GetAssetsInCollection(CurrentCollectionName, CurrentShareType, ObjectPaths) )
	{
		// Failed to get assets in the current collection
		return false;
	}

	// Create a new collection
	if ( !CreateCollection(NewCollectionName, NewShareType) )
	{
		// Failed to create collection
		return false;
	}

	if ( ObjectPaths.Num() > 0 )
	{
		// Add all the objects from the old collection to the new collection
		if ( !AddToCollection(NewCollectionName, NewShareType, ObjectPaths) )
		{
			// Failed to add paths to the new collection. Destroy the collection we created.
			DestroyCollection(NewCollectionName, NewShareType);
			return false;
		}
	}

	// Delete the old collection
	if ( !DestroyCollection(CurrentCollectionName, CurrentShareType) )
	{
		// Failed to destroy the old collection. Destroy the collection we created.
		DestroyCollection(NewCollectionName, NewShareType);
		return false;
	}

	// Success
	FCollectionNameType OriginalCollectionNameType( CurrentCollectionName, CurrentShareType );
	FCollectionNameType NewCollectionNameType( NewCollectionName, NewShareType );
	CollectionRenamedEvent.Broadcast( OriginalCollectionNameType, NewCollectionNameType );
	return true;
}
void DestroyMap(void)
{
	ptagLevelCollection pCollection1;
	ptagLevelCollection pCollection2;
	ptagLevelCollection pCollection3;

	pCollection1 = theMap->head;
	if (pCollection1) {
		pCollection2 = pCollection1->next;
		while ((pCollection2) && (pCollection2 != pCollection1)) {
			pCollection3 = pCollection2;
			DestroyCollection(pCollection3);
			pCollection2 = pCollection2->next;
		}
		DestroyCollection(pCollection1);
	}
	DestroyLevel(theMap->currentLevel);
	DestroyStep();
	free(theMap);
}