2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-09-01 14:37:25 +00:00

refactor: make use of IOutputPath in ObjWriting

This commit is contained in:
Jan
2025-01-11 13:06:48 +01:00
parent b584cd7423
commit 2d58054ffc
25 changed files with 143 additions and 171 deletions

View File

@@ -15,12 +15,12 @@ using namespace T6;
namespace
{
std::unique_ptr<Texture> LoadImageFromLoadDef(const GfxImage* image)
std::unique_ptr<Texture> LoadImageFromLoadDef(const GfxImage& image)
{
Dx12TextureLoader textureLoader;
const auto& loadDef = *image->texture.loadDef;
textureLoader.Width(image->width).Height(image->height).Depth(image->depth);
const auto& loadDef = *image.texture.loadDef;
textureLoader.Width(image.width).Height(image.height).Depth(image.depth);
if (loadDef.flags & iwi27::IMG_FLAG_VOLMAP)
textureLoader.Type(TextureType::T_3D);
@@ -34,13 +34,13 @@ namespace
return textureLoader.LoadTexture(loadDef.data);
}
std::unique_ptr<Texture> LoadImageFromIwi(const GfxImage* image, ISearchPath* searchPath)
std::unique_ptr<Texture> LoadImageFromIwi(const GfxImage& image, ISearchPath& searchPath)
{
if (image->streamedPartCount > 0)
if (image.streamedPartCount > 0)
{
for (auto* ipak : IIPak::Repository)
{
auto ipakStream = ipak->GetEntryStream(image->hash, image->streamedParts[0].hash);
auto ipakStream = ipak->GetEntryStream(image.hash, image.streamedParts[0].hash);
if (ipakStream)
{
@@ -53,20 +53,20 @@ namespace
}
}
const auto imageFileName = std::format("images/{}.iwi", image->name);
const auto filePathImage = searchPath->Open(imageFileName);
const auto imageFileName = std::format("images/{}.iwi", image.name);
const auto filePathImage = searchPath.Open(imageFileName);
if (!filePathImage.IsOpen())
{
std::cerr << std::format("Could not find data for image \"{}\"\n", image->name);
std::cerr << std::format("Could not find data for image \"{}\"\n", image.name);
return nullptr;
}
return iwi::LoadIwi(*filePathImage.m_stream);
}
std::unique_ptr<Texture> LoadImageData(ISearchPath* searchPath, const GfxImage* image)
std::unique_ptr<Texture> LoadImageData(ISearchPath& searchPath, const GfxImage& image)
{
if (image->texture.loadDef && image->texture.loadDef->resourceSize > 0)
if (image.texture.loadDef && image.texture.loadDef->resourceSize > 0)
return LoadImageFromLoadDef(image);
return LoadImageFromIwi(image, searchPath);
@@ -106,7 +106,7 @@ std::string AssetDumperGfxImage::GetAssetFileName(const XAssetInfo<GfxImage>& as
void AssetDumperGfxImage::DumpAsset(AssetDumpingContext& context, XAssetInfo<GfxImage>* asset)
{
const auto* image = asset->Asset();
const auto texture = LoadImageData(context.m_obj_search_path, image);
const auto texture = LoadImageData(context.m_obj_search_path, *image);
if (!texture)
return;

View File

@@ -3,7 +3,8 @@
#include "Dumping/Localize/StringFileDumper.h"
#include "Localize/LocalizeCommon.h"
#include <sstream>
#include <format>
#include <iostream>
using namespace T6;
@@ -12,11 +13,8 @@ void AssetDumperLocalizeEntry::DumpPool(AssetDumpingContext& context, AssetPool<
if (pool->m_asset_lookup.empty())
return;
const auto language = LocalizeCommon::GetNameOfLanguage(context.m_zone->m_language);
std::ostringstream ss;
ss << language << "/localizedstrings/" << context.m_zone->m_name << ".str";
const auto assetFile = context.OpenAssetFile(ss.str());
const auto language = LocalizeCommon::GetNameOfLanguage(context.m_zone.m_language);
const auto assetFile = context.OpenAssetFile(std::format("{}/localizedstrings/{}.str", language, context.m_zone.m_name));
if (assetFile)
{
@@ -38,6 +36,6 @@ void AssetDumperLocalizeEntry::DumpPool(AssetDumpingContext& context, AssetPool<
}
else
{
printf("Could not create string file for dumping localized strings of zone '%s'\n", context.m_zone->m_name.c_str());
std::cerr << std::format("Could not create string file for dumping localized strings of zone '{}'\n", context.m_zone.m_name);
}
}

View File

@@ -37,7 +37,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const
dumper.DumpPool(context, assetPools->poolName.get()); \
}
const auto* assetPools = dynamic_cast<GameAssetPoolT6*>(context.m_zone->m_pools.get());
const auto* assetPools = dynamic_cast<GameAssetPoolT6*>(context.m_zone.m_pools.get());
DUMP_ASSET_POOL(AssetDumperPhysPreset, m_phys_preset, ASSET_TYPE_PHYSPRESET)
DUMP_ASSET_POOL(AssetDumperPhysConstraints, m_phys_constraints, ASSET_TYPE_PHYSCONSTRAINTS)