#ifndef CPACKAGE #define CPACKAGE #include #include #include #include #include "Core/IProgressNotifier.h" class CGameProject; enum class EPackageDefinitionVersion { Initial, // Add new versions before this line Max, Current = EPackageDefinitionVersion::Max - 1 }; struct SNamedResource { TString Name; CAssetID ID; CFourCC Type; void Serialize(IArchive& rArc) { rArc << SerialParameter("Name", Name) << SerialParameter("ID", ID) << SerialParameter("Type", Type); } }; class CPackage { CGameProject *mpProject = nullptr; TString mPakName; TString mPakPath; std::vector mResources; bool mNeedsRecook = false; // Cached dependency list; used to figure out if a given resource is in this package mutable bool mCacheDirty = false; mutable std::set mCachedDependencies; public: CPackage() = default; CPackage(CGameProject *pProj, const TString& rkName, const TString& rkPath) : mpProject(pProj) , mPakName(rkName) , mPakPath(rkPath) , mCacheDirty(true) {} bool Load(); bool Save(); void Serialize(IArchive& rArc); void AddResource(const TString& rkName, const CAssetID& rkID, const CFourCC& rkType); void UpdateDependencyCache() const; void MarkDirty(); void Cook(IProgressNotifier *pProgress); void CompareOriginalAssetList(const std::list& rkNewList); bool ContainsAsset(const CAssetID& rkID) const; TString DefinitionPath(bool Relative) const; TString CookedPackagePath(bool Relative) const; // Accessors TString Name() const { return mPakName; } TString Path() const { return mPakPath; } CGameProject* Project() const { return mpProject; } uint32 NumNamedResources() const { return mResources.size(); } const SNamedResource& NamedResourceByIndex(uint32 Idx) const { return mResources[Idx]; } bool NeedsRecook() const { return mNeedsRecook; } void SetPakName(TString NewName) { mPakName = std::move(NewName); } }; #endif // CPACKAGE