mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-19 11:17:57 -05:00
Make dumpers works as gdt dumpers and raw dumpers
This commit is contained in:
@ -10,12 +10,17 @@ bool AssetDumperAddonMapEnts::ShouldDump(XAssetInfo<AddonMapEnts>* asset)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetDumperAddonMapEnts::CanDumpAsRaw()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string AssetDumperAddonMapEnts::GetFileNameForAsset(Zone* zone, XAssetInfo<AddonMapEnts>* asset)
|
||||
{
|
||||
return asset->m_name;
|
||||
}
|
||||
|
||||
void AssetDumperAddonMapEnts::DumpAsset(AssetDumpingContext& context, XAssetInfo<AddonMapEnts>* asset, std::ostream& stream)
|
||||
void AssetDumperAddonMapEnts::DumpRaw(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,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractFileDumper.h"
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
|
||||
namespace IW4
|
||||
{
|
||||
class AssetDumperAddonMapEnts final : public AbstractFileDumper<AddonMapEnts>
|
||||
class AssetDumperAddonMapEnts final : public AbstractAssetDumper<AddonMapEnts>
|
||||
{
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<AddonMapEnts>* asset) override;
|
||||
bool CanDumpAsRaw() override;
|
||||
std::string GetFileNameForAsset(Zone* zone, XAssetInfo<AddonMapEnts>* asset) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<AddonMapEnts>* asset, std::ostream& stream) override;
|
||||
void DumpRaw(AssetDumpingContext& context, XAssetInfo<AddonMapEnts>* asset, std::ostream& stream) override;
|
||||
};
|
||||
}
|
||||
|
@ -13,10 +13,10 @@ AssetDumperGfxImage::AssetDumperGfxImage()
|
||||
switch (ObjWriting::Configuration.ImageOutputFormat)
|
||||
{
|
||||
case ObjWriting::Configuration_t::ImageOutputFormat_e::DDS:
|
||||
m_writer = new DdsWriter();
|
||||
m_writer = std::make_unique<DdsWriter>();
|
||||
break;
|
||||
case ObjWriting::Configuration_t::ImageOutputFormat_e::IWI:
|
||||
m_writer = new iwi8::IwiWriter();
|
||||
m_writer = std::make_unique<iwi8::IwiWriter>();
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
@ -25,24 +25,23 @@ AssetDumperGfxImage::AssetDumperGfxImage()
|
||||
}
|
||||
}
|
||||
|
||||
AssetDumperGfxImage::~AssetDumperGfxImage()
|
||||
{
|
||||
delete m_writer;
|
||||
m_writer = nullptr;
|
||||
}
|
||||
|
||||
bool AssetDumperGfxImage::ShouldDump(XAssetInfo<GfxImage>* asset)
|
||||
{
|
||||
const auto* image = asset->Asset();
|
||||
return image->cardMemory.platform[0] > 0;
|
||||
}
|
||||
|
||||
bool AssetDumperGfxImage::CanDumpAsRaw()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string AssetDumperGfxImage::GetFileNameForAsset(Zone* zone, XAssetInfo<GfxImage>* asset)
|
||||
{
|
||||
return "images/" + asset->m_name + m_writer->GetFileExtension();
|
||||
}
|
||||
|
||||
void AssetDumperGfxImage::DumpAsset(AssetDumpingContext& context, XAssetInfo<GfxImage>* asset, std::ostream& stream)
|
||||
void AssetDumperGfxImage::DumpRaw(AssetDumpingContext& context, XAssetInfo<GfxImage>* asset, std::ostream& stream)
|
||||
{
|
||||
const auto* image = asset->Asset();
|
||||
m_writer->DumpImage(stream, image->texture.texture);
|
||||
|
@ -1,27 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractFileDumper.h"
|
||||
#include <memory>
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "Image/IImageWriter.h"
|
||||
|
||||
namespace IW4
|
||||
{
|
||||
class AssetDumperGfxImage final : public AbstractFileDumper<GfxImage>
|
||||
class AssetDumperGfxImage final : public AbstractAssetDumper<GfxImage>
|
||||
{
|
||||
IImageWriter* m_writer;
|
||||
std::unique_ptr<IImageWriter> m_writer;
|
||||
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<GfxImage>* asset) override;
|
||||
bool CanDumpAsRaw() override;
|
||||
std::string GetFileNameForAsset(Zone* zone, XAssetInfo<GfxImage>* asset) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<GfxImage>* asset, std::ostream& stream) override;
|
||||
void DumpRaw(AssetDumpingContext& context, XAssetInfo<GfxImage>* asset, std::ostream& stream) override;
|
||||
|
||||
public:
|
||||
AssetDumperGfxImage();
|
||||
~AssetDumperGfxImage() override;
|
||||
|
||||
AssetDumperGfxImage(const AssetDumperGfxImage& other) = delete;
|
||||
AssetDumperGfxImage(AssetDumperGfxImage&& other) noexcept = delete;
|
||||
AssetDumperGfxImage& operator=(const AssetDumperGfxImage& other) = delete;
|
||||
AssetDumperGfxImage& operator=(AssetDumperGfxImage&& other) noexcept = delete;
|
||||
};
|
||||
}
|
||||
|
@ -9,6 +9,11 @@ bool AssetDumperLoadedSound::ShouldDump(XAssetInfo<LoadedSound>* asset)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetDumperLoadedSound::CanDumpAsRaw()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string AssetDumperLoadedSound::GetFileNameForAsset(Zone* zone, XAssetInfo<LoadedSound>* asset)
|
||||
{
|
||||
return "sound/" + asset->m_name;
|
||||
@ -55,7 +60,7 @@ void AssetDumperLoadedSound::DumpWavPcm(AssetDumpingContext& context, const Load
|
||||
stream.write(asset->sound.data, asset->sound.info.data_len);
|
||||
}
|
||||
|
||||
void AssetDumperLoadedSound::DumpAsset(AssetDumpingContext& context, XAssetInfo<LoadedSound>* asset, std::ostream& stream)
|
||||
void AssetDumperLoadedSound::DumpRaw(AssetDumpingContext& context, XAssetInfo<LoadedSound>* asset, std::ostream& stream)
|
||||
{
|
||||
const auto* loadedSound = asset->Asset();
|
||||
switch (static_cast<WavFormat>(loadedSound->sound.info.format))
|
||||
|
@ -1,16 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractFileDumper.h"
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
|
||||
namespace IW4
|
||||
{
|
||||
class AssetDumperLoadedSound final : public AbstractFileDumper<LoadedSound>
|
||||
class AssetDumperLoadedSound final : public AbstractAssetDumper<LoadedSound>
|
||||
{
|
||||
static void DumpWavPcm(AssetDumpingContext& context, const LoadedSound* asset, std::ostream& stream);
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<LoadedSound>* asset) override;
|
||||
bool CanDumpAsRaw() override;
|
||||
std::string GetFileNameForAsset(Zone* zone, XAssetInfo<LoadedSound>* asset) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<LoadedSound>* asset, std::ostream& stream) override;
|
||||
void DumpRaw(AssetDumpingContext& context, XAssetInfo<LoadedSound>* asset, std::ostream& stream) override;
|
||||
};
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractFileDumper.h"
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
|
||||
namespace IW4
|
||||
|
@ -10,12 +10,17 @@ bool AssetDumperRawFile::ShouldDump(XAssetInfo<RawFile>* asset)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetDumperRawFile::CanDumpAsRaw()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string AssetDumperRawFile::GetFileNameForAsset(Zone* zone, XAssetInfo<RawFile>* asset)
|
||||
{
|
||||
return asset->m_name;
|
||||
}
|
||||
|
||||
void AssetDumperRawFile::DumpAsset(AssetDumpingContext& context, XAssetInfo<RawFile>* asset, std::ostream& stream)
|
||||
void AssetDumperRawFile::DumpRaw(AssetDumpingContext& context, XAssetInfo<RawFile>* asset, std::ostream& stream)
|
||||
{
|
||||
const auto* rawFile = asset->Asset();
|
||||
if (rawFile->compressedLen > 0)
|
||||
|
@ -1,15 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractFileDumper.h"
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
|
||||
namespace IW4
|
||||
{
|
||||
class AssetDumperRawFile final : public AbstractFileDumper<RawFile>
|
||||
class AssetDumperRawFile final : public AbstractAssetDumper<RawFile>
|
||||
{
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<RawFile>* asset) override;
|
||||
bool CanDumpAsRaw() override;
|
||||
std::string GetFileNameForAsset(Zone* zone, XAssetInfo<RawFile>* asset) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<RawFile>* asset, std::ostream& stream) override;
|
||||
void DumpRaw(AssetDumpingContext& context, XAssetInfo<RawFile>* asset, std::ostream& stream) override;
|
||||
};
|
||||
}
|
||||
|
@ -9,12 +9,17 @@ bool AssetDumperStringTable::ShouldDump(XAssetInfo<StringTable>* asset)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetDumperStringTable::CanDumpAsRaw()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string AssetDumperStringTable::GetFileNameForAsset(Zone* zone, XAssetInfo<StringTable>* asset)
|
||||
{
|
||||
return asset->m_name;
|
||||
}
|
||||
|
||||
void AssetDumperStringTable::DumpAsset(AssetDumpingContext& context, XAssetInfo<StringTable>* asset, std::ostream& stream)
|
||||
void AssetDumperStringTable::DumpRaw(AssetDumpingContext& context, XAssetInfo<StringTable>* asset, std::ostream& stream)
|
||||
{
|
||||
const auto* stringTable = asset->Asset();
|
||||
CsvWriter csv(stream);
|
||||
@ -29,4 +34,4 @@ void AssetDumperStringTable::DumpAsset(AssetDumpingContext& context, XAssetInfo<
|
||||
|
||||
csv.NextRow();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractFileDumper.h"
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
|
||||
namespace IW4
|
||||
{
|
||||
class AssetDumperStringTable final : public AbstractFileDumper<StringTable>
|
||||
class AssetDumperStringTable final : public AbstractAssetDumper<StringTable>
|
||||
{
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<StringTable>* asset) override;
|
||||
bool CanDumpAsRaw() override;
|
||||
|
||||
std::string GetFileNameForAsset(Zone* zone, XAssetInfo<StringTable>* asset) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<StringTable>* asset, std::ostream& stream) override;
|
||||
void DumpRaw(AssetDumpingContext& context, XAssetInfo<StringTable>* asset, std::ostream& stream) override;
|
||||
};
|
||||
}
|
||||
|
@ -231,17 +231,7 @@ namespace IW4
|
||||
};
|
||||
}
|
||||
|
||||
bool AssetDumperVehicle::ShouldDump(XAssetInfo<VehicleDef>* asset)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string AssetDumperVehicle::GetFileNameForAsset(Zone* zone, XAssetInfo<VehicleDef>* asset)
|
||||
{
|
||||
return "vehicles/" + asset->m_name;
|
||||
}
|
||||
|
||||
void AssetDumperVehicle::DumpAsset(AssetDumpingContext& context, XAssetInfo<VehicleDef>* asset, std::ostream& stream)
|
||||
InfoString AssetDumperVehicle::CreateInfoString(XAssetInfo<VehicleDef>* asset)
|
||||
{
|
||||
InfoStringFromVehicleConverter converter(asset->Asset(), vehicle_fields, std::extent<decltype(vehicle_fields)>::value, [asset](const scr_string_t scrStr) -> std::string
|
||||
{
|
||||
@ -252,7 +242,41 @@ void AssetDumperVehicle::DumpAsset(AssetDumpingContext& context, XAssetInfo<Vehi
|
||||
return asset->m_zone->m_script_strings[scrStr];
|
||||
});
|
||||
|
||||
const auto infoString = converter.Convert();
|
||||
const auto stringValue = infoString.ToString("VEHICLEFILE");
|
||||
return converter.Convert();
|
||||
}
|
||||
|
||||
bool AssetDumperVehicle::ShouldDump(XAssetInfo<VehicleDef>* asset)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetDumperVehicle::CanDumpAsRaw()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetDumperVehicle::CanDumpAsGdtEntry()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string AssetDumperVehicle::GetFileNameForAsset(Zone* zone, XAssetInfo<VehicleDef>* asset)
|
||||
{
|
||||
return "vehicles/" + asset->m_name;
|
||||
}
|
||||
|
||||
GdtEntry AssetDumperVehicle::DumpGdtEntry(AssetDumpingContext& context, XAssetInfo<VehicleDef>* asset)
|
||||
{
|
||||
const auto infoString = CreateInfoString(asset);
|
||||
GdtEntry gdtEntry(asset->m_name, GDF_NAME);
|
||||
infoString.ToGdtProperties(FILE_TYPE_STR, gdtEntry);
|
||||
|
||||
return gdtEntry;
|
||||
}
|
||||
|
||||
void AssetDumperVehicle::DumpRaw(AssetDumpingContext& context, XAssetInfo<VehicleDef>* asset, std::ostream& stream)
|
||||
{
|
||||
const auto infoString = CreateInfoString(asset);
|
||||
const auto stringValue = infoString.ToString(FILE_TYPE_STR);
|
||||
stream.write(stringValue.c_str(), stringValue.size());
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractFileDumper.h"
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "Utils/InfoString.h"
|
||||
|
||||
namespace IW4
|
||||
{
|
||||
class AssetDumperVehicle final : public AbstractFileDumper<VehicleDef>
|
||||
class AssetDumperVehicle final : public AbstractAssetDumper<VehicleDef>
|
||||
{
|
||||
static constexpr const char* FILE_TYPE_STR = "VEHICLEFILE";
|
||||
static constexpr const char* GDF_NAME = "vehicle.gdf";
|
||||
static cspField_t vehicle_fields[];
|
||||
static cspField_t vehicle_fields2[];
|
||||
|
||||
static InfoString CreateInfoString(XAssetInfo<VehicleDef>* asset);
|
||||
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<VehicleDef>* asset) override;
|
||||
bool CanDumpAsRaw() override;
|
||||
bool CanDumpAsGdtEntry() override;
|
||||
|
||||
std::string GetFileNameForAsset(Zone* zone, XAssetInfo<VehicleDef>* asset) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<VehicleDef>* asset, std::ostream& stream) override;
|
||||
GdtEntry DumpGdtEntry(AssetDumpingContext& context, XAssetInfo<VehicleDef>* asset) override;
|
||||
void DumpRaw(AssetDumpingContext& context, XAssetInfo<VehicleDef>* asset, std::ostream& stream) override;
|
||||
};
|
||||
}
|
||||
|
@ -1162,34 +1162,56 @@ void AssetDumperWeapon::CopyToFullDef(const WeaponCompleteDef* weapon, WeaponFul
|
||||
}
|
||||
}
|
||||
|
||||
InfoString AssetDumperWeapon::CreateInfoString(XAssetInfo<WeaponCompleteDef>* asset)
|
||||
{
|
||||
const auto fullDef = std::make_unique<WeaponFullDef>();
|
||||
memset(fullDef.get(), 0, sizeof(WeaponFullDef));
|
||||
CopyToFullDef(asset->Asset(), fullDef.get());
|
||||
|
||||
InfoStringFromWeaponConverter converter(fullDef.get(), weapon_fields, std::extent<decltype(weapon_fields)>::value, [asset](const scr_string_t scrStr) -> std::string
|
||||
{
|
||||
assert(scrStr < asset->m_zone->m_script_strings.size());
|
||||
if (scrStr >= asset->m_zone->m_script_strings.size())
|
||||
return "";
|
||||
|
||||
return asset->m_zone->m_script_strings[scrStr];
|
||||
});
|
||||
|
||||
return converter.Convert();
|
||||
}
|
||||
|
||||
bool AssetDumperWeapon::ShouldDump(XAssetInfo<WeaponCompleteDef>* asset)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetDumperWeapon::CanDumpAsRaw()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetDumperWeapon::CanDumpAsGdtEntry()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string AssetDumperWeapon::GetFileNameForAsset(Zone* zone, XAssetInfo<WeaponCompleteDef>* asset)
|
||||
{
|
||||
return "weapons/" + asset->m_name;
|
||||
}
|
||||
|
||||
void AssetDumperWeapon::DumpAsset(AssetDumpingContext& context, XAssetInfo<WeaponCompleteDef>* asset, std::ostream& stream)
|
||||
GdtEntry AssetDumperWeapon::DumpGdtEntry(AssetDumpingContext& context, XAssetInfo<WeaponCompleteDef>* asset)
|
||||
{
|
||||
auto* fullDef = new WeaponFullDef;
|
||||
memset(fullDef, 0, sizeof(WeaponFullDef));
|
||||
CopyToFullDef(asset->Asset(), fullDef);
|
||||
const auto infoString = CreateInfoString(asset);
|
||||
GdtEntry gdtEntry(asset->m_name, GDF_NAME);
|
||||
infoString.ToGdtProperties(FILE_TYPE_STR, gdtEntry);
|
||||
|
||||
InfoStringFromWeaponConverter converter(fullDef, weapon_fields, std::extent<decltype(weapon_fields)>::value, [asset](const scr_string_t scrStr) -> std::string
|
||||
{
|
||||
assert(scrStr < asset->m_zone->m_script_strings.size());
|
||||
if (scrStr >= asset->m_zone->m_script_strings.size())
|
||||
return "";
|
||||
|
||||
return asset->m_zone->m_script_strings[scrStr];
|
||||
});
|
||||
|
||||
const auto infoString = converter.Convert();
|
||||
const auto stringValue = infoString.ToString("WEAPONFILE");
|
||||
stream.write(stringValue.c_str(), stringValue.size());
|
||||
|
||||
delete fullDef;
|
||||
return gdtEntry;
|
||||
}
|
||||
|
||||
void AssetDumperWeapon::DumpRaw(AssetDumpingContext& context, XAssetInfo<WeaponCompleteDef>* asset, std::ostream& stream)
|
||||
{
|
||||
const auto infoString = CreateInfoString(asset);
|
||||
const auto stringValue = infoString.ToString(FILE_TYPE_STR);
|
||||
stream.write(stringValue.c_str(), stringValue.size());
|
||||
}
|
||||
|
@ -1,19 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractFileDumper.h"
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "Utils/InfoString.h"
|
||||
|
||||
namespace IW4
|
||||
{
|
||||
class AssetDumperWeapon final : public AbstractFileDumper<WeaponCompleteDef>
|
||||
class AssetDumperWeapon final : public AbstractAssetDumper<WeaponCompleteDef>
|
||||
{
|
||||
static constexpr const char* FILE_TYPE_STR = "WEAPONFILE";
|
||||
static constexpr const char* GDF_NAME = "weapon.gdf";
|
||||
static cspField_t weapon_fields[];
|
||||
|
||||
static void CopyToFullDef(const WeaponCompleteDef* weapon, WeaponFullDef* fullDef);
|
||||
static InfoString CreateInfoString(XAssetInfo<WeaponCompleteDef>* asset);
|
||||
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<WeaponCompleteDef>* asset) override;
|
||||
bool CanDumpAsRaw() override;
|
||||
bool CanDumpAsGdtEntry() override;
|
||||
|
||||
std::string GetFileNameForAsset(Zone* zone, XAssetInfo<WeaponCompleteDef>* asset) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<WeaponCompleteDef>* asset, std::ostream& stream) override;
|
||||
GdtEntry DumpGdtEntry(AssetDumpingContext& context, XAssetInfo<WeaponCompleteDef>* asset) override;
|
||||
void DumpRaw(AssetDumpingContext& context, XAssetInfo<WeaponCompleteDef>* asset, std::ostream& stream) override;
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user