2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2026-02-10 17:43:03 +00:00

refactor: retrieve asset names from IGame

This commit is contained in:
Jan Laupetin
2026-02-04 23:00:10 +01:00
parent 1540b69ac1
commit e5784d09ed
11 changed files with 389 additions and 122 deletions

View File

@@ -1,8 +1,10 @@
#pragma once #pragma once
#include "GameLanguage.h" #include "GameLanguage.h"
#include "Zone/ZoneTypes.h"
#include <cstdint> #include <cstdint>
#include <optional>
#include <type_traits> #include <type_traits>
#include <vector> #include <vector>
@@ -64,5 +66,8 @@ public:
[[nodiscard]] virtual const std::string& GetShortName() const = 0; [[nodiscard]] virtual const std::string& GetShortName() const = 0;
[[nodiscard]] virtual const std::vector<GameLanguagePrefix>& GetLanguagePrefixes() const = 0; [[nodiscard]] virtual const std::vector<GameLanguagePrefix>& GetLanguagePrefixes() const = 0;
[[nodiscard]] virtual asset_type_t GetAssetTypeCount() const = 0;
[[nodiscard]] virtual std::optional<const char*> GetAssetTypeName(asset_type_t assetType) const = 0;
static IGame* GetGameById(GameId gameId); static IGame* GetGameById(GameId gameId);
}; };

View File

@@ -1,28 +1,56 @@
#include "GameIW3.h" #include "GameIW3.h"
#include "IW3.h"
#include <algorithm> #include <algorithm>
using namespace IW3; using namespace IW3;
GameId Game::GetId() const namespace
{ {
return GameId::IW3; constexpr const char* ASSET_TYPE_NAMES[ASSET_TYPE_COUNT]{
} "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",
};
} // namespace
const std::string& Game::GetFullName() const namespace IW3
{ {
static std::string fullName = "Call Of Duty 4: Modern Warfare"; GameId Game::GetId() const
return fullName; {
} return GameId::IW3;
}
const std::string& Game::GetShortName() const const std::string& Game::GetFullName() const
{ {
static std::string shortName = "IW3"; static std::string fullName = "Call Of Duty 4: Modern Warfare";
return shortName; return fullName;
} }
const std::vector<GameLanguagePrefix>& Game::GetLanguagePrefixes() const const std::string& Game::GetShortName() const
{ {
static std::vector<GameLanguagePrefix> prefixes; static std::string shortName = "IW3";
return prefixes; 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;
}
} // namespace IW3

View File

@@ -1,4 +1,5 @@
#pragma once #pragma once
#include "Game/IGame.h" #include "Game/IGame.h"
namespace IW3 namespace IW3
@@ -10,5 +11,8 @@ namespace IW3
[[nodiscard]] const std::string& GetFullName() const override; [[nodiscard]] const std::string& GetFullName() const override;
[[nodiscard]] const std::string& GetShortName() const override; [[nodiscard]] const std::string& GetShortName() const override;
[[nodiscard]] const std::vector<GameLanguagePrefix>& GetLanguagePrefixes() 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;
}; };
} // namespace IW3 } // namespace IW3

View File

@@ -1,28 +1,61 @@
#include "GameIW4.h" #include "GameIW4.h"
#include "IW4.h"
#include <algorithm> #include <algorithm>
using namespace IW4; using namespace IW4;
GameId Game::GetId() const namespace
{ {
return GameId::IW4; constexpr const char* ASSET_TYPE_NAMES[ASSET_TYPE_COUNT]{
} "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",
};
} // namespace
const std::string& Game::GetFullName() const namespace IW4
{ {
static std::string fullName = "Call Of Duty: Modern Warfare 2"; GameId Game::GetId() const
return fullName; {
} return GameId::IW4;
}
const std::string& Game::GetShortName() const const std::string& Game::GetFullName() const
{ {
static std::string shortName = "IW4"; static std::string fullName = "Call Of Duty: Modern Warfare 2";
return shortName; return fullName;
} }
const std::vector<GameLanguagePrefix>& Game::GetLanguagePrefixes() const const std::string& Game::GetShortName() const
{ {
static std::vector<GameLanguagePrefix> prefixes; static std::string shortName = "IW4";
return prefixes; 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;
}
} // namespace IW4

View File

@@ -10,5 +10,8 @@ namespace IW4
[[nodiscard]] const std::string& GetFullName() const override; [[nodiscard]] const std::string& GetFullName() const override;
[[nodiscard]] const std::string& GetShortName() const override; [[nodiscard]] const std::string& GetShortName() const override;
[[nodiscard]] const std::vector<GameLanguagePrefix>& GetLanguagePrefixes() 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;
}; };
} // namespace IW4 } // namespace IW4

View File

@@ -1,28 +1,98 @@
#include "GameIW5.h" #include "GameIW5.h"
#include "IW5.h"
#include <algorithm> #include <algorithm>
using namespace IW5; using namespace IW5;
GameId Game::GetId() const namespace
{ {
return GameId::IW5; constexpr const char* ASSET_TYPE_NAMES[ASSET_TYPE_COUNT]{
} "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",
};
} // namespace
const std::string& Game::GetFullName() const namespace IW5
{ {
static std::string fullName = "Call Of Duty: Modern Warfare 3"; GameId Game::GetId() const
return fullName; {
} return GameId::IW5;
}
const std::string& Game::GetShortName() const const std::string& Game::GetFullName() const
{ {
static std::string shortName = "IW5"; static std::string fullName = "Call Of Duty: Modern Warfare 3";
return shortName; return fullName;
} }
const std::vector<GameLanguagePrefix>& Game::GetLanguagePrefixes() const const std::string& Game::GetShortName() const
{ {
static std::vector<GameLanguagePrefix> prefixes; static std::string shortName = "IW5";
return prefixes; 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;
}
} // namespace IW5

View File

@@ -10,5 +10,8 @@ namespace IW5
[[nodiscard]] const std::string& GetFullName() const override; [[nodiscard]] const std::string& GetFullName() const override;
[[nodiscard]] const std::string& GetShortName() const override; [[nodiscard]] const std::string& GetShortName() const override;
[[nodiscard]] const std::vector<GameLanguagePrefix>& GetLanguagePrefixes() 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;
}; };
} // namespace IW5 } // namespace IW5

View File

@@ -1,43 +1,74 @@
#include "GameT5.h" #include "GameT5.h"
#include "T5.h"
#include <algorithm> #include <algorithm>
using namespace T5; using namespace T5;
GameId Game::GetId() const namespace
{ {
return GameId::T5; constexpr const char* ASSET_TYPE_NAMES[ASSET_TYPE_COUNT]{
} "xmodelpieces", "physpreset", "physconstraints", "destructibledef", "xanim", "xmodel", "material",
"techniqueset", "image", "soundbank", "soundpatch", "clipmap_unused", "clipmap", "comworld",
const std::string& Game::GetFullName() const "gameworldsp", "gameworldmp", "mapents", "gfxworld", "gfxlightdef", "uimap", "font",
{ "menulist", "menu", "localize", "weapon", "weapondef", "weaponvariant", "snddriverglobals",
static std::string fullName = "Call Of Duty: Black Ops"; "fx", "fximpacttable", "aitype", "mptype", "mpbody", "mphead", "character",
return fullName; "xmodelalias", "rawfile", "stringtable", "packindex", "xglobals", "ddl", "glasses",
} "emblemset",
const std::string& Game::GetShortName() const
{
static std::string shortName = "T5";
return shortName;
}
const std::vector<GameLanguagePrefix>& Game::GetLanguagePrefixes() const
{
static std::vector<GameLanguagePrefix> prefixes{
{GameLanguage::LANGUAGE_ENGLISH, "en_"},
{GameLanguage::LANGUAGE_FRENCH, "fr_"},
{GameLanguage::LANGUAGE_FRENCH_CAN, "fc_"},
{GameLanguage::LANGUAGE_GERMAN, "ge_"},
{GameLanguage::LANGUAGE_AUSTRIAN, "ge_"},
{GameLanguage::LANGUAGE_ITALIAN, "it_"},
{GameLanguage::LANGUAGE_SPANISH, "sp_"},
{GameLanguage::LANGUAGE_BRITISH, "br_"},
{GameLanguage::LANGUAGE_RUSSIAN, "ru_"},
{GameLanguage::LANGUAGE_POLISH, "po_"},
{GameLanguage::LANGUAGE_KOREAN, "ko_"},
{GameLanguage::LANGUAGE_JAPANESE, "ja_"},
{GameLanguage::LANGUAGE_CZECH, "cz_"},
}; };
} // namespace
return prefixes; namespace T5
} {
GameId Game::GetId() const
{
return GameId::T5;
}
const std::string& Game::GetFullName() const
{
static std::string fullName = "Call Of Duty: Black Ops";
return fullName;
}
const std::string& Game::GetShortName() const
{
static std::string shortName = "T5";
return shortName;
}
const std::vector<GameLanguagePrefix>& Game::GetLanguagePrefixes() const
{
static std::vector<GameLanguagePrefix> prefixes{
{GameLanguage::LANGUAGE_ENGLISH, "en_"},
{GameLanguage::LANGUAGE_FRENCH, "fr_"},
{GameLanguage::LANGUAGE_FRENCH_CAN, "fc_"},
{GameLanguage::LANGUAGE_GERMAN, "ge_"},
{GameLanguage::LANGUAGE_AUSTRIAN, "ge_"},
{GameLanguage::LANGUAGE_ITALIAN, "it_"},
{GameLanguage::LANGUAGE_SPANISH, "sp_"},
{GameLanguage::LANGUAGE_BRITISH, "br_"},
{GameLanguage::LANGUAGE_RUSSIAN, "ru_"},
{GameLanguage::LANGUAGE_POLISH, "po_"},
{GameLanguage::LANGUAGE_KOREAN, "ko_"},
{GameLanguage::LANGUAGE_JAPANESE, "ja_"},
{GameLanguage::LANGUAGE_CZECH, "cz_"},
};
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;
}
} // namespace T5

View File

@@ -10,5 +10,8 @@ namespace T5
[[nodiscard]] const std::string& GetFullName() const override; [[nodiscard]] const std::string& GetFullName() const override;
[[nodiscard]] const std::string& GetShortName() const override; [[nodiscard]] const std::string& GetShortName() const override;
[[nodiscard]] const std::vector<GameLanguagePrefix>& GetLanguagePrefixes() 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;
}; };
} // namespace T5 } // namespace T5

View File

@@ -1,46 +1,130 @@
#include "GameT6.h" #include "GameT6.h"
#include "T6.h"
#include <algorithm> #include <algorithm>
using namespace T6; using namespace T6;
GameId Game::GetId() const namespace
{ {
return GameId::T6; constexpr const char* ASSET_TYPE_NAMES[ASSET_TYPE_COUNT]{
} "xmodelpieces",
"physpreset",
const std::string& Game::GetFullName() const "physconstraints",
{ "destructibledef",
static std::string fullName = "Call Of Duty: Black Ops II"; "xanim",
return fullName; "xmodel",
} "material",
"techniqueset",
const std::string& Game::GetShortName() const "image",
{ "soundbank",
static std::string shortName = "T6"; "soundpatch",
return shortName; "clipmap_unused",
} "clipmap",
"comworld",
const std::vector<GameLanguagePrefix>& Game::GetLanguagePrefixes() const "gameworldsp",
{ "gameworldmp",
static std::vector<GameLanguagePrefix> prefixes{ "mapents",
{GameLanguage::LANGUAGE_ENGLISH, "en_"}, "gfxworld",
{GameLanguage::LANGUAGE_FRENCH, "fr_"}, "gfxlightdef",
{GameLanguage::LANGUAGE_FRENCH_CAN, "fc_"}, "uimap",
{GameLanguage::LANGUAGE_GERMAN, "ge_"}, "font",
{GameLanguage::LANGUAGE_AUSTRIAN, "as_"}, "fonticon",
{GameLanguage::LANGUAGE_ITALIAN, "it_"}, "menulist",
{GameLanguage::LANGUAGE_SPANISH, "sp_"}, "menu",
{GameLanguage::LANGUAGE_BRITISH, "br_"}, "localize",
{GameLanguage::LANGUAGE_RUSSIAN, "ru_"}, "weapon",
{GameLanguage::LANGUAGE_POLISH, "po_"}, "weapondef",
{GameLanguage::LANGUAGE_KOREAN, "ko_"}, "weaponvariant",
{GameLanguage::LANGUAGE_JAPANESE, "ja_"}, "weaponfull",
{GameLanguage::LANGUAGE_CZECH, "cz_"}, "attachment",
{GameLanguage::LANGUAGE_FULL_JAPANESE, "fj_"}, "attachmentunique",
{GameLanguage::LANGUAGE_PORTUGUESE, "bp_"}, "camo",
{GameLanguage::LANGUAGE_MEXICAN_SPANISH, "ms_"}, "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
return prefixes; namespace T6
} {
GameId Game::GetId() const
{
return GameId::T6;
}
const std::string& Game::GetFullName() const
{
static std::string fullName = "Call Of Duty: Black Ops II";
return fullName;
}
const std::string& Game::GetShortName() const
{
static std::string shortName = "T6";
return shortName;
}
const std::vector<GameLanguagePrefix>& Game::GetLanguagePrefixes() const
{
static std::vector<GameLanguagePrefix> prefixes{
{GameLanguage::LANGUAGE_ENGLISH, "en_"},
{GameLanguage::LANGUAGE_FRENCH, "fr_"},
{GameLanguage::LANGUAGE_FRENCH_CAN, "fc_"},
{GameLanguage::LANGUAGE_GERMAN, "ge_"},
{GameLanguage::LANGUAGE_AUSTRIAN, "as_"},
{GameLanguage::LANGUAGE_ITALIAN, "it_"},
{GameLanguage::LANGUAGE_SPANISH, "sp_"},
{GameLanguage::LANGUAGE_BRITISH, "br_"},
{GameLanguage::LANGUAGE_RUSSIAN, "ru_"},
{GameLanguage::LANGUAGE_POLISH, "po_"},
{GameLanguage::LANGUAGE_KOREAN, "ko_"},
{GameLanguage::LANGUAGE_JAPANESE, "ja_"},
{GameLanguage::LANGUAGE_CZECH, "cz_"},
{GameLanguage::LANGUAGE_FULL_JAPANESE, "fj_"},
{GameLanguage::LANGUAGE_PORTUGUESE, "bp_"},
{GameLanguage::LANGUAGE_MEXICAN_SPANISH, "ms_"},
};
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;
}
} // namespace T6

View File

@@ -10,5 +10,8 @@ namespace T6
[[nodiscard]] const std::string& GetFullName() const override; [[nodiscard]] const std::string& GetFullName() const override;
[[nodiscard]] const std::string& GetShortName() const override; [[nodiscard]] const std::string& GetShortName() const override;
[[nodiscard]] const std::vector<GameLanguagePrefix>& GetLanguagePrefixes() 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;
}; };
} // namespace T6 } // namespace T6