feat: accept aliases for asset type names

This commit is contained in:
Jan Laupetin
2026-05-02 18:08:12 +02:00
parent 0cbe0c2891
commit 08c128addd
20 changed files with 175 additions and 251 deletions
+7 -32
View File
@@ -29,6 +29,13 @@ namespace
namespace IW4
{
Game::Game()
: AbstractGame(ASSET_TYPE_NAMES, std::extent_v<decltype(ASSET_TYPE_NAMES)>, SUB_ASSET_TYPE_NAMES, std::extent_v<decltype(SUB_ASSET_TYPE_NAMES)>)
{
AddAssetTypeNameAlias<AssetTechniqueSet>("techset");
AddAssetTypeNameAlias<AssetLightDef>("gfxlightdef");
}
GameId Game::GetId() const
{
return GameId::IW4;
@@ -45,36 +52,4 @@ namespace IW4
static std::string shortName = "IW4";
return shortName;
}
const std::vector<GameLanguagePrefix>& Game::GetLanguagePrefixes() const
{
static std::vector<GameLanguagePrefix> prefixes;
return prefixes;
}
asset_type_t Game::GetAssetTypeCount() const
{
return ASSET_TYPE_COUNT;
}
std::optional<const char*> Game::GetAssetTypeName(const asset_type_t assetType) const
{
if (assetType < std::extent_v<decltype(ASSET_TYPE_NAMES)>)
return ASSET_TYPE_NAMES[assetType];
return std::nullopt;
}
asset_type_t Game::GetSubAssetTypeCount() const
{
return SUB_ASSET_TYPE_COUNT;
}
std::optional<const char*> Game::GetSubAssetTypeName(const asset_type_t subAssetType) const
{
if (subAssetType < std::extent_v<decltype(SUB_ASSET_TYPE_NAMES)>)
return SUB_ASSET_TYPE_NAMES[subAssetType];
return std::nullopt;
}
} // namespace IW4
+4 -7
View File
@@ -1,19 +1,16 @@
#pragma once
#include "Game/IGame.h"
namespace IW4
{
class Game final : public IGame
class Game final : public AbstractGame
{
public:
Game();
[[nodiscard]] GameId GetId() const override;
[[nodiscard]] const std::string& GetFullName() const override;
[[nodiscard]] const std::string& GetShortName() const override;
[[nodiscard]] const std::vector<GameLanguagePrefix>& GetLanguagePrefixes() const override;
[[nodiscard]] asset_type_t GetAssetTypeCount() const override;
[[nodiscard]] std::optional<const char*> GetAssetTypeName(asset_type_t assetType) const override;
[[nodiscard]] asset_type_t GetSubAssetTypeCount() const override;
[[nodiscard]] std::optional<const char*> GetSubAssetTypeName(asset_type_t subAssetType) const override;
};
} // namespace IW4