mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-02-11 01:53:02 +00:00
refactor: move asset type names to IGame implementations
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
#include "AssetNameResolverIW3.h"
|
||||
|
||||
#include "Game/IW3/GameAssetPoolIW3.h"
|
||||
#include "Utils/StringUtils.h"
|
||||
|
||||
using namespace IW3;
|
||||
|
||||
AssetNameResolver::AssetNameResolver()
|
||||
{
|
||||
for (auto assetType = 0; assetType < ASSET_TYPE_COUNT; assetType++)
|
||||
AddAssetTypeName(assetType, *GameAssetPoolIW3::AssetTypeNameByType(assetType));
|
||||
}
|
||||
|
||||
GameId AssetNameResolver::GetGameId() const
|
||||
{
|
||||
return GameId::IW3;
|
||||
}
|
||||
|
||||
std::optional<const char*> AssetNameResolver::GetAssetTypeName(const asset_type_t assetType) const
|
||||
{
|
||||
return GameAssetPoolIW3::AssetTypeNameByType(assetType);
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Zone/AssetNameResolver.h"
|
||||
|
||||
namespace IW3
|
||||
{
|
||||
class AssetNameResolver final : public HashMapBasedAssetNameResolver
|
||||
{
|
||||
public:
|
||||
AssetNameResolver();
|
||||
[[nodiscard]] GameId GetGameId() const override;
|
||||
[[nodiscard]] std::optional<const char*> GetAssetTypeName(asset_type_t assetType) const override;
|
||||
};
|
||||
} // namespace IW3
|
||||
@@ -3,26 +3,13 @@
|
||||
#include "Pool/AssetPoolDynamic.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <type_traits>
|
||||
|
||||
using namespace IW3;
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr const char* ASSET_TYPE_NAMES[]{
|
||||
"xmodelpieces", "physpreset", "xanim", "xmodel", "material", "techniqueset", "image", "sound", "soundcurve", "loadedsound",
|
||||
"clipmap_unused", "clipmap", "comworld", "gameworldsp", "gameworldmp", "mapents", "gfxworld", "lightdef", "uimap", "font",
|
||||
"menulist", "menu", "localize", "weapon", "snddriverglobals", "fx", "impactfx", "aitype", "mptype", "character",
|
||||
"xmodelalias", "rawfile", "stringtable",
|
||||
};
|
||||
}
|
||||
|
||||
GameAssetPoolIW3::GameAssetPoolIW3(Zone* zone, const zone_priority_t priority)
|
||||
: ZoneAssetPools(zone),
|
||||
m_priority(priority)
|
||||
{
|
||||
static_assert(std::extent_v<decltype(ASSET_TYPE_NAMES)> == ASSET_TYPE_COUNT);
|
||||
|
||||
#define INIT_POOL(poolName) (poolName) = std::make_unique<AssetPoolDynamic<decltype(poolName)::element_type::type>>(m_priority)
|
||||
|
||||
INIT_POOL(m_phys_preset);
|
||||
@@ -151,26 +138,3 @@ XAssetInfoGeneric* GameAssetPoolIW3::GetAsset(const asset_type_t type, const std
|
||||
|
||||
#undef CASE_GET_ASSET
|
||||
}
|
||||
|
||||
std::optional<const char*> GameAssetPoolIW3::AssetTypeNameByType(const asset_type_t assetType)
|
||||
{
|
||||
if (assetType >= 0 && assetType < static_cast<int>(std::extent_v<decltype(ASSET_TYPE_NAMES)>))
|
||||
return ASSET_TYPE_NAMES[assetType];
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<const char*> GameAssetPoolIW3::GetAssetTypeName(const asset_type_t assetType) const
|
||||
{
|
||||
return AssetTypeNameByType(assetType);
|
||||
}
|
||||
|
||||
asset_type_t GameAssetPoolIW3::AssetTypeCount()
|
||||
{
|
||||
return ASSET_TYPE_COUNT;
|
||||
}
|
||||
|
||||
asset_type_t GameAssetPoolIW3::GetAssetTypeCount() const
|
||||
{
|
||||
return AssetTypeCount();
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "Pool/ZoneAssetPools.h"
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
class GameAssetPoolIW3 final : public ZoneAssetPools
|
||||
{
|
||||
@@ -41,12 +40,6 @@ public:
|
||||
|
||||
[[nodiscard]] XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const override;
|
||||
|
||||
static std::optional<const char*> AssetTypeNameByType(asset_type_t assetType);
|
||||
[[nodiscard]] std::optional<const char*> GetAssetTypeName(asset_type_t assetType) const override;
|
||||
|
||||
static asset_type_t AssetTypeCount();
|
||||
[[nodiscard]] asset_type_t GetAssetTypeCount() const override;
|
||||
|
||||
protected:
|
||||
XAssetInfoGeneric* AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) override;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ void ZoneDefWriter::WriteMetaData(ZoneDefinitionOutputStream& stream, const Zone
|
||||
|
||||
void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const Zone& zone) const
|
||||
{
|
||||
const auto* game = IGame::GetGameById(zone.m_game_id);
|
||||
const auto* pools = dynamic_cast<GameAssetPoolIW3*>(zone.m_pools.get());
|
||||
|
||||
assert(pools);
|
||||
@@ -18,7 +19,7 @@ void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const Zone&
|
||||
|
||||
// Localized strings are all collected in one string file. So only add this to the zone file.
|
||||
if (!pools->m_localize->m_asset_lookup.empty())
|
||||
stream.WriteEntry(*pools->GetAssetTypeName(ASSET_TYPE_LOCALIZE_ENTRY), zone.m_name);
|
||||
stream.WriteEntry(*game->GetAssetTypeName(ASSET_TYPE_LOCALIZE_ENTRY), zone.m_name);
|
||||
|
||||
for (const auto& asset : *pools)
|
||||
{
|
||||
@@ -28,7 +29,7 @@ void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const Zone&
|
||||
break;
|
||||
|
||||
default:
|
||||
stream.WriteEntry(*pools->GetAssetTypeName(asset->m_type), asset->m_name);
|
||||
stream.WriteEntry(*game->GetAssetTypeName(asset->m_type), asset->m_name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
#include "AssetNameResolverIW4.h"
|
||||
|
||||
#include "Game/IW4/GameAssetPoolIW4.h"
|
||||
#include "Utils/StringUtils.h"
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
AssetNameResolver::AssetNameResolver()
|
||||
{
|
||||
for (auto assetType = 0; assetType < ASSET_TYPE_COUNT; assetType++)
|
||||
AddAssetTypeName(assetType, *GameAssetPoolIW4::AssetTypeNameByType(assetType));
|
||||
}
|
||||
|
||||
GameId AssetNameResolver::GetGameId() const
|
||||
{
|
||||
return GameId::IW4;
|
||||
}
|
||||
|
||||
std::optional<const char*> AssetNameResolver::GetAssetTypeName(const asset_type_t assetType) const
|
||||
{
|
||||
return GameAssetPoolIW4::AssetTypeNameByType(assetType);
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Zone/AssetNameResolver.h"
|
||||
|
||||
namespace IW4
|
||||
{
|
||||
class AssetNameResolver final : public HashMapBasedAssetNameResolver
|
||||
{
|
||||
public:
|
||||
AssetNameResolver();
|
||||
[[nodiscard]] GameId GetGameId() const override;
|
||||
[[nodiscard]] std::optional<const char*> GetAssetTypeName(asset_type_t assetType) const override;
|
||||
};
|
||||
} // namespace IW4
|
||||
@@ -3,31 +3,13 @@
|
||||
#include "Pool/AssetPoolDynamic.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <type_traits>
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr const char* ASSET_TYPE_NAMES[]{
|
||||
"physpreset", "physcollmap", "xanim", "xmodelsurfs", "xmodel",
|
||||
"material", "pixelshader", "vertexshader", "vertexdecl", "techniqueset",
|
||||
"image", "sound", "soundcurve", "loadedsound", "clipmap_unused",
|
||||
"clipmap", "comworld", "gameworldsp", "gameworldmp", "mapents",
|
||||
"fxworld", "gfxworld", "lightdef", "uimap", "font",
|
||||
"menulist", "menu", "localize", "weapon", "snddriverglobals",
|
||||
"fx", "impactfx", "aitype", "mptype", "character",
|
||||
"xmodelalias", "rawfile", "stringtable", "leaderboard", "structureddatadef",
|
||||
"tracer", "vehicle", "addonmapents",
|
||||
};
|
||||
}
|
||||
|
||||
GameAssetPoolIW4::GameAssetPoolIW4(Zone* zone, const zone_priority_t priority)
|
||||
: ZoneAssetPools(zone),
|
||||
m_priority(priority)
|
||||
{
|
||||
static_assert(std::extent_v<decltype(ASSET_TYPE_NAMES)> == ASSET_TYPE_COUNT);
|
||||
|
||||
#define INIT_POOL(poolName) (poolName) = std::make_unique<AssetPoolDynamic<decltype(poolName)::element_type::type>>(m_priority)
|
||||
|
||||
INIT_POOL(m_phys_preset);
|
||||
@@ -186,26 +168,3 @@ XAssetInfoGeneric* GameAssetPoolIW4::GetAsset(const asset_type_t type, const std
|
||||
|
||||
#undef CASE_GET_ASSET
|
||||
}
|
||||
|
||||
std::optional<const char*> GameAssetPoolIW4::AssetTypeNameByType(const asset_type_t assetType)
|
||||
{
|
||||
if (assetType >= 0 && assetType < static_cast<int>(std::extent_v<decltype(ASSET_TYPE_NAMES)>))
|
||||
return ASSET_TYPE_NAMES[assetType];
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<const char*> GameAssetPoolIW4::GetAssetTypeName(const asset_type_t assetType) const
|
||||
{
|
||||
return AssetTypeNameByType(assetType);
|
||||
}
|
||||
|
||||
asset_type_t GameAssetPoolIW4::AssetTypeCount()
|
||||
{
|
||||
return ASSET_TYPE_COUNT;
|
||||
}
|
||||
|
||||
asset_type_t GameAssetPoolIW4::GetAssetTypeCount() const
|
||||
{
|
||||
return AssetTypeCount();
|
||||
}
|
||||
|
||||
@@ -50,12 +50,6 @@ public:
|
||||
|
||||
[[nodiscard]] XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const override;
|
||||
|
||||
static std::optional<const char*> AssetTypeNameByType(asset_type_t assetType);
|
||||
[[nodiscard]] std::optional<const char*> GetAssetTypeName(asset_type_t assetType) const override;
|
||||
|
||||
static asset_type_t AssetTypeCount();
|
||||
[[nodiscard]] asset_type_t GetAssetTypeCount() const override;
|
||||
|
||||
protected:
|
||||
XAssetInfoGeneric* AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) override;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ void ZoneDefWriter::WriteMetaData(ZoneDefinitionOutputStream& stream, const Zone
|
||||
|
||||
void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const Zone& zone) const
|
||||
{
|
||||
const auto* game = IGame::GetGameById(zone.m_game_id);
|
||||
const auto* pools = dynamic_cast<GameAssetPoolIW4*>(zone.m_pools.get());
|
||||
|
||||
assert(pools);
|
||||
@@ -18,7 +19,7 @@ void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const Zone&
|
||||
|
||||
// Localized strings are all collected in one string file. So only add this to the zone file.
|
||||
if (!pools->m_localize->m_asset_lookup.empty())
|
||||
stream.WriteEntry(*pools->GetAssetTypeName(ASSET_TYPE_LOCALIZE_ENTRY), zone.m_name);
|
||||
stream.WriteEntry(*game->GetAssetTypeName(ASSET_TYPE_LOCALIZE_ENTRY), zone.m_name);
|
||||
|
||||
for (const auto& asset : *pools)
|
||||
{
|
||||
@@ -28,7 +29,7 @@ void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const Zone&
|
||||
break;
|
||||
|
||||
default:
|
||||
stream.WriteEntry(*pools->GetAssetTypeName(asset->m_type), asset->m_name);
|
||||
stream.WriteEntry(*game->GetAssetTypeName(asset->m_type), asset->m_name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
#include "AssetNameResolverIW5.h"
|
||||
|
||||
#include "Game/IW5/GameAssetPoolIW5.h"
|
||||
#include "Utils/StringUtils.h"
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
AssetNameResolver::AssetNameResolver()
|
||||
{
|
||||
for (auto assetType = 0; assetType < ASSET_TYPE_COUNT; assetType++)
|
||||
AddAssetTypeName(assetType, *GameAssetPoolIW5::AssetTypeNameByType(assetType));
|
||||
}
|
||||
|
||||
GameId AssetNameResolver::GetGameId() const
|
||||
{
|
||||
return GameId::IW5;
|
||||
}
|
||||
|
||||
std::optional<const char*> AssetNameResolver::GetAssetTypeName(const asset_type_t assetType) const
|
||||
{
|
||||
return GameAssetPoolIW5::AssetTypeNameByType(assetType);
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Zone/AssetNameResolver.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class AssetNameResolver final : public HashMapBasedAssetNameResolver
|
||||
{
|
||||
public:
|
||||
AssetNameResolver();
|
||||
[[nodiscard]] GameId GetGameId() const override;
|
||||
[[nodiscard]] std::optional<const char*> GetAssetTypeName(asset_type_t assetType) const override;
|
||||
};
|
||||
} // namespace IW5
|
||||
@@ -3,68 +3,13 @@
|
||||
#include "Pool/AssetPoolDynamic.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <type_traits>
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr const char* ASSET_TYPE_NAMES[]{
|
||||
"physpreset",
|
||||
"physcollmap",
|
||||
"xanim",
|
||||
"xmodelsurfs",
|
||||
"xmodel",
|
||||
"material",
|
||||
"pixelshader",
|
||||
"vertexshader",
|
||||
"vertexdecl",
|
||||
"techniqueset",
|
||||
"image",
|
||||
"sound",
|
||||
"soundcurve",
|
||||
"loadedsound",
|
||||
"clipmap",
|
||||
"comworld",
|
||||
"glassworld",
|
||||
"pathdata",
|
||||
"vehicletrack",
|
||||
"mapents",
|
||||
"fxworld",
|
||||
"gfxworld",
|
||||
"lightdef",
|
||||
"uimap",
|
||||
"font",
|
||||
"menulist",
|
||||
"menu",
|
||||
"localize",
|
||||
"attachment",
|
||||
"weapon",
|
||||
"snddriverglobals",
|
||||
"fx",
|
||||
"impactfx",
|
||||
"surfacefx",
|
||||
"aitype",
|
||||
"mptype",
|
||||
"character",
|
||||
"xmodelalias",
|
||||
"rawfile",
|
||||
"scriptfile",
|
||||
"stringtable",
|
||||
"leaderboard",
|
||||
"structureddatadef",
|
||||
"tracer",
|
||||
"vehicle",
|
||||
"addonmapents",
|
||||
};
|
||||
}
|
||||
|
||||
GameAssetPoolIW5::GameAssetPoolIW5(Zone* zone, const zone_priority_t priority)
|
||||
: ZoneAssetPools(zone),
|
||||
m_priority(priority)
|
||||
{
|
||||
static_assert(std::extent_v<decltype(ASSET_TYPE_NAMES)> == ASSET_TYPE_COUNT);
|
||||
|
||||
#define INIT_POOL(poolName) (poolName) = std::make_unique<AssetPoolDynamic<decltype(poolName)::element_type::type>>(m_priority)
|
||||
|
||||
INIT_POOL(m_phys_preset);
|
||||
@@ -236,26 +181,3 @@ XAssetInfoGeneric* GameAssetPoolIW5::GetAsset(const asset_type_t type, const std
|
||||
|
||||
#undef CASE_GET_ASSET
|
||||
}
|
||||
|
||||
std::optional<const char*> GameAssetPoolIW5::AssetTypeNameByType(const asset_type_t assetType)
|
||||
{
|
||||
if (assetType >= 0 && assetType < static_cast<int>(std::extent_v<decltype(ASSET_TYPE_NAMES)>))
|
||||
return ASSET_TYPE_NAMES[assetType];
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<const char*> GameAssetPoolIW5::GetAssetTypeName(const asset_type_t assetType) const
|
||||
{
|
||||
return AssetTypeNameByType(assetType);
|
||||
}
|
||||
|
||||
asset_type_t GameAssetPoolIW5::AssetTypeCount()
|
||||
{
|
||||
return ASSET_TYPE_COUNT;
|
||||
}
|
||||
|
||||
asset_type_t GameAssetPoolIW5::GetAssetTypeCount() const
|
||||
{
|
||||
return AssetTypeCount();
|
||||
}
|
||||
|
||||
@@ -55,12 +55,6 @@ public:
|
||||
|
||||
[[nodiscard]] XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const override;
|
||||
|
||||
static std::optional<const char*> AssetTypeNameByType(asset_type_t assetType);
|
||||
[[nodiscard]] std::optional<const char*> GetAssetTypeName(asset_type_t assetType) const override;
|
||||
|
||||
static asset_type_t AssetTypeCount();
|
||||
[[nodiscard]] asset_type_t GetAssetTypeCount() const override;
|
||||
|
||||
protected:
|
||||
XAssetInfoGeneric* AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) override;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ void ZoneDefWriter::WriteMetaData(ZoneDefinitionOutputStream& stream, const Zone
|
||||
|
||||
void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const Zone& zone) const
|
||||
{
|
||||
const auto* game = IGame::GetGameById(zone.m_game_id);
|
||||
const auto* pools = dynamic_cast<GameAssetPoolIW5*>(zone.m_pools.get());
|
||||
|
||||
assert(pools);
|
||||
@@ -18,7 +19,7 @@ void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const Zone&
|
||||
|
||||
// Localized strings are all collected in one string file. So only add this to the zone file.
|
||||
if (!pools->m_localize->m_asset_lookup.empty())
|
||||
stream.WriteEntry(*pools->GetAssetTypeName(ASSET_TYPE_LOCALIZE_ENTRY), zone.m_name);
|
||||
stream.WriteEntry(*game->GetAssetTypeName(ASSET_TYPE_LOCALIZE_ENTRY), zone.m_name);
|
||||
|
||||
for (const auto& asset : *pools)
|
||||
{
|
||||
@@ -28,7 +29,7 @@ void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const Zone&
|
||||
break;
|
||||
|
||||
default:
|
||||
stream.WriteEntry(*pools->GetAssetTypeName(asset->m_type), asset->m_name);
|
||||
stream.WriteEntry(*game->GetAssetTypeName(asset->m_type), asset->m_name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
#include "AssetNameResolverT5.h"
|
||||
|
||||
#include "Game/T5/GameAssetPoolT5.h"
|
||||
#include "Utils/StringUtils.h"
|
||||
|
||||
using namespace T5;
|
||||
|
||||
AssetNameResolver::AssetNameResolver()
|
||||
{
|
||||
for (auto assetType = 0; assetType < ASSET_TYPE_COUNT; assetType++)
|
||||
AddAssetTypeName(assetType, *GameAssetPoolT5::AssetTypeNameByType(assetType));
|
||||
}
|
||||
|
||||
GameId AssetNameResolver::GetGameId() const
|
||||
{
|
||||
return GameId::T5;
|
||||
}
|
||||
|
||||
std::optional<const char*> AssetNameResolver::GetAssetTypeName(const asset_type_t assetType) const
|
||||
{
|
||||
return GameAssetPoolT5::AssetTypeNameByType(assetType);
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Zone/AssetNameResolver.h"
|
||||
|
||||
namespace T5
|
||||
{
|
||||
class AssetNameResolver final : public HashMapBasedAssetNameResolver
|
||||
{
|
||||
public:
|
||||
AssetNameResolver();
|
||||
[[nodiscard]] GameId GetGameId() const override;
|
||||
[[nodiscard]] std::optional<const char*> GetAssetTypeName(asset_type_t assetType) const override;
|
||||
};
|
||||
} // namespace T5
|
||||
@@ -3,29 +3,13 @@
|
||||
#include "Pool/AssetPoolDynamic.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <type_traits>
|
||||
|
||||
using namespace T5;
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr const char* ASSET_TYPE_NAMES[]{
|
||||
"xmodelpieces", "physpreset", "physconstraints", "destructibledef", "xanim", "xmodel", "material",
|
||||
"techniqueset", "image", "soundbank", "soundpatch", "clipmap_unused", "clipmap", "comworld",
|
||||
"gameworldsp", "gameworldmp", "mapents", "gfxworld", "gfxlightdef", "uimap", "font",
|
||||
"menulist", "menu", "localize", "weapon", "weapondef", "weaponvariant", "snddriverglobals",
|
||||
"fx", "fximpacttable", "aitype", "mptype", "mpbody", "mphead", "character",
|
||||
"xmodelalias", "rawfile", "stringtable", "packindex", "xglobals", "ddl", "glasses",
|
||||
"emblemset",
|
||||
};
|
||||
}
|
||||
|
||||
GameAssetPoolT5::GameAssetPoolT5(Zone* zone, const zone_priority_t priority)
|
||||
: ZoneAssetPools(zone),
|
||||
m_priority(priority)
|
||||
{
|
||||
static_assert(std::extent_v<decltype(ASSET_TYPE_NAMES)> == ASSET_TYPE_COUNT);
|
||||
|
||||
#define INIT_POOL(poolName) (poolName) = std::make_unique<AssetPoolDynamic<decltype(poolName)::element_type::type>>(m_priority)
|
||||
|
||||
INIT_POOL(m_phys_preset);
|
||||
@@ -175,26 +159,3 @@ XAssetInfoGeneric* GameAssetPoolT5::GetAsset(const asset_type_t type, const std:
|
||||
|
||||
#undef CASE_GET_ASSET
|
||||
}
|
||||
|
||||
std::optional<const char*> GameAssetPoolT5::AssetTypeNameByType(const asset_type_t assetType)
|
||||
{
|
||||
if (assetType >= 0 && assetType < static_cast<int>(std::extent_v<decltype(ASSET_TYPE_NAMES)>))
|
||||
return ASSET_TYPE_NAMES[assetType];
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<const char*> GameAssetPoolT5::GetAssetTypeName(const asset_type_t assetType) const
|
||||
{
|
||||
return AssetTypeNameByType(assetType);
|
||||
}
|
||||
|
||||
asset_type_t GameAssetPoolT5::AssetTypeCount()
|
||||
{
|
||||
return ASSET_TYPE_COUNT;
|
||||
}
|
||||
|
||||
asset_type_t GameAssetPoolT5::GetAssetTypeCount() const
|
||||
{
|
||||
return AssetTypeCount();
|
||||
}
|
||||
|
||||
@@ -47,12 +47,6 @@ public:
|
||||
|
||||
[[nodiscard]] XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const override;
|
||||
|
||||
static std::optional<const char*> AssetTypeNameByType(asset_type_t assetType);
|
||||
[[nodiscard]] std::optional<const char*> GetAssetTypeName(asset_type_t assetType) const override;
|
||||
|
||||
static asset_type_t AssetTypeCount();
|
||||
[[nodiscard]] asset_type_t GetAssetTypeCount() const override;
|
||||
|
||||
protected:
|
||||
XAssetInfoGeneric* AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) override;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ void ZoneDefWriter::WriteMetaData(ZoneDefinitionOutputStream& stream, const Zone
|
||||
|
||||
void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const Zone& zone) const
|
||||
{
|
||||
const auto* game = IGame::GetGameById(zone.m_game_id);
|
||||
const auto* pools = dynamic_cast<GameAssetPoolT5*>(zone.m_pools.get());
|
||||
|
||||
assert(pools);
|
||||
@@ -18,7 +19,7 @@ void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const Zone&
|
||||
|
||||
// Localized strings are all collected in one string file. So only add this to the zone file.
|
||||
if (!pools->m_localize->m_asset_lookup.empty())
|
||||
stream.WriteEntry(*pools->GetAssetTypeName(ASSET_TYPE_LOCALIZE_ENTRY), zone.m_name);
|
||||
stream.WriteEntry(*game->GetAssetTypeName(ASSET_TYPE_LOCALIZE_ENTRY), zone.m_name);
|
||||
|
||||
for (const auto& asset : *pools)
|
||||
{
|
||||
@@ -28,7 +29,7 @@ void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const Zone&
|
||||
break;
|
||||
|
||||
default:
|
||||
stream.WriteEntry(*pools->GetAssetTypeName(asset->m_type), asset->m_name);
|
||||
stream.WriteEntry(*game->GetAssetTypeName(asset->m_type), asset->m_name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
#include "AssetNameResolverT6.h"
|
||||
|
||||
#include "Game/T6/GameAssetPoolT6.h"
|
||||
#include "Utils/StringUtils.h"
|
||||
|
||||
using namespace T6;
|
||||
|
||||
AssetNameResolver::AssetNameResolver()
|
||||
{
|
||||
for (auto assetType = 0; assetType < ASSET_TYPE_COUNT; assetType++)
|
||||
AddAssetTypeName(assetType, *GameAssetPoolT6::AssetTypeNameByType(assetType));
|
||||
}
|
||||
|
||||
GameId AssetNameResolver::GetGameId() const
|
||||
{
|
||||
return GameId::T6;
|
||||
}
|
||||
|
||||
std::optional<const char*> AssetNameResolver::GetAssetTypeName(const asset_type_t assetType) const
|
||||
{
|
||||
return GameAssetPoolT6::AssetTypeNameByType(assetType);
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Zone/AssetNameResolver.h"
|
||||
|
||||
namespace T6
|
||||
{
|
||||
class AssetNameResolver final : public HashMapBasedAssetNameResolver
|
||||
{
|
||||
public:
|
||||
AssetNameResolver();
|
||||
[[nodiscard]] GameId GetGameId() const override;
|
||||
[[nodiscard]] std::optional<const char*> GetAssetTypeName(asset_type_t assetType) const override;
|
||||
};
|
||||
} // namespace T6
|
||||
@@ -3,82 +3,13 @@
|
||||
#include "Pool/AssetPoolDynamic.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <type_traits>
|
||||
|
||||
using namespace T6;
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr const char* ASSET_TYPE_NAMES[]{
|
||||
"xmodelpieces",
|
||||
"physpreset",
|
||||
"physconstraints",
|
||||
"destructibledef",
|
||||
"xanim",
|
||||
"xmodel",
|
||||
"material",
|
||||
"techniqueset",
|
||||
"image",
|
||||
"soundbank",
|
||||
"soundpatch",
|
||||
"clipmap_unused",
|
||||
"clipmap",
|
||||
"comworld",
|
||||
"gameworldsp",
|
||||
"gameworldmp",
|
||||
"mapents",
|
||||
"gfxworld",
|
||||
"gfxlightdef",
|
||||
"uimap",
|
||||
"font",
|
||||
"fonticon",
|
||||
"menulist",
|
||||
"menu",
|
||||
"localize",
|
||||
"weapon",
|
||||
"weapondef",
|
||||
"weaponvariant",
|
||||
"weaponfull",
|
||||
"attachment",
|
||||
"attachmentunique",
|
||||
"camo",
|
||||
"snddriverglobals",
|
||||
"fx",
|
||||
"fximpacttable",
|
||||
"aitype",
|
||||
"mptype",
|
||||
"mpbody",
|
||||
"mphead",
|
||||
"character",
|
||||
"xmodelalias",
|
||||
"rawfile",
|
||||
"stringtable",
|
||||
"leaderboard",
|
||||
"xglobals",
|
||||
"ddl",
|
||||
"glasses",
|
||||
"emblemset",
|
||||
"script",
|
||||
"keyvaluepairs",
|
||||
"vehicle",
|
||||
"memoryblock",
|
||||
"addonmapents",
|
||||
"tracer",
|
||||
"skinnedverts",
|
||||
"qdb",
|
||||
"slug",
|
||||
"footsteptable",
|
||||
"footstepfxtable",
|
||||
"zbarrier",
|
||||
};
|
||||
} // namespace
|
||||
|
||||
GameAssetPoolT6::GameAssetPoolT6(Zone* zone, const zone_priority_t priority)
|
||||
: ZoneAssetPools(zone),
|
||||
m_priority(priority)
|
||||
{
|
||||
static_assert(std::extent_v<decltype(ASSET_TYPE_NAMES)> == ASSET_TYPE_COUNT);
|
||||
|
||||
#define INIT_POOL(poolName) (poolName) = std::make_unique<AssetPoolDynamic<decltype(poolName)::element_type::type>>(m_priority)
|
||||
|
||||
INIT_POOL(m_phys_preset);
|
||||
@@ -276,26 +207,3 @@ XAssetInfoGeneric* GameAssetPoolT6::GetAsset(const asset_type_t type, const std:
|
||||
|
||||
#undef CASE_GET_ASSET
|
||||
}
|
||||
|
||||
std::optional<const char*> GameAssetPoolT6::AssetTypeNameByType(const asset_type_t assetType)
|
||||
{
|
||||
if (assetType >= 0 && assetType < static_cast<int>(std::extent_v<decltype(ASSET_TYPE_NAMES)>))
|
||||
return ASSET_TYPE_NAMES[assetType];
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<const char*> GameAssetPoolT6::GetAssetTypeName(const asset_type_t assetType) const
|
||||
{
|
||||
return AssetTypeNameByType(assetType);
|
||||
}
|
||||
|
||||
asset_type_t GameAssetPoolT6::AssetTypeCount()
|
||||
{
|
||||
return ASSET_TYPE_COUNT;
|
||||
}
|
||||
|
||||
asset_type_t GameAssetPoolT6::GetAssetTypeCount() const
|
||||
{
|
||||
return AssetTypeCount();
|
||||
}
|
||||
|
||||
@@ -63,12 +63,6 @@ public:
|
||||
|
||||
[[nodiscard]] XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const override;
|
||||
|
||||
static std::optional<const char*> AssetTypeNameByType(asset_type_t assetType);
|
||||
[[nodiscard]] std::optional<const char*> GetAssetTypeName(asset_type_t assetType) const override;
|
||||
|
||||
static asset_type_t AssetTypeCount();
|
||||
[[nodiscard]] asset_type_t GetAssetTypeCount() const override;
|
||||
|
||||
protected:
|
||||
XAssetInfoGeneric* AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) override;
|
||||
|
||||
|
||||
@@ -66,6 +66,7 @@ void ZoneDefWriter::WriteMetaData(ZoneDefinitionOutputStream& stream, const Zone
|
||||
|
||||
void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const Zone& zone) const
|
||||
{
|
||||
const auto* game = IGame::GetGameById(zone.m_game_id);
|
||||
const auto* pools = dynamic_cast<GameAssetPoolT6*>(zone.m_pools.get());
|
||||
|
||||
assert(pools);
|
||||
@@ -74,7 +75,7 @@ void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const Zone&
|
||||
|
||||
// Localized strings are all collected in one string file. So only add this to the zone file.
|
||||
if (!pools->m_localize->m_asset_lookup.empty())
|
||||
stream.WriteEntry(*pools->GetAssetTypeName(ASSET_TYPE_LOCALIZE_ENTRY), zone.m_name);
|
||||
stream.WriteEntry(*game->GetAssetTypeName(ASSET_TYPE_LOCALIZE_ENTRY), zone.m_name);
|
||||
|
||||
for (const auto& asset : *pools)
|
||||
{
|
||||
@@ -85,7 +86,7 @@ void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const Zone&
|
||||
break;
|
||||
|
||||
default:
|
||||
stream.WriteEntry(*pools->GetAssetTypeName(asset->m_type), asset->m_name);
|
||||
stream.WriteEntry(*game->GetAssetTypeName(asset->m_type), asset->m_name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user