mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-16 08:27:01 +00:00
Cleanup & refactoring
This commit is contained in:
@@ -26,8 +26,8 @@ void ApplyGeneratedName(CResourceEntry *pEntry, const TString& rkDir, const TStr
|
||||
ASSERT(pEntry != nullptr);
|
||||
|
||||
// Don't overwrite hand-picked names and directories with auto-generated ones
|
||||
bool HasCustomDir = !pEntry->HasFlag(eREF_AutoResDir);
|
||||
bool HasCustomName = !pEntry->HasFlag(eREF_AutoResName);
|
||||
bool HasCustomDir = !pEntry->HasFlag(EResEntryFlag::AutoResDir);
|
||||
bool HasCustomName = !pEntry->HasFlag(EResEntryFlag::AutoResName);
|
||||
if (HasCustomDir && HasCustomName) return;
|
||||
|
||||
// Determine final directory to use
|
||||
@@ -94,8 +94,8 @@ void GenerateAssetNames(CGameProject *pProj)
|
||||
|
||||
for (CResourceIterator It(pStore); It; ++It)
|
||||
{
|
||||
bool HasCustomDir = !It->HasFlag(eREF_AutoResDir);
|
||||
bool HasCustomName = !It->HasFlag(eREF_AutoResName);
|
||||
bool HasCustomDir = !It->HasFlag(EResEntryFlag::AutoResDir);
|
||||
bool HasCustomName = !It->HasFlag(EResEntryFlag::AutoResName);
|
||||
if (HasCustomDir && HasCustomName) continue;
|
||||
|
||||
TString NewDir = (HasCustomDir ? It->DirectoryPath() : pStore->DefaultResourceDirPath());
|
||||
@@ -131,7 +131,7 @@ void GenerateAssetNames(CGameProject *pProj)
|
||||
debugf("Processing worlds");
|
||||
const TString kWorldsRoot = "Worlds/";
|
||||
|
||||
for (TResourceIterator<eWorld> It(pStore); It; ++It)
|
||||
for (TResourceIterator<EResourceType::World> It(pStore); It; ++It)
|
||||
{
|
||||
// Set world name
|
||||
TResPtr<CWorld> pWorld = It->Load();
|
||||
@@ -245,7 +245,7 @@ void GenerateAssetNames(CGameProject *pProj)
|
||||
{
|
||||
CMaterialPass *pPass = pMat->Pass(iPass);
|
||||
|
||||
bool IsLightmap = ( (pArea->Game() <= EGame::Echoes && pMat->Options().HasFlag(CMaterial::eLightmap) && iPass == 0) ||
|
||||
bool IsLightmap = ( (pArea->Game() <= EGame::Echoes && pMat->Options().HasFlag(EMaterialOption::Lightmap) && iPass == 0) ||
|
||||
(pArea->Game() >= EGame::CorruptionProto && pPass->Type() == "DIFF") );
|
||||
bool IsBloomLightmap = (pArea->Game() >= EGame::CorruptionProto && pPass->Type() == "BLOL");
|
||||
|
||||
@@ -398,7 +398,7 @@ void GenerateAssetNames(CGameProject *pProj)
|
||||
// Generate Model Lightmap names
|
||||
debugf("Processing model lightmaps");
|
||||
|
||||
for (TResourceIterator<eModel> It(pStore); It; ++It)
|
||||
for (TResourceIterator<EResourceType::Model> It(pStore); It; ++It)
|
||||
{
|
||||
CModel *pModel = (CModel*) It->Load();
|
||||
uint32 LightmapNum = 0;
|
||||
@@ -415,7 +415,7 @@ void GenerateAssetNames(CGameProject *pProj)
|
||||
{
|
||||
CMaterialPass *pPass = pMat->Pass(iPass);
|
||||
|
||||
bool IsLightmap = ( (pMat->Version() <= EGame::Echoes && pMat->Options().HasFlag(CMaterial::eLightmap) && iPass == 0) ||
|
||||
bool IsLightmap = ( (pMat->Version() <= EGame::Echoes && pMat->Options().HasFlag(EMaterialOption::Lightmap) && iPass == 0) ||
|
||||
(pMat->Version() >= EGame::CorruptionProto && pPass->Type() == "DIFF") );
|
||||
|
||||
if (IsLightmap)
|
||||
@@ -442,7 +442,7 @@ void GenerateAssetNames(CGameProject *pProj)
|
||||
debugf("Processing audio groups");
|
||||
const TString kAudioGrpDir = "Audio/";
|
||||
|
||||
for (TResourceIterator<eAudioGroup> It(pStore); It; ++It)
|
||||
for (TResourceIterator<EResourceType::AudioGroup> It(pStore); It; ++It)
|
||||
{
|
||||
CAudioGroup *pGroup = (CAudioGroup*) It->Load();
|
||||
TString GroupName = pGroup->GroupName();
|
||||
@@ -455,7 +455,7 @@ void GenerateAssetNames(CGameProject *pProj)
|
||||
debugf("Processing audio macros");
|
||||
const TString kSfxDir = "Audio/Uncategorized/";
|
||||
|
||||
for (TResourceIterator<eAudioMacro> It(pStore); It; ++It)
|
||||
for (TResourceIterator<EResourceType::AudioMacro> It(pStore); It; ++It)
|
||||
{
|
||||
CAudioMacro *pMacro = (CAudioMacro*) It->Load();
|
||||
TString MacroName = pMacro->MacroName();
|
||||
@@ -485,7 +485,9 @@ void GenerateAssetNames(CGameProject *pProj)
|
||||
// Generate animation format names
|
||||
// Hacky syntax because animsets are under eAnimSet in MP1/2 and eCharacter in MP3/DKCR
|
||||
debugf("Processing animation data");
|
||||
CResourceIterator *pIter = (pProj->Game() <= EGame::Echoes ? (CResourceIterator*) new TResourceIterator<eAnimSet> : (CResourceIterator*) new TResourceIterator<eCharacter>);
|
||||
CResourceIterator *pIter = (pProj->Game() <= EGame::Echoes ?
|
||||
(CResourceIterator*) new TResourceIterator<EResourceType::AnimSet> :
|
||||
(CResourceIterator*) new TResourceIterator<EResourceType::Character>);
|
||||
CResourceIterator& It = *pIter;
|
||||
|
||||
for (; It; ++It)
|
||||
@@ -523,10 +525,10 @@ void GenerateAssetNames(CGameProject *pProj)
|
||||
if (rkOverlay.ModelID.IsValid() || rkOverlay.SkinID.IsValid())
|
||||
{
|
||||
TString TypeName = (
|
||||
rkOverlay.Type == eOT_Frozen ? "frozen" :
|
||||
rkOverlay.Type == eOT_Acid ? "acid" :
|
||||
rkOverlay.Type == eOT_Hypermode ? "hypermode" :
|
||||
rkOverlay.Type == eOT_XRay ? "xray" :
|
||||
rkOverlay.Type == EOverlayType::Frozen ? "frozen" :
|
||||
rkOverlay.Type == EOverlayType::Acid ? "acid" :
|
||||
rkOverlay.Type == EOverlayType::Hypermode ? "hypermode" :
|
||||
rkOverlay.Type == EOverlayType::XRay ? "xray" :
|
||||
""
|
||||
);
|
||||
ASSERT(TypeName != "");
|
||||
@@ -576,7 +578,7 @@ void GenerateAssetNames(CGameProject *pProj)
|
||||
debugf("Processing strings");
|
||||
const TString kStringsDir = "Strings/Uncategorized/";
|
||||
|
||||
for (TResourceIterator<eStringTable> It(pStore); It; ++It)
|
||||
for (TResourceIterator<EResourceType::StringTable> It(pStore); It; ++It)
|
||||
{
|
||||
if (It->IsNamed()) continue;
|
||||
CStringTable *pString = (CStringTable*) It->Load();
|
||||
@@ -601,7 +603,7 @@ void GenerateAssetNames(CGameProject *pProj)
|
||||
#if PROCESS_SCANS
|
||||
// Generate scan names
|
||||
debugf("Processing scans");
|
||||
for (TResourceIterator<eScan> It(pStore); It; ++It)
|
||||
for (TResourceIterator<EResourceType::Scan> It(pStore); It; ++It)
|
||||
{
|
||||
if (It->IsNamed()) continue;
|
||||
CScan *pScan = (CScan*) It->Load();
|
||||
@@ -641,7 +643,7 @@ void GenerateAssetNames(CGameProject *pProj)
|
||||
#if PROCESS_FONTS
|
||||
// Generate font names
|
||||
debugf("Processing fonts");
|
||||
for (TResourceIterator<eFont> It(pStore); It; ++It)
|
||||
for (TResourceIterator<EResourceType::Font> It(pStore); It; ++It)
|
||||
{
|
||||
CFont *pFont = (CFont*) It->Load();
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ bool CAssetNameMap::LoadAssetNames(TString Path /*= ""*/)
|
||||
else
|
||||
{
|
||||
debugf("Failed to load asset names; expected %s IDs, got %s",
|
||||
mIDLength == e32Bit ? "32-bit" : "64-bit",
|
||||
FileIDLength == e32Bit ? "32-bit" : "64-bit" );
|
||||
mIDLength == k32Bit ? "32-bit" : "64-bit",
|
||||
FileIDLength == k32Bit ? "32-bit" : "64-bit" );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,7 @@ bool CAssetNameMap::SaveAssetNames(TString Path /*= ""*/)
|
||||
if (Path.IsEmpty())
|
||||
Path = DefaultNameMapPath(mIDLength);
|
||||
|
||||
EGame Game = (mIDLength == e32Bit ? EGame::Prime : EGame::Corruption);
|
||||
EGame Game = (mIDLength == k32Bit ? EGame::Prime : EGame::Corruption);
|
||||
CXMLWriter Writer(Path, "AssetNameMap", 0, Game);
|
||||
Serialize(Writer);
|
||||
return Writer.Save();
|
||||
@@ -58,7 +58,7 @@ bool CAssetNameMap::GetNameInfo(CAssetID ID, TString& rOutDirectory, TString& rO
|
||||
|
||||
else
|
||||
{
|
||||
EGame Game = (ID.Length() == e32Bit ? EGame::Prime : EGame::Corruption);
|
||||
EGame Game = (ID.Length() == k32Bit ? EGame::Prime : EGame::Corruption);
|
||||
rOutDirectory = CResourceStore::StaticDefaultResourceDirPath(Game);
|
||||
rOutName = ID.ToString();
|
||||
rOutAutoGenDir = true;
|
||||
@@ -99,8 +99,8 @@ void CAssetNameMap::CopyFromStore(CResourceStore *pStore /*= gpResourceStore*/)
|
||||
TString Name = It->Name();
|
||||
TString Directory = It->Directory()->FullPath();
|
||||
CFourCC Type = It->CookedExtension();
|
||||
bool AutoName = It->HasFlag(eREF_AutoResName);
|
||||
bool AutoDir = It->HasFlag(eREF_AutoResDir);
|
||||
bool AutoName = It->HasFlag(EResEntryFlag::AutoResName);
|
||||
bool AutoDir = It->HasFlag(EResEntryFlag::AutoResDir);
|
||||
SAssetNameInfo NameInfo { Name, Directory, Type, AutoName, AutoDir };
|
||||
|
||||
// Check for conflicts with new name
|
||||
@@ -193,8 +193,8 @@ void CAssetNameMap::PostLoadValidate()
|
||||
|
||||
TString CAssetNameMap::DefaultNameMapPath(EIDLength IDLength)
|
||||
{
|
||||
ASSERT(IDLength != eInvalidIDLength);
|
||||
TString Suffix = (IDLength == e32Bit ? "32" : "64");
|
||||
ASSERT(IDLength != kInvalidIDLength);
|
||||
TString Suffix = (IDLength == k32Bit ? "32" : "64");
|
||||
return gkAssetMapPath + Suffix + "." + gkAssetMapExt;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,8 +56,8 @@ class CAssetNameMap
|
||||
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); }
|
||||
CAssetNameMap(EIDLength IDLength) : mIsValid(true), mIDLength(IDLength) { ASSERT(mIDLength != kInvalidIDLength); }
|
||||
CAssetNameMap(EGame Game) : mIsValid(true), mIDLength( CAssetID::GameIDLength(Game) ) { ASSERT(mIDLength != kInvalidIDLength); }
|
||||
bool LoadAssetNames(TString Path = "");
|
||||
bool SaveAssetNames(TString Path = "");
|
||||
bool GetNameInfo(CAssetID ID, TString& rOutDirectory, TString& rOutName, bool& rOutAutoGenDir, bool& rOutAutoGenName);
|
||||
|
||||
@@ -35,23 +35,23 @@ IDependencyNode* IDependencyNode::ArchiveConstructor(EDependencyNodeType Type)
|
||||
{
|
||||
switch (Type)
|
||||
{
|
||||
case eDNT_DependencyTree: return new CDependencyTree;
|
||||
case eDNT_ResourceDependency: return new CResourceDependency;
|
||||
case eDNT_ScriptInstance: return new CScriptInstanceDependency;
|
||||
case eDNT_ScriptProperty: return new CPropertyDependency;
|
||||
case eDNT_CharacterProperty: return new CCharPropertyDependency;
|
||||
case eDNT_SetCharacter: return new CSetCharacterDependency;
|
||||
case eDNT_SetAnimation: return new CSetAnimationDependency;
|
||||
case eDNT_AnimEvent: return new CAnimEventDependency;
|
||||
case eDNT_Area: return new CAreaDependencyTree;
|
||||
default: ASSERT(false); return nullptr;
|
||||
case EDependencyNodeType::DependencyTree: return new CDependencyTree;
|
||||
case EDependencyNodeType::Resource: return new CResourceDependency;
|
||||
case EDependencyNodeType::ScriptInstance: return new CScriptInstanceDependency;
|
||||
case EDependencyNodeType::ScriptProperty: return new CPropertyDependency;
|
||||
case EDependencyNodeType::CharacterProperty: return new CCharPropertyDependency;
|
||||
case EDependencyNodeType::SetCharacter: return new CSetCharacterDependency;
|
||||
case EDependencyNodeType::SetAnimation: return new CSetAnimationDependency;
|
||||
case EDependencyNodeType::AnimEvent: return new CAnimEventDependency;
|
||||
case EDependencyNodeType::Area: return new CAreaDependencyTree;
|
||||
default: ASSERT(false); return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// ************ CDependencyTree ************
|
||||
EDependencyNodeType CDependencyTree::Type() const
|
||||
{
|
||||
return eDNT_DependencyTree;
|
||||
return EDependencyNodeType::DependencyTree;
|
||||
}
|
||||
|
||||
void CDependencyTree::Serialize(IArchive& rArc)
|
||||
@@ -90,7 +90,7 @@ void CDependencyTree::AddCharacterDependency(const CAnimationParameters& rkAnimP
|
||||
// ************ CResourceDependency ************
|
||||
EDependencyNodeType CResourceDependency::Type() const
|
||||
{
|
||||
return eDNT_ResourceDependency;
|
||||
return EDependencyNodeType::Resource;
|
||||
}
|
||||
|
||||
void CResourceDependency::Serialize(IArchive& rArc)
|
||||
@@ -111,7 +111,7 @@ bool CResourceDependency::HasDependency(const CAssetID& rkID) const
|
||||
// ************ CPropertyDependency ************
|
||||
EDependencyNodeType CPropertyDependency::Type() const
|
||||
{
|
||||
return eDNT_ScriptProperty;
|
||||
return EDependencyNodeType::ScriptProperty;
|
||||
}
|
||||
|
||||
void CPropertyDependency::Serialize(IArchive& rArc)
|
||||
@@ -123,7 +123,7 @@ void CPropertyDependency::Serialize(IArchive& rArc)
|
||||
// ************ CCharacterPropertyDependency ************
|
||||
EDependencyNodeType CCharPropertyDependency::Type() const
|
||||
{
|
||||
return eDNT_CharacterProperty;
|
||||
return EDependencyNodeType::CharacterProperty;
|
||||
}
|
||||
|
||||
void CCharPropertyDependency::Serialize(IArchive& rArc)
|
||||
@@ -135,7 +135,7 @@ void CCharPropertyDependency::Serialize(IArchive& rArc)
|
||||
// ************ CScriptInstanceDependency ************
|
||||
EDependencyNodeType CScriptInstanceDependency::Type() const
|
||||
{
|
||||
return eDNT_ScriptInstance;
|
||||
return EDependencyNodeType::ScriptInstance;
|
||||
}
|
||||
|
||||
void CScriptInstanceDependency::Serialize(IArchive& rArc)
|
||||
@@ -222,7 +222,7 @@ void CScriptInstanceDependency::ParseStructDependencies(CScriptInstanceDependenc
|
||||
// ************ CSetCharacterDependency ************
|
||||
EDependencyNodeType CSetCharacterDependency::Type() const
|
||||
{
|
||||
return eDNT_SetCharacter;
|
||||
return EDependencyNodeType::SetCharacter;
|
||||
}
|
||||
|
||||
void CSetCharacterDependency::Serialize(IArchive& rArc)
|
||||
@@ -267,7 +267,7 @@ CSetCharacterDependency* CSetCharacterDependency::BuildTree(const SSetCharacter&
|
||||
// ************ CSetAnimationDependency ************
|
||||
EDependencyNodeType CSetAnimationDependency::Type() const
|
||||
{
|
||||
return eDNT_SetAnimation;
|
||||
return EDependencyNodeType::SetAnimation;
|
||||
}
|
||||
|
||||
void CSetAnimationDependency::Serialize(IArchive& rArc)
|
||||
@@ -313,7 +313,7 @@ CSetAnimationDependency* CSetAnimationDependency::BuildTree(const CAnimSet *pkOw
|
||||
// ************ CAnimEventDependency ************
|
||||
EDependencyNodeType CAnimEventDependency::Type() const
|
||||
{
|
||||
return eDNT_AnimEvent;
|
||||
return EDependencyNodeType::AnimEvent;
|
||||
}
|
||||
|
||||
void CAnimEventDependency::Serialize(IArchive& rArc)
|
||||
@@ -325,7 +325,7 @@ void CAnimEventDependency::Serialize(IArchive& rArc)
|
||||
// ************ CAreaDependencyTree ************
|
||||
EDependencyNodeType CAreaDependencyTree::Type() const
|
||||
{
|
||||
return eDNT_Area;
|
||||
return EDependencyNodeType::Area;
|
||||
}
|
||||
|
||||
void CAreaDependencyTree::Serialize(IArchive& rArc)
|
||||
@@ -379,7 +379,7 @@ void CAreaDependencyTree::GetModuleDependencies(EGame Game, std::vector<TString>
|
||||
for (uint32 iInst = StartIdx; iInst < EndIdx; iInst++)
|
||||
{
|
||||
IDependencyNode *pNode = mChildren[iInst];
|
||||
if (pNode->Type() != eDNT_ScriptInstance) continue;
|
||||
if (pNode->Type() != EDependencyNodeType::ScriptInstance) continue;
|
||||
|
||||
CScriptInstanceDependency *pInst = static_cast<CScriptInstanceDependency*>(pNode);
|
||||
uint32 ObjType = pInst->ObjectType();
|
||||
|
||||
@@ -14,17 +14,17 @@ class CAnimationParameters;
|
||||
struct SSetCharacter;
|
||||
|
||||
// Group of node classes forming a tree of cached resource dependencies.
|
||||
enum EDependencyNodeType
|
||||
enum class EDependencyNodeType
|
||||
{
|
||||
eDNT_DependencyTree = FOURCC('TREE'),
|
||||
eDNT_ResourceDependency = FOURCC('RSDP'),
|
||||
eDNT_ScriptInstance = FOURCC('SCIN'),
|
||||
eDNT_ScriptProperty = FOURCC('SCPR'),
|
||||
eDNT_CharacterProperty = FOURCC('CRPR'),
|
||||
eDNT_SetCharacter = FOURCC('SCHR'),
|
||||
eDNT_SetAnimation = FOURCC('SANM'),
|
||||
eDNT_AnimEvent = FOURCC('EVNT'),
|
||||
eDNT_Area = FOURCC('AREA'),
|
||||
DependencyTree = FOURCC('TREE'),
|
||||
Resource = FOURCC('RSDP'),
|
||||
ScriptInstance = FOURCC('SCIN'),
|
||||
ScriptProperty = FOURCC('SCPR'),
|
||||
CharacterProperty = FOURCC('CRPR'),
|
||||
SetCharacter = FOURCC('SCHR'),
|
||||
SetAnimation = FOURCC('SANM'),
|
||||
AnimEvent = FOURCC('EVNT'),
|
||||
Area = FOURCC('AREA'),
|
||||
};
|
||||
|
||||
// Base class providing an interface for a basic dependency node.
|
||||
|
||||
@@ -100,7 +100,7 @@ void CGameExporter::LoadResource(const CAssetID& rkID, std::vector<uint8>& rBuff
|
||||
|
||||
bool CGameExporter::ShouldExportDiscNode(const nod::Node *pkNode, bool IsInRoot)
|
||||
{
|
||||
if (IsInRoot && mDiscType != eDT_Normal)
|
||||
if (IsInRoot && mDiscType != EDiscType::Normal)
|
||||
{
|
||||
// Directories - exclude the filesystem for other games
|
||||
if (pkNode->getKind() == nod::Node::Kind::Directory)
|
||||
@@ -115,15 +115,15 @@ bool CGameExporter::ShouldExportDiscNode(const nod::Node *pkNode, bool IsInRoot)
|
||||
switch (mGame)
|
||||
{
|
||||
case EGame::Prime:
|
||||
return ( (mDiscType == eDT_WiiDeAsobu && pkNode->getName() == "MP1JPN") ||
|
||||
(mDiscType == eDT_Trilogy && pkNode->getName() == "MP1") );
|
||||
return ( (mDiscType == EDiscType::WiiDeAsobu && pkNode->getName() == "MP1JPN") ||
|
||||
(mDiscType == EDiscType::Trilogy && pkNode->getName() == "MP1") );
|
||||
|
||||
case EGame::Echoes:
|
||||
return ( (mDiscType == eDT_WiiDeAsobu && pkNode->getName() == "MP2JPN") ||
|
||||
(mDiscType == eDT_Trilogy && pkNode->getName() == "MP2") );
|
||||
return ( (mDiscType == EDiscType::WiiDeAsobu && pkNode->getName() == "MP2JPN") ||
|
||||
(mDiscType == EDiscType::Trilogy && pkNode->getName() == "MP2") );
|
||||
|
||||
case EGame::Corruption:
|
||||
return (mDiscType == eDT_Trilogy && pkNode->getName() == "MP3");
|
||||
return (mDiscType == EDiscType::Trilogy && pkNode->getName() == "MP3");
|
||||
|
||||
default:
|
||||
return false;
|
||||
@@ -143,15 +143,15 @@ bool CGameExporter::ShouldExportDiscNode(const nod::Node *pkNode, bool IsInRoot)
|
||||
switch (mGame)
|
||||
{
|
||||
case EGame::Prime:
|
||||
return ( (mDiscType == eDT_WiiDeAsobu && pkNode->getName() == "rs5mp1jpn_p.dol") ||
|
||||
(mDiscType == eDT_Trilogy && pkNode->getName() == "rs5mp1_p.dol") );
|
||||
return ( (mDiscType == EDiscType::WiiDeAsobu && pkNode->getName() == "rs5mp1jpn_p.dol") ||
|
||||
(mDiscType == EDiscType::Trilogy && pkNode->getName() == "rs5mp1_p.dol") );
|
||||
|
||||
case EGame::Echoes:
|
||||
return ( (mDiscType == eDT_WiiDeAsobu && pkNode->getName() == "rs5mp2jpn_p.dol") ||
|
||||
(mDiscType == eDT_Trilogy && pkNode->getName() == "rs5mp2_p.dol") );
|
||||
return ( (mDiscType == EDiscType::WiiDeAsobu && pkNode->getName() == "rs5mp2jpn_p.dol") ||
|
||||
(mDiscType == EDiscType::Trilogy && pkNode->getName() == "rs5mp2_p.dol") );
|
||||
|
||||
case EGame::Corruption:
|
||||
return (mDiscType == eDT_Trilogy && pkNode->getName() == "rs5mp3_p.dol");
|
||||
return (mDiscType == EDiscType::Trilogy && pkNode->getName() == "rs5mp3_p.dol");
|
||||
|
||||
default:
|
||||
return false;
|
||||
@@ -232,7 +232,7 @@ bool CGameExporter::ExtractDiscNodeRecursive(const nod::Node *pkNode, const TStr
|
||||
if (FilePath.GetFileExtension().CaseInsensitiveCompare("pak"))
|
||||
{
|
||||
// For multi-game Wii discs, don't track packages for frontend unless we're exporting frontend
|
||||
if (mDiscType == eDT_Normal || mFrontEnd || pkNode->getName() != "fe")
|
||||
if (mDiscType == EDiscType::Normal || mFrontEnd || pkNode->getName() != "fe")
|
||||
mPaks.push_back(FilePath);
|
||||
}
|
||||
}
|
||||
@@ -264,7 +264,7 @@ void CGameExporter::LoadPaks()
|
||||
for (auto It = mPaks.begin(); It != mPaks.end(); It++)
|
||||
{
|
||||
TString PakPath = *It;
|
||||
CFileInStream Pak(PakPath, IOUtil::eBigEndian);
|
||||
CFileInStream Pak(PakPath, EEndian::BigEndian);
|
||||
|
||||
if (!Pak.IsValid())
|
||||
{
|
||||
@@ -427,7 +427,7 @@ void CGameExporter::LoadPaks()
|
||||
|
||||
void CGameExporter::LoadResource(const SResourceInstance& rkResource, std::vector<uint8>& rBuffer)
|
||||
{
|
||||
CFileInStream Pak(rkResource.PakFile, IOUtil::eBigEndian);
|
||||
CFileInStream Pak(rkResource.PakFile, EEndian::BigEndian);
|
||||
|
||||
if (Pak.IsValid())
|
||||
{
|
||||
@@ -559,13 +559,13 @@ void CGameExporter::ExportResourceEditorData()
|
||||
for (CResourceIterator It(mpStore); It && !mpProgress->ShouldCancel(); ++It, ++ResIndex)
|
||||
{
|
||||
// Update progress
|
||||
if ((ResIndex & 0x3) == 0 || It->ResourceType() == eArea)
|
||||
if ((ResIndex & 0x3) == 0 || It->ResourceType() == EResourceType::Area)
|
||||
mpProgress->Report(ResIndex, mpStore->NumTotalResources(), TString::Format("Processing asset %d/%d: %s",
|
||||
ResIndex, mpStore->NumTotalResources(), *It->CookedAssetPath(true).GetFileName()) );
|
||||
|
||||
// Worlds need some info we can only get from the pak at export time; namely, which areas can
|
||||
// have duplicates, as well as the world's internal name.
|
||||
if (It->ResourceType() == eWorld)
|
||||
if (It->ResourceType() == EResourceType::World)
|
||||
{
|
||||
CWorld *pWorld = (CWorld*) It->Load();
|
||||
|
||||
@@ -629,15 +629,15 @@ void CGameExporter::ExportResource(SResourceInstance& rRes)
|
||||
CResourceEntry *pEntry = mpStore->RegisterResource(rRes.ResourceID, CResTypeInfo::TypeForCookedExtension(mGame, rRes.ResourceType)->Type(), Directory, Name);
|
||||
|
||||
// Set flags
|
||||
pEntry->SetFlag(eREF_IsBaseGameResource);
|
||||
pEntry->SetFlagEnabled(eREF_AutoResDir, AutoDir);
|
||||
pEntry->SetFlagEnabled(eREF_AutoResName, AutoName);
|
||||
pEntry->SetFlag(EResEntryFlag::IsBaseGameResource);
|
||||
pEntry->SetFlagEnabled(EResEntryFlag::AutoResDir, AutoDir);
|
||||
pEntry->SetFlagEnabled(EResEntryFlag::AutoResName, AutoName);
|
||||
|
||||
#if EXPORT_COOKED
|
||||
// Save cooked asset
|
||||
TString OutCookedPath = pEntry->CookedAssetPath();
|
||||
FileUtil::MakeDirectory(OutCookedPath.GetFileDirectory());
|
||||
CFileOutStream Out(OutCookedPath, IOUtil::eBigEndian);
|
||||
CFileOutStream Out(OutCookedPath, EEndian::BigEndian);
|
||||
|
||||
if (Out.IsValid())
|
||||
Out.WriteBytes(ResourceData.data(), ResourceData.size());
|
||||
@@ -652,7 +652,7 @@ void CGameExporter::ExportResource(SResourceInstance& rRes)
|
||||
TString CGameExporter::MakeWorldName(CAssetID WorldID)
|
||||
{
|
||||
CResourceEntry *pWorldEntry = mpStore->FindEntry(WorldID);
|
||||
ASSERT(pWorldEntry && pWorldEntry->ResourceType() == eWorld);
|
||||
ASSERT(pWorldEntry && pWorldEntry->ResourceType() == EResourceType::World);
|
||||
|
||||
// Find the original world name in the package resource names
|
||||
TString WorldName;
|
||||
|
||||
@@ -11,11 +11,11 @@
|
||||
#include <map>
|
||||
#include <nod/nod.hpp>
|
||||
|
||||
enum EDiscType
|
||||
enum class EDiscType
|
||||
{
|
||||
eDT_Normal,
|
||||
eDT_WiiDeAsobu,
|
||||
eDT_Trilogy
|
||||
Normal,
|
||||
WiiDeAsobu,
|
||||
Trilogy
|
||||
};
|
||||
|
||||
class CGameExporter
|
||||
|
||||
@@ -26,7 +26,7 @@ bool CGameProject::Save()
|
||||
{
|
||||
mProjFileLock.Release();
|
||||
TString ProjPath = ProjectPath();
|
||||
CXMLWriter Writer(ProjPath, "GameProject", eVer_Current, mGame);
|
||||
CXMLWriter Writer(ProjPath, "GameProject", (int) EProjectVersion::Current, mGame);
|
||||
Serialize(Writer);
|
||||
bool SaveSuccess = Writer.Save();
|
||||
mProjFileLock.Lock(*ProjPath);
|
||||
|
||||
@@ -15,6 +15,15 @@
|
||||
|
||||
namespace nod { class DiscWii; }
|
||||
|
||||
enum class EProjectVersion
|
||||
{
|
||||
Initial,
|
||||
// Add new versions before this line
|
||||
|
||||
Max,
|
||||
Current = EProjectVersion::Max - 1
|
||||
};
|
||||
|
||||
class CGameProject
|
||||
{
|
||||
TString mProjectName;
|
||||
@@ -33,14 +42,6 @@ class CGameProject
|
||||
// in multiple instances of PWE
|
||||
CFileLock mProjFileLock;
|
||||
|
||||
enum EProjectVersion
|
||||
{
|
||||
eVer_Initial,
|
||||
|
||||
eVer_Max,
|
||||
eVer_Current = eVer_Max - 1
|
||||
};
|
||||
|
||||
// Private Constructor
|
||||
CGameProject()
|
||||
: mProjectName("Unnamed Project")
|
||||
|
||||
@@ -7,7 +7,7 @@ COpeningBanner::COpeningBanner(CGameProject *pProj)
|
||||
mWii = mpProj->IsWiiBuild();
|
||||
|
||||
TString BannerPath = mpProj->DiscFilesystemRoot(false) + "opening.bnr";
|
||||
CFileInStream Banner(BannerPath, IOUtil::eBigEndian);
|
||||
CFileInStream Banner(BannerPath, EEndian::BigEndian);
|
||||
|
||||
if (Banner.IsValid())
|
||||
{
|
||||
@@ -20,7 +20,7 @@ TString COpeningBanner::EnglishGameName() const
|
||||
{
|
||||
// opening.bnr stores the game name in a fixed-length buffer. Need to account for
|
||||
// this and prevent the string-reading function from overrunning the buffer
|
||||
CMemoryInStream Banner(mBannerData.data(), mBannerData.size(), IOUtil::eBigEndian);
|
||||
CMemoryInStream Banner(mBannerData.data(), mBannerData.size(), EEndian::BigEndian);
|
||||
|
||||
uint32 CharSize = mWii ? 2 : 1;
|
||||
uint32 MaxLen = MaxGameNameLength();
|
||||
@@ -29,13 +29,13 @@ TString COpeningBanner::EnglishGameName() const
|
||||
Banner.GoTo( mWii ? 0xB0 : 0x1860 );
|
||||
Banner.ReadBytes(NameBuffer.data(), MaxLen * CharSize);
|
||||
|
||||
Banner.SetData(NameBuffer.data(), NameBuffer.size(), IOUtil::eBigEndian);
|
||||
Banner.SetData(NameBuffer.data(), NameBuffer.size(), EEndian::BigEndian);
|
||||
return mWii ? Banner.ReadWString().ToUTF8() : Banner.ReadString();
|
||||
}
|
||||
|
||||
void COpeningBanner::SetEnglishGameName(const TString& rkName)
|
||||
{
|
||||
CMemoryOutStream Banner(mBannerData.data(), mBannerData.size(), IOUtil::eBigEndian);
|
||||
CMemoryOutStream Banner(mBannerData.data(), mBannerData.size(), EEndian::BigEndian);
|
||||
uint32 PadCount = 0;
|
||||
|
||||
uint32 MaxLen = MaxGameNameLength();
|
||||
@@ -61,7 +61,7 @@ void COpeningBanner::SetEnglishGameName(const TString& rkName)
|
||||
void COpeningBanner::Save()
|
||||
{
|
||||
TString BannerPath = mpProj->DiscFilesystemRoot(false) + "opening.bnr";
|
||||
CFileOutStream Banner(BannerPath, IOUtil::eBigEndian);
|
||||
CFileOutStream Banner(BannerPath, EEndian::BigEndian);
|
||||
Banner.WriteBytes(mBannerData.data(), mBannerData.size());
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ void CPackage::Cook(IProgressNotifier *pProgress)
|
||||
|
||||
// Write new pak
|
||||
TString PakPath = CookedPackagePath(false);
|
||||
CFileOutStream Pak(PakPath, IOUtil::eBigEndian);
|
||||
CFileOutStream Pak(PakPath, EEndian::BigEndian);
|
||||
|
||||
if (!Pak.IsValid())
|
||||
{
|
||||
@@ -191,7 +191,7 @@ void CPackage::Cook(IProgressNotifier *pProgress)
|
||||
rTableInfo.Offset = (Game <= EGame::Echoes ? AssetOffset : AssetOffset - ResDataOffset);
|
||||
|
||||
// Load resource data
|
||||
CFileInStream CookedAsset(pEntry->CookedAssetPath(), IOUtil::eBigEndian);
|
||||
CFileInStream CookedAsset(pEntry->CookedAssetPath(), EEndian::BigEndian);
|
||||
ASSERT(CookedAsset.IsValid());
|
||||
uint32 ResourceSize = CookedAsset.Size();
|
||||
|
||||
@@ -200,24 +200,28 @@ void CPackage::Cook(IProgressNotifier *pProgress)
|
||||
|
||||
// Check if this asset should be compressed; there are a few resource types that are
|
||||
// always compressed, and some types that are compressed if they're over a certain size
|
||||
EResType Type = pEntry->ResourceType();
|
||||
EResourceType Type = pEntry->ResourceType();
|
||||
uint32 CompressThreshold = (Game <= EGame::CorruptionProto ? 0x400 : 0x80);
|
||||
|
||||
bool ShouldAlwaysCompress = (Type == eTexture || Type == eModel || Type == eSkin ||
|
||||
Type == eAnimSet || Type == eAnimation || Type == eFont);
|
||||
bool ShouldAlwaysCompress = (Type == EResourceType::Texture || Type == EResourceType::Model ||
|
||||
Type == EResourceType::Skin || Type == EResourceType::AnimSet ||
|
||||
Type == EResourceType::Animation || Type == EResourceType::Font);
|
||||
|
||||
if (Game >= EGame::Corruption)
|
||||
{
|
||||
ShouldAlwaysCompress = ShouldAlwaysCompress ||
|
||||
(Type == eCharacter || Type == eSourceAnimData || Type == eScan ||
|
||||
Type == eAudioSample || Type == eStringTable || Type == eAudioAmplitudeData ||
|
||||
Type == eDynamicCollision);
|
||||
(Type == EResourceType::Character || Type == EResourceType::SourceAnimData ||
|
||||
Type == EResourceType::Scan || Type == EResourceType::AudioSample ||
|
||||
Type == EResourceType::StringTable || Type == EResourceType::AudioAmplitudeData ||
|
||||
Type == EResourceType::DynamicCollision);
|
||||
}
|
||||
|
||||
bool ShouldCompressConditional = !ShouldAlwaysCompress &&
|
||||
(Type == eParticle || Type == eParticleElectric || Type == eParticleSwoosh ||
|
||||
Type == eParticleWeapon || Type == eParticleDecal || Type == eParticleCollisionResponse ||
|
||||
Type == eParticleSpawn || Type == eParticleSorted || Type == eBurstFireData);
|
||||
(Type == EResourceType::Particle || Type == EResourceType::ParticleElectric ||
|
||||
Type == EResourceType::ParticleSwoosh || Type == EResourceType::ParticleWeapon ||
|
||||
Type == EResourceType::ParticleDecal || Type == EResourceType::ParticleCollisionResponse ||
|
||||
Type == EResourceType::ParticleSpawn || Type == EResourceType::ParticleSorted ||
|
||||
Type == EResourceType::BurstFireData);
|
||||
|
||||
bool ShouldCompress = ShouldAlwaysCompress || (ShouldCompressConditional && ResourceSize >= CompressThreshold);
|
||||
|
||||
@@ -342,7 +346,7 @@ void CPackage::CompareOriginalAssetList(const std::list<CAssetID>& rkNewList)
|
||||
|
||||
// Read the original pak
|
||||
TString CookedPath = CookedPackagePath(false);
|
||||
CFileInStream Pak(CookedPath, IOUtil::eBigEndian);
|
||||
CFileInStream Pak(CookedPath, EEndian::BigEndian);
|
||||
|
||||
if (!Pak.IsValid() || Pak.Size() == 0)
|
||||
{
|
||||
@@ -373,7 +377,7 @@ void CPackage::CompareOriginalAssetList(const std::list<CAssetID>& rkNewList)
|
||||
for (uint32 iRes = 0; iRes < NumResources; iRes++)
|
||||
{
|
||||
Pak.Seek(0x8, SEEK_CUR);
|
||||
OldListSet.insert( CAssetID(Pak, e32Bit) );
|
||||
OldListSet.insert( CAssetID(Pak, k32Bit) );
|
||||
Pak.Seek(0x8, SEEK_CUR);
|
||||
}
|
||||
}
|
||||
@@ -397,7 +401,7 @@ void CPackage::CompareOriginalAssetList(const std::list<CAssetID>& rkNewList)
|
||||
for (uint32 iRes = 0; iRes < NumResources; iRes++)
|
||||
{
|
||||
Pak.Seek(0x8, SEEK_CUR);
|
||||
OldListSet.insert( CAssetID(Pak, e64Bit) );
|
||||
OldListSet.insert( CAssetID(Pak, k64Bit) );
|
||||
Pak.Seek(0x8, SEEK_CUR);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,15 @@
|
||||
|
||||
class CGameProject;
|
||||
|
||||
enum class EPackageDefinitionVersion
|
||||
{
|
||||
Initial,
|
||||
// Add new versions before this line
|
||||
|
||||
Max,
|
||||
Current = EPackageDefinitionVersion::Max - 1
|
||||
};
|
||||
|
||||
struct SNamedResource
|
||||
{
|
||||
TString Name;
|
||||
@@ -35,14 +44,6 @@ class CPackage
|
||||
mutable bool mCacheDirty;
|
||||
mutable std::set<CAssetID> mCachedDependencies;
|
||||
|
||||
enum EPackageDefinitionVersion
|
||||
{
|
||||
eVer_Initial,
|
||||
|
||||
eVer_Max,
|
||||
eVer_Current = eVer_Max - 1
|
||||
};
|
||||
|
||||
public:
|
||||
CPackage() {}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ CResourceEntry::CResourceEntry(CResourceStore *pStore)
|
||||
// Static constructors
|
||||
CResourceEntry* CResourceEntry::CreateNewResource(CResourceStore *pStore, const CAssetID& rkID,
|
||||
const TString& rkDir, const TString& rkName,
|
||||
EResType Type)
|
||||
EResourceType Type)
|
||||
{
|
||||
// Initialize all entry info with the input data.
|
||||
CResourceEntry *pEntry = new CResourceEntry(pStore);
|
||||
@@ -257,7 +257,7 @@ bool CResourceEntry::NeedsRecook() const
|
||||
// toggled to arbitrarily flag any asset for recook.
|
||||
if (!HasRawVersion()) return false;
|
||||
if (!HasCookedVersion()) return true;
|
||||
if (HasFlag(eREF_NeedsRecook)) return true;
|
||||
if (HasFlag(EResEntryFlag::NeedsRecook)) return true;
|
||||
return (FileUtil::LastModifiedTime(CookedAssetPath()) < FileUtil::LastModifiedTime(RawAssetPath()));
|
||||
}
|
||||
|
||||
@@ -298,7 +298,7 @@ bool CResourceEntry::Save(bool SkipCacheSave /*= false*/)
|
||||
return false;
|
||||
}
|
||||
|
||||
SetFlag(eREF_NeedsRecook);
|
||||
SetFlag(EResEntryFlag::NeedsRecook);
|
||||
}
|
||||
|
||||
// This resource type doesn't have a raw format; save cooked instead
|
||||
@@ -314,7 +314,7 @@ bool CResourceEntry::Save(bool SkipCacheSave /*= false*/)
|
||||
}
|
||||
|
||||
// Resource has been saved; now make sure metadata, dependencies, and packages are all up to date
|
||||
SetFlag(eREF_HasBeenModified);
|
||||
SetFlag(EResEntryFlag::HasBeenModified);
|
||||
SaveMetadata();
|
||||
UpdateDependencies();
|
||||
|
||||
@@ -348,7 +348,7 @@ bool CResourceEntry::Cook()
|
||||
FileUtil::MakeDirectory(Dir);
|
||||
|
||||
// Attempt to open output cooked file
|
||||
CFileOutStream File(Path, IOUtil::eBigEndian);
|
||||
CFileOutStream File(Path, EEndian::BigEndian);
|
||||
if (!File.IsValid())
|
||||
{
|
||||
errorf("Failed to open cooked file for writing: %s", *Path);
|
||||
@@ -359,8 +359,8 @@ bool CResourceEntry::Cook()
|
||||
|
||||
if (Success)
|
||||
{
|
||||
ClearFlag(eREF_NeedsRecook);
|
||||
SetFlag(eREF_HasBeenModified);
|
||||
ClearFlag(EResEntryFlag::NeedsRecook);
|
||||
SetFlag(EResEntryFlag::HasBeenModified);
|
||||
SaveMetadata();
|
||||
}
|
||||
|
||||
@@ -409,7 +409,7 @@ CResource* CResourceEntry::Load()
|
||||
ASSERT(!mpResource);
|
||||
if (HasCookedVersion())
|
||||
{
|
||||
CFileInStream File(CookedAssetPath(), IOUtil::eBigEndian);
|
||||
CFileInStream File(CookedAssetPath(), EEndian::BigEndian);
|
||||
|
||||
if (!File.IsValid())
|
||||
{
|
||||
@@ -571,12 +571,12 @@ bool CResourceEntry::MoveAndRename(const TString& rkDir, const TString& rkName,
|
||||
FSMoveSuccess = pOldDir->RemoveChildResource(this);
|
||||
ASSERT(FSMoveSuccess == true); // this shouldn't be able to fail
|
||||
mpDirectory->AddChild("", this);
|
||||
SetFlagEnabled(eREF_AutoResDir, IsAutoGenDir);
|
||||
SetFlagEnabled(EResEntryFlag::AutoResDir, IsAutoGenDir);
|
||||
}
|
||||
|
||||
if (mName != OldName)
|
||||
{
|
||||
SetFlagEnabled(eREF_AutoResName, IsAutoGenName);
|
||||
SetFlagEnabled(EResEntryFlag::AutoResName, IsAutoGenName);
|
||||
}
|
||||
|
||||
mpStore->SetCacheDirty();
|
||||
|
||||
@@ -13,14 +13,14 @@ class CResource;
|
||||
class CGameProject;
|
||||
class CDependencyTree;
|
||||
|
||||
enum EResEntryFlag
|
||||
enum class EResEntryFlag
|
||||
{
|
||||
eREF_NeedsRecook = 0x00000001, // Resource has been updated but not recooked
|
||||
eREF_IsBaseGameResource = 0x00000002, // Resource is from the original game, not user-created
|
||||
eREF_Hidden = 0x00000004, // Resource is hidden, doesn't show up in resource browser
|
||||
eREF_HasBeenModified = 0x00000008, // Resource has been modified and resaved by the user
|
||||
eREF_AutoResName = 0x00000010, // Resource name is auto-generated
|
||||
eREF_AutoResDir = 0x00000020, // Resource directory name is auto-generated
|
||||
NeedsRecook = 0x00000001, // Resource has been updated but not recooked
|
||||
IsBaseGameResource = 0x00000002, // Resource is from the original game, not user-created
|
||||
Hidden = 0x00000004, // Resource is hidden, doesn't show up in resource browser
|
||||
HasBeenModified = 0x00000008, // Resource has been modified and resaved by the user
|
||||
AutoResName = 0x00000010, // Resource name is auto-generated
|
||||
AutoResDir = 0x00000020, // Resource directory name is auto-generated
|
||||
};
|
||||
DECLARE_FLAGS(EResEntryFlag, FResEntryFlags)
|
||||
|
||||
@@ -45,7 +45,7 @@ class CResourceEntry
|
||||
public:
|
||||
static CResourceEntry* CreateNewResource(CResourceStore *pStore, const CAssetID& rkID,
|
||||
const TString& rkDir, const TString& rkName,
|
||||
EResType Type);
|
||||
EResourceType Type);
|
||||
static CResourceEntry* BuildFromArchive(CResourceStore *pStore, IArchive& rArc);
|
||||
static CResourceEntry* BuildFromDirectory(CResourceStore *pStore, CResTypeInfo *pTypeInfo,
|
||||
const TString& rkDirPath, const TString& rkName);
|
||||
@@ -86,10 +86,10 @@ public:
|
||||
// Accessors
|
||||
inline void SetFlagEnabled(EResEntryFlag Flag, bool Enabled) { Enabled ? SetFlag(Flag) : ClearFlag(Flag); }
|
||||
|
||||
inline void SetDirty() { SetFlag(eREF_NeedsRecook); }
|
||||
inline void SetHidden(bool Hidden) { Hidden ? SetFlag(eREF_Hidden) : ClearFlag(eREF_Hidden); }
|
||||
inline void SetDirty() { SetFlag(EResEntryFlag::NeedsRecook); }
|
||||
inline void SetHidden(bool Hidden) { Hidden ? SetFlag(EResEntryFlag::Hidden) : ClearFlag(EResEntryFlag::Hidden); }
|
||||
inline bool HasFlag(EResEntryFlag Flag) const { return mFlags.HasFlag(Flag); }
|
||||
inline bool IsHidden() const { return HasFlag(eREF_Hidden); }
|
||||
inline bool IsHidden() const { return HasFlag(EResEntryFlag::Hidden); }
|
||||
|
||||
inline bool IsLoaded() const { return mpResource != nullptr; }
|
||||
inline bool IsCategorized() const { return mpDirectory && !mpDirectory->FullPath().CaseInsensitiveCompare( mpStore->DefaultResourceDirPath() ); }
|
||||
@@ -103,7 +103,7 @@ public:
|
||||
inline TString DirectoryPath() const { return mpDirectory->FullPath(); }
|
||||
inline TString Name() const { return mName; }
|
||||
inline const TString& UppercaseName() const { return mCachedUppercaseName; }
|
||||
inline EResType ResourceType() const { return mpTypeInfo->Type(); }
|
||||
inline EResourceType ResourceType() const { return mpTypeInfo->Type(); }
|
||||
|
||||
protected:
|
||||
CResource* InternalLoad(IInputStream& rInput);
|
||||
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
template<EResType ResType>
|
||||
template<EResourceType ResType>
|
||||
class TResourceIterator : public CResourceIterator
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -384,7 +384,7 @@ bool CResourceStore::IsResourceRegistered(const CAssetID& rkID) const
|
||||
return FindEntry(rkID) != nullptr;
|
||||
}
|
||||
|
||||
CResourceEntry* CResourceStore::RegisterResource(const CAssetID& rkID, EResType Type, const TString& rkDir, const TString& rkName)
|
||||
CResourceEntry* CResourceStore::RegisterResource(const CAssetID& rkID, EResourceType Type, const TString& rkDir, const TString& rkName)
|
||||
{
|
||||
CResourceEntry *pEntry = FindEntry(rkID);
|
||||
|
||||
@@ -424,7 +424,7 @@ CResource* CResourceStore::LoadResource(const CAssetID& rkID)
|
||||
}
|
||||
}
|
||||
|
||||
CResource* CResourceStore::LoadResource(const CAssetID& rkID, EResType Type)
|
||||
CResource* CResourceStore::LoadResource(const CAssetID& rkID, EResourceType Type)
|
||||
{
|
||||
CResource *pRes = LoadResource(rkID);
|
||||
|
||||
|
||||
@@ -14,6 +14,15 @@ class CGameExporter;
|
||||
class CGameProject;
|
||||
class CResource;
|
||||
|
||||
enum class EDatabaseVersion
|
||||
{
|
||||
Initial,
|
||||
// Add new versions before this line
|
||||
|
||||
Max,
|
||||
Current = EDatabaseVersion::Max - 1
|
||||
};
|
||||
|
||||
class CResourceStore
|
||||
{
|
||||
friend class CResourceIterator;
|
||||
@@ -28,14 +37,6 @@ class CResourceStore
|
||||
// Directory paths
|
||||
TString mDatabasePath;
|
||||
|
||||
enum EDatabaseVersion
|
||||
{
|
||||
eVer_Initial,
|
||||
|
||||
eVer_Max,
|
||||
eVer_Current = eVer_Max - 1
|
||||
};
|
||||
|
||||
public:
|
||||
CResourceStore(const TString& rkDatabasePath);
|
||||
CResourceStore(CGameProject *pProject);
|
||||
@@ -53,7 +54,7 @@ public:
|
||||
TString DefaultResourceDirPath() const;
|
||||
|
||||
bool IsResourceRegistered(const CAssetID& rkID) const;
|
||||
CResourceEntry* RegisterResource(const CAssetID& rkID, EResType Type, const TString& rkDir, const TString& rkName);
|
||||
CResourceEntry* RegisterResource(const CAssetID& rkID, EResourceType Type, const TString& rkDir, const TString& rkName);
|
||||
CResourceEntry* FindEntry(const CAssetID& rkID) const;
|
||||
CResourceEntry* FindEntry(const TString& rkPath) const;
|
||||
bool AreAllEntriesValid() const;
|
||||
@@ -63,7 +64,7 @@ public:
|
||||
|
||||
template<typename ResType> ResType* LoadResource(const CAssetID& rkID) { return static_cast<ResType*>(LoadResource(rkID, ResType::StaticType())); }
|
||||
CResource* LoadResource(const CAssetID& rkID);
|
||||
CResource* LoadResource(const CAssetID& rkID, EResType Type);
|
||||
CResource* LoadResource(const CAssetID& rkID, EResourceType Type);
|
||||
CResource* LoadResource(const TString& rkPath);
|
||||
void TrackLoadedResource(CResourceEntry *pEntry);
|
||||
void DestroyUnreferencedResources();
|
||||
|
||||
@@ -117,14 +117,14 @@ CResourceEntry* CVirtualDirectory::FindChildResource(const TString& rkPath)
|
||||
else if (!Name.IsEmpty())
|
||||
{
|
||||
TString Ext = Name.GetFileExtension();
|
||||
EResType Type = CResTypeInfo::TypeForCookedExtension(mpStore->Game(), Ext)->Type();
|
||||
EResourceType Type = CResTypeInfo::TypeForCookedExtension(mpStore->Game(), Ext)->Type();
|
||||
return FindChildResource(Name.GetFileName(false), Type);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CResourceEntry* CVirtualDirectory::FindChildResource(const TString& rkName, EResType Type)
|
||||
CResourceEntry* CVirtualDirectory::FindChildResource(const TString& rkName, EResourceType Type)
|
||||
{
|
||||
for (uint32 iRes = 0; iRes < mResources.size(); iRes++)
|
||||
{
|
||||
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
CVirtualDirectory* GetRoot();
|
||||
CVirtualDirectory* FindChildDirectory(const TString& rkName, bool AllowCreate);
|
||||
CResourceEntry* FindChildResource(const TString& rkPath);
|
||||
CResourceEntry* FindChildResource(const TString& rkName, EResType Type);
|
||||
CResourceEntry* FindChildResource(const TString& rkName, EResourceType Type);
|
||||
bool AddChild(const TString& rkPath, CResourceEntry *pEntry);
|
||||
bool AddChild(CVirtualDirectory *pDir);
|
||||
bool RemoveChildDirectory(CVirtualDirectory *pSubdir);
|
||||
|
||||
@@ -35,7 +35,7 @@ void CCharacterUsageMap::FindUsagesForAsset(CResourceEntry *pEntry)
|
||||
|
||||
void CCharacterUsageMap::FindUsagesForArea(CWorld *pWorld, CResourceEntry *pEntry)
|
||||
{
|
||||
ASSERT(pEntry->ResourceType() == eArea);
|
||||
ASSERT(pEntry->ResourceType() == EResourceType::Area);
|
||||
|
||||
for (uint32 iArea = 0; iArea < pWorld->NumAreas(); iArea++)
|
||||
{
|
||||
@@ -59,7 +59,7 @@ void CCharacterUsageMap::FindUsagesForArea(CWorld *pWorld, uint32 AreaIndex)
|
||||
|
||||
CAssetID AreaID = pWorld->AreaResourceID(iArea);
|
||||
CResourceEntry *pEntry = mpStore->FindEntry(AreaID);
|
||||
ASSERT(pEntry && pEntry->ResourceType() == eArea);
|
||||
ASSERT(pEntry && pEntry->ResourceType() == EResourceType::Area);
|
||||
|
||||
ParseDependencyNode(pEntry->Dependencies());
|
||||
mIsInitialArea = false;
|
||||
@@ -72,7 +72,7 @@ void CCharacterUsageMap::FindUsagesForLayer(CResourceEntry *pAreaEntry, uint32 L
|
||||
mLayerIndex = LayerIndex;
|
||||
|
||||
CAreaDependencyTree *pTree = static_cast<CAreaDependencyTree*>(pAreaEntry->Dependencies());
|
||||
ASSERT(pTree->Type() == eDNT_Area);
|
||||
ASSERT(pTree->Type() == EDependencyNodeType::Area);
|
||||
|
||||
// Only examine dependencies of the particular layer specified by the caller
|
||||
bool IsLastLayer = (mLayerIndex == pTree->NumScriptLayers() - 1);
|
||||
@@ -115,7 +115,7 @@ void CCharacterUsageMap::ParseDependencyNode(IDependencyNode *pNode)
|
||||
{
|
||||
EDependencyNodeType Type = pNode->Type();
|
||||
|
||||
if (Type == eDNT_CharacterProperty)
|
||||
if (Type == EDependencyNodeType::CharacterProperty)
|
||||
{
|
||||
CCharPropertyDependency *pDep = static_cast<CCharPropertyDependency*>(pNode);
|
||||
CAssetID ResID = pDep->ID();
|
||||
@@ -150,12 +150,12 @@ void CCharacterUsageMap::ParseDependencyNode(IDependencyNode *pNode)
|
||||
}
|
||||
|
||||
// Parse dependencies of the referenced resource if it's a type that can reference animsets
|
||||
else if (Type == eDNT_ResourceDependency || Type == eDNT_ScriptProperty)
|
||||
else if (Type == EDependencyNodeType::Resource || Type == EDependencyNodeType::ScriptProperty)
|
||||
{
|
||||
CResourceDependency *pDep = static_cast<CResourceDependency*>(pNode);
|
||||
CResourceEntry *pEntry = mpStore->FindEntry(pDep->ID());
|
||||
|
||||
if (pEntry && pEntry->ResourceType() == eScan)
|
||||
if (pEntry && pEntry->ResourceType() == EResourceType::Scan)
|
||||
{
|
||||
ParseDependencyNode(pEntry->Dependencies());
|
||||
}
|
||||
@@ -206,17 +206,17 @@ void CPackageDependencyListBuilder::BuildDependencyList(bool AllowDuplicates, st
|
||||
|
||||
void CPackageDependencyListBuilder::AddDependency(CResourceEntry *pCurEntry, const CAssetID& rkID, std::list<CAssetID>& rOut)
|
||||
{
|
||||
if (pCurEntry && pCurEntry->ResourceType() == eDependencyGroup) return;
|
||||
if (pCurEntry && pCurEntry->ResourceType() == EResourceType::DependencyGroup) return;
|
||||
CResourceEntry *pEntry = mpStore->FindEntry(rkID);
|
||||
if (!pEntry) return;
|
||||
|
||||
EResType ResType = pEntry->ResourceType();
|
||||
EResourceType ResType = pEntry->ResourceType();
|
||||
|
||||
// Is this entry valid?
|
||||
bool IsValid = ResType != eMidi &&
|
||||
(ResType != eAudioGroup || mGame >= EGame::EchoesDemo) &&
|
||||
(ResType != eWorld || !pCurEntry) &&
|
||||
(ResType != eArea || !pCurEntry || pCurEntry->ResourceType() == eWorld);
|
||||
bool IsValid = ResType != EResourceType::Midi &&
|
||||
(ResType != EResourceType::AudioGroup || mGame >= EGame::EchoesDemo) &&
|
||||
(ResType != EResourceType::World || !pCurEntry) &&
|
||||
(ResType != EResourceType::Area || !pCurEntry || pCurEntry->ResourceType() == EResourceType::World);
|
||||
|
||||
if (!IsValid) return;
|
||||
|
||||
@@ -230,7 +230,7 @@ void CPackageDependencyListBuilder::AddDependency(CResourceEntry *pCurEntry, con
|
||||
mAreaUsedAssets.insert(rkID);
|
||||
|
||||
// New area - toggle duplicates and find character usages
|
||||
if (ResType == eArea)
|
||||
if (ResType == EResourceType::Area)
|
||||
{
|
||||
if (mGame <= EGame::Echoes)
|
||||
mCharacterUsageMap.FindUsagesForArea(mpWorld, pEntry);
|
||||
@@ -252,7 +252,7 @@ void CPackageDependencyListBuilder::AddDependency(CResourceEntry *pCurEntry, con
|
||||
}
|
||||
|
||||
// Animset - keep track of the current animset ID
|
||||
else if (ResType == eAnimSet)
|
||||
else if (ResType == EResourceType::AnimSet)
|
||||
mCurrentAnimSetID = rkID;
|
||||
|
||||
// Evaluate dependencies of this entry
|
||||
@@ -261,11 +261,11 @@ void CPackageDependencyListBuilder::AddDependency(CResourceEntry *pCurEntry, con
|
||||
rOut.push_back(rkID);
|
||||
|
||||
// Revert current animset ID
|
||||
if (ResType == eAnimSet)
|
||||
if (ResType == EResourceType::AnimSet)
|
||||
mCurrentAnimSetID = CAssetID::InvalidID(mGame);
|
||||
|
||||
// Revert duplicate flag
|
||||
else if (ResType == eArea)
|
||||
else if (ResType == EResourceType::Area)
|
||||
mCurrentAreaHasDuplicates = false;
|
||||
}
|
||||
|
||||
@@ -275,14 +275,14 @@ void CPackageDependencyListBuilder::EvaluateDependencyNode(CResourceEntry *pCurE
|
||||
bool ParseChildren = false;
|
||||
|
||||
// Straight resource dependencies should just be added to the tree directly
|
||||
if (Type == eDNT_ResourceDependency || Type == eDNT_ScriptProperty || Type == eDNT_CharacterProperty)
|
||||
if (Type == EDependencyNodeType::Resource || Type == EDependencyNodeType::ScriptProperty || Type == EDependencyNodeType::CharacterProperty)
|
||||
{
|
||||
CResourceDependency *pDep = static_cast<CResourceDependency*>(pNode);
|
||||
AddDependency(pCurEntry, pDep->ID(), rOut);
|
||||
}
|
||||
|
||||
// Anim events should be added if either they apply to characters, or their character index is used
|
||||
else if (Type == eDNT_AnimEvent)
|
||||
else if (Type == EDependencyNodeType::AnimEvent)
|
||||
{
|
||||
CAnimEventDependency *pDep = static_cast<CAnimEventDependency*>(pNode);
|
||||
uint32 CharIndex = pDep->CharIndex();
|
||||
@@ -292,14 +292,14 @@ void CPackageDependencyListBuilder::EvaluateDependencyNode(CResourceEntry *pCurE
|
||||
}
|
||||
|
||||
// Set characters should only be added if their character index is used
|
||||
else if (Type == eDNT_SetCharacter)
|
||||
else if (Type == EDependencyNodeType::SetCharacter)
|
||||
{
|
||||
CSetCharacterDependency *pChar = static_cast<CSetCharacterDependency*>(pNode);
|
||||
ParseChildren = mCharacterUsageMap.IsCharacterUsed(mCurrentAnimSetID, pChar->CharSetIndex()) || mIsPlayerActor;
|
||||
}
|
||||
|
||||
// Set animations should only be added if they're being used by at least one used character
|
||||
else if (Type == eDNT_SetAnimation)
|
||||
else if (Type == EDependencyNodeType::SetAnimation)
|
||||
{
|
||||
CSetAnimationDependency *pAnim = static_cast<CSetAnimationDependency*>(pNode);
|
||||
ParseChildren = mCharacterUsageMap.IsAnimationUsed(mCurrentAnimSetID, pAnim) || (mIsPlayerActor && pAnim->IsUsedByAnyCharacter());
|
||||
@@ -311,7 +311,7 @@ void CPackageDependencyListBuilder::EvaluateDependencyNode(CResourceEntry *pCurE
|
||||
// Analyze this node's children
|
||||
if (ParseChildren)
|
||||
{
|
||||
if (Type == eDNT_ScriptInstance)
|
||||
if (Type == EDependencyNodeType::ScriptInstance)
|
||||
{
|
||||
uint32 ObjType = static_cast<CScriptInstanceDependency*>(pNode)->ObjectType();
|
||||
mIsPlayerActor = (ObjType == 0x4C || ObjType == FOURCC('PLAC'));
|
||||
@@ -320,7 +320,7 @@ void CPackageDependencyListBuilder::EvaluateDependencyNode(CResourceEntry *pCurE
|
||||
for (uint32 iChild = 0; iChild < pNode->NumChildren(); iChild++)
|
||||
EvaluateDependencyNode(pCurEntry, pNode->ChildByIndex(iChild), rOut);
|
||||
|
||||
if (Type == eDNT_ScriptInstance)
|
||||
if (Type == EDependencyNodeType::ScriptInstance)
|
||||
mIsPlayerActor = false;
|
||||
}
|
||||
}
|
||||
@@ -388,7 +388,7 @@ void CAreaDependencyListBuilder::BuildDependencyList(std::list<CAssetID>& rAsset
|
||||
for (uint32 iDep = 0; iDep < BaseEndIndex; iDep++)
|
||||
{
|
||||
CResourceDependency *pRes = static_cast<CResourceDependency*>(pTree->ChildByIndex(iDep));
|
||||
ASSERT(pRes->Type() == eDNT_ResourceDependency);
|
||||
ASSERT(pRes->Type() == EDependencyNodeType::Resource);
|
||||
mBaseUsedAssets.insert(pRes->ID());
|
||||
}
|
||||
|
||||
@@ -407,7 +407,7 @@ void CAreaDependencyListBuilder::BuildDependencyList(std::list<CAssetID>& rAsset
|
||||
{
|
||||
IDependencyNode *pNode = pTree->ChildByIndex(iChild);
|
||||
|
||||
if (pNode->Type() == eDNT_ScriptInstance)
|
||||
if (pNode->Type() == EDependencyNodeType::ScriptInstance)
|
||||
{
|
||||
CScriptInstanceDependency *pInst = static_cast<CScriptInstanceDependency*>(pNode);
|
||||
mIsPlayerActor = (pInst->ObjectType() == 0x4C || pInst->ObjectType() == FOURCC('PLAC'));
|
||||
@@ -435,7 +435,7 @@ void CAreaDependencyListBuilder::BuildDependencyList(std::list<CAssetID>& rAsset
|
||||
AddDependency(pDep->ID(), rAssetsOut, pAudioGroupsOut);
|
||||
}
|
||||
}
|
||||
else if (pNode->Type() == eDNT_ResourceDependency)
|
||||
else if (pNode->Type() == EDependencyNodeType::Resource)
|
||||
{
|
||||
CResourceDependency *pResDep = static_cast<CResourceDependency*>(pNode);
|
||||
AddDependency(pResDep->ID(), rAssetsOut, pAudioGroupsOut);
|
||||
@@ -464,10 +464,10 @@ void CAreaDependencyListBuilder::AddDependency(const CAssetID& rkID, std::list<C
|
||||
CResourceEntry *pEntry = mpStore->FindEntry(rkID);
|
||||
if (!pEntry) return;
|
||||
|
||||
EResType ResType = pEntry->ResourceType();
|
||||
EResourceType ResType = pEntry->ResourceType();
|
||||
|
||||
// If this is an audio group, for MP1, save it in the output set. For MP2, treat audio groups as a normal dependency.
|
||||
if (mGame <= EGame::Prime && ResType == eAudioGroup)
|
||||
if (mGame <= EGame::Prime && ResType == EResourceType::AudioGroup)
|
||||
{
|
||||
if (pAudioGroupsOut)
|
||||
pAudioGroupsOut->insert(rkID);
|
||||
@@ -475,20 +475,20 @@ void CAreaDependencyListBuilder::AddDependency(const CAssetID& rkID, std::list<C
|
||||
}
|
||||
|
||||
// If this is an audio stream, skip
|
||||
if (ResType == eStreamedAudio)
|
||||
if (ResType == EResourceType::StreamedAudio)
|
||||
return;
|
||||
|
||||
// Check to ensure this is a valid/new dependency
|
||||
if (ResType == eWorld || ResType == eArea)
|
||||
if (ResType == EResourceType::World || ResType == EResourceType::Area)
|
||||
return;
|
||||
|
||||
if (mBaseUsedAssets.find(rkID) != mBaseUsedAssets.end() || mLayerUsedAssets.find(rkID) != mLayerUsedAssets.end())
|
||||
return;
|
||||
|
||||
// Dependency is valid! Evaluate the node tree (except for SCAN and DGRP)
|
||||
if (ResType != eScan && ResType != eDependencyGroup)
|
||||
if (ResType != EResourceType::Scan && ResType != EResourceType::DependencyGroup)
|
||||
{
|
||||
if (ResType == eAnimSet)
|
||||
if (ResType == EResourceType::AnimSet)
|
||||
{
|
||||
ASSERT(!mCurrentAnimSetID.IsValid());
|
||||
mCurrentAnimSetID = pEntry->ID();
|
||||
@@ -496,7 +496,7 @@ void CAreaDependencyListBuilder::AddDependency(const CAssetID& rkID, std::list<C
|
||||
|
||||
EvaluateDependencyNode(pEntry, pEntry->Dependencies(), rOut, pAudioGroupsOut);
|
||||
|
||||
if (ResType == eAnimSet)
|
||||
if (ResType == EResourceType::AnimSet)
|
||||
{
|
||||
ASSERT(mCurrentAnimSetID.IsValid());
|
||||
mCurrentAnimSetID = CAssetID::InvalidID(mGame);
|
||||
@@ -504,7 +504,7 @@ void CAreaDependencyListBuilder::AddDependency(const CAssetID& rkID, std::list<C
|
||||
}
|
||||
|
||||
// Don't add CSNGs to the output dependency list (we parse them because we need their AGSC dependencies in the output AudioGroup set)
|
||||
if (ResType != eMidi)
|
||||
if (ResType != EResourceType::Midi)
|
||||
{
|
||||
rOut.push_back(rkID);
|
||||
mLayerUsedAssets.insert(rkID);
|
||||
@@ -516,13 +516,13 @@ void CAreaDependencyListBuilder::EvaluateDependencyNode(CResourceEntry *pCurEntr
|
||||
EDependencyNodeType Type = pNode->Type();
|
||||
bool ParseChildren = false;
|
||||
|
||||
if (Type == eDNT_ResourceDependency || Type == eDNT_ScriptProperty || Type == eDNT_CharacterProperty)
|
||||
if (Type == EDependencyNodeType::Resource || Type == EDependencyNodeType::ScriptProperty || Type == EDependencyNodeType::CharacterProperty)
|
||||
{
|
||||
CResourceDependency *pDep = static_cast<CResourceDependency*>(pNode);
|
||||
AddDependency(pDep->ID(), rOut, pAudioGroupsOut);
|
||||
}
|
||||
|
||||
else if (Type == eDNT_AnimEvent)
|
||||
else if (Type == EDependencyNodeType::AnimEvent)
|
||||
{
|
||||
CAnimEventDependency *pDep = static_cast<CAnimEventDependency*>(pNode);
|
||||
uint32 CharIndex = pDep->CharIndex();
|
||||
@@ -531,7 +531,7 @@ void CAreaDependencyListBuilder::EvaluateDependencyNode(CResourceEntry *pCurEntr
|
||||
AddDependency(pDep->ID(), rOut, pAudioGroupsOut);
|
||||
}
|
||||
|
||||
else if (Type == eDNT_SetCharacter)
|
||||
else if (Type == EDependencyNodeType::SetCharacter)
|
||||
{
|
||||
// Note: For MP1/2 PlayerActor, always treat as if Empty Suit is the only used one
|
||||
const uint32 kEmptySuitIndex = (mGame >= EGame::EchoesDemo ? 3 : 5);
|
||||
@@ -541,7 +541,7 @@ void CAreaDependencyListBuilder::EvaluateDependencyNode(CResourceEntry *pCurEntr
|
||||
ParseChildren = mCharacterUsageMap.IsCharacterUsed(mCurrentAnimSetID, pChar->CharSetIndex()) || (mIsPlayerActor && SetIndex == kEmptySuitIndex);
|
||||
}
|
||||
|
||||
else if (Type == eDNT_SetAnimation)
|
||||
else if (Type == EDependencyNodeType::SetAnimation)
|
||||
{
|
||||
CSetAnimationDependency *pAnim = static_cast<CSetAnimationDependency*>(pNode);
|
||||
ParseChildren = mCharacterUsageMap.IsAnimationUsed(mCurrentAnimSetID, pAnim) || (mIsPlayerActor && pAnim->IsUsedByAnyCharacter());
|
||||
|
||||
@@ -88,7 +88,7 @@ public:
|
||||
, mGame(pAreaEntry->Game())
|
||||
, mCharacterUsageMap(pAreaEntry->ResourceStore())
|
||||
{
|
||||
ASSERT(mpAreaEntry->ResourceType() == eArea);
|
||||
ASSERT(mpAreaEntry->ResourceType() == EResourceType::Area);
|
||||
}
|
||||
|
||||
void BuildDependencyList(std::list<CAssetID>& rAssetsOut, std::list<uint32>& rLayerOffsetsOut, std::set<CAssetID> *pAudioGroupsOut = nullptr);
|
||||
|
||||
Reference in New Issue
Block a user