You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.5 KiB
C
57 lines
1.5 KiB
C
|
4 years ago
|
/******************************************************************************
|
||
|
4 years ago
|
* File - asset_index.h
|
||
|
4 years ago
|
* Author - Joey Pollack
|
||
|
|
* Date - 2021/10/25 (y/m/d)
|
||
|
|
* Mod Date - 2021/10/25 (y/m/d)
|
||
|
|
* Description - Loads and stores the index.dat file. Allows querying
|
||
|
|
* the asset index by asset ID or name.
|
||
|
|
******************************************************************************/
|
||
|
|
|
||
|
|
#ifndef ASSET_INDEX_H_
|
||
|
|
#define ASSET_INDEX_H_
|
||
|
|
|
||
|
4 years ago
|
#include <core/common_defs.h>
|
||
|
|
#include <core/types.h>
|
||
|
|
#include <utils/op_res.h>
|
||
|
|
#include <assets/types/asset.h>
|
||
|
|
|
||
|
4 years ago
|
#include <string>
|
||
|
|
#include <map>
|
||
|
|
|
||
|
|
namespace lunarium
|
||
|
|
{
|
||
|
|
class AssetIndex
|
||
|
|
{
|
||
|
|
public:
|
||
|
|
struct AssetInfo
|
||
|
|
{
|
||
|
|
int32_t ID;
|
||
|
|
std::string Name;
|
||
|
|
AssetType Type;
|
||
|
4 years ago
|
std::string File; // The data file the asset is stored in
|
||
|
|
u32 Offset; // The offset into the file at which the asset can be found
|
||
|
4 years ago
|
};
|
||
|
|
|
||
|
|
public:
|
||
|
|
|
||
|
|
static AssetIndex& GetInstance();
|
||
|
|
static void FreeInstance();
|
||
|
|
|
||
|
|
OpRes LoadIndex(const char* filename);
|
||
|
|
const AssetInfo* GetAssetInfo(int id) const;
|
||
|
|
const AssetInfo* GetAssetInfo(const char* name) const;
|
||
|
|
|
||
|
|
|
||
|
|
private:
|
||
|
|
static AssetIndex* mpInstance;
|
||
|
|
std::map<int, AssetInfo*> mAssets;
|
||
|
|
std::map<std::string, AssetInfo*> mAssetsByName;
|
||
|
|
|
||
|
|
AssetIndex();
|
||
|
|
AssetIndex(const AssetIndex&) = delete;
|
||
|
|
AssetIndex& operator=(const AssetIndex&) = delete;
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
#endif // ASSET_INDEX_H_
|