iw4x-client/src/Components/Modules/AssetHandler.hpp

73 lines
2.9 KiB
C++
Raw Normal View History

2015-12-23 16:21:03 -05:00
namespace Components
{
class AssetHandler : public Component
{
public:
2016-01-12 13:08:26 -05:00
class IAsset
{
public:
virtual Game::XAssetType GetType() { return Game::XAssetType::ASSET_TYPE_INVALID; };
virtual void Mark(Game::XAssetHeader header, ZoneBuilder::Zone* builder) { /*ErrorTypeNotSupported(this);*/ };
virtual void Save(Game::XAssetHeader header, ZoneBuilder::Zone* builder) { /*ErrorTypeNotSupported(this);*/ };
virtual void Dump(Game::XAssetHeader header) { /*ErrorTypeNotSupported(this);*/ };
virtual void Load(Game::XAssetHeader* header, std::string name, ZoneBuilder::Zone* builder) { /*ErrorTypeNotSupported(this);*/ };
2016-01-12 13:08:26 -05:00
};
typedef Game::XAssetHeader(Callback)(Game::XAssetType type, std::string name);
typedef void(RestrictCallback)(Game::XAssetType type, Game::XAssetHeader asset, std::string name, bool* restrict);
2015-12-23 16:21:03 -05:00
AssetHandler();
~AssetHandler();
const char* GetName() { return "AssetHandler"; };
static void OnFind(Game::XAssetType type, Callback* callback);
static void OnLoad(RestrictCallback* callback);
2015-12-26 08:27:34 -05:00
2015-12-28 19:45:04 -05:00
static void Relocate(void* start, void* to, DWORD size = 4);
2015-12-23 16:21:03 -05:00
2016-01-12 13:08:26 -05:00
static void ZoneSave(Game::XAsset asset, ZoneBuilder::Zone* builder);
static void ZoneMark(Game::XAsset asset, ZoneBuilder::Zone* builder);
static Game::XAssetHeader FindOriginalAsset(Game::XAssetType type, const char* filename);
static Game::XAssetHeader FindAssetForZone(Game::XAssetType type, std::string filename, ZoneBuilder::Zone* builder);
2016-01-22 12:10:45 -05:00
static void ClearTemporaryAssets();
static void StoreTemporaryAsset(Game::XAssetType type, Game::XAssetHeader asset);
2015-12-23 16:21:03 -05:00
private:
static bool BypassState;
2016-01-12 13:08:26 -05:00
static void RegisterInterface(IAsset* iAsset);
2015-12-23 16:21:03 -05:00
static Game::XAssetHeader FindAsset(Game::XAssetType type, const char* filename);
2015-12-25 20:51:58 -05:00
static bool IsAssetEligible(Game::XAssetType type, Game::XAssetHeader* asset);
2015-12-23 16:21:03 -05:00
static void FindAssetStub();
2015-12-25 20:51:58 -05:00
static void AddAssetStub();
2015-12-23 16:21:03 -05:00
2016-01-05 19:23:43 -05:00
static void OffsetToAlias(Utils::Stream::Offset* offset);
2015-12-28 19:45:04 -05:00
2016-01-22 12:10:45 -05:00
static std::map<std::string, Game::XAssetHeader> TemporaryAssets[Game::XAssetType::ASSET_TYPE_COUNT];
2016-01-12 13:08:26 -05:00
static std::map<Game::XAssetType, IAsset*> AssetInterfaces;
static std::map<Game::XAssetType, wink::slot<Callback>> TypeCallbacks;
static wink::signal<wink::slot<RestrictCallback>> RestrictSignal;
2015-12-28 19:45:04 -05:00
static std::map<void*, void*> Relocations;
2015-12-23 16:21:03 -05:00
};
}
2016-01-12 13:08:26 -05:00
2016-01-25 17:47:50 -05:00
#include "AssetInterfaces\IXModel.hpp"
2016-01-12 13:08:26 -05:00
#include "AssetInterfaces\IRawFile.hpp"
2016-01-22 05:59:43 -05:00
#include "AssetInterfaces\IGfxImage.hpp"
#include "AssetInterfaces\IMaterial.hpp"
2016-01-25 17:47:50 -05:00
#include "AssetInterfaces\IPhysPreset.hpp"
2016-01-26 13:54:39 -05:00
#include "AssetInterfaces\IXAnimParts.hpp"
2016-01-25 17:47:50 -05:00
#include "AssetInterfaces\IPhysCollmap.hpp"
#include "AssetInterfaces\IXModelSurfs.hpp"
2016-01-12 13:08:26 -05:00
#include "AssetInterfaces\ILocalizedEntry.hpp"
2016-01-22 05:59:43 -05:00
#include "AssetInterfaces\IMaterialPixelShader.hpp"
#include "AssetInterfaces\IMaterialTechniqueSet.hpp"
#include "AssetInterfaces\IMaterialVertexShader.hpp"
2016-03-04 11:02:00 -05:00
#include "AssetInterfaces\IStructuredDataDefSet.hpp"
2016-01-22 05:59:43 -05:00
#include "AssetInterfaces\IMaterialVertexDeclaration.hpp"