mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-19 15:52:53 +00:00
Add AssetDumperContext to bundle context fields for dumping
(cherry picked from commit ed8331280392ef3a2b4657c5dbd0880463d85f2c)
This commit is contained in:
parent
88c48e8107
commit
abb268a819
@ -7,15 +7,15 @@
|
||||
#include <iostream>
|
||||
|
||||
template<class T>
|
||||
class AbstractAssetDumper : public IAssetDumper<T>
|
||||
class AbstractFileDumper : public IAssetDumper<T>
|
||||
{
|
||||
protected:
|
||||
virtual bool ShouldDump(XAssetInfo<T>* asset) = 0;
|
||||
virtual std::string GetFileNameForAsset(Zone* zone, XAssetInfo<T>* asset) = 0;
|
||||
virtual void DumpAsset(Zone* zone, XAssetInfo<T>* asset, std::ostream& stream) = 0;
|
||||
virtual void DumpAsset(AssetDumpingContext& context, XAssetInfo<T>* asset, std::ostream& stream) = 0;
|
||||
|
||||
public:
|
||||
void DumpPool(Zone* zone, AssetPool<T>* pool, const std::string& basePath) override
|
||||
void DumpPool(AssetDumpingContext& context, AssetPool<T>* pool) override
|
||||
{
|
||||
for(auto assetInfo : *pool)
|
||||
{
|
||||
@ -25,8 +25,8 @@ public:
|
||||
continue;
|
||||
}
|
||||
|
||||
std::filesystem::path assetFilePath(basePath);
|
||||
assetFilePath.append(GetFileNameForAsset(zone, assetInfo));
|
||||
std::filesystem::path assetFilePath(context.m_base_path);
|
||||
assetFilePath.append(GetFileNameForAsset(context.m_zone, assetInfo));
|
||||
|
||||
auto assetFileFolder(assetFilePath);
|
||||
assetFileFolder.replace_filename("");
|
||||
@ -35,7 +35,7 @@ public:
|
||||
std::ofstream file(assetFilePath, std::fstream::out | std::fstream::binary);
|
||||
if(file.is_open())
|
||||
{
|
||||
DumpAsset(zone, assetInfo, file);
|
||||
DumpAsset(context, assetInfo, file);
|
||||
|
||||
file.close();
|
||||
}
|
0
src/ObjWriting/Dumping/AssetDumpingContext.cpp
Normal file
0
src/ObjWriting/Dumping/AssetDumpingContext.cpp
Normal file
12
src/ObjWriting/Dumping/AssetDumpingContext.h
Normal file
12
src/ObjWriting/Dumping/AssetDumpingContext.h
Normal file
@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "Zone/Zone.h"
|
||||
|
||||
class AssetDumpingContext
|
||||
{
|
||||
public:
|
||||
Zone* m_zone;
|
||||
std::string m_base_path;
|
||||
};
|
@ -1,13 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include "Zone/Zone.h"
|
||||
#include "AssetDumpingContext.h"
|
||||
#include "Pool/AssetPool.h"
|
||||
|
||||
template<class T>
|
||||
class IAssetDumper
|
||||
{
|
||||
public:
|
||||
IAssetDumper() = default;
|
||||
virtual ~IAssetDumper() = default;
|
||||
IAssetDumper(const IAssetDumper& other) = default;
|
||||
IAssetDumper(IAssetDumper&& other) noexcept = default;
|
||||
IAssetDumper& operator=(const IAssetDumper& other) = default;
|
||||
IAssetDumper& operator=(IAssetDumper&& other) noexcept = default;
|
||||
|
||||
virtual void DumpPool(Zone* zone, AssetPool<T>* pool, const std::string& basePath) = 0;
|
||||
virtual void DumpPool(AssetDumpingContext& context, AssetPool<T>* pool) = 0;
|
||||
};
|
@ -1,12 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "Zone/Zone.h"
|
||||
#include "AssetDumpingContext.h"
|
||||
|
||||
class IZoneDumper
|
||||
{
|
||||
public:
|
||||
IZoneDumper() = default;
|
||||
virtual ~IZoneDumper() = default;
|
||||
IZoneDumper(const IZoneDumper& other) = default;
|
||||
IZoneDumper(IZoneDumper&& other) noexcept = default;
|
||||
IZoneDumper& operator=(const IZoneDumper& other) = default;
|
||||
IZoneDumper& operator=(IZoneDumper&& other) noexcept = default;
|
||||
|
||||
virtual bool CanHandleZone(Zone* zone) const = 0;
|
||||
virtual bool DumpZone(Zone* zone, const std::string& basePath) const = 0;
|
||||
virtual bool CanHandleZone(AssetDumpingContext& assetDumpingContext) const = 0;
|
||||
virtual bool DumpZone(AssetDumpingContext& assetDumpingContext) const = 0;
|
||||
};
|
@ -15,7 +15,7 @@ std::string AssetDumperAddonMapEnts::GetFileNameForAsset(Zone* zone, XAssetInfo<
|
||||
return asset->m_name;
|
||||
}
|
||||
|
||||
void AssetDumperAddonMapEnts::DumpAsset(Zone* zone, XAssetInfo<AddonMapEnts>* asset, std::ostream& stream)
|
||||
void AssetDumperAddonMapEnts::DumpAsset(AssetDumpingContext& context, XAssetInfo<AddonMapEnts>* asset, std::ostream& stream)
|
||||
{
|
||||
const auto* addonMapEnts = asset->Asset();
|
||||
stream.write(addonMapEnts->entityString, std::max(addonMapEnts->numEntityChars - 1, 0));
|
||||
|
@ -1,15 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Dumping/AbstractFileDumper.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
|
||||
namespace IW4
|
||||
{
|
||||
class AssetDumperAddonMapEnts final : public AbstractAssetDumper<AddonMapEnts>
|
||||
class AssetDumperAddonMapEnts final : public AbstractFileDumper<AddonMapEnts>
|
||||
{
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<AddonMapEnts>* asset) override;
|
||||
std::string GetFileNameForAsset(Zone* zone, XAssetInfo<AddonMapEnts>* asset) override;
|
||||
void DumpAsset(Zone* zone, XAssetInfo<AddonMapEnts>* asset, std::ostream& stream) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<AddonMapEnts>* asset, std::ostream& stream) override;
|
||||
};
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ std::string AssetDumperGfxImage::GetFileNameForAsset(Zone* zone, XAssetInfo<GfxI
|
||||
return "images/" + asset->m_name + m_writer->GetFileExtension();
|
||||
}
|
||||
|
||||
void AssetDumperGfxImage::DumpAsset(Zone* zone, XAssetInfo<GfxImage>* asset, std::ostream& stream)
|
||||
void AssetDumperGfxImage::DumpAsset(AssetDumpingContext& context, XAssetInfo<GfxImage>* asset, std::ostream& stream)
|
||||
{
|
||||
const auto* image = asset->Asset();
|
||||
m_writer->DumpImage(stream, image->texture.texture);
|
||||
|
@ -1,19 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Dumping/AbstractFileDumper.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "Image/IImageWriter.h"
|
||||
|
||||
namespace IW4
|
||||
{
|
||||
class AssetDumperGfxImage final : public AbstractAssetDumper<GfxImage>
|
||||
class AssetDumperGfxImage final : public AbstractFileDumper<GfxImage>
|
||||
{
|
||||
IImageWriter* m_writer;
|
||||
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<GfxImage>* asset) override;
|
||||
std::string GetFileNameForAsset(Zone* zone, XAssetInfo<GfxImage>* asset) override;
|
||||
void DumpAsset(Zone* zone, XAssetInfo<GfxImage>* asset, std::ostream& stream) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<GfxImage>* asset, std::ostream& stream) override;
|
||||
|
||||
public:
|
||||
AssetDumperGfxImage();
|
||||
|
@ -14,7 +14,7 @@ std::string AssetDumperLoadedSound::GetFileNameForAsset(Zone* zone, XAssetInfo<L
|
||||
return "sound/" + asset->m_name;
|
||||
}
|
||||
|
||||
void AssetDumperLoadedSound::DumpWavPcm(Zone* zone, const LoadedSound* asset, std::ostream& stream)
|
||||
void AssetDumperLoadedSound::DumpWavPcm(AssetDumpingContext& context, const LoadedSound* asset, std::ostream& stream)
|
||||
{
|
||||
const auto riffMasterChunkSize = sizeof(WAV_CHUNK_ID_RIFF)
|
||||
+ sizeof(uint32_t)
|
||||
@ -55,13 +55,13 @@ void AssetDumperLoadedSound::DumpWavPcm(Zone* zone, const LoadedSound* asset, st
|
||||
stream.write(asset->sound.data, asset->sound.info.data_len);
|
||||
}
|
||||
|
||||
void AssetDumperLoadedSound::DumpAsset(Zone* zone, XAssetInfo<LoadedSound>* asset, std::ostream& stream)
|
||||
void AssetDumperLoadedSound::DumpAsset(AssetDumpingContext& context, XAssetInfo<LoadedSound>* asset, std::ostream& stream)
|
||||
{
|
||||
const auto* loadedSound = asset->Asset();
|
||||
switch (static_cast<WavFormat>(loadedSound->sound.info.format))
|
||||
{
|
||||
case WavFormat::PCM:
|
||||
DumpWavPcm(zone, loadedSound, stream);
|
||||
DumpWavPcm(context, loadedSound, stream);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -1,16 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Dumping/AbstractFileDumper.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
|
||||
namespace IW4
|
||||
{
|
||||
class AssetDumperLoadedSound final : public AbstractAssetDumper<LoadedSound>
|
||||
class AssetDumperLoadedSound final : public AbstractFileDumper<LoadedSound>
|
||||
{
|
||||
static void DumpWavPcm(Zone* zone, const LoadedSound* asset, std::ostream& stream);
|
||||
static void DumpWavPcm(AssetDumpingContext& context, const LoadedSound* asset, std::ostream& stream);
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<LoadedSound>* asset) override;
|
||||
std::string GetFileNameForAsset(Zone* zone, XAssetInfo<LoadedSound>* asset) override;
|
||||
void DumpAsset(Zone* zone, XAssetInfo<LoadedSound>* asset, std::ostream& stream) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<LoadedSound>* asset, std::ostream& stream) override;
|
||||
};
|
||||
}
|
||||
|
@ -9,27 +9,27 @@
|
||||
using namespace IW4;
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
void AssetDumperLocalizeEntry::DumpPool(Zone* zone, AssetPool<LocalizeEntry>* pool, const std::string& basePath)
|
||||
void AssetDumperLocalizeEntry::DumpPool(AssetDumpingContext& context, AssetPool<LocalizeEntry>* pool)
|
||||
{
|
||||
if (pool->m_asset_lookup.empty())
|
||||
return;
|
||||
|
||||
const auto language = LocalizeCommon::GetNameOfLanguage(zone->m_language);
|
||||
fs::path stringsPath(basePath);
|
||||
const auto language = LocalizeCommon::GetNameOfLanguage(context.m_zone->m_language);
|
||||
fs::path stringsPath(context.m_base_path);
|
||||
stringsPath.append(language);
|
||||
stringsPath.append("/localizedstrings");
|
||||
|
||||
create_directories(stringsPath);
|
||||
|
||||
auto stringFilePath(stringsPath);
|
||||
stringFilePath.append(zone->m_name);
|
||||
stringFilePath.append(context.m_zone->m_name);
|
||||
stringFilePath.append(".str");
|
||||
|
||||
std::ofstream stringFile(stringFilePath, std::fstream::out | std::ofstream::binary);
|
||||
|
||||
if (stringFile.is_open())
|
||||
{
|
||||
StringFileDumper stringFileDumper(zone, stringFile);
|
||||
StringFileDumper stringFileDumper(context.m_zone, stringFile);
|
||||
|
||||
stringFileDumper.SetLanguageName(language);
|
||||
|
||||
@ -49,6 +49,6 @@ void AssetDumperLocalizeEntry::DumpPool(Zone* zone, AssetPool<LocalizeEntry>* po
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Could not create string file for dumping localized strings of zone '%s'\n", zone->m_name.c_str());
|
||||
printf("Could not create string file for dumping localized strings of zone '%s'\n", context.m_zone->m_name.c_str());
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Dumping/AbstractFileDumper.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
|
||||
namespace IW4
|
||||
@ -8,6 +8,6 @@ namespace IW4
|
||||
class AssetDumperLocalizeEntry final : public IAssetDumper<LocalizeEntry>
|
||||
{
|
||||
public:
|
||||
void DumpPool(Zone* zone, AssetPool<LocalizeEntry>* pool, const std::string& basePath) override;
|
||||
void DumpPool(AssetDumpingContext& context, AssetPool<LocalizeEntry>* pool) override;
|
||||
};
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ std::string AssetDumperRawFile::GetFileNameForAsset(Zone* zone, XAssetInfo<RawFi
|
||||
return asset->m_name;
|
||||
}
|
||||
|
||||
void AssetDumperRawFile::DumpAsset(Zone* zone, XAssetInfo<RawFile>* asset, std::ostream& stream)
|
||||
void AssetDumperRawFile::DumpAsset(AssetDumpingContext& context, XAssetInfo<RawFile>* asset, std::ostream& stream)
|
||||
{
|
||||
const auto* rawFile = asset->Asset();
|
||||
if (rawFile->compressedLen > 0)
|
||||
|
@ -1,15 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Dumping/AbstractFileDumper.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
|
||||
namespace IW4
|
||||
{
|
||||
class AssetDumperRawFile final : public AbstractAssetDumper<RawFile>
|
||||
class AssetDumperRawFile final : public AbstractFileDumper<RawFile>
|
||||
{
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<RawFile>* asset) override;
|
||||
std::string GetFileNameForAsset(Zone* zone, XAssetInfo<RawFile>* asset) override;
|
||||
void DumpAsset(Zone* zone, XAssetInfo<RawFile>* asset, std::ostream& stream) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<RawFile>* asset, std::ostream& stream) override;
|
||||
};
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ std::string AssetDumperStringTable::GetFileNameForAsset(Zone* zone, XAssetInfo<S
|
||||
return asset->m_name;
|
||||
}
|
||||
|
||||
void AssetDumperStringTable::DumpAsset(Zone* zone, XAssetInfo<StringTable>* asset, std::ostream& stream)
|
||||
void AssetDumperStringTable::DumpAsset(AssetDumpingContext& context, XAssetInfo<StringTable>* asset, std::ostream& stream)
|
||||
{
|
||||
const auto* stringTable = asset->Asset();
|
||||
CsvWriter csv(stream);
|
||||
|
@ -1,15 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Dumping/AbstractFileDumper.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
|
||||
namespace IW4
|
||||
{
|
||||
class AssetDumperStringTable final : public AbstractAssetDumper<StringTable>
|
||||
class AssetDumperStringTable final : public AbstractFileDumper<StringTable>
|
||||
{
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<StringTable>* asset) override;
|
||||
std::string GetFileNameForAsset(Zone* zone, XAssetInfo<StringTable>* asset) override;
|
||||
void DumpAsset(Zone* zone, XAssetInfo<StringTable>* asset, std::ostream& stream) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<StringTable>* asset, std::ostream& stream) override;
|
||||
};
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ std::string AssetDumperVehicle::GetFileNameForAsset(Zone* zone, XAssetInfo<Vehic
|
||||
return "vehicles/" + asset->m_name;
|
||||
}
|
||||
|
||||
void AssetDumperVehicle::DumpAsset(Zone* zone, XAssetInfo<VehicleDef>* asset, std::ostream& stream)
|
||||
void AssetDumperVehicle::DumpAsset(AssetDumpingContext& context, XAssetInfo<VehicleDef>* asset, std::ostream& stream)
|
||||
{
|
||||
InfoStringFromVehicleConverter converter(asset->Asset(), vehicle_fields, std::extent<decltype(vehicle_fields)>::value, [asset](const scr_string_t scrStr) -> std::string
|
||||
{
|
||||
|
@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Dumping/AbstractFileDumper.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
|
||||
namespace IW4
|
||||
{
|
||||
class AssetDumperVehicle final : public AbstractAssetDumper<VehicleDef>
|
||||
class AssetDumperVehicle final : public AbstractFileDumper<VehicleDef>
|
||||
{
|
||||
static cspField_t vehicle_fields[];
|
||||
static cspField_t vehicle_fields2[];
|
||||
@ -13,6 +13,6 @@ namespace IW4
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<VehicleDef>* asset) override;
|
||||
std::string GetFileNameForAsset(Zone* zone, XAssetInfo<VehicleDef>* asset) override;
|
||||
void DumpAsset(Zone* zone, XAssetInfo<VehicleDef>* asset, std::ostream& stream) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<VehicleDef>* asset, std::ostream& stream) override;
|
||||
};
|
||||
}
|
||||
|
@ -1172,7 +1172,7 @@ std::string AssetDumperWeapon::GetFileNameForAsset(Zone* zone, XAssetInfo<Weapon
|
||||
return "weapons/" + asset->m_name;
|
||||
}
|
||||
|
||||
void AssetDumperWeapon::DumpAsset(Zone* zone, XAssetInfo<WeaponCompleteDef>* asset, std::ostream& stream)
|
||||
void AssetDumperWeapon::DumpAsset(AssetDumpingContext& context, XAssetInfo<WeaponCompleteDef>* asset, std::ostream& stream)
|
||||
{
|
||||
auto* fullDef = new WeaponFullDef;
|
||||
memset(fullDef, 0, sizeof(WeaponFullDef));
|
||||
|
@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Dumping/AbstractFileDumper.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
|
||||
namespace IW4
|
||||
{
|
||||
class AssetDumperWeapon final : public AbstractAssetDumper<WeaponCompleteDef>
|
||||
class AssetDumperWeapon final : public AbstractFileDumper<WeaponCompleteDef>
|
||||
{
|
||||
static cspField_t weapon_fields[];
|
||||
|
||||
@ -14,6 +14,6 @@ namespace IW4
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<WeaponCompleteDef>* asset) override;
|
||||
std::string GetFileNameForAsset(Zone* zone, XAssetInfo<WeaponCompleteDef>* asset) override;
|
||||
void DumpAsset(Zone* zone, XAssetInfo<WeaponCompleteDef>* asset, std::ostream& stream) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<WeaponCompleteDef>* asset, std::ostream& stream) override;
|
||||
};
|
||||
}
|
||||
|
@ -14,21 +14,21 @@
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
bool ZoneDumper::CanHandleZone(Zone* zone) const
|
||||
bool ZoneDumper::CanHandleZone(AssetDumpingContext& context) const
|
||||
{
|
||||
return zone->m_game == &g_GameIW4;
|
||||
return context.m_zone->m_game == &g_GameIW4;
|
||||
}
|
||||
|
||||
bool ZoneDumper::DumpZone(Zone* zone, const std::string& basePath) const
|
||||
bool ZoneDumper::DumpZone(AssetDumpingContext& context) const
|
||||
{
|
||||
#define DUMP_ASSET_POOL(dumperType, poolName) \
|
||||
if(assetPools->poolName) \
|
||||
{ \
|
||||
dumperType dumper; \
|
||||
dumper.DumpPool(zone, assetPools->poolName.get(), basePath); \
|
||||
dumper.DumpPool(context, assetPools->poolName.get()); \
|
||||
}
|
||||
|
||||
const auto* assetPools = dynamic_cast<GameAssetPoolIW4*>(zone->m_pools.get());
|
||||
const auto* assetPools = dynamic_cast<GameAssetPoolIW4*>(context.m_zone->m_pools.get());
|
||||
|
||||
// DUMP_ASSET_POOL(AssetDumperPhysPreset, m_phys_preset)
|
||||
// DUMP_ASSET_POOL(AssetDumperPhysCollmap, m_phys_collmap)
|
||||
|
@ -6,7 +6,7 @@ namespace IW4
|
||||
class ZoneDumper final : public IZoneDumper
|
||||
{
|
||||
public:
|
||||
bool CanHandleZone(Zone* zone) const override;
|
||||
bool DumpZone(Zone* zone, const std::string& basePath) const override;
|
||||
bool CanHandleZone(AssetDumpingContext& context) const override;
|
||||
bool DumpZone(AssetDumpingContext& context) const override;
|
||||
};
|
||||
}
|
||||
|
@ -265,7 +265,7 @@ std::string AssetDumperFontIcon::GetFileNameForAsset(Zone* zone, XAssetInfo<Font
|
||||
return asset->m_name;
|
||||
}
|
||||
|
||||
void AssetDumperFontIcon::DumpAsset(Zone* zone, XAssetInfo<FontIcon>* asset, std::ostream& stream)
|
||||
void AssetDumperFontIcon::DumpAsset(AssetDumpingContext& context, XAssetInfo<FontIcon>* asset, std::ostream& stream)
|
||||
{
|
||||
AssetDumperFontIconInternal dumper(stream);
|
||||
dumper.DumpFontIcon(asset->Asset());
|
||||
|
@ -1,15 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Dumping/AbstractFileDumper.h"
|
||||
#include "Game/T6/T6.h"
|
||||
|
||||
namespace T6
|
||||
{
|
||||
class AssetDumperFontIcon final : public AbstractAssetDumper<FontIcon>
|
||||
class AssetDumperFontIcon final : public AbstractFileDumper<FontIcon>
|
||||
{
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<FontIcon>* asset) override;
|
||||
std::string GetFileNameForAsset(Zone* zone, XAssetInfo<FontIcon>* asset) override;
|
||||
void DumpAsset(Zone* zone, XAssetInfo<FontIcon>* asset, std::ostream& stream) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<FontIcon>* asset, std::ostream& stream) override;
|
||||
};
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ std::string AssetDumperGfxImage::GetFileNameForAsset(Zone* zone, XAssetInfo<GfxI
|
||||
return "images/" + asset->m_name + m_writer->GetFileExtension();
|
||||
}
|
||||
|
||||
void AssetDumperGfxImage::DumpAsset(Zone* zone, XAssetInfo<GfxImage>* asset, std::ostream& stream)
|
||||
void AssetDumperGfxImage::DumpAsset(AssetDumpingContext& context, XAssetInfo<GfxImage>* asset, std::ostream& stream)
|
||||
{
|
||||
const auto* image = asset->Asset();
|
||||
m_writer->DumpImage(stream, image->texture.texture);
|
||||
|
@ -1,19 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Dumping/AbstractFileDumper.h"
|
||||
#include "Game/T6/T6.h"
|
||||
#include "Image/IImageWriter.h"
|
||||
|
||||
namespace T6
|
||||
{
|
||||
class AssetDumperGfxImage final : public AbstractAssetDumper<GfxImage>
|
||||
class AssetDumperGfxImage final : public AbstractFileDumper<GfxImage>
|
||||
{
|
||||
IImageWriter* m_writer;
|
||||
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<GfxImage>* asset) override;
|
||||
std::string GetFileNameForAsset(Zone* zone, XAssetInfo<GfxImage>* asset) override;
|
||||
void DumpAsset(Zone* zone, XAssetInfo<GfxImage>* asset, std::ostream& stream) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<GfxImage>* asset, std::ostream& stream) override;
|
||||
|
||||
public:
|
||||
AssetDumperGfxImage();
|
||||
|
@ -9,27 +9,27 @@
|
||||
using namespace T6;
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
void AssetDumperLocalizeEntry::DumpPool(Zone* zone, AssetPool<LocalizeEntry>* pool, const std::string& basePath)
|
||||
void AssetDumperLocalizeEntry::DumpPool(AssetDumpingContext& context, AssetPool<LocalizeEntry>* pool)
|
||||
{
|
||||
if (pool->m_asset_lookup.empty())
|
||||
return;
|
||||
|
||||
const auto language = LocalizeCommon::GetNameOfLanguage(zone->m_language);
|
||||
fs::path stringsPath(basePath);
|
||||
const auto language = LocalizeCommon::GetNameOfLanguage(context.m_zone->m_language);
|
||||
fs::path stringsPath(context.m_base_path);
|
||||
stringsPath.append(language);
|
||||
stringsPath.append("/localizedstrings");
|
||||
|
||||
create_directories(stringsPath);
|
||||
|
||||
auto stringFilePath(stringsPath);
|
||||
stringFilePath.append(zone->m_name);
|
||||
stringFilePath.append(context.m_zone->m_name);
|
||||
stringFilePath.append(".str");
|
||||
|
||||
std::ofstream stringFile(stringFilePath, std::fstream::out | std::ofstream::binary);
|
||||
|
||||
if(stringFile.is_open())
|
||||
{
|
||||
StringFileDumper stringFileDumper(zone, stringFile);
|
||||
StringFileDumper stringFileDumper(context.m_zone, stringFile);
|
||||
|
||||
stringFileDumper.SetLanguageName(language);
|
||||
|
||||
@ -49,6 +49,6 @@ void AssetDumperLocalizeEntry::DumpPool(Zone* zone, AssetPool<LocalizeEntry>* po
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Could not create string file for dumping localized strings of zone '%s'\n", zone->m_name.c_str());
|
||||
printf("Could not create string file for dumping localized strings of zone '%s'\n", context.m_zone->m_name.c_str());
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Dumping/AbstractFileDumper.h"
|
||||
#include "Game/T6/T6.h"
|
||||
|
||||
namespace T6
|
||||
@ -8,6 +8,6 @@ namespace T6
|
||||
class AssetDumperLocalizeEntry final : public IAssetDumper<LocalizeEntry>
|
||||
{
|
||||
public:
|
||||
void DumpPool(Zone* zone, AssetPool<LocalizeEntry>* pool, const std::string& basePath) override;
|
||||
void DumpPool(AssetDumpingContext& context, AssetPool<LocalizeEntry>* pool) override;
|
||||
};
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ std::string AssetDumperPhysConstraints::GetFileNameForAsset(Zone* zone, XAssetIn
|
||||
return "physconstraints/" + asset->m_name;
|
||||
}
|
||||
|
||||
void AssetDumperPhysConstraints::DumpAsset(Zone* zone, XAssetInfo<PhysConstraints>* asset, std::ostream& stream)
|
||||
void AssetDumperPhysConstraints::DumpAsset(AssetDumpingContext& context, XAssetInfo<PhysConstraints>* asset, std::ostream& stream)
|
||||
{
|
||||
assert(asset->Asset()->count <= 4);
|
||||
|
||||
|
@ -1,17 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Dumping/AbstractFileDumper.h"
|
||||
#include "Game/T6/T6.h"
|
||||
|
||||
namespace T6
|
||||
{
|
||||
class AssetDumperPhysConstraints final : public AbstractAssetDumper<PhysConstraints>
|
||||
class AssetDumperPhysConstraints final : public AbstractFileDumper<PhysConstraints>
|
||||
{
|
||||
static cspField_t phys_constraints_fields[];
|
||||
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<PhysConstraints>* asset) override;
|
||||
std::string GetFileNameForAsset(Zone* zone, XAssetInfo<PhysConstraints>* asset) override;
|
||||
void DumpAsset(Zone* zone, XAssetInfo<PhysConstraints>* asset, std::ostream& stream) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<PhysConstraints>* asset, std::ostream& stream) override;
|
||||
};
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ std::string AssetDumperPhysPreset::GetFileNameForAsset(Zone* zone, XAssetInfo<Ph
|
||||
return "physic/" + asset->m_name;
|
||||
}
|
||||
|
||||
void AssetDumperPhysPreset::DumpAsset(Zone* zone, XAssetInfo<PhysPreset>* asset, std::ostream& stream)
|
||||
void AssetDumperPhysPreset::DumpAsset(AssetDumpingContext& context, XAssetInfo<PhysPreset>* asset, std::ostream& stream)
|
||||
{
|
||||
auto* physPresetInfo = new PhysPresetInfo;
|
||||
CopyToPhysPresetInfo(asset->Asset(), physPresetInfo);
|
||||
|
@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Dumping/AbstractFileDumper.h"
|
||||
#include "Game/T6/T6.h"
|
||||
|
||||
namespace T6
|
||||
{
|
||||
class AssetDumperPhysPreset final : public AbstractAssetDumper<PhysPreset>
|
||||
class AssetDumperPhysPreset final : public AbstractFileDumper<PhysPreset>
|
||||
{
|
||||
static cspField_t physpreset_fields[];
|
||||
|
||||
@ -14,6 +14,6 @@ namespace T6
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<PhysPreset>* asset) override;
|
||||
std::string GetFileNameForAsset(Zone* zone, XAssetInfo<PhysPreset>* asset) override;
|
||||
void DumpAsset(Zone* zone, XAssetInfo<PhysPreset>* asset, std::ostream& stream) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<PhysPreset>* asset, std::ostream& stream) override;
|
||||
};
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ std::string AssetDumperQdb::GetFileNameForAsset(Zone* zone, XAssetInfo<Qdb>* ass
|
||||
return asset->m_name;
|
||||
}
|
||||
|
||||
void AssetDumperQdb::DumpAsset(Zone* zone, XAssetInfo<Qdb>* asset, std::ostream& stream)
|
||||
void AssetDumperQdb::DumpAsset(AssetDumpingContext& context, XAssetInfo<Qdb>* asset, std::ostream& stream)
|
||||
{
|
||||
const auto* qdb = asset->Asset();
|
||||
stream.write(qdb->buffer, qdb->len);
|
||||
|
@ -1,15 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Dumping/AbstractFileDumper.h"
|
||||
#include "Game/T6/T6.h"
|
||||
|
||||
namespace T6
|
||||
{
|
||||
class AssetDumperQdb final : public AbstractAssetDumper<Qdb>
|
||||
class AssetDumperQdb final : public AbstractFileDumper<Qdb>
|
||||
{
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<Qdb>* asset) override;
|
||||
std::string GetFileNameForAsset(Zone* zone, XAssetInfo<Qdb>* asset) override;
|
||||
void DumpAsset(Zone* zone, XAssetInfo<Qdb>* asset, std::ostream& stream) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<Qdb>* asset, std::ostream& stream) override;
|
||||
};
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ std::string AssetDumperRawFile::GetFileNameForAsset(Zone* zone, XAssetInfo<RawFi
|
||||
return asset->m_name;
|
||||
}
|
||||
|
||||
void AssetDumperRawFile::DumpAsset(Zone* zone, XAssetInfo<RawFile>* asset, std::ostream& stream)
|
||||
void AssetDumperRawFile::DumpAsset(AssetDumpingContext& context, XAssetInfo<RawFile>* asset, std::ostream& stream)
|
||||
{
|
||||
const auto* rawFile = asset->Asset();
|
||||
stream.write(rawFile->buffer, rawFile->len);
|
||||
|
@ -1,15 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Dumping/AbstractFileDumper.h"
|
||||
#include "Game/T6/T6.h"
|
||||
|
||||
namespace T6
|
||||
{
|
||||
class AssetDumperRawFile final : public AbstractAssetDumper<RawFile>
|
||||
class AssetDumperRawFile final : public AbstractFileDumper<RawFile>
|
||||
{
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<RawFile>* asset) override;
|
||||
std::string GetFileNameForAsset(Zone* zone, XAssetInfo<RawFile>* asset) override;
|
||||
void DumpAsset(Zone* zone, XAssetInfo<RawFile>* asset, std::ostream& stream) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<RawFile>* asset, std::ostream& stream) override;
|
||||
};
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ std::string AssetDumperScriptParseTree::GetFileNameForAsset(Zone* zone, XAssetIn
|
||||
return asset->m_name;
|
||||
}
|
||||
|
||||
void AssetDumperScriptParseTree::DumpAsset(Zone* zone, XAssetInfo<ScriptParseTree>* asset, std::ostream& stream)
|
||||
void AssetDumperScriptParseTree::DumpAsset(AssetDumpingContext& context, XAssetInfo<ScriptParseTree>* asset, std::ostream& stream)
|
||||
{
|
||||
const auto* scriptParseTree = asset->Asset();
|
||||
stream.write(scriptParseTree->buffer, scriptParseTree->len);
|
||||
|
@ -1,15 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Dumping/AbstractFileDumper.h"
|
||||
#include "Game/T6/T6.h"
|
||||
|
||||
namespace T6
|
||||
{
|
||||
class AssetDumperScriptParseTree final : public AbstractAssetDumper<ScriptParseTree>
|
||||
class AssetDumperScriptParseTree final : public AbstractFileDumper<ScriptParseTree>
|
||||
{
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<ScriptParseTree>* asset) override;
|
||||
std::string GetFileNameForAsset(Zone* zone, XAssetInfo<ScriptParseTree>* asset) override;
|
||||
void DumpAsset(Zone* zone, XAssetInfo<ScriptParseTree>* asset, std::ostream& stream) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<ScriptParseTree>* asset, std::ostream& stream) override;
|
||||
};
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ std::string AssetDumperSlug::GetFileNameForAsset(Zone* zone, XAssetInfo<Slug>* a
|
||||
return asset->m_name;
|
||||
}
|
||||
|
||||
void AssetDumperSlug::DumpAsset(Zone* zone, XAssetInfo<Slug>* asset, std::ostream& stream)
|
||||
void AssetDumperSlug::DumpAsset(AssetDumpingContext& context, XAssetInfo<Slug>* asset, std::ostream& stream)
|
||||
{
|
||||
const auto* slug = asset->Asset();
|
||||
stream.write(slug->buffer, slug->len);
|
||||
|
@ -1,15 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Dumping/AbstractFileDumper.h"
|
||||
#include "Game/T6/T6.h"
|
||||
|
||||
namespace T6
|
||||
{
|
||||
class AssetDumperSlug final : public AbstractAssetDumper<Slug>
|
||||
class AssetDumperSlug final : public AbstractFileDumper<Slug>
|
||||
{
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<Slug>* asset) override;
|
||||
std::string GetFileNameForAsset(Zone* zone, XAssetInfo<Slug>* asset) override;
|
||||
void DumpAsset(Zone* zone, XAssetInfo<Slug>* asset, std::ostream& stream) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<Slug>* asset, std::ostream& stream) override;
|
||||
};
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ std::string AssetDumperStringTable::GetFileNameForAsset(Zone* zone, XAssetInfo<S
|
||||
return asset->m_name;
|
||||
}
|
||||
|
||||
void AssetDumperStringTable::DumpAsset(Zone* zone, XAssetInfo<StringTable>* asset, std::ostream& stream)
|
||||
void AssetDumperStringTable::DumpAsset(AssetDumpingContext& context, XAssetInfo<StringTable>* asset, std::ostream& stream)
|
||||
{
|
||||
const auto* stringTable = asset->Asset();
|
||||
CsvWriter csv(stream);
|
||||
|
@ -1,15 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Dumping/AbstractFileDumper.h"
|
||||
#include "Game/T6/T6.h"
|
||||
|
||||
namespace T6
|
||||
{
|
||||
class AssetDumperStringTable final : public AbstractAssetDumper<StringTable>
|
||||
class AssetDumperStringTable final : public AbstractFileDumper<StringTable>
|
||||
{
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<StringTable>* asset) override;
|
||||
std::string GetFileNameForAsset(Zone* zone, XAssetInfo<StringTable>* asset) override;
|
||||
void DumpAsset(Zone* zone, XAssetInfo<StringTable>* asset, std::ostream& stream) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<StringTable>* asset, std::ostream& stream) override;
|
||||
};
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ std::string AssetDumperTracer::GetFileNameForAsset(Zone* zone, XAssetInfo<Tracer
|
||||
return "tracer/" + asset->m_name;
|
||||
}
|
||||
|
||||
void AssetDumperTracer::DumpAsset(Zone* zone, XAssetInfo<TracerDef>* asset, std::ostream& stream)
|
||||
void AssetDumperTracer::DumpAsset(AssetDumpingContext& context, XAssetInfo<TracerDef>* asset, std::ostream& stream)
|
||||
{
|
||||
InfoStringFromTracerConverter converter(asset->Asset(), tracer_fields, std::extent<decltype(tracer_fields)>::value, [asset](const scr_string_t scrStr) -> std::string
|
||||
{
|
||||
|
@ -1,17 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Dumping/AbstractFileDumper.h"
|
||||
#include "Game/T6/T6.h"
|
||||
|
||||
namespace T6
|
||||
{
|
||||
class AssetDumperTracer final : public AbstractAssetDumper<TracerDef>
|
||||
class AssetDumperTracer final : public AbstractFileDumper<TracerDef>
|
||||
{
|
||||
static cspField_t tracer_fields[];
|
||||
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<TracerDef>* asset) override;
|
||||
std::string GetFileNameForAsset(Zone* zone, XAssetInfo<TracerDef>* asset) override;
|
||||
void DumpAsset(Zone* zone, XAssetInfo<TracerDef>* asset, std::ostream& stream) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<TracerDef>* asset, std::ostream& stream) override;
|
||||
};
|
||||
}
|
||||
|
@ -681,7 +681,7 @@ std::string AssetDumperVehicle::GetFileNameForAsset(Zone* zone, XAssetInfo<Vehic
|
||||
return "vehicles/" + asset->m_name;
|
||||
}
|
||||
|
||||
void AssetDumperVehicle::DumpAsset(Zone* zone, XAssetInfo<VehicleDef>* asset, std::ostream& stream)
|
||||
void AssetDumperVehicle::DumpAsset(AssetDumpingContext& context, XAssetInfo<VehicleDef>* asset, std::ostream& stream)
|
||||
{
|
||||
InfoStringFromVehicleConverter converter(asset->Asset(), vehicle_fields, std::extent<decltype(vehicle_fields)>::value, [asset](const scr_string_t scrStr) -> std::string
|
||||
{
|
||||
|
@ -1,17 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Dumping/AbstractFileDumper.h"
|
||||
#include "Game/T6/T6.h"
|
||||
|
||||
namespace T6
|
||||
{
|
||||
class AssetDumperVehicle final : public AbstractAssetDumper<VehicleDef>
|
||||
class AssetDumperVehicle final : public AbstractFileDumper<VehicleDef>
|
||||
{
|
||||
static cspField_t vehicle_fields[];
|
||||
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<VehicleDef>* asset) override;
|
||||
std::string GetFileNameForAsset(Zone* zone, XAssetInfo<VehicleDef>* asset) override;
|
||||
void DumpAsset(Zone* zone, XAssetInfo<VehicleDef>* asset, std::ostream& stream) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<VehicleDef>* asset, std::ostream& stream) override;
|
||||
};
|
||||
}
|
||||
|
@ -1633,7 +1633,7 @@ std::string AssetDumperWeapon::GetFileNameForAsset(Zone* zone, XAssetInfo<Weapon
|
||||
return "weapons/" + asset->m_name;
|
||||
}
|
||||
|
||||
void AssetDumperWeapon::DumpAsset(Zone* zone, XAssetInfo<WeaponVariantDef>* asset, std::ostream& stream)
|
||||
void AssetDumperWeapon::DumpAsset(AssetDumpingContext& context, XAssetInfo<WeaponVariantDef>* asset, std::ostream& stream)
|
||||
{
|
||||
auto* fullDef = new WeaponFullDef;
|
||||
memset(fullDef, 0, sizeof(WeaponFullDef));
|
||||
|
@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Dumping/AbstractFileDumper.h"
|
||||
#include "Game/T6/T6.h"
|
||||
|
||||
namespace T6
|
||||
{
|
||||
class AssetDumperWeapon final : public AbstractAssetDumper<WeaponVariantDef>
|
||||
class AssetDumperWeapon final : public AbstractFileDumper<WeaponVariantDef>
|
||||
{
|
||||
static cspField_t weapon_fields[];
|
||||
|
||||
@ -14,6 +14,6 @@ namespace T6
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<WeaponVariantDef>* asset) override;
|
||||
std::string GetFileNameForAsset(Zone* zone, XAssetInfo<WeaponVariantDef>* asset) override;
|
||||
void DumpAsset(Zone* zone, XAssetInfo<WeaponVariantDef>* asset, std::ostream& stream) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<WeaponVariantDef>* asset, std::ostream& stream) override;
|
||||
};
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ std::string AssetDumperZBarrier::GetFileNameForAsset(Zone* zone, XAssetInfo<ZBar
|
||||
return "zbarrier/" + asset->m_name;
|
||||
}
|
||||
|
||||
void AssetDumperZBarrier::DumpAsset(Zone* zone, XAssetInfo<ZBarrierDef>* asset, std::ostream& stream)
|
||||
void AssetDumperZBarrier::DumpAsset(AssetDumpingContext& context, XAssetInfo<ZBarrierDef>* asset, std::ostream& stream)
|
||||
{
|
||||
InfoStringFromZBarrierConverter converter(asset->Asset(), zbarrier_fields, std::extent<decltype(zbarrier_fields)>::value, [asset](const scr_string_t scrStr) -> std::string
|
||||
{
|
||||
|
@ -1,17 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Dumping/AbstractFileDumper.h"
|
||||
#include "Game/T6/T6.h"
|
||||
|
||||
namespace T6
|
||||
{
|
||||
class AssetDumperZBarrier final : public AbstractAssetDumper<ZBarrierDef>
|
||||
class AssetDumperZBarrier final : public AbstractFileDumper<ZBarrierDef>
|
||||
{
|
||||
static cspField_t zbarrier_fields[];
|
||||
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<ZBarrierDef>* asset) override;
|
||||
std::string GetFileNameForAsset(Zone* zone, XAssetInfo<ZBarrierDef>* asset) override;
|
||||
void DumpAsset(Zone* zone, XAssetInfo<ZBarrierDef>* asset, std::ostream& stream) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<ZBarrierDef>* asset, std::ostream& stream) override;
|
||||
};
|
||||
}
|
||||
|
@ -20,21 +20,21 @@
|
||||
|
||||
using namespace T6;
|
||||
|
||||
bool ZoneDumper::CanHandleZone(Zone* zone) const
|
||||
bool ZoneDumper::CanHandleZone(AssetDumpingContext& context) const
|
||||
{
|
||||
return zone->m_game == &g_GameT6;
|
||||
return context.m_zone->m_game == &g_GameT6;
|
||||
}
|
||||
|
||||
bool ZoneDumper::DumpZone(Zone* zone, const std::string& basePath) const
|
||||
bool ZoneDumper::DumpZone(AssetDumpingContext& context) const
|
||||
{
|
||||
#define DUMP_ASSET_POOL(dumperType, poolName) \
|
||||
if(assetPools->poolName) \
|
||||
{ \
|
||||
dumperType dumper; \
|
||||
dumper.DumpPool(zone, assetPools->poolName, basePath); \
|
||||
dumper.DumpPool(context, assetPools->poolName); \
|
||||
}
|
||||
|
||||
const auto* assetPools = dynamic_cast<GameAssetPoolT6*>(zone->m_pools.get());
|
||||
const auto* assetPools = dynamic_cast<GameAssetPoolT6*>(context.m_zone->m_pools.get());
|
||||
|
||||
DUMP_ASSET_POOL(AssetDumperPhysPreset, m_phys_preset);
|
||||
DUMP_ASSET_POOL(AssetDumperPhysConstraints, m_phys_constraints);
|
||||
|
@ -6,7 +6,7 @@ namespace T6
|
||||
class ZoneDumper final : public IZoneDumper
|
||||
{
|
||||
public:
|
||||
bool CanHandleZone(Zone* zone) const override;
|
||||
bool DumpZone(Zone* zone, const std::string& basePath) const override;
|
||||
bool CanHandleZone(AssetDumpingContext& context) const override;
|
||||
bool DumpZone(AssetDumpingContext& context) const override;
|
||||
};
|
||||
}
|
||||
|
@ -11,18 +11,18 @@ const IZoneDumper* const ZONE_DUMPER[]
|
||||
new T6::ZoneDumper()
|
||||
};
|
||||
|
||||
bool ObjWriting::DumpZone(Zone* zone, const std::string& basePath)
|
||||
bool ObjWriting::DumpZone(AssetDumpingContext& context)
|
||||
{
|
||||
for (auto dumper : ZONE_DUMPER)
|
||||
for (const auto* dumper : ZONE_DUMPER)
|
||||
{
|
||||
if (dumper->CanHandleZone(zone))
|
||||
if (dumper->CanHandleZone(context))
|
||||
{
|
||||
if (dumper->DumpZone(zone, basePath))
|
||||
if (dumper->DumpZone(context))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
printf("Dumper for zone '%s' failed!\n", zone->m_name.c_str());
|
||||
printf("Dumper for zone '%s' failed!\n", context.m_zone->m_name.c_str());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "Zone/Zone.h"
|
||||
#include <string>
|
||||
#include "Dumping/AssetDumpingContext.h"
|
||||
|
||||
class ObjWriting
|
||||
{
|
||||
@ -20,5 +19,5 @@ public:
|
||||
|
||||
} Configuration;
|
||||
|
||||
static bool DumpZone(Zone* zone, const std::string& basePath);
|
||||
static bool DumpZone(AssetDumpingContext& context);
|
||||
};
|
||||
|
@ -150,6 +150,39 @@ class Unlinker::Impl
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool WriteZoneDefinitionFile(Zone* zone, const fs::path& zoneDefinitionFileFolder)
|
||||
{
|
||||
auto zoneDefinitionFilePath(zoneDefinitionFileFolder);
|
||||
zoneDefinitionFilePath.append(zone->m_name);
|
||||
zoneDefinitionFilePath.replace_extension(".zone");
|
||||
|
||||
std::ofstream zoneDefinitionFile(zoneDefinitionFilePath, std::fstream::out | std::fstream::binary);
|
||||
if (!zoneDefinitionFile.is_open())
|
||||
{
|
||||
printf("Failed to open file for zone definition file of zone \"%s\".\n", zone->m_name.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
auto result = false;
|
||||
for (const auto* zoneDefWriter : ZONE_DEF_WRITERS)
|
||||
{
|
||||
if (zoneDefWriter->CanHandleZone(zone))
|
||||
{
|
||||
zoneDefWriter->WriteZoneDef(zone, zoneDefinitionFile);
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!result)
|
||||
{
|
||||
printf("Failed to find writer for zone definition file of zone \"%s\".\n", zone->m_name.c_str());
|
||||
}
|
||||
|
||||
zoneDefinitionFile.close();
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Performs the tasks specified by the command line arguments on the specified zone.
|
||||
* \param zone The zone to handle.
|
||||
@ -171,31 +204,12 @@ class Unlinker::Impl
|
||||
zoneDefinitionFileFolder.append("zone_source");
|
||||
fs::create_directories(zoneDefinitionFileFolder);
|
||||
|
||||
auto zoneDefinitionFilePath(zoneDefinitionFileFolder);
|
||||
zoneDefinitionFilePath.append(zone->m_name);
|
||||
zoneDefinitionFilePath.replace_extension(".zone");
|
||||
WriteZoneDefinitionFile(zone, zoneDefinitionFileFolder);
|
||||
|
||||
std::ofstream zoneDefinitionFile(zoneDefinitionFilePath, std::fstream::out | std::fstream::binary);
|
||||
|
||||
if (zoneDefinitionFile.is_open())
|
||||
{
|
||||
for (const auto* zoneDefWriter : ZONE_DEF_WRITERS)
|
||||
{
|
||||
if (zoneDefWriter->CanHandleZone(zone))
|
||||
{
|
||||
zoneDefWriter->WriteZoneDef(zone, zoneDefinitionFile);
|
||||
break;
|
||||
}
|
||||
}
|
||||
ObjWriting::DumpZone(zone, outputFolderPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Failed to open file for zone definition file of zone \"%s\".\n", zone->m_name.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
zoneDefinitionFile.close();
|
||||
AssetDumpingContext context;
|
||||
context.m_zone = zone;
|
||||
context.m_base_path = outputFolderPath;
|
||||
ObjWriting::DumpZone(context);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user