mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-06-18 12:33:30 +00:00
Integrated latest changes from nod, and updated the structure of the Disc folder for compatibility with the upcoming Dolphin directory blob updates
This commit is contained in:
parent
2ddba0cacc
commit
665a098d50
@ -63,11 +63,7 @@ bool CGameExporter::Export(nod::DiscBase *pDisc, const TString& rkOutputDir, CAs
|
||||
mGame,
|
||||
mRegion,
|
||||
mGameID,
|
||||
mBuildVersion,
|
||||
mDolPath,
|
||||
mApploaderPath,
|
||||
mPartitionHeaderPath,
|
||||
mFilesystemAddress);
|
||||
mBuildVersion);
|
||||
|
||||
mpProject->SetProjectName(mGameName);
|
||||
mpStore = mpProject->ResourceStore();
|
||||
@ -111,54 +107,42 @@ bool CGameExporter::ExtractDiscData()
|
||||
|
||||
// Create Disc output folder
|
||||
TString AbsDiscDir = mExportDir + mDiscDir;
|
||||
bool IsWii = (mBuildVersion >= 3.f);
|
||||
if (IsWii) AbsDiscDir += "DATA/";
|
||||
FileUtil::MakeDirectory(AbsDiscDir);
|
||||
|
||||
// Extract disc filesystem
|
||||
nod::Partition *pDataPartition = mpDisc->getDataPartition();
|
||||
nod::ExtractionContext Context;
|
||||
Context.force = false;
|
||||
Context.verbose = true;
|
||||
Context.progressCB = [&](const std::string& rkDesc, float ProgressPercent) {
|
||||
mpProgress->Report((int) (ProgressPercent * 10000), 10000, rkDesc);
|
||||
};
|
||||
|
||||
bool Success = ExtractDiscNodeRecursive(&pDataPartition->getFSTRoot(), AbsDiscDir, Context);
|
||||
TString FilesDir = AbsDiscDir + "files/";
|
||||
FileUtil::MakeDirectory(FilesDir);
|
||||
|
||||
bool Success = ExtractDiscNodeRecursive(&pDataPartition->getFSTRoot(), FilesDir, Context);
|
||||
if (!Success) return false;
|
||||
|
||||
// Extract the remaining disc data
|
||||
if (!mpProgress->ShouldCancel())
|
||||
{
|
||||
// Extract dol
|
||||
mDolPath = "boot.dol";
|
||||
CFileOutStream DolFile(mExportDir + mDolPath);
|
||||
if (!DolFile.IsValid()) return false;
|
||||
|
||||
std::unique_ptr<uint8_t[]> pDolBuffer = pDataPartition->getDOLBuf();
|
||||
DolFile.WriteBytes(pDolBuffer.get(), (u32) pDataPartition->getDOLSize());
|
||||
DolFile.Close();
|
||||
|
||||
// Extract apploader
|
||||
mApploaderPath = "apploader.img";
|
||||
CFileOutStream ApploaderFile(mExportDir + mApploaderPath);
|
||||
if (!ApploaderFile.IsValid()) return false;
|
||||
|
||||
std::unique_ptr<uint8_t[]> pApploaderBuffer = pDataPartition->getApploaderBuf();
|
||||
ApploaderFile.WriteBytes(pApploaderBuffer.get(), (u32) pDataPartition->getApploaderSize());
|
||||
ApploaderFile.Close();
|
||||
|
||||
// Extract Wii partition header
|
||||
bool IsWii = (mBuildVersion >= 3.f);
|
||||
Context.progressCB = nullptr;
|
||||
|
||||
if (IsWii)
|
||||
{
|
||||
mFilesystemAddress = 0;
|
||||
mPartitionHeaderPath = "partition_header.bin";
|
||||
nod::DiscWii *pDiscWii = static_cast<nod::DiscWii*>(mpDisc);
|
||||
Success = pDiscWii->writeOutDataPartitionHeader(*TString(mExportDir + mPartitionHeaderPath).ToUTF16());
|
||||
if (!Success) return false;
|
||||
// Extract crypto files
|
||||
if (!pDataPartition->extractCryptoFiles(*AbsDiscDir.ToUTF16(), Context))
|
||||
return false;
|
||||
|
||||
// Extract disc header files
|
||||
if (!mpDisc->extractDiscHeaderFiles(*AbsDiscDir.ToUTF16(), Context))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
mFilesystemAddress = (u32) pDataPartition->getFSTMemoryAddr();
|
||||
|
||||
// Extract system files
|
||||
if (!pDataPartition->extractSysFiles(*AbsDiscDir.ToUTF16(), Context))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -215,7 +199,8 @@ void CGameExporter::LoadPaks()
|
||||
continue;
|
||||
}
|
||||
|
||||
CPackage *pPackage = new CPackage(mpProject, PakPath.GetFileName(false), FileUtil::MakeRelative(PakPath.GetFileDirectory(), mExportDir + mDiscDir));
|
||||
TString RelPakPath = FileUtil::MakeRelative(PakPath.GetFileDirectory(), mpProject->DiscFilesystemRoot(false));
|
||||
CPackage *pPackage = new CPackage(mpProject, PakPath.GetFileName(false), RelPakPath);
|
||||
|
||||
// MP1-MP3Proto
|
||||
if (mGame < eCorruption)
|
||||
|
@ -23,10 +23,6 @@ class CGameExporter
|
||||
TString mGameName;
|
||||
TString mGameID;
|
||||
float mBuildVersion;
|
||||
TString mDolPath;
|
||||
TString mApploaderPath;
|
||||
TString mPartitionHeaderPath;
|
||||
u32 mFilesystemAddress;
|
||||
|
||||
// Directories
|
||||
TString mExportDir;
|
||||
|
@ -39,17 +39,7 @@ bool CGameProject::Serialize(IArchive& rArc)
|
||||
rArc << SERIAL("Name", mProjectName)
|
||||
<< SERIAL("Region", mRegion)
|
||||
<< SERIAL("GameID", mGameID)
|
||||
<< SERIAL("BuildVersion", mBuildVersion)
|
||||
<< SERIAL("DolPath", mDolPath)
|
||||
<< SERIAL("ApploaderPath", mApploaderPath);
|
||||
|
||||
if (rArc.Game() >= eCorruption)
|
||||
rArc << SERIAL("PartitionHeaderPath", mPartitionHeaderPath);
|
||||
|
||||
if (!IsWiiBuild())
|
||||
rArc << SERIAL("FstAddress", mFilesystemAddress);
|
||||
|
||||
rArc << SERIAL("ResourceDB", mResourceDBPath);
|
||||
<< SERIAL("BuildVersion", mBuildVersion);
|
||||
|
||||
// Serialize package list
|
||||
std::vector<TString> PackageList;
|
||||
@ -104,14 +94,11 @@ bool CGameProject::BuildISO(const TString& rkIsoPath, IProgressNotifier *pProgre
|
||||
pProgress->Report((int) (ProgressPercent * 10000), 10000, TWideString(rkInfoString).ToUTF8());
|
||||
};
|
||||
|
||||
nod::DiscBuilderGCN *pBuilder = new nod::DiscBuilderGCN(*rkIsoPath.ToUTF16(), *mGameID, *mProjectName, mFilesystemAddress, ProgressCallback);
|
||||
nod::DiscBuilderGCN *pBuilder = new nod::DiscBuilderGCN(*rkIsoPath.ToUTF16(), ProgressCallback);
|
||||
pProgress->SetTask(0, "Building " + rkIsoPath.GetFileName());
|
||||
|
||||
TWideString ProjRoot = ProjectRoot().ToUTF16();
|
||||
TWideString DiscRoot = DiscDir(false).ToUTF16();
|
||||
TWideString DolPath = ProjRoot + mDolPath.ToUTF16();
|
||||
TWideString ApploaderPath = ProjRoot + mApploaderPath.ToUTF16();
|
||||
return pBuilder->buildFromDirectory(*DiscRoot, *DolPath, *ApploaderPath) == nod::EBuildResult::Success;
|
||||
return pBuilder->buildFromDirectory(*DiscRoot) == nod::EBuildResult::Success;
|
||||
}
|
||||
}
|
||||
|
||||
@ -184,11 +171,7 @@ CGameProject* CGameProject::CreateProjectForExport(
|
||||
EGame Game,
|
||||
ERegion Region,
|
||||
const TString& rkGameID,
|
||||
float BuildVer,
|
||||
const TString& rkDolPath,
|
||||
const TString& rkApploaderPath,
|
||||
const TString& rkPartitionHeaderPath,
|
||||
u32 FstAddress
|
||||
float BuildVer
|
||||
)
|
||||
{
|
||||
CGameProject *pProj = new CGameProject;
|
||||
@ -196,10 +179,6 @@ CGameProject* CGameProject::CreateProjectForExport(
|
||||
pProj->mRegion = Region;
|
||||
pProj->mGameID = rkGameID;
|
||||
pProj->mBuildVersion = BuildVer;
|
||||
pProj->mDolPath = rkDolPath;
|
||||
pProj->mApploaderPath = rkApploaderPath;
|
||||
pProj->mPartitionHeaderPath = rkPartitionHeaderPath;
|
||||
pProj->mFilesystemAddress = FstAddress;
|
||||
|
||||
pProj->mProjectRoot = rkProjRootDir;
|
||||
pProj->mProjectRoot.Replace("\\", "/");
|
||||
|
@ -21,13 +21,8 @@ class CGameProject
|
||||
ERegion mRegion;
|
||||
TString mGameID;
|
||||
float mBuildVersion;
|
||||
TString mDolPath;
|
||||
TString mApploaderPath;
|
||||
TString mPartitionHeaderPath;
|
||||
u32 mFilesystemAddress;
|
||||
|
||||
TString mProjectRoot;
|
||||
TString mResourceDBPath;
|
||||
std::vector<CPackage*> mPackages;
|
||||
CResourceStore *mpResourceStore;
|
||||
CGameInfo *mpGameInfo;
|
||||
@ -52,7 +47,6 @@ class CGameProject
|
||||
, mRegion(eRegion_Unknown)
|
||||
, mGameID("000000")
|
||||
, mBuildVersion(0.f)
|
||||
, mResourceDBPath("ResourceDB.rdb")
|
||||
, mpResourceStore(nullptr)
|
||||
{
|
||||
mpGameInfo = new CGameInfo();
|
||||
@ -75,23 +69,20 @@ public:
|
||||
EGame Game,
|
||||
ERegion Region,
|
||||
const TString& rkGameID,
|
||||
float BuildVer,
|
||||
const TString& rkDolPath,
|
||||
const TString& rkApploaderPath,
|
||||
const TString& rkPartitionHeaderPath,
|
||||
u32 FstAddress
|
||||
float BuildVer
|
||||
);
|
||||
|
||||
static CGameProject* LoadProject(const TString& rkProjPath, IProgressNotifier *pProgress);
|
||||
|
||||
// Directory Handling
|
||||
inline TString ProjectRoot() const { return mProjectRoot; }
|
||||
inline TString ResourceDBPath(bool Relative) const { return Relative ? mResourceDBPath : mProjectRoot + mResourceDBPath; }
|
||||
inline TString ProjectPath() const { return mProjectRoot + FileUtil::SanitizeName(mProjectName, false) + ".prj"; }
|
||||
inline TString DiscDir(bool Relative) const { return Relative ? "Disc/" : mProjectRoot + "Disc/"; }
|
||||
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"; }
|
||||
|
||||
// Disc Filesystem Management
|
||||
inline TString DiscFilesystemRoot(bool Relative) const { return DiscDir(Relative) + (IsWiiBuild() ? "DATA/" : "") + "files/"; }
|
||||
|
||||
// Accessors
|
||||
inline void SetProjectName(const TString& rkName) { mProjectName = rkName; }
|
||||
|
@ -446,5 +446,5 @@ TString CPackage::DefinitionPath(bool Relative) const
|
||||
TString CPackage::CookedPackagePath(bool Relative) const
|
||||
{
|
||||
TString RelPath = mPakPath + mPakName + ".pak";
|
||||
return Relative ? RelPath : mpProject->DiscDir(false) + RelPath;
|
||||
return Relative ? RelPath : mpProject->DiscFilesystemRoot(false) + RelPath;
|
||||
}
|
||||
|
@ -173,8 +173,7 @@ void CResourceStore::SetProject(CGameProject *pProj)
|
||||
|
||||
if (mpProj)
|
||||
{
|
||||
TString DatabasePath = mpProj->ResourceDBPath(false);
|
||||
mDatabasePath = DatabasePath.GetFileDirectory();
|
||||
mDatabasePath = mpProj->ProjectRoot();
|
||||
mpDatabaseRoot = new CVirtualDirectory(this);
|
||||
mGame = mpProj->Game();
|
||||
}
|
||||
|
@ -266,7 +266,7 @@ void CWorldTreeModel::OnProjectChanged(CGameProject *pProj)
|
||||
// DKCR - Get worlds from areas.lst
|
||||
else
|
||||
{
|
||||
TString AreaListPath = pProj->DiscDir(false) + "areas.lst";
|
||||
TString AreaListPath = pProj->DiscFilesystemRoot(false) + "areas.lst";
|
||||
|
||||
// I really need a good text stream class at some point
|
||||
FILE* pAreaList = fopen(*AreaListPath, "r");
|
||||
|
Loading…
x
Reference in New Issue
Block a user