ObjWriting: Add method to AbstractAssetDumper for checking whether an asset should be dumped

This commit is contained in:
Jan 2020-02-11 20:46:59 +01:00
parent dd4987c2f1
commit 7d809faf07
11 changed files with 37 additions and 0 deletions

View File

@ -10,6 +10,7 @@ template<class T>
class AbstractAssetDumper : public IAssetDumper<T> class AbstractAssetDumper : public IAssetDumper<T>
{ {
protected: protected:
virtual bool ShouldDump(T* asset) = 0;
virtual std::string GetFileNameForAsset(Zone* zone, T* asset) = 0; virtual std::string GetFileNameForAsset(Zone* zone, T* asset) = 0;
virtual void DumpAsset(Zone* zone, T* asset, FileAPI::File* out) = 0; virtual void DumpAsset(Zone* zone, T* asset, FileAPI::File* out) = 0;
@ -18,6 +19,12 @@ public:
{ {
for(auto assetInfo : *pool) for(auto assetInfo : *pool)
{ {
if(assetInfo->m_name[0] == ','
|| !ShouldDump(assetInfo->m_asset))
{
continue;
}
std::string assetFilePath = utils::Path::Combine(basePath, GetFileNameForAsset(zone, assetInfo->m_asset)); std::string assetFilePath = utils::Path::Combine(basePath, GetFileNameForAsset(zone, assetInfo->m_asset));
FileAPI::DirectoryCreate(utils::Path::GetDirectory(assetFilePath)); FileAPI::DirectoryCreate(utils::Path::GetDirectory(assetFilePath));

View File

@ -2,6 +2,11 @@
using namespace T6; using namespace T6;
bool AssetDumperQdb::ShouldDump(Qdb* asset)
{
return true;
}
std::string AssetDumperQdb::GetFileNameForAsset(Zone* zone, Qdb* asset) std::string AssetDumperQdb::GetFileNameForAsset(Zone* zone, Qdb* asset)
{ {
return std::string(asset->name); return std::string(asset->name);

View File

@ -6,6 +6,7 @@
class AssetDumperQdb final : public AbstractAssetDumper<T6::Qdb> class AssetDumperQdb final : public AbstractAssetDumper<T6::Qdb>
{ {
protected: protected:
bool ShouldDump(T6::Qdb* asset) override;
std::string GetFileNameForAsset(Zone* zone, T6::Qdb* asset) override; std::string GetFileNameForAsset(Zone* zone, T6::Qdb* asset) override;
void DumpAsset(Zone* zone, T6::Qdb* asset, FileAPI::File* out) override; void DumpAsset(Zone* zone, T6::Qdb* asset, FileAPI::File* out) override;
}; };

View File

@ -2,6 +2,11 @@
using namespace T6; using namespace T6;
bool AssetDumperRawFile::ShouldDump(RawFile* asset)
{
return true;
}
std::string AssetDumperRawFile::GetFileNameForAsset(Zone* zone, RawFile* asset) std::string AssetDumperRawFile::GetFileNameForAsset(Zone* zone, RawFile* asset)
{ {
return std::string(asset->name); return std::string(asset->name);

View File

@ -6,6 +6,7 @@
class AssetDumperRawFile final : public AbstractAssetDumper<T6::RawFile> class AssetDumperRawFile final : public AbstractAssetDumper<T6::RawFile>
{ {
protected: protected:
bool ShouldDump(T6::RawFile* asset) override;
std::string GetFileNameForAsset(Zone* zone, T6::RawFile* asset) override; std::string GetFileNameForAsset(Zone* zone, T6::RawFile* asset) override;
void DumpAsset(Zone* zone, T6::RawFile* asset, FileAPI::File* out) override; void DumpAsset(Zone* zone, T6::RawFile* asset, FileAPI::File* out) override;
}; };

View File

@ -2,6 +2,11 @@
using namespace T6; using namespace T6;
bool AssetDumperScriptParseTree::ShouldDump(ScriptParseTree* asset)
{
return true;
}
std::string AssetDumperScriptParseTree::GetFileNameForAsset(Zone* zone, ScriptParseTree* asset) std::string AssetDumperScriptParseTree::GetFileNameForAsset(Zone* zone, ScriptParseTree* asset)
{ {
return std::string(asset->name); return std::string(asset->name);

View File

@ -6,6 +6,7 @@
class AssetDumperScriptParseTree final : public AbstractAssetDumper<T6::ScriptParseTree> class AssetDumperScriptParseTree final : public AbstractAssetDumper<T6::ScriptParseTree>
{ {
protected: protected:
bool ShouldDump(T6::ScriptParseTree* asset) override;
std::string GetFileNameForAsset(Zone* zone, T6::ScriptParseTree* asset) override; std::string GetFileNameForAsset(Zone* zone, T6::ScriptParseTree* asset) override;
void DumpAsset(Zone* zone, T6::ScriptParseTree* asset, FileAPI::File* out) override; void DumpAsset(Zone* zone, T6::ScriptParseTree* asset, FileAPI::File* out) override;
}; };

View File

@ -2,6 +2,11 @@
using namespace T6; using namespace T6;
bool AssetDumperSlug::ShouldDump(Slug* asset)
{
return true;
}
std::string AssetDumperSlug::GetFileNameForAsset(Zone* zone, Slug* asset) std::string AssetDumperSlug::GetFileNameForAsset(Zone* zone, Slug* asset)
{ {
return std::string(asset->name); return std::string(asset->name);

View File

@ -6,6 +6,7 @@
class AssetDumperSlug final : public AbstractAssetDumper<T6::Slug> class AssetDumperSlug final : public AbstractAssetDumper<T6::Slug>
{ {
protected: protected:
bool ShouldDump(T6::Slug* asset) override;
std::string GetFileNameForAsset(Zone* zone, T6::Slug* asset) override; std::string GetFileNameForAsset(Zone* zone, T6::Slug* asset) override;
void DumpAsset(Zone* zone, T6::Slug* asset, FileAPI::File* out) override; void DumpAsset(Zone* zone, T6::Slug* asset, FileAPI::File* out) override;
}; };

View File

@ -2,6 +2,11 @@
using namespace T6; using namespace T6;
bool AssetDumperStringTable::ShouldDump(StringTable* asset)
{
return true;
}
std::string AssetDumperStringTable::GetFileNameForAsset(Zone* zone, StringTable* asset) std::string AssetDumperStringTable::GetFileNameForAsset(Zone* zone, StringTable* asset)
{ {
return std::string(asset->name); return std::string(asset->name);

View File

@ -6,6 +6,7 @@
class AssetDumperStringTable final : public AbstractAssetDumper<T6::StringTable> class AssetDumperStringTable final : public AbstractAssetDumper<T6::StringTable>
{ {
protected: protected:
bool ShouldDump(T6::StringTable* asset) override;
std::string GetFileNameForAsset(Zone* zone, T6::StringTable* asset) override; std::string GetFileNameForAsset(Zone* zone, T6::StringTable* asset) override;
void DumpAsset(Zone* zone, T6::StringTable* asset, FileAPI::File* out) override; void DumpAsset(Zone* zone, T6::StringTable* asset, FileAPI::File* out) override;
}; };