mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 16:15:43 +00:00
ZoneLoading: Make AssetDumpers get the zone via their args
This commit is contained in:
parent
7077ba8ce3
commit
11168c782f
@ -10,15 +10,15 @@ template<class T>
|
||||
class AbstractAssetDumper : public IAssetDumper<T>
|
||||
{
|
||||
protected:
|
||||
virtual std::string GetFileNameForAsset(T* asset) = 0;
|
||||
virtual void DumpAsset(T* asset, FileAPI::File* out) = 0;
|
||||
virtual std::string GetFileNameForAsset(Zone* zone, T* asset) = 0;
|
||||
virtual void DumpAsset(Zone* zone, T* asset, FileAPI::File* out) = 0;
|
||||
|
||||
public:
|
||||
void DumpPool(AssetPool<T>* pool, const std::string& basePath) override
|
||||
void DumpPool(Zone* zone, AssetPool<T>* pool, const std::string& basePath) override
|
||||
{
|
||||
for(auto assetInfo : *pool)
|
||||
{
|
||||
std::string assetFilePath = utils::Path::Combine(basePath, GetFileNameForAsset(assetInfo->m_asset));
|
||||
std::string assetFilePath = utils::Path::Combine(basePath, GetFileNameForAsset(zone, assetInfo->m_asset));
|
||||
|
||||
FileAPI::DirectoryCreate(utils::Path::GetDirectory(assetFilePath));
|
||||
|
||||
@ -26,7 +26,7 @@ public:
|
||||
|
||||
if(file.IsOpen())
|
||||
{
|
||||
DumpAsset(assetInfo->m_asset, &file);
|
||||
DumpAsset(zone, assetInfo->m_asset, &file);
|
||||
|
||||
file.Close();
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "Zone/Zone.h"
|
||||
#include "Pool/AssetPool.h"
|
||||
|
||||
template<class T>
|
||||
@ -8,5 +9,5 @@ class IAssetDumper
|
||||
public:
|
||||
virtual ~IAssetDumper() = default;
|
||||
|
||||
virtual void DumpPool(AssetPool<T>* pool, const std::string& basePath) = 0;
|
||||
virtual void DumpPool(Zone* zone, AssetPool<T>* pool, const std::string& basePath) = 0;
|
||||
};
|
@ -2,7 +2,7 @@
|
||||
|
||||
using namespace T6;
|
||||
|
||||
void AssetDumperLocalizeEntry::DumpPool(AssetPool<T6::LocalizeEntry>* pool, const std::string& basePath)
|
||||
std::string AssetDumperLocalizeEntry::GetNameOfLanguage(ZoneLanguage language)
|
||||
{
|
||||
// TODO: Add a dumping method that dumps all localized strings to a .str file and not in separate files.
|
||||
}
|
@ -6,5 +6,5 @@
|
||||
class AssetDumperLocalizeEntry final : public IAssetDumper<T6::LocalizeEntry>
|
||||
{
|
||||
public:
|
||||
void DumpPool(AssetPool<T6::LocalizeEntry>* pool, const std::string& basePath) override;
|
||||
void DumpPool(Zone* zone, AssetPool<T6::LocalizeEntry>* pool, const std::string& basePath) override;
|
||||
};
|
@ -2,12 +2,12 @@
|
||||
|
||||
using namespace T6;
|
||||
|
||||
std::string AssetDumperQdb::GetFileNameForAsset(Qdb* asset)
|
||||
std::string AssetDumperQdb::GetFileNameForAsset(Zone* zone, Qdb* asset)
|
||||
{
|
||||
return std::string(asset->name);
|
||||
}
|
||||
|
||||
void AssetDumperQdb::DumpAsset(Qdb* asset, FileAPI::File* out)
|
||||
void AssetDumperQdb::DumpAsset(Zone* zone, Qdb* asset, FileAPI::File* out)
|
||||
{
|
||||
out->Write(asset->buffer, 1, asset->len);
|
||||
}
|
@ -6,6 +6,6 @@
|
||||
class AssetDumperQdb final : public AbstractAssetDumper<T6::Qdb>
|
||||
{
|
||||
protected:
|
||||
std::string GetFileNameForAsset(T6::Qdb* asset) override;
|
||||
void DumpAsset(T6::Qdb* asset, FileAPI::File* out) override;
|
||||
std::string GetFileNameForAsset(Zone* zone, T6::Qdb* asset) override;
|
||||
void DumpAsset(Zone* zone, T6::Qdb* asset, FileAPI::File* out) override;
|
||||
};
|
@ -2,12 +2,12 @@
|
||||
|
||||
using namespace T6;
|
||||
|
||||
std::string AssetDumperRawFile::GetFileNameForAsset(RawFile* asset)
|
||||
std::string AssetDumperRawFile::GetFileNameForAsset(Zone* zone, RawFile* asset)
|
||||
{
|
||||
return std::string(asset->name);
|
||||
}
|
||||
|
||||
void AssetDumperRawFile::DumpAsset(RawFile* asset, FileAPI::File* out)
|
||||
void AssetDumperRawFile::DumpAsset(Zone* zone, RawFile* asset, FileAPI::File* out)
|
||||
{
|
||||
out->Write(asset->buffer, 1, asset->len);
|
||||
}
|
@ -6,6 +6,6 @@
|
||||
class AssetDumperRawFile final : public AbstractAssetDumper<T6::RawFile>
|
||||
{
|
||||
protected:
|
||||
std::string GetFileNameForAsset(T6::RawFile* asset) override;
|
||||
void DumpAsset(T6::RawFile* asset, FileAPI::File* out) override;
|
||||
std::string GetFileNameForAsset(Zone* zone, T6::RawFile* asset) override;
|
||||
void DumpAsset(Zone* zone, T6::RawFile* asset, FileAPI::File* out) override;
|
||||
};
|
@ -2,12 +2,12 @@
|
||||
|
||||
using namespace T6;
|
||||
|
||||
std::string AssetDumperScriptParseTree::GetFileNameForAsset(ScriptParseTree* asset)
|
||||
std::string AssetDumperScriptParseTree::GetFileNameForAsset(Zone* zone, ScriptParseTree* asset)
|
||||
{
|
||||
return std::string(asset->name);
|
||||
}
|
||||
|
||||
void AssetDumperScriptParseTree::DumpAsset(ScriptParseTree* asset, FileAPI::File* out)
|
||||
void AssetDumperScriptParseTree::DumpAsset(Zone* zone, ScriptParseTree* asset, FileAPI::File* out)
|
||||
{
|
||||
out->Write(asset->buffer, 1, asset->len);
|
||||
}
|
@ -6,6 +6,6 @@
|
||||
class AssetDumperScriptParseTree final : public AbstractAssetDumper<T6::ScriptParseTree>
|
||||
{
|
||||
protected:
|
||||
std::string GetFileNameForAsset(T6::ScriptParseTree* asset) override;
|
||||
void DumpAsset(T6::ScriptParseTree* asset, FileAPI::File* out) override;
|
||||
std::string GetFileNameForAsset(Zone* zone, T6::ScriptParseTree* asset) override;
|
||||
void DumpAsset(Zone* zone, T6::ScriptParseTree* asset, FileAPI::File* out) override;
|
||||
};
|
@ -2,12 +2,12 @@
|
||||
|
||||
using namespace T6;
|
||||
|
||||
std::string AssetDumperSlug::GetFileNameForAsset(Slug* asset)
|
||||
std::string AssetDumperSlug::GetFileNameForAsset(Zone* zone, Slug* asset)
|
||||
{
|
||||
return std::string(asset->name);
|
||||
}
|
||||
|
||||
void AssetDumperSlug::DumpAsset(Slug* asset, FileAPI::File* out)
|
||||
void AssetDumperSlug::DumpAsset(Zone* zone, Slug* asset, FileAPI::File* out)
|
||||
{
|
||||
out->Write(asset->buffer, 1, asset->len);
|
||||
}
|
@ -6,6 +6,6 @@
|
||||
class AssetDumperSlug final : public AbstractAssetDumper<T6::Slug>
|
||||
{
|
||||
protected:
|
||||
std::string GetFileNameForAsset(T6::Slug* asset) override;
|
||||
void DumpAsset(T6::Slug* asset, FileAPI::File* out) override;
|
||||
std::string GetFileNameForAsset(Zone* zone, T6::Slug* asset) override;
|
||||
void DumpAsset(Zone* zone, T6::Slug* asset, FileAPI::File* out) override;
|
||||
};
|
@ -2,12 +2,12 @@
|
||||
|
||||
using namespace T6;
|
||||
|
||||
std::string AssetDumperStringTable::GetFileNameForAsset(StringTable* asset)
|
||||
std::string AssetDumperStringTable::GetFileNameForAsset(Zone* zone, StringTable* asset)
|
||||
{
|
||||
return std::string(asset->name);
|
||||
}
|
||||
|
||||
void AssetDumperStringTable::DumpAsset(StringTable* asset, FileAPI::File* out)
|
||||
void AssetDumperStringTable::DumpAsset(Zone* zone, StringTable* asset, FileAPI::File* out)
|
||||
{
|
||||
char separator[]{ ',' };
|
||||
char newLine[]{ '\n' };
|
||||
|
@ -6,6 +6,6 @@
|
||||
class AssetDumperStringTable final : public AbstractAssetDumper<T6::StringTable>
|
||||
{
|
||||
protected:
|
||||
std::string GetFileNameForAsset(T6::StringTable* asset) override;
|
||||
void DumpAsset(T6::StringTable* asset, FileAPI::File* out) override;
|
||||
std::string GetFileNameForAsset(Zone* zone, T6::StringTable* asset) override;
|
||||
void DumpAsset(Zone* zone, T6::StringTable* asset, FileAPI::File* out) override;
|
||||
};
|
@ -19,7 +19,7 @@ bool ZoneDumperT6::DumpZone(Zone* zone, const std::string& basePath)
|
||||
if(assetPools->poolName) \
|
||||
{ \
|
||||
dumperType dumper; \
|
||||
dumper.DumpPool(assetPools->poolName, basePath); \
|
||||
dumper.DumpPool(zone, assetPools->poolName, basePath); \
|
||||
}
|
||||
|
||||
const auto assetPools = dynamic_cast<GameAssetPoolT6*>(zone->GetPools());
|
||||
|
Loading…
x
Reference in New Issue
Block a user