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

53 lines
1.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) { /*ErrorTypeNotSupported(this);*/ };
};
2015-12-23 16:21:03 -05:00
typedef Game::XAssetHeader(*Callback)(Game::XAssetType, const char*);
2015-12-25 20:51:58 -05:00
typedef bool(*RestrictCallback)(Game::XAssetType type, Game::XAssetHeader asset, const char* name);
2015-12-23 16:21:03 -05:00
AssetHandler();
~AssetHandler();
const char* GetName() { return "AssetHandler"; };
2015-12-26 08:27:34 -05:00
static void OnFind(Game::XAssetType type, Callback callback);
static void OnLoad(RestrictCallback callback);
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);
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-12 13:08:26 -05:00
static std::map<Game::XAssetType, IAsset*> AssetInterfaces;
2015-12-23 16:21:03 -05:00
static std::map<Game::XAssetType, Callback> TypeCallbacks;
2015-12-25 20:51:58 -05:00
static std::vector<RestrictCallback> RestrictCallbacks;
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
#include "AssetInterfaces\IRawFile.hpp"
#include "AssetInterfaces\ILocalizedEntry.hpp"