2016-05-21 23:58:52 -07:00
|
|
|
#ifndef CGAMEEXPORTER_H
|
|
|
|
#define CGAMEEXPORTER_H
|
|
|
|
|
2016-12-12 00:33:46 -08:00
|
|
|
#include "CAssetNameMap.h"
|
2017-01-31 10:23:28 -08:00
|
|
|
#include "CGameInfo.h"
|
2016-05-21 23:58:52 -07:00
|
|
|
#include "CGameProject.h"
|
2016-07-04 19:28:17 -07:00
|
|
|
#include "CResourceStore.h"
|
2016-07-25 02:25:22 -07:00
|
|
|
#include <Common/CAssetID.h>
|
2016-05-21 23:58:52 -07:00
|
|
|
#include <Common/Flags.h>
|
|
|
|
#include <Common/TString.h>
|
|
|
|
#include <map>
|
2019-11-24 18:46:57 -08:00
|
|
|
#include <nod/DiscBase.hpp>
|
2016-05-21 23:58:52 -07:00
|
|
|
|
2018-12-16 13:00:40 -08:00
|
|
|
enum class EDiscType
|
2017-07-24 20:08:12 -07:00
|
|
|
{
|
2018-12-16 13:00:40 -08:00
|
|
|
Normal,
|
|
|
|
WiiDeAsobu,
|
|
|
|
Trilogy
|
2017-07-24 20:08:12 -07:00
|
|
|
};
|
|
|
|
|
2016-05-21 23:58:52 -07:00
|
|
|
class CGameExporter
|
|
|
|
{
|
2017-02-06 08:20:18 -08:00
|
|
|
// Project Data
|
2016-05-21 23:58:52 -07:00
|
|
|
CGameProject *mpProject;
|
2017-05-04 14:43:25 -07:00
|
|
|
TString mProjectPath;
|
2016-08-31 01:09:13 -07:00
|
|
|
CResourceStore *mpStore;
|
2016-09-16 01:47:46 -07:00
|
|
|
EGame mGame;
|
2017-02-06 08:20:18 -08:00
|
|
|
ERegion mRegion;
|
|
|
|
TString mGameName;
|
|
|
|
TString mGameID;
|
2017-01-31 10:23:28 -08:00
|
|
|
float mBuildVersion;
|
2016-05-21 23:58:52 -07:00
|
|
|
|
|
|
|
// Directories
|
2017-05-04 14:43:25 -07:00
|
|
|
TString mExportDir;
|
|
|
|
TString mDiscDir;
|
2017-07-01 18:03:56 -07:00
|
|
|
TString mResourcesDir;
|
2016-07-04 19:28:17 -07:00
|
|
|
|
2017-05-04 14:43:25 -07:00
|
|
|
TString mWorldsDirName;
|
2016-05-21 23:58:52 -07:00
|
|
|
|
2017-01-31 10:23:28 -08:00
|
|
|
// Files
|
2017-02-06 08:20:18 -08:00
|
|
|
nod::DiscBase *mpDisc;
|
2017-07-24 20:08:12 -07:00
|
|
|
EDiscType mDiscType;
|
|
|
|
bool mFrontEnd;
|
2017-01-31 10:23:28 -08:00
|
|
|
|
2016-05-21 23:58:52 -07:00
|
|
|
// Resources
|
2017-05-04 14:43:25 -07:00
|
|
|
TStringList mPaks;
|
2016-08-12 03:27:19 -07:00
|
|
|
std::map<CAssetID, bool> mAreaDuplicateMap;
|
2017-02-06 08:20:18 -08:00
|
|
|
CAssetNameMap *mpNameMap;
|
|
|
|
CGameInfo *mpGameInfo;
|
2016-05-21 23:58:52 -07:00
|
|
|
|
|
|
|
struct SResourceInstance
|
|
|
|
{
|
2017-05-04 14:43:25 -07:00
|
|
|
TString PakFile;
|
2016-07-25 02:25:22 -07:00
|
|
|
CAssetID ResourceID;
|
2016-05-21 23:58:52 -07:00
|
|
|
CFourCC ResourceType;
|
2018-12-11 21:50:46 -08:00
|
|
|
uint32 PakOffset;
|
|
|
|
uint32 PakSize;
|
2016-05-21 23:58:52 -07:00
|
|
|
bool Compressed;
|
2016-06-05 00:57:31 -07:00
|
|
|
bool Exported;
|
2016-05-21 23:58:52 -07:00
|
|
|
};
|
2016-08-12 03:27:19 -07:00
|
|
|
std::map<CAssetID, SResourceInstance> mResourceMap;
|
2016-05-21 23:58:52 -07:00
|
|
|
|
2017-05-21 17:01:09 -07:00
|
|
|
// Progress
|
|
|
|
IProgressNotifier *mpProgress;
|
|
|
|
|
2019-05-25 23:24:13 -07:00
|
|
|
public:
|
2017-05-21 17:01:09 -07:00
|
|
|
enum EExportStep
|
|
|
|
{
|
|
|
|
eES_ExtractDisc,
|
|
|
|
eES_ExportCooked,
|
|
|
|
eES_GenerateRaw,
|
|
|
|
// eES_Max must be last
|
|
|
|
eES_NumSteps
|
|
|
|
};
|
|
|
|
|
2017-07-24 20:08:12 -07:00
|
|
|
CGameExporter(EDiscType DiscType, EGame Game, bool FrontEnd, ERegion Region, const TString& rkGameName, const TString& rkGameID, float BuildVersion);
|
2017-05-21 17:01:09 -07:00
|
|
|
bool Export(nod::DiscBase *pDisc, const TString& rkOutputDir, CAssetNameMap *pNameMap, CGameInfo *pGameInfo, IProgressNotifier *pProgress);
|
2018-12-11 21:50:46 -08:00
|
|
|
void LoadResource(const CAssetID& rkID, std::vector<uint8>& rBuffer);
|
2017-07-24 20:08:12 -07:00
|
|
|
bool ShouldExportDiscNode(const nod::Node *pkNode, bool IsInRoot);
|
2016-05-21 23:58:52 -07:00
|
|
|
|
2017-05-04 14:43:25 -07:00
|
|
|
inline TString ProjectPath() const { return mProjectPath; }
|
2017-02-06 08:20:18 -08:00
|
|
|
|
2016-05-21 23:58:52 -07:00
|
|
|
protected:
|
2017-02-06 08:20:18 -08:00
|
|
|
bool ExtractDiscData();
|
2017-07-24 20:08:12 -07:00
|
|
|
bool ExtractDiscNodeRecursive(const nod::Node *pkNode, const TString& rkDir, bool RootNode, const nod::ExtractionContext& rkContext);
|
2016-05-21 23:58:52 -07:00
|
|
|
void LoadPaks();
|
2018-12-11 21:50:46 -08:00
|
|
|
void LoadResource(const SResourceInstance& rkResource, std::vector<uint8>& rBuffer);
|
2016-05-21 23:58:52 -07:00
|
|
|
void ExportCookedResources();
|
2016-09-16 01:47:46 -07:00
|
|
|
void ExportResourceEditorData();
|
2016-06-05 00:57:31 -07:00
|
|
|
void ExportResource(SResourceInstance& rRes);
|
2017-02-20 02:42:04 -08:00
|
|
|
TString MakeWorldName(CAssetID WorldID);
|
2016-06-05 00:57:31 -07:00
|
|
|
|
|
|
|
// Convenience Functions
|
2016-07-25 02:25:22 -07:00
|
|
|
inline SResourceInstance* FindResourceInstance(const CAssetID& rkID)
|
2016-06-05 00:57:31 -07:00
|
|
|
{
|
2018-12-11 21:50:46 -08:00
|
|
|
uint64 IntegralID = rkID.ToLongLong();
|
2016-06-05 00:57:31 -07:00
|
|
|
auto Found = mResourceMap.find(IntegralID);
|
|
|
|
return (Found == mResourceMap.end() ? nullptr : &Found->second);
|
|
|
|
}
|
2016-05-21 23:58:52 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CGAMEEXPORTER_H
|