mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-10 06:49:28 -05:00
Add AssetLoader basis
This commit is contained in:
@ -4,6 +4,8 @@
|
||||
#include "Game/T6/GameAssetPoolT6.h"
|
||||
#include "ObjContainer/IPak/IPak.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "AssetLoaders/AssetLoaderRawFile.h"
|
||||
#include "AssetLoading/AssetLoadingManager.h"
|
||||
#include "Image/Texture.h"
|
||||
#include "Image/IwiLoader.h"
|
||||
#include "Game/T6/CommonT6.h"
|
||||
@ -13,6 +15,64 @@ namespace T6
|
||||
const int ObjLoader::IPAK_READ_HASH = CommonT6::Com_HashKey("ipak_read", 64);
|
||||
const int ObjLoader::GLOBAL_HASH = CommonT6::Com_HashKey("GLOBAL", 64);
|
||||
|
||||
ObjLoader::ObjLoader()
|
||||
{
|
||||
#define REGISTER_ASSET_LOADER(t) {auto l = std::make_unique<t>(); m_asset_loaders_by_type[l->GetHandlingAssetType()] = std::move(l);}
|
||||
#define BASIC_LOADER(assetType, assetClass) BasicAssetLoader<assetType, assetClass>
|
||||
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_PHYSPRESET, PhysPreset))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_PHYSCONSTRAINTS, PhysConstraints))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_DESTRUCTIBLEDEF, DestructibleDef))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_XANIMPARTS, XAnimParts))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_XMODEL, XModel))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_MATERIAL, Material))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_TECHNIQUE_SET, MaterialTechniqueSet))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_IMAGE, GfxImage))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_SOUND, SndBank))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_SOUND_PATCH, SndPatch))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_CLIPMAP, clipMap_t))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_CLIPMAP_PVS, clipMap_t))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_COMWORLD, ComWorld))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_GAMEWORLD_SP, GameWorldSp))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_GAMEWORLD_MP, GameWorldMp))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_MAP_ENTS, MapEnts))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_GFXWORLD, GfxWorld))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_LIGHT_DEF, GfxLightDef))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_FONT, Font_s))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_FONTICON, FontIcon))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_MENULIST, MenuList))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_MENU, menuDef_t))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_LOCALIZE_ENTRY, LocalizeEntry))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_WEAPON, WeaponVariantDef))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_ATTACHMENT, WeaponAttachment))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_ATTACHMENT_UNIQUE, WeaponAttachmentUnique))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_WEAPON_CAMO, WeaponCamo))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_SNDDRIVER_GLOBALS, SndDriverGlobals))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_FX, FxEffectDef))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_IMPACT_FX, FxImpactTable))
|
||||
REGISTER_ASSET_LOADER(AssetLoaderRawFile)
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_STRINGTABLE, StringTable))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_LEADERBOARD, LeaderboardDef))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_XGLOBALS, XGlobals))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_DDL, ddlDef_t))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_GLASSES, Glasses))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_EMBLEMSET, EmblemSet))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_SCRIPTPARSETREE, ScriptParseTree))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_VEHICLEDEF, VehicleDef))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_MEMORYBLOCK, MemoryBlock))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_ADDON_MAP_ENTS, AddonMapEnts))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_TRACER, TracerDef))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_SKINNEDVERTS, SkinnedVertsDef))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_QDB, Qdb))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_SLUG, Slug))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_FOOTSTEP_TABLE, FootstepTableDef))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_FOOTSTEPFX_TABLE, FootstepFXTableDef))
|
||||
REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_ZBARRIER, ZBarrierDef))
|
||||
|
||||
#undef BASIC_LOADER
|
||||
#undef REGISTER_ASSET_LOADER
|
||||
}
|
||||
|
||||
bool ObjLoader::SupportsZone(Zone* zone) const
|
||||
{
|
||||
return zone->m_game == &g_GameT6;
|
||||
@ -227,4 +287,10 @@ namespace T6
|
||||
{
|
||||
LoadImageData(searchPath, zone);
|
||||
}
|
||||
|
||||
bool ObjLoader::LoadAssetForZone(AssetLoadingContext* context, const asset_type_t assetType, const std::string& assetName) const
|
||||
{
|
||||
AssetLoadingManager assetLoadingManager(m_asset_loaders_by_type, *context);
|
||||
return assetLoadingManager.LoadAssetFromLoader(assetType, assetName);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user