Files
Seele/src/Engine/Asset/AssetRegistry.h
T

70 lines
2.5 KiB
C++
Raw Normal View History

2020-06-02 11:46:18 +02:00
#pragma once
#include "MinimalEngine.h"
#include "Asset.h"
#include "Material/MaterialAsset.h"
2020-06-02 11:46:18 +02:00
#include <string>
2021-04-25 23:43:40 +02:00
#include <map>
2020-06-02 11:46:18 +02:00
namespace Seele
{
2021-04-01 16:40:14 +02:00
DECLARE_REF(TextureLoader)
2022-04-13 13:01:35 +02:00
DECLARE_REF(FontLoader)
2021-04-01 16:40:14 +02:00
DECLARE_REF(MeshLoader)
DECLARE_REF(MaterialLoader)
DECLARE_REF(TextureAsset)
2022-04-13 13:01:35 +02:00
DECLARE_REF(FontAsset)
2021-04-01 16:40:14 +02:00
DECLARE_REF(MeshAsset)
DECLARE_REF(MaterialAsset)
DECLARE_NAME_REF(Gfx, Graphics)
2020-06-02 11:46:18 +02:00
class AssetRegistry
{
public:
~AssetRegistry();
static void init(const std::string& rootFolder);
2020-09-19 14:36:50 +02:00
static std::string getRootFolder();
2020-06-02 11:46:18 +02:00
static void importFile(const std::string& filePath);
static PMeshAsset findMesh(const std::string& filePath);
static PTextureAsset findTexture(const std::string& filePath);
2022-04-13 13:01:35 +02:00
static PFontAsset findFont(const std::string& name);
2020-06-02 11:46:18 +02:00
static PMaterialAsset findMaterial(const std::string& filePath);
2020-09-19 14:36:50 +02:00
2021-04-01 16:40:14 +02:00
static std::ofstream createWriteStream(const std::string& relativePath, std::ios_base::openmode openmode = std::ios::out);
static std::ifstream createReadStream(const std::string& relativePath, std::ios_base::openmode openmode = std::ios::in);
2020-06-02 11:46:18 +02:00
private:
static AssetRegistry& get();
AssetRegistry();
2020-06-08 01:44:47 +02:00
void init(const std::filesystem::path& rootFolder, Gfx::PGraphics graphics);
2020-06-02 11:46:18 +02:00
2020-09-19 14:36:50 +02:00
void importMesh(const std::filesystem::path& filePath);
void importTexture(const std::filesystem::path& filePath);
2022-04-13 13:01:35 +02:00
void importFont(const std::filesystem::path& filePath);
2020-09-19 14:36:50 +02:00
void importMaterial(const std::filesystem::path& filePath);
void registerMesh(PMeshAsset mesh);
void registerTexture(PTextureAsset texture);
2022-04-13 13:01:35 +02:00
void registerFont(PFontAsset font);
2020-09-19 14:36:50 +02:00
void registerMaterial(PMaterialAsset material);
2021-04-01 16:40:14 +02:00
std::ofstream internalCreateWriteStream(const std::string& relativePath, std::ios_base::openmode openmode = std::ios::out);
std::ifstream internalCreateReadStream(const std::string& relaitvePath, std::ios_base::openmode openmode = std::ios::in);
2020-09-19 14:36:50 +02:00
2020-06-08 01:44:47 +02:00
std::filesystem::path rootFolder;
2021-04-25 23:43:40 +02:00
//Todo: Seele::Map doesn't really work with strings for some reason, so just use std::map for now
std::map<std::string, PTextureAsset> textures;
2022-04-13 13:01:35 +02:00
std::map<std::string, PFontAsset> fonts;
2021-04-25 23:43:40 +02:00
std::map<std::string, PMeshAsset> meshes;
std::map<std::string, PMaterialAsset> materials;
2020-06-02 11:46:18 +02:00
UPTextureLoader textureLoader;
2022-04-13 13:01:35 +02:00
UPFontLoader fontLoader;
2020-06-02 11:46:18 +02:00
UPMeshLoader meshLoader;
UPMaterialLoader materialLoader;
friend class TextureLoader;
2022-04-13 13:01:35 +02:00
friend class FontLoader;
2020-06-02 11:46:18 +02:00
friend class MaterialLoader;
friend class MeshLoader;
};
}