mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-10 23:08:05 -05:00
more t5 stuffs
This commit is contained in:
@ -0,0 +1,48 @@
|
||||
#include "AssetDumperGfxImage.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "ObjWriting.h"
|
||||
#include "Image/IwiWriter27.h"
|
||||
#include "Image/DdsWriter.h"
|
||||
|
||||
using namespace T5;
|
||||
|
||||
AssetDumperGfxImage::AssetDumperGfxImage()
|
||||
{
|
||||
switch (ObjWriting::Configuration.ImageOutputFormat)
|
||||
{
|
||||
case ObjWriting::Configuration_t::ImageOutputFormat_e::DDS:
|
||||
m_writer = std::make_unique<DdsWriter>();
|
||||
break;
|
||||
case ObjWriting::Configuration_t::ImageOutputFormat_e::IWI:
|
||||
m_writer = std::make_unique<iwi27::IwiWriter>();
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
m_writer = nullptr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool AssetDumperGfxImage::ShouldDump(XAssetInfo<GfxImage>* asset)
|
||||
{
|
||||
const auto* image = asset->Asset();
|
||||
return image->loadedSize > 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::DumpRaw(AssetDumpingContext& context, XAssetInfo<GfxImage>* asset, std::ostream& stream)
|
||||
{
|
||||
const auto* image = asset->Asset();
|
||||
m_writer->DumpImage(stream, image->texture.texture);
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/T5/T5.h"
|
||||
#include "Image/IImageWriter.h"
|
||||
|
||||
namespace T5
|
||||
{
|
||||
class AssetDumperGfxImage final : public AbstractAssetDumper<GfxImage>
|
||||
{
|
||||
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 DumpRaw(AssetDumpingContext& context, XAssetInfo<GfxImage>* asset, std::ostream& stream) override;
|
||||
|
||||
public:
|
||||
AssetDumperGfxImage();
|
||||
};
|
||||
}
|
||||
|
@ -0,0 +1,53 @@
|
||||
#include "AssetDumperLocalizeEntry.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <filesystem>
|
||||
|
||||
#include "Localize/LocalizeCommon.h"
|
||||
#include "Dumping/Localize/StringFileDumper.h"
|
||||
|
||||
using namespace T5;
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
void AssetDumperLocalizeEntry::DumpPool(AssetDumpingContext& context, AssetPool<LocalizeEntry>* pool)
|
||||
{
|
||||
if (pool->m_asset_lookup.empty())
|
||||
return;
|
||||
|
||||
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(context.m_zone->m_name + ".str");
|
||||
|
||||
std::ofstream stringFile(stringFilePath, std::fstream::out | std::ofstream::binary);
|
||||
|
||||
if (stringFile.is_open())
|
||||
{
|
||||
StringFileDumper stringFileDumper(context.m_zone, stringFile);
|
||||
|
||||
stringFileDumper.SetLanguageName(language);
|
||||
|
||||
// Magic string. Original string files do have this config file. The purpose of the config file is unknown though.
|
||||
stringFileDumper.SetConfigFile(R"(C:\projects\cod\t5\bin\StringEd.cfg)");
|
||||
|
||||
stringFileDumper.SetNotes("");
|
||||
|
||||
for (auto* localizeEntry : *pool)
|
||||
{
|
||||
stringFileDumper.WriteLocalizeEntry(localizeEntry->m_name, localizeEntry->Asset()->value);
|
||||
}
|
||||
|
||||
stringFileDumper.Finalize();
|
||||
|
||||
stringFile.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Could not create string file for dumping localized strings of zone '%s'\n", context.m_zone->m_name.c_str());
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/T5/T5.h"
|
||||
|
||||
namespace T5
|
||||
{
|
||||
class AssetDumperLocalizeEntry final : public IAssetDumper<LocalizeEntry>
|
||||
{
|
||||
public:
|
||||
void DumpPool(AssetDumpingContext& context, AssetPool<LocalizeEntry>* pool) override;
|
||||
};
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
#include "AssetDumperRawFile.h"
|
||||
|
||||
using namespace T5;
|
||||
|
||||
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::DumpRaw(AssetDumpingContext& context, XAssetInfo<RawFile>* asset, std::ostream& stream)
|
||||
{
|
||||
const auto* rawFile = asset->Asset();
|
||||
stream.write(rawFile->buffer, rawFile->len);
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/T5/T5.h"
|
||||
|
||||
namespace T5
|
||||
{
|
||||
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 DumpRaw(AssetDumpingContext& context, XAssetInfo<RawFile>* asset, std::ostream& stream) override;
|
||||
};
|
||||
}
|
||||
|
@ -0,0 +1,37 @@
|
||||
#include "AssetDumperStringTable.h"
|
||||
|
||||
#include "Csv/CsvStream.h"
|
||||
|
||||
using namespace T5;
|
||||
|
||||
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::DumpRaw(AssetDumpingContext& context, XAssetInfo<StringTable>* asset, std::ostream& stream)
|
||||
{
|
||||
const auto* stringTable = asset->Asset();
|
||||
CsvOutputStream csv(stream);
|
||||
|
||||
for (auto row = 0; row < stringTable->rowCount; row++)
|
||||
{
|
||||
for (auto column = 0; column < stringTable->columnCount; column++)
|
||||
{
|
||||
const auto* cell = &stringTable->values[column + row * stringTable->columnCount];
|
||||
csv.WriteColumn(cell->string);
|
||||
}
|
||||
|
||||
csv.NextRow();
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/T5/T5.h"
|
||||
|
||||
namespace T5
|
||||
{
|
||||
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 DumpRaw(AssetDumpingContext& context, XAssetInfo<StringTable>* asset, std::ostream& stream) override;
|
||||
};
|
||||
}
|
||||
|
@ -0,0 +1,69 @@
|
||||
#include "ZoneDumperT5.h"
|
||||
|
||||
#include "Game/T5/GameT5.h"
|
||||
#include "Game/T5/GameAssetPoolT5.h"
|
||||
|
||||
#include "AssetDumpers/AssetDumperRawFile.h"
|
||||
#include "AssetDumpers/AssetDumperStringTable.h"
|
||||
#include "AssetDumpers/AssetDumperLocalizeEntry.h"
|
||||
#include "AssetDumpers/AssetDumperGfxImage.h"
|
||||
#include "AssetDumpers/AssetDumperPhysConstraints.h"
|
||||
#include "AssetDumpers/AssetDumperPhysPreset.h"
|
||||
#include "AssetDumpers/AssetDumperSndBank.h"
|
||||
#include "AssetDumpers/AssetDumperWeapon.h"
|
||||
|
||||
using namespace T5;
|
||||
|
||||
bool ZoneDumper::CanHandleZone(AssetDumpingContext& context) const
|
||||
{
|
||||
return context.m_zone->m_game == &g_GameT5;
|
||||
}
|
||||
|
||||
bool ZoneDumper::DumpZone(AssetDumpingContext& context) const
|
||||
{
|
||||
#define DUMP_ASSET_POOL(dumperType, poolName) \
|
||||
if(assetPools->poolName) \
|
||||
{ \
|
||||
dumperType dumper; \
|
||||
dumper.DumpPool(context, assetPools->poolName); \
|
||||
}
|
||||
|
||||
const auto* assetPools = dynamic_cast<GameAssetPoolT5*>(context.m_zone->m_pools.get());
|
||||
|
||||
// DUMP_ASSET_POOL(AssetDumperPhysPreset, m_phys_preset);
|
||||
// DUMP_ASSET_POOL(AssetDumperPhysConstraints, m_phys_constraints);
|
||||
// DUMP_ASSET_POOL(AssetDumperDestructibleDef, m_destructible_def);
|
||||
// DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts);
|
||||
// DUMP_ASSET_POOL(AssetDumperXModel, m_xmodel);
|
||||
// DUMP_ASSET_POOL(AssetDumperMaterial, m_material);
|
||||
// DUMP_ASSET_POOL(AssetDumperTechniqueSet, m_technique_set);
|
||||
DUMP_ASSET_POOL(AssetDumperGfxImage, m_image);
|
||||
// DUMP_ASSET_POOL(AssetDumperSndBank, m_sound_bank);
|
||||
// DUMP_ASSET_POOL(AssetDumperSndPatch, m_sound_patch);
|
||||
// DUMP_ASSET_POOL(AssetDumperClipMap, m_clip_map);
|
||||
// DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world);
|
||||
// DUMP_ASSET_POOL(AssetDumperGameWorldSp, m_game_world_sp);
|
||||
// DUMP_ASSET_POOL(AssetDumperGameWorldMp, m_game_world_mp);
|
||||
// DUMP_ASSET_POOL(AssetDumperMapEnts, m_map_ents);
|
||||
// DUMP_ASSET_POOL(AssetDumperGfxWorld, m_gfx_world);
|
||||
// DUMP_ASSET_POOL(AssetDumperGfxLightDef, m_gfx_light_def);
|
||||
// DUMP_ASSET_POOL(AssetDumperFont, m_font);
|
||||
// DUMP_ASSET_POOL(AssetDumperMenuList, m_menu_list);
|
||||
// DUMP_ASSET_POOL(AssetDumperMenuDef, m_menu_def);
|
||||
DUMP_ASSET_POOL(AssetDumperLocalizeEntry, m_localize);
|
||||
// DUMP_ASSET_POOL(AssetDumperWeapon, m_weapon);
|
||||
// DUMP_ASSET_POOL(AssetDumperSndDriverGlobals, m_snd_driver_globals);
|
||||
// DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx);
|
||||
// DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table);
|
||||
DUMP_ASSET_POOL(AssetDumperRawFile, m_raw_file);
|
||||
DUMP_ASSET_POOL(AssetDumperStringTable, m_string_table);
|
||||
// DUMP_ASSET_POOL(AssetDumperPackIndex, m_pack_index);
|
||||
// DUMP_ASSET_POOL(AssetDumperXGlobals, m_xglobals);
|
||||
// DUMP_ASSET_POOL(AssetDumperDDLRoot, m_ddl);
|
||||
// DUMP_ASSET_POOL(AssetDumperGlasses, m_glasses);
|
||||
// DUMP_ASSET_POOL(AssetDumperEmblemSet, m_emblem_set);
|
||||
|
||||
return true;
|
||||
|
||||
#undef DUMP_ASSET_POOL
|
||||
}
|
||||
|
@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
#include "Dumping/IZoneDumper.h"
|
||||
|
||||
namespace T5
|
||||
{
|
||||
class ZoneDumper final : public IZoneDumper
|
||||
{
|
||||
public:
|
||||
bool CanHandleZone(AssetDumpingContext& context) const override;
|
||||
bool DumpZone(AssetDumpingContext& context) const override;
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user