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.
72 lines
2.2 KiB
C
72 lines
2.2 KiB
C
|
4 years ago
|
/******************************************************************************
|
||
|
|
* File - content_manager.h
|
||
|
|
* Author - Joey Pollack
|
||
|
|
* Date - 2022/02/22 (y/m/d)
|
||
|
|
* Mod Date - 2022/02/22 (y/m/d)
|
||
|
|
* Description - Keeps track of all resource files in the project.
|
||
|
|
* Reads/Writes meta-data to the contents_meta.xml file.
|
||
|
|
* Also manages the physical location of each asset file.
|
||
|
|
******************************************************************************/
|
||
|
|
|
||
|
|
#ifndef CONTENT_MANAGER_H_
|
||
|
|
#define CONTENT_MANAGER_H_
|
||
|
|
|
||
|
|
#include "definitions.h"
|
||
|
|
#include <filesystem>
|
||
|
|
#include <string>
|
||
|
|
#include <utils/opRes.h>
|
||
|
|
#include <map>
|
||
|
4 years ago
|
#include <vector>
|
||
|
|
|
||
|
|
namespace pugi { class xml_node; }
|
||
|
4 years ago
|
|
||
|
|
namespace lunarium { namespace editor
|
||
|
|
{
|
||
|
|
|
||
|
|
class Project;
|
||
|
|
class EditorAsset;
|
||
|
|
|
||
|
|
class ContentManager
|
||
|
|
{
|
||
|
|
public:
|
||
|
|
|
||
|
|
static ContentManager& GetInstance();
|
||
|
|
static void FreeInstance();
|
||
|
|
|
||
|
|
[[nodiscard]] OpRes Load(Project* project);
|
||
|
|
[[nodiscard]] OpRes Save();
|
||
|
|
void Unload();
|
||
|
|
|
||
|
4 years ago
|
void GetAllAssetIDs(std::vector<uint64_t>& container) const;
|
||
|
|
void GetAllAssetsByType(std::vector<EditorAsset*>& container, AssetType type) const;
|
||
|
|
EditorAsset* GetAsset(uint64_t id);
|
||
|
|
|
||
|
|
/// Add an asset that was generated by the editor (like tile maps or scripts)
|
||
|
|
[[nodiscard]] OpRes AddGeneratedAsset(EditorAsset* asset, uint64_t& id);
|
||
|
|
|
||
|
|
/// Import a raw asset file from outside of the project (like image or sound files)
|
||
|
|
[[nodiscard]] OpRes ImportFile(std::filesystem::path file, std::filesystem::path to_location, AssetType type, uint64_t& id);
|
||
|
|
void RemoveAsset(uint64_t asset_id);
|
||
|
4 years ago
|
|
||
|
|
private:
|
||
|
|
static ContentManager* mpInstance;
|
||
|
|
Project* mpProject;
|
||
|
|
std::filesystem::path mContentFile;
|
||
|
|
std::map<uint64_t, EditorAsset*> mAssets;
|
||
|
4 years ago
|
uint64_t mNextID;
|
||
|
4 years ago
|
|
||
|
|
private:
|
||
|
|
ContentManager();
|
||
|
|
ContentManager(ContentManager&) = delete;
|
||
|
|
ContentManager& operator=(const ContentManager&) = delete;
|
||
|
|
|
||
|
4 years ago
|
private: // Helpers
|
||
|
|
[[nodiscard]] bool IsValidAsset(pugi::xml_node& node);
|
||
|
|
[[nodiscord]] EditorAsset* CreateAsset(AssetType type);
|
||
|
|
void FreeAssets();
|
||
|
|
|
||
|
|
|
||
|
4 years ago
|
};
|
||
|
|
}}
|
||
|
|
|
||
|
|
#endif // CONTENT_MANAGER_H_
|