You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
UETOOL-332 - Collections 2.0 Removed some duplicated data from FCollection (AssetList and AssetSet) as they had to be manually kept in sync. Only AssetSet exists now, and is converted into an array and sorted before being written to disk (to keep the order consistent for diffing). DiskAssetList has also been converted into a set (now DiskAssetSet) as this is only ever used for lookup queries. All manually memory management has been removed from FCollectionManager, and the array of maps to collections has been converted into a single map using FCollectionNameType as its key. This simplifies collection lookup code in most cases, and removes the need to manually track the total number of collections outside of the map (NumCollections has now been removed). Renamed ICollectionManager::GetCollectionsContainingAsset to ICollectionManager::GetCollectionsContainingObject as the function checks for any objects, not just assets. Renamed FCollection::IsAssetInCollection to FCollection::IsObjectInCollection as the function checks for any objects, not just assets. Made ICollectionManager::IsCollectionEmpty const. Replaced all appropriate loop usage with range-based-for, and replaced any NULL with nullptr. [CL 2560621 by Jamie Dale in Main branch]
90 lines
3.8 KiB
C++
90 lines
3.8 KiB
C++
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
/** A class to represent a collection of assets */
|
|
class FCollection
|
|
{
|
|
public:
|
|
FCollection();
|
|
FCollection(FName InCollectionName, const FString& SourceFolder, const FString& CollectionExtension, bool InUseSCC);
|
|
|
|
/** Loads content from a file into this collection. */
|
|
bool LoadFromFile(const FString& InFilename, bool InUseSCC);
|
|
/** Saves this collection to SourceFilename. If false, OutError is a human readable warning depicting the error. */
|
|
bool Save(FText& OutError);
|
|
/** Deletes the source file for this collection. If false, OutError is a human readable warning depicting the error. */
|
|
bool DeleteSourceFile(FText& OutError);
|
|
|
|
/** Adds a single asset to the collection */
|
|
bool AddAssetToCollection(FName ObjectPath);
|
|
/** Removes a single asset from the collection */
|
|
bool RemoveAssetFromCollection(FName ObjectPath);
|
|
/** Gets a list of assets in the collection. Static collections only. */
|
|
void GetAssetsInCollection(TArray<FName>& Assets) const;
|
|
/** Gets a list of classes in the collection. Static collections only. */
|
|
void GetClassesInCollection(TArray<FName>& Classes) const;
|
|
/** Gets a list of objects in the collection. Static collections only. */
|
|
void GetObjectsInCollection(TArray<FName>& Objects) const;
|
|
/** Returns true when the specified object is in the collection. Static collections only. */
|
|
bool IsObjectInCollection(FName ObjectPath) const;
|
|
/** Resets a collection to its default values */
|
|
void Clear();
|
|
|
|
/** Returns true if the collection contains rules instead of a flat list */
|
|
bool IsDynamic() const;
|
|
|
|
/** Whether the collection has any contents */
|
|
bool IsEmpty() const;
|
|
|
|
/** Logs the contents of the collection */
|
|
void PrintCollection() const;
|
|
|
|
/** Returns the name of the collection */
|
|
FORCEINLINE const FName& GetCollectionName() const { return CollectionName; }
|
|
|
|
private:
|
|
/** Generates the header pairs for the collection file. */
|
|
void GenerateHeaderPairs(TMap<FString,FString>& OutHeaderPairs);
|
|
|
|
/**
|
|
* Processes header pairs from the top of a collection file.
|
|
*
|
|
* @param InHeaderPairs The header pairs found at the start of a collection file
|
|
* @return true if the header was valid and loaded properly
|
|
*/
|
|
bool LoadHeaderPairs(const TMap<FString,FString>& InHeaderPairs);
|
|
|
|
/** Merges the assets from the specified collection with this collection */
|
|
void MergeWithCollection(const FCollection& Other);
|
|
/** Gets the differences between Lists A and B */
|
|
void GetDifferencesFromDisk(TArray<FName>& AssetsAdded, TArray<FName>& AssetsRemoved);
|
|
/** Checks the shared collection out from source control so it may be saved. If false, OutError is a human readable warning depicting the error. */
|
|
bool CheckoutCollection(FText& OutError);
|
|
/** Checks the shared collection in to source control after it is saved. If false, OutError is a human readable warning depicting the error. */
|
|
bool CheckinCollection(FText& OutError);
|
|
/** Reverts the collection in the event that the save was not successful. If false, OutError is a human readable warning depicting the error.*/
|
|
bool RevertCollection(FText& OutError);
|
|
/** Marks the source file for delete in source control. If false, OutError is a human readable warning depicting the error. */
|
|
bool DeleteFromSourceControl(FText& OutError);
|
|
|
|
private:
|
|
/** The name of the collection */
|
|
FName CollectionName;
|
|
|
|
/** Source control is used if true */
|
|
bool bUseSCC;
|
|
|
|
/** The filename used to load this collection. Empty if it is new or never loaded from disk. */
|
|
FString SourceFilename;
|
|
|
|
/** The set of assets in the collection. Takes the form PackageName.AssetName */
|
|
TSet<FName> AssetSet;
|
|
|
|
/** The set of assets that were in the collection last time it was loaded from or saved to disk. Takes the form PackageName.AssetName */
|
|
TSet<FName> DiskAssetSet;
|
|
|
|
/** The file version for this collection */
|
|
int32 FileVersion;
|
|
};
|