2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-12-29 13:31:51 +00:00

refactor: do not nest asset namespaces in game namespaces

* Duplicated namespace names are kind of annoying
This commit is contained in:
Jan Laupetin
2025-08-06 00:50:35 +02:00
parent 33c09dfe61
commit 46fb919a52
336 changed files with 1430 additions and 1480 deletions

View File

@@ -15,7 +15,6 @@
#include <format>
using namespace IW3;
using namespace ::image;
namespace
{
@@ -40,7 +39,7 @@ namespace
std::unique_ptr<Texture> LoadImageFromIwi(const GfxImage& image, ISearchPath& searchPath)
{
const auto imageFileName = std::format("images/{}.iwi", image.name);
const auto imageFileName = image::GetFileNameForAsset(image.name, ".iwi");
const auto filePathImage = searchPath.Open(imageFileName);
if (!filePathImage.IsOpen())
{
@@ -60,9 +59,9 @@ namespace
}
} // namespace
namespace IW3::image
namespace image
{
Dumper::Dumper()
DumperIW3::DumperIW3()
{
switch (ObjWriting::Configuration.ImageOutputFormat)
{
@@ -79,12 +78,12 @@ namespace IW3::image
}
}
bool Dumper::ShouldDump(XAssetInfo<GfxImage>* asset)
bool DumperIW3::ShouldDump(XAssetInfo<GfxImage>* asset)
{
return true;
}
void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo<GfxImage>* asset)
void DumperIW3::DumpAsset(AssetDumpingContext& context, XAssetInfo<GfxImage>* asset)
{
const auto* image = asset->Asset();
const auto texture = LoadImageData(context.m_obj_search_path, *image);
@@ -99,4 +98,4 @@ namespace IW3::image
auto& stream = *assetFile;
m_writer->DumpImage(stream, texture.get());
}
} // namespace IW3::image
} // namespace image

View File

@@ -6,18 +6,18 @@
#include <memory>
namespace IW3::image
namespace image
{
class Dumper final : public AbstractAssetDumper<GfxImage>
class DumperIW3 final : public AbstractAssetDumper<IW3::GfxImage>
{
public:
Dumper();
DumperIW3();
protected:
bool ShouldDump(XAssetInfo<GfxImage>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<GfxImage>* asset) override;
bool ShouldDump(XAssetInfo<IW3::GfxImage>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW3::GfxImage>* asset) override;
private:
std::unique_ptr<IImageWriter> m_writer;
};
} // namespace IW3::image
} // namespace image

View File

@@ -8,9 +8,9 @@
using namespace IW3;
namespace IW3::localize
namespace localize
{
void Dumper::DumpPool(AssetDumpingContext& context, AssetPool<LocalizeEntry>* pool)
void DumperIW3::DumpPool(AssetDumpingContext& context, AssetPool<LocalizeEntry>* pool)
{
if (pool->m_asset_lookup.empty())
return;
@@ -41,4 +41,4 @@ namespace IW3::localize
std::cerr << std::format("Could not create string file for dumping localized strings of zone '{}'\n", context.m_zone.m_name);
}
}
} // namespace IW3::localize
} // namespace localize

View File

@@ -3,11 +3,11 @@
#include "Dumping/AbstractAssetDumper.h"
#include "Game/IW3/IW3.h"
namespace IW3::localize
namespace localize
{
class Dumper final : public IAssetDumper<LocalizeEntry>
class DumperIW3 final : public IAssetDumper<IW3::LocalizeEntry>
{
public:
void DumpPool(AssetDumpingContext& context, AssetPool<LocalizeEntry>* pool) override;
void DumpPool(AssetDumpingContext& context, AssetPool<IW3::LocalizeEntry>* pool) override;
};
} // namespace IW3::localize
} // namespace localize

View File

@@ -2,14 +2,14 @@
using namespace IW3;
namespace IW3::map_ents
namespace map_ents
{
bool Dumper::ShouldDump(XAssetInfo<MapEnts>* asset)
bool DumperIW3::ShouldDump(XAssetInfo<MapEnts>* asset)
{
return true;
}
void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo<MapEnts>* asset)
void DumperIW3::DumpAsset(AssetDumpingContext& context, XAssetInfo<MapEnts>* asset)
{
const auto* mapEnts = asset->Asset();
const auto assetFile = context.OpenAssetFile(asset->m_name + ".ents");
@@ -20,4 +20,4 @@ namespace IW3::map_ents
auto& stream = *assetFile;
stream.write(mapEnts->entityString, mapEnts->numEntityChars);
}
} // namespace IW3::map_ents
} // namespace map_ents

View File

@@ -3,12 +3,12 @@
#include "Dumping/AbstractAssetDumper.h"
#include "Game/IW3/IW3.h"
namespace IW3::map_ents
namespace map_ents
{
class Dumper final : public AbstractAssetDumper<MapEnts>
class DumperIW3 final : public AbstractAssetDumper<IW3::MapEnts>
{
protected:
bool ShouldDump(XAssetInfo<MapEnts>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<MapEnts>* asset) override;
bool ShouldDump(XAssetInfo<IW3::MapEnts>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW3::MapEnts>* asset) override;
};
} // namespace IW3::map_ents
} // namespace map_ents

View File

@@ -26,30 +26,30 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const
// DUMP_ASSET_POOL(AssetDumperPhysPreset, m_phys_preset, ASSET_TYPE_PHYSPRESET)
// DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS)
DUMP_ASSET_POOL(xmodel::Dumper, m_xmodel, ASSET_TYPE_XMODEL)
DUMP_ASSET_POOL(material::JsonDumper, m_material, ASSET_TYPE_MATERIAL)
DUMP_ASSET_POOL(xmodel::DumperIW3, m_xmodel, ASSET_TYPE_XMODEL)
DUMP_ASSET_POOL(material::JsonDumperIW3, m_material, ASSET_TYPE_MATERIAL)
// DUMP_ASSET_POOL(AssetDumperMaterialTechniqueSet, m_technique_set, ASSET_TYPE_TECHNIQUE_SET)
DUMP_ASSET_POOL(image::Dumper, m_image, ASSET_TYPE_IMAGE)
DUMP_ASSET_POOL(image::DumperIW3, m_image, ASSET_TYPE_IMAGE)
// DUMP_ASSET_POOL(AssetDumpersnd_alias_list_t, m_sound, ASSET_TYPE_SOUND)
// DUMP_ASSET_POOL(AssetDumperSndCurve, m_sound_curve, ASSET_TYPE_SOUND_CURVE)
DUMP_ASSET_POOL(sound::LoadedSoundDumper, m_loaded_sound, ASSET_TYPE_LOADED_SOUND)
DUMP_ASSET_POOL(sound::LoadedSoundDumperIW3, m_loaded_sound, ASSET_TYPE_LOADED_SOUND)
// DUMP_ASSET_POOL(AssetDumperClipMap, m_clip_map, ASSET_TYPE_CLIPMAP_PVS)
// DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world, ASSET_TYPE_COMWORLD)
// DUMP_ASSET_POOL(AssetDumperGameWorldSp, m_game_world_sp, ASSET_TYPE_GAMEWORLD_SP)
// DUMP_ASSET_POOL(AssetDumperGameWorldMp, m_game_world_mp, ASSET_TYPE_GAMEWORLD_MP)
DUMP_ASSET_POOL(map_ents::Dumper, m_map_ents, ASSET_TYPE_MAP_ENTS)
DUMP_ASSET_POOL(map_ents::DumperIW3, m_map_ents, ASSET_TYPE_MAP_ENTS)
// DUMP_ASSET_POOL(AssetDumperGfxWorld, m_gfx_world, ASSET_TYPE_GFXWORLD)
// DUMP_ASSET_POOL(AssetDumperGfxLightDef, m_gfx_light_def, ASSET_TYPE_LIGHT_DEF)
// DUMP_ASSET_POOL(AssetDumperFont_s, m_font, ASSET_TYPE_FONT)
// DUMP_ASSET_POOL(AssetDumperMenuList, m_menu_list, ASSET_TYPE_MENULIST)
// DUMP_ASSET_POOL(AssetDumpermenuDef_t, m_menu_def, ASSET_TYPE_MENU)
DUMP_ASSET_POOL(localize::Dumper, m_localize, ASSET_TYPE_LOCALIZE_ENTRY)
DUMP_ASSET_POOL(localize::DumperIW3, m_localize, ASSET_TYPE_LOCALIZE_ENTRY)
// DUMP_ASSET_POOL(AssetDumperWeapon, m_weapon, ASSET_TYPE_WEAPON)
// DUMP_ASSET_POOL(AssetDumperSndDriverGlobals, m_snd_driver_globals, ASSET_TYPE_SNDDRIVER_GLOBALS)
// DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx, ASSET_TYPE_FX)
// DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table, ASSET_TYPE_IMPACT_FX)
DUMP_ASSET_POOL(raw_file::Dumper, m_raw_file, ASSET_TYPE_RAWFILE)
DUMP_ASSET_POOL(string_table::Dumper, m_string_table, ASSET_TYPE_STRINGTABLE)
DUMP_ASSET_POOL(raw_file::DumperIW3, m_raw_file, ASSET_TYPE_RAWFILE)
DUMP_ASSET_POOL(string_table::DumperIW3, m_string_table, ASSET_TYPE_STRINGTABLE)
return true;

View File

@@ -2,14 +2,14 @@
using namespace IW3;
namespace IW3::raw_file
namespace raw_file
{
bool Dumper::ShouldDump(XAssetInfo<RawFile>* asset)
bool DumperIW3::ShouldDump(XAssetInfo<RawFile>* asset)
{
return true;
}
void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo<RawFile>* asset)
void DumperIW3::DumpAsset(AssetDumpingContext& context, XAssetInfo<RawFile>* asset)
{
const auto* rawFile = asset->Asset();
const auto assetFile = context.OpenAssetFile(asset->m_name);
@@ -20,4 +20,4 @@ namespace IW3::raw_file
auto& stream = *assetFile;
stream.write(rawFile->buffer, rawFile->len);
}
} // namespace IW3::raw_file
} // namespace raw_file

View File

@@ -3,12 +3,12 @@
#include "Dumping/AbstractAssetDumper.h"
#include "Game/IW3/IW3.h"
namespace IW3::raw_file
namespace raw_file
{
class Dumper final : public AbstractAssetDumper<RawFile>
class DumperIW3 final : public AbstractAssetDumper<IW3::RawFile>
{
protected:
bool ShouldDump(XAssetInfo<RawFile>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<RawFile>* asset) override;
bool ShouldDump(XAssetInfo<IW3::RawFile>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW3::RawFile>* asset) override;
};
} // namespace IW3::raw_file
} // namespace raw_file

View File

@@ -22,14 +22,14 @@ namespace
}
} // namespace
namespace IW3::sound
namespace sound
{
bool LoadedSoundDumper::ShouldDump(XAssetInfo<LoadedSound>* asset)
bool LoadedSoundDumperIW3::ShouldDump(XAssetInfo<LoadedSound>* asset)
{
return true;
}
void LoadedSoundDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo<LoadedSound>* asset)
void LoadedSoundDumperIW3::DumpAsset(AssetDumpingContext& context, XAssetInfo<LoadedSound>* asset)
{
const auto* loadedSound = asset->Asset();
const auto assetFile = context.OpenAssetFile(std::format("sound/{}", asset->m_name));
@@ -49,4 +49,4 @@ namespace IW3::sound
break;
}
}
} // namespace IW3::sound
} // namespace sound

View File

@@ -3,12 +3,12 @@
#include "Dumping/AbstractAssetDumper.h"
#include "Game/IW3/IW3.h"
namespace IW3::sound
namespace sound
{
class LoadedSoundDumper final : public AbstractAssetDumper<LoadedSound>
class LoadedSoundDumperIW3 final : public AbstractAssetDumper<IW3::LoadedSound>
{
protected:
bool ShouldDump(XAssetInfo<LoadedSound>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<LoadedSound>* asset) override;
bool ShouldDump(XAssetInfo<IW3::LoadedSound>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW3::LoadedSound>* asset) override;
};
} // namespace IW3::sound
} // namespace sound

View File

@@ -4,14 +4,14 @@
using namespace IW3;
namespace IW3::string_table
namespace string_table
{
bool Dumper::ShouldDump(XAssetInfo<StringTable>* asset)
bool DumperIW3::ShouldDump(XAssetInfo<StringTable>* asset)
{
return true;
}
void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo<StringTable>* asset)
void DumperIW3::DumpAsset(AssetDumpingContext& context, XAssetInfo<StringTable>* asset)
{
const auto* stringTable = asset->Asset();
const auto assetFile = context.OpenAssetFile(asset->m_name);
@@ -31,4 +31,4 @@ namespace IW3::string_table
csv.NextRow();
}
}
} // namespace IW3::string_table
} // namespace string_table

View File

@@ -3,12 +3,12 @@
#include "Dumping/AbstractAssetDumper.h"
#include "Game/IW3/IW3.h"
namespace IW3::string_table
namespace string_table
{
class Dumper final : public AbstractAssetDumper<StringTable>
class DumperIW3 final : public AbstractAssetDumper<IW3::StringTable>
{
protected:
bool ShouldDump(XAssetInfo<StringTable>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<StringTable>* asset) override;
bool ShouldDump(XAssetInfo<IW3::StringTable>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<IW3::StringTable>* asset) override;
};
} // namespace IW3::string_table
} // namespace string_table