Files
OpenAssetTools/src/ObjLoading/Game/T4/ObjLoaderT4.cpp
T
moandJan Laupetin 4da55a351a feat: add T4 menu dumping and loading (#986)
* feat: add T4 menu dumping

* chore: align with latest changes

* feat: add T4 menu loading

Load T4 menulists and menu files through the shared menu parser.

Preserve T4-specific menu and listbox fields and cover loading, dumping, linking, and round-trip behaviour.

* chore: make flag fields unsigned

* chore: rename `expOperationEnum` -> `operationEnum`

* chore: use default enum numeration for T4 operationEnum

* chore: remove unused members of operationEnum

* chore: remove redundant op from operationEnum

* refactor: align T4 expression operand names with IW3

* chore: small adjustment to iw3,t4 types

---------

Co-authored-by: Jan Laupetin <[email protected]>
2026-09-03 23:19:03 +02:00

129 lines
8.9 KiB
C++

#include "ObjLoaderT4.h"
#include "Asset/GlobalAssetPoolsLoader.h"
#include "Game/T4/AssetMarkerT4.h"
#include "Game/T4/Font/FontLoaderT4.h"
#include "Game/T4/Image/ImageLoaderEmbeddedT4.h"
#include "Game/T4/Image/ImageLoaderExternalT4.h"
#include "Game/T4/Menu/LoaderMenuListT4.h"
#include "Game/T4/T4.h"
#include "Game/T4/Weapon/AccuracyGraphLoaderT4.h"
#include "Game/T4/XAnim/XAnimLoaderT4.h"
#include "Localize/AssetLoaderLocalizeT4.h"
#include "Maps/MapEntsLoaderT4.h"
#include "Material/LoaderMaterialT4.h"
#include "PhysPreset/GdtLoaderPhysPresetT4.h"
#include "PhysPreset/RawLoaderPhysPresetT4.h"
#include "RawFile/AssetLoaderRawFileT4.h"
#include "StringTable/LoaderStringTableT4.h"
#include "Weapon/FlameTableLoaderT4.h"
#include "Weapon/WeaponGdtLoaderT4.h"
#include "Weapon/WeaponRawLoaderT4.h"
using namespace T4;
void ObjLoader::LoadReferencedContainersForZone(ISearchPath& searchPath, Zone& zone) const {}
void ObjLoader::UnloadContainersOfZone(Zone& zone) const {}
namespace
{
void ConfigureDefaultCreators(AssetCreatorCollection& collection, const Zone& zone)
{
auto& memory = zone.Memory();
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetPhysPreset>>(memory));
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetPhysConstraints>>(memory));
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetDestructibleDef>>(memory));
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetXAnim>>(memory));
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetXModel>>(memory));
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetMaterial>>(memory));
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetTechniqueSet>>(memory));
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetImage>>(memory));
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetSound>>(memory));
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetLoadedSound>>(memory));
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetClipMap>>(memory));
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetClipMapPvs>>(memory));
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetComWorld>>(memory));
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetGameWorldSp>>(memory));
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetGameWorldMp>>(memory));
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetMapEnts>>(memory));
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetGfxWorld>>(memory));
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetLightDef>>(memory));
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetFont>>(memory));
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetMenuList>>(memory));
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetMenu>>(memory));
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetLocalize>>(memory));
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetWeapon>>(memory));
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetSoundDriverGlobals>>(memory));
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetFx>>(memory));
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetImpactFx>>(memory));
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetRawFile>>(memory));
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetStringTable>>(memory));
collection.AddDefaultAssetCreator(std::make_unique<DefaultAssetCreator<AssetPackIndex>>(memory));
}
void ConfigureGlobalAssetPoolsLoaders(AssetCreatorCollection& collection, Zone& zone)
{
collection.AddAssetCreator(std::make_unique<GlobalAssetPoolsLoader<AssetPhysPreset>>(zone));
collection.AddAssetCreator(std::make_unique<GlobalAssetPoolsLoader<AssetPhysConstraints>>(zone));
collection.AddAssetCreator(std::make_unique<GlobalAssetPoolsLoader<AssetDestructibleDef>>(zone));
collection.AddAssetCreator(std::make_unique<GlobalAssetPoolsLoader<AssetXAnim>>(zone));
collection.AddAssetCreator(std::make_unique<GlobalAssetPoolsLoader<AssetXModel>>(zone));
collection.AddAssetCreator(std::make_unique<GlobalAssetPoolsLoader<AssetMaterial>>(zone));
collection.AddAssetCreator(std::make_unique<GlobalAssetPoolsLoader<AssetTechniqueSet>>(zone));
collection.AddAssetCreator(std::make_unique<GlobalAssetPoolsLoader<AssetImage>>(zone));
collection.AddAssetCreator(std::make_unique<GlobalAssetPoolsLoader<AssetSound>>(zone));
collection.AddAssetCreator(std::make_unique<GlobalAssetPoolsLoader<AssetLoadedSound>>(zone));
// collection.AddAssetCreator(std::make_unique<GlobalAssetPoolsLoader<AssetClipMap>>(zone));
collection.AddAssetCreator(std::make_unique<GlobalAssetPoolsLoader<AssetClipMapPvs>>(zone));
collection.AddAssetCreator(std::make_unique<GlobalAssetPoolsLoader<AssetComWorld>>(zone));
collection.AddAssetCreator(std::make_unique<GlobalAssetPoolsLoader<AssetGameWorldSp>>(zone));
collection.AddAssetCreator(std::make_unique<GlobalAssetPoolsLoader<AssetGameWorldMp>>(zone));
collection.AddAssetCreator(std::make_unique<GlobalAssetPoolsLoader<AssetMapEnts>>(zone));
collection.AddAssetCreator(std::make_unique<GlobalAssetPoolsLoader<AssetGfxWorld>>(zone));
collection.AddAssetCreator(std::make_unique<GlobalAssetPoolsLoader<AssetLightDef>>(zone));
collection.AddAssetCreator(std::make_unique<GlobalAssetPoolsLoader<AssetFont>>(zone));
collection.AddAssetCreator(std::make_unique<GlobalAssetPoolsLoader<AssetMenuList>>(zone));
collection.AddAssetCreator(std::make_unique<GlobalAssetPoolsLoader<AssetMenu>>(zone));
collection.AddAssetCreator(std::make_unique<GlobalAssetPoolsLoader<AssetLocalize>>(zone));
collection.AddAssetCreator(std::make_unique<GlobalAssetPoolsLoader<AssetWeapon>>(zone));
collection.AddAssetCreator(std::make_unique<GlobalAssetPoolsLoader<AssetSoundDriverGlobals>>(zone));
collection.AddAssetCreator(std::make_unique<GlobalAssetPoolsLoader<AssetFx>>(zone));
collection.AddAssetCreator(std::make_unique<GlobalAssetPoolsLoader<AssetImpactFx>>(zone));
collection.AddAssetCreator(std::make_unique<GlobalAssetPoolsLoader<AssetRawFile>>(zone));
collection.AddAssetCreator(std::make_unique<GlobalAssetPoolsLoader<AssetStringTable>>(zone));
collection.AddAssetCreator(std::make_unique<GlobalAssetPoolsLoader<AssetPackIndex>>(zone));
}
void ConfigureLoaders(AssetCreatorCollection& collection, Zone& zone, ISearchPath& searchPath, IGdtQueryable& gdt)
{
auto& memory = zone.Memory();
collection.AddAssetCreator(xanim::CreateLoaderT4(memory, searchPath, zone));
collection.AddAssetCreator(image::CreateLoaderEmbeddedT4(memory, searchPath));
collection.AddAssetCreator(image::CreateLoaderExternalT4(memory, searchPath));
collection.AddAssetCreator(material::CreateLoaderT4(memory, searchPath));
collection.AddAssetCreator(font::CreateLoaderT4(memory, searchPath));
collection.AddAssetCreator(menu::CreateMenuListLoaderT4(memory, searchPath));
collection.AddAssetCreator(localize::CreateLoaderT4(memory, searchPath, zone));
collection.AddAssetCreator(map_ents::CreateLoaderT4(memory, searchPath));
collection.AddAssetCreator(phys_preset::CreateRawLoaderT4(memory, searchPath, zone));
collection.AddAssetCreator(phys_preset::CreateGdtLoaderT4(memory, gdt, zone));
collection.AddAssetCreator(raw_file::CreateLoaderT4(memory, searchPath));
collection.AddAssetCreator(string_table::CreateLoaderT4(memory, searchPath));
collection.AddAssetCreator(weapon::CreateRawLoaderT4(memory, searchPath, zone));
collection.AddAssetCreator(weapon::CreateGdtLoaderT4(memory, searchPath, gdt, zone));
collection.AddSubAssetCreator(weapon::CreateAccuracyGraphLoaderT4(memory, searchPath));
collection.AddSubAssetCreator(weapon::CreateFlameTableLoaderT4(memory, searchPath, zone));
}
} // namespace
void ObjLoader::ConfigureCreatorCollection(AssetCreatorCollection& collection, Zone& zone, ISearchPath& searchPath, IGdtQueryable& gdt) const
{
ConfigureDefaultCreators(collection, zone);
ConfigureLoaders(collection, zone, searchPath, gdt);
ConfigureGlobalAssetPoolsLoaders(collection, zone);
}