Unify directory structure for cooked/raw assets
This commit is contained in:
parent
4dc11023df
commit
c6e6ccaa89
|
@ -71,8 +71,7 @@ bool CGameExporter::Export(nod::DiscBase *pDisc, const TString& rkOutputDir, CAs
|
|||
|
||||
mpProject->SetProjectName(mGameName);
|
||||
mpStore = mpProject->ResourceStore();
|
||||
mContentDir = mpStore->RawDir(false);
|
||||
mCookedDir = mpStore->CookedDir(false);
|
||||
mResourcesDir = mpStore->ResourcesDir();
|
||||
|
||||
CResourceStore *pOldStore = gpResourceStore;
|
||||
gpResourceStore = mpStore;
|
||||
|
@ -467,7 +466,7 @@ void CGameExporter::LoadResource(const SResourceInstance& rkResource, std::vecto
|
|||
void CGameExporter::ExportCookedResources()
|
||||
{
|
||||
SCOPED_TIMER(ExportCookedResources);
|
||||
FileUtil::MakeDirectory(mCookedDir);
|
||||
FileUtil::MakeDirectory(mResourcesDir);
|
||||
|
||||
mpProgress->SetTask(eES_ExportCooked, "Unpacking cooked assets");
|
||||
int ResIndex = 0;
|
||||
|
@ -502,7 +501,7 @@ void CGameExporter::ExportResourceEditorData()
|
|||
for (CResourceIterator It(mpStore); It && !mpProgress->ShouldCancel(); ++It, ++ResIndex)
|
||||
{
|
||||
// Update progress
|
||||
if ((ResIndex & 0x3) == 0)
|
||||
if ((ResIndex & 0x3) == 0 || It->ResourceType() == eArea)
|
||||
mpProgress->Report(ResIndex, mpStore->NumTotalResources(), TString::Format("Processing asset %d/%d: %s",
|
||||
ResIndex, mpStore->NumTotalResources(), *It->CookedAssetPath(true).GetFileName()) );
|
||||
|
||||
|
|
|
@ -31,8 +31,7 @@ class CGameExporter
|
|||
// Directories
|
||||
TString mExportDir;
|
||||
TString mDiscDir;
|
||||
TString mContentDir;
|
||||
TString mCookedDir;
|
||||
TString mResourcesDir;
|
||||
|
||||
TString mWorldsDirName;
|
||||
|
||||
|
|
|
@ -211,7 +211,7 @@ CGameProject* CGameProject::CreateProjectForExport(
|
|||
|
||||
pProj->mProjectRoot = rkProjRootDir;
|
||||
pProj->mProjectRoot.Replace("\\", "/");
|
||||
pProj->mpResourceStore = new CResourceStore(pProj, "Content/", "Cooked/", Game);
|
||||
pProj->mpResourceStore = new CResourceStore(pProj);
|
||||
pProj->mpGameInfo->LoadGameInfo(Game);
|
||||
pProj->mLoadSuccess = true;
|
||||
return pProj;
|
||||
|
|
|
@ -90,8 +90,8 @@ public:
|
|||
inline TString ProjectRoot() const { return mProjectRoot; }
|
||||
inline TString ResourceDBPath(bool Relative) const { return Relative ? mResourceDBPath : mProjectRoot + mResourceDBPath; }
|
||||
inline TString DiscDir(bool Relative) const { return Relative ? "Disc/" : mProjectRoot + "Disc/"; }
|
||||
inline TString CacheDir(bool Relative) const { return Relative ? "Cache/" : mProjectRoot + "Cache/"; }
|
||||
inline TString PackagesDir(bool Relative) const { return Relative ? "Packages/" : mProjectRoot + "Packages/"; }
|
||||
inline TString ResourcesDir(bool Relative) const { return Relative ? "Resources/" : mProjectRoot + "Resources/"; }
|
||||
inline TString ProjectPath() const { return mProjectRoot + FileUtil::SanitizeName(mProjectName, false) + ".prj"; }
|
||||
inline TString ResourceCachePath(bool Relative) const { return ResourceDBPath(Relative).GetFileDirectory() + "ResourceCacheData.rcd"; }
|
||||
|
||||
|
|
|
@ -92,15 +92,12 @@ bool CResourceEntry::HasCookedVersion() const
|
|||
|
||||
TString CResourceEntry::RawAssetPath(bool Relative) const
|
||||
{
|
||||
TString Ext = RawExtension();
|
||||
TString Path = mpDirectory ? mpDirectory->FullPath() : "";
|
||||
TString Name = mName + "." + Ext;
|
||||
return Relative ? Path + Name : mpStore->RawDir(false) + Path + Name;
|
||||
return CookedAssetPath(Relative) + ".raw";
|
||||
}
|
||||
|
||||
TString CResourceEntry::RawExtension() const
|
||||
{
|
||||
return mpTypeInfo->RawExtension();
|
||||
return CookedExtension().ToString() + ".raw";
|
||||
}
|
||||
|
||||
TString CResourceEntry::CookedAssetPath(bool Relative) const
|
||||
|
@ -108,7 +105,7 @@ TString CResourceEntry::CookedAssetPath(bool Relative) const
|
|||
TString Ext = CookedExtension().ToString();
|
||||
TString Path = mpDirectory ? mpDirectory->FullPath() : "";
|
||||
TString Name = mName + "." + Ext;
|
||||
return Relative ? Path + Name : mpStore->CookedDir(false) + Path + Name;
|
||||
return Relative ? Path + Name : mpStore->ResourcesDir() + Path + Name;
|
||||
}
|
||||
|
||||
CFourCC CResourceEntry::CookedExtension() const
|
||||
|
@ -383,7 +380,7 @@ bool CResourceEntry::Move(const TString& rkDir, const TString& rkName)
|
|||
TString NewCookedPath = CookedAssetPath();
|
||||
TString NewRawPath = RawAssetPath();
|
||||
|
||||
Log::Write("MOVING RESOURCE: " + FileUtil::MakeRelative(OldCookedPath, mpStore->CookedDir(false)) + " --> " + FileUtil::MakeRelative(NewCookedPath, mpStore->CookedDir(false)));
|
||||
Log::Write("MOVING RESOURCE: " + FileUtil::MakeRelative(OldCookedPath, mpStore->ResourcesDir()) + " --> " + FileUtil::MakeRelative(NewCookedPath, mpStore->ResourcesDir()));
|
||||
|
||||
// If the old/new paths are the same then we should have already exited as CanMoveTo() should have returned false
|
||||
ASSERT(OldCookedPath != NewCookedPath && OldRawPath != NewRawPath);
|
||||
|
@ -432,7 +429,6 @@ bool CResourceEntry::Move(const TString& rkDir, const TString& rkName)
|
|||
FSMoveSuccess = pOldDir->RemoveChildResource(this);
|
||||
ASSERT(FSMoveSuccess == true); // this shouldn't be able to fail
|
||||
mpDirectory->AddChild("", this);
|
||||
mpStore->ConditionalDeleteDirectory(pOldDir);
|
||||
}
|
||||
|
||||
mpStore->SetDatabaseDirty();
|
||||
|
|
|
@ -26,19 +26,7 @@ CResourceStore::CResourceStore(const TString& rkDatabasePath)
|
|||
mDatabaseName = rkDatabasePath.GetFileName();
|
||||
}
|
||||
|
||||
// Constructor for game exporter
|
||||
CResourceStore::CResourceStore(CGameProject *pProject, const TString& rkRawDir, const TString& rkCookedDir, EGame Game)
|
||||
: mpProj(nullptr)
|
||||
, mGame(Game)
|
||||
, mRawDir(rkRawDir)
|
||||
, mCookedDir(rkCookedDir)
|
||||
, mDatabaseDirty(false)
|
||||
, mCacheFileDirty(false)
|
||||
{
|
||||
SetProject(pProject);
|
||||
}
|
||||
|
||||
// Main constructor for game projects
|
||||
// Main constructor for game projects and game exporter
|
||||
CResourceStore::CResourceStore(CGameProject *pProject)
|
||||
: mpProj(nullptr)
|
||||
, mGame(eUnknownGame)
|
||||
|
@ -84,9 +72,7 @@ void CResourceStore::SerializeResourceDatabase(IArchive& rArc)
|
|||
}
|
||||
|
||||
// Serialize
|
||||
rArc << SERIAL("RawDir", mRawDir)
|
||||
<< SERIAL("CookedDir", mCookedDir)
|
||||
<< SERIAL_CONTAINER_AUTO(Resources, "Resource");
|
||||
rArc << SERIAL_CONTAINER_AUTO(Resources, "Resource");
|
||||
|
||||
// Register resources
|
||||
if (rArc.IsReader())
|
||||
|
@ -310,10 +296,9 @@ void CResourceStore::ConditionalDeleteDirectory(CVirtualDirectory *pDir)
|
|||
if (pDir->IsEmpty())
|
||||
{
|
||||
// If this directory is part of the project, then we should delete the corresponding filesystem directories
|
||||
if (pDir->GetRoot() == mpDatabaseRoot)
|
||||
if (pDir->GetRoot() == mpDatabaseRoot && !pDir->IsRoot())
|
||||
{
|
||||
FileUtil::DeleteDirectory(RawDir(false) + pDir->FullPath(), true);
|
||||
FileUtil::DeleteDirectory(CookedDir(false) + pDir->FullPath(), true);
|
||||
FileUtil::DeleteDirectory(ResourcesDir() + pDir->FullPath(), true);
|
||||
}
|
||||
|
||||
CVirtualDirectory *pParent = pDir->Parent();
|
||||
|
@ -419,11 +404,11 @@ CResource* CResourceStore::LoadResource(const TString& rkPath)
|
|||
{
|
||||
if (Ext.Length() == 4)
|
||||
{
|
||||
ASSERT(Ext.CaseInsensitiveCompare(pEntry->CookedExtension().ToString()));
|
||||
ASSERT( Ext.CaseInsensitiveCompare(pEntry->CookedExtension().ToString()) );
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSERT(Ext.CaseInsensitiveCompare(pEntry->RawExtension()));
|
||||
ASSERT( rkPath.EndsWith(pEntry->RawExtension()) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,8 +30,6 @@ class CResourceStore
|
|||
// Directory paths
|
||||
TString mDatabasePath;
|
||||
TString mDatabaseName;
|
||||
TString mRawDir;
|
||||
TString mCookedDir;
|
||||
|
||||
enum EDatabaseVersion
|
||||
{
|
||||
|
@ -43,7 +41,6 @@ class CResourceStore
|
|||
|
||||
public:
|
||||
CResourceStore(const TString& rkDatabasePath);
|
||||
CResourceStore(CGameProject *pProject, const TString& rkRawDir, const TString& rkCookedDir, EGame Game);
|
||||
CResourceStore(CGameProject *pProject);
|
||||
~CResourceStore();
|
||||
void SerializeResourceDatabase(IArchive& rArc);
|
||||
|
@ -78,10 +75,9 @@ public:
|
|||
inline CGameProject* Project() const { return mpProj; }
|
||||
inline EGame Game() const { return mGame; }
|
||||
inline TString DatabaseRootPath() const { return mDatabasePath; }
|
||||
inline TString RawDir(bool Relative) const { return Relative ? mRawDir : mDatabasePath + mRawDir; }
|
||||
inline TString CookedDir(bool Relative) const { return Relative ? mCookedDir : mDatabasePath + mCookedDir; }
|
||||
inline TString DatabasePath() const { return DatabaseRootPath() + mDatabaseName; }
|
||||
inline TString CacheDataPath() const { return DatabaseRootPath() + "ResourceCacheData.rcd"; }
|
||||
inline TString ResourcesDir() const { return IsEditorStore() ? DatabaseRootPath() : DatabaseRootPath() + "Resources/"; }
|
||||
inline TString DatabasePath() const { return DatabaseRootPath() + "ResourceDatabase.xml"; }
|
||||
inline TString CacheDataPath() const { return DatabaseRootPath() + "ResourceCacheData.bin"; }
|
||||
inline CVirtualDirectory* RootDirectory() const { return mpDatabaseRoot; }
|
||||
inline u32 NumTotalResources() const { return mResourceEntries.size(); }
|
||||
inline u32 NumLoadedResources() const { return mLoadedResources.size(); }
|
||||
|
@ -89,6 +85,7 @@ public:
|
|||
|
||||
inline void SetDatabaseDirty() { mDatabaseDirty = true; }
|
||||
inline void SetCacheDataDirty() { mCacheFileDirty = true; }
|
||||
inline bool IsEditorStore() const { return mpProj == nullptr; }
|
||||
};
|
||||
|
||||
extern CResourceStore *gpResourceStore;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "Core/GameProject/DependencyListBuilders.h"
|
||||
#include <Common/Log.h>
|
||||
|
||||
const bool gkForceDisableCompression = true;
|
||||
const bool gkForceDisableCompression = false;
|
||||
|
||||
CAreaCooker::CAreaCooker()
|
||||
: mGeometrySecNum(-1)
|
||||
|
|
|
@ -614,6 +614,8 @@ void CAreaLoader::SetUpObjects(CScriptLayer *pGenLayer)
|
|||
}
|
||||
|
||||
// Merge objects from the generated layer back into the regular script layers
|
||||
if (pGenLayer)
|
||||
{
|
||||
while (pGenLayer->NumInstances() != 0)
|
||||
{
|
||||
CScriptObject *pInst = pGenLayer->InstanceByIndex(0);
|
||||
|
@ -634,6 +636,7 @@ void CAreaLoader::SetUpObjects(CScriptLayer *pGenLayer)
|
|||
mpArea->mObjectMap[InstanceID] = pInst;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Iterate over all objects
|
||||
for (auto Iter = mpArea->mObjectMap.begin(); Iter != mpArea->mObjectMap.end(); Iter++)
|
||||
|
|
|
@ -101,7 +101,9 @@ public:
|
|||
|
||||
case eStateMachine:
|
||||
// AFSM currently unsupported
|
||||
if (pEntry->Game() == eCorruptionProto || pEntry->Game() == eCorruption)
|
||||
if (pEntry->Game() <= eEchoes)
|
||||
pRes = new CDependencyGroup(pEntry);
|
||||
else if (pEntry->Game() <= eCorruption)
|
||||
pRes = CUnsupportedFormatLoader::LoadFSM2(rInput, pEntry);
|
||||
else if (pEntry->Game() == eReturns)
|
||||
pRes = CUnsupportedFormatLoader::LoadFSMC(rInput, pEntry);
|
||||
|
|
Loading…
Reference in New Issue