44 lines
2.1 KiB
C++
44 lines
2.1 KiB
C++
/* ================================================================
|
|
Asset Manager
|
|
----------------
|
|
This class is responsible for the loading of all files considered as assets.
|
|
|
|
An Asset is an object that holds some amount of unique data that is normally read from a file in one of the asset directories. Each Asset has a file checksum, a special UUID, the pathname of the file it references, and the data for said file.
|
|
|
|
The AssetManager holds a special Files Cache. This cache is a basic list of unloaded Asset files, containing all but their data. It is constructed from all files in the assets directories and is updated when a new file has been added to the cache.
|
|
|
|
Files may be added to the Cache through the following manners:
|
|
1. Adding to an assets folder and updating the cache
|
|
2. Loading a specific file with addFile
|
|
* This will add the file to the preferred user assets folder
|
|
3. Calling addData(const char *filename, const char *bytes, size_t len)
|
|
* This will create the given filename in the preferred user assets folder and write bytes up to len to the file.
|
|
|
|
Beyond the File Cache, there is the Live Cache. This cache is the current list of loaded Assets. These Live Caches are generally loaded from and saved to a Campaign.
|
|
|
|
================================================================ */
|
|
#include "AssetCache.hpp"
|
|
#include "Asset.hpp"
|
|
#include "fio.hpp"
|
|
#include <vector>
|
|
|
|
class AssetManager {
|
|
public:
|
|
AssetManager();
|
|
~AssetManager();
|
|
// loads given file as an asset
|
|
Asset* loadFile(const char *filename);
|
|
//Asset* loadAsset(const char *filename);
|
|
// attempts to find asset with the given UUID in the asset cache
|
|
// Asset* loadAsset(const char *uuid);
|
|
// saves the loaded assets in the asset cache
|
|
// saves all Assets in assets to the given cache file
|
|
int addCache(AssetCache* cache);
|
|
// int saveCache(const char *cachefile);
|
|
//
|
|
// int loadCache(const char *cachefile)
|
|
private:
|
|
Asset null_asset; // Special null asset to return from loadAsset if it could not be found
|
|
std::vector<AssetCache*> caches; // Caches
|
|
AssetCache live_cache; // Cache of loaded assets
|
|
}; |