#ifndef CASSETNAMEMAP #define CASSETNAMEMAP #include "CResourceIterator.h" #include "CResourceStore.h" #include #include #include #include const TString gkAssetMapPath = "..\\resources\\gameinfo\\AssetNameMap"; const TString gkAssetMapExt = "xml"; class CAssetNameMap { struct SAssetNameInfo { TString Name; TString Directory; CFourCC Type; // This is mostly just needed to verify no name conflicts TString FullPath() const { return Directory + Name + '.' + Type.ToString(); } void Serialize(IArchive& rArc) { rArc << SERIAL_AUTO(Name) << SERIAL_AUTO(Directory) << SERIAL_AUTO(Type); } bool operator<(const SAssetNameInfo& rkOther) const { return FullPath().ToUpper() < rkOther.FullPath().ToUpper(); } bool operator==(const SAssetNameInfo& rkOther) const { return FullPath().CaseInsensitiveCompare(rkOther.FullPath()); } }; std::set mUsedSet; // Used to prevent name conflicts std::map mMap; bool mIsValid; EIDLength mIDLength; // Private Methods void Serialize(IArchive& rArc); void PostLoadValidate(); public: CAssetNameMap(EIDLength IDLength) : mIsValid(true), mIDLength(IDLength) { ASSERT(mIDLength != eInvalidIDLength); } CAssetNameMap(EGame Game) : mIsValid(true), mIDLength( CAssetID::GameIDLength(Game) ) { ASSERT(mIDLength != eInvalidIDLength); } bool LoadAssetNames(TString Path = ""); bool SaveAssetNames(TString Path = ""); bool GetNameInfo(CAssetID ID, TString& rOutDirectory, TString& rOutName); void CopyFromStore(CResourceStore *pStore); static TString DefaultNameMapPath(EIDLength IDLength); static TString DefaultNameMapPath(EGame Game); inline bool IsValid() const { return mIsValid; } inline static TString GetExtension() { return gkAssetMapExt; } }; #endif // CASSETNAMEMAP