mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-08-19 21:44:26 +00:00
* feat: QOS (007: Quantum of Solace) support * feat: add qos localize loader * feat: add qos stringtable loader * chore: comment about official zones * fix: add qos gfximage runtime fields * chore: remove useless dev time comments * fix: remove all `static_asserts`s from asset headers causing build fail on x64 * chore: change union ordering of qos `entryInternalData` * chore: move qos asset type enum to qos.h * fix: qos and t4 xsurface index buffer * chore: implement qos MaterialInfo struct * chore: adjust some gfxworld struct members * chore: implement qos PhysPreset and PhysConstraints * chore: fix and adjust slight inconsistencies with qos zone code * chore: reorder qos ZoneCode.lua entries in order of asset type enum * chore: remove asset types that are not actual asset types in zones * chore: check common asset arrays with static_assert * chore: rename qos assets * chore: reorder qos in templates to be in alphabetical order * chore: use function for CopyMipLevel in Dx9TextureLoader * chore: use templates for qos MapEntsDumper * chore: add missing braces in XModelToCommonConverter * chore: add generic way to peek at zone data * Qos does not use a classic ZoneHeader so code needs to be more generic * fix: do not use raw_byte and raw_uint typedefs for qos * fix: not being able to write clipmapmp * chore: additional research on qos vertex property and stuff --------- Co-authored-by: Jan Laupetin <[email protected]>
101 lines
2.8 KiB
C++
101 lines
2.8 KiB
C++
#include "IGame.h"
|
|
|
|
#include "IW3/GameIW3.h"
|
|
#include "IW4/GameIW4.h"
|
|
#include "IW5/GameIW5.h"
|
|
#include "QOS/GameQOS.h"
|
|
#include "T4/GameT4.h"
|
|
#include "T5/GameT5.h"
|
|
#include "T6/GameT6.h"
|
|
#include "Utils/StringUtils.h"
|
|
|
|
#include <cassert>
|
|
|
|
IGame* IGame::GetGameById(GameId gameId)
|
|
{
|
|
static IGame* games[]{
|
|
new IW3::Game(),
|
|
new IW4::Game(),
|
|
new IW5::Game(),
|
|
new QOS::Game(),
|
|
new T4::Game(),
|
|
new T5::Game(),
|
|
new T6::Game(),
|
|
};
|
|
static_assert(std::extent_v<decltype(games)> == static_cast<unsigned>(GameId::COUNT));
|
|
|
|
assert(static_cast<unsigned>(gameId) < static_cast<unsigned>(GameId::COUNT));
|
|
auto* result = games[static_cast<unsigned>(gameId)];
|
|
assert(result);
|
|
|
|
return result;
|
|
}
|
|
|
|
AbstractGame::AbstractGame(const char* const* assetTypeNames,
|
|
const asset_type_t assetTypeCount,
|
|
const char* const* subAssetTypeNames,
|
|
const asset_type_t subAssetTypeCount)
|
|
: m_asset_type_names(assetTypeNames),
|
|
m_asset_type_count(assetTypeCount),
|
|
m_sub_asset_type_names(subAssetTypeNames),
|
|
m_sub_asset_type_count(subAssetTypeCount)
|
|
{
|
|
for (asset_type_t assetType = 0; assetType < assetTypeCount; ++assetType)
|
|
{
|
|
assert(assetTypeNames[assetType] != nullptr);
|
|
AddAssetTypeNameAlias(assetType, assetTypeNames[assetType]);
|
|
}
|
|
}
|
|
|
|
const std::vector<GameLanguagePrefix>& AbstractGame::GetLanguagePrefixes() const
|
|
{
|
|
static std::vector<GameLanguagePrefix> prefixes;
|
|
return prefixes;
|
|
}
|
|
|
|
asset_type_t AbstractGame::GetAssetTypeCount() const
|
|
{
|
|
return m_asset_type_count;
|
|
}
|
|
|
|
std::optional<const char*> AbstractGame::GetAssetTypeName(const asset_type_t assetType) const
|
|
{
|
|
if (assetType < m_asset_type_count)
|
|
return m_asset_type_names[assetType];
|
|
|
|
return std::nullopt;
|
|
}
|
|
|
|
std::optional<asset_type_t> AbstractGame::FindAssetTypeByName(const std::string& potentialAssetTypeName) const
|
|
{
|
|
std::string lowerCaseName = potentialAssetTypeName;
|
|
utils::MakeStringLowerCase(lowerCaseName);
|
|
|
|
const auto existingAssetType = m_asset_type_name_lookup.find(lowerCaseName);
|
|
if (existingAssetType != m_asset_type_name_lookup.end())
|
|
return existingAssetType->second;
|
|
|
|
return std::nullopt;
|
|
}
|
|
|
|
asset_type_t AbstractGame::GetSubAssetTypeCount() const
|
|
{
|
|
return m_sub_asset_type_count;
|
|
}
|
|
|
|
std::optional<const char*> AbstractGame::GetSubAssetTypeName(const asset_type_t subAssetType) const
|
|
{
|
|
if (subAssetType < m_sub_asset_type_count)
|
|
return m_sub_asset_type_names[subAssetType];
|
|
|
|
return std::nullopt;
|
|
}
|
|
|
|
void AbstractGame::AddAssetTypeNameAlias(const asset_type_t assetType, const std::string& assetTypeName)
|
|
{
|
|
std::string lowerCaseName = assetTypeName;
|
|
utils::MakeStringLowerCase(lowerCaseName);
|
|
|
|
m_asset_type_name_lookup.emplace(lowerCaseName, assetType);
|
|
}
|