asset rework

This commit is contained in:
Jorijn van der Graaf 2025-05-23 23:53:15 +02:00
commit df4ee20976
22 changed files with 145 additions and 87 deletions

View file

@ -1,5 +1,5 @@
/*
Crafter.Build
Crafter®.Asset
Copyright (C) 2025 Catcrafts®
Catcrafts.net
@ -193,22 +193,52 @@ export namespace Crafter {
public:
std::string name;
std::string type;
std::vector<char> data;
AssetEntry();
AssetEntry(std::string name, std::string type, std::vector<char> data);
AssetEntry(std::string name, std::string type, void* data);
uint32_t offset;
uint32_t lenght;
AssetEntry() = default;
AssetEntry(std::string_view name, std::string_view type, uint32_t lenght) : name(name), type(type), lenght(lenght) {
}
};
class Asset {
class AssetLoad {
public:
std::vector<AssetEntry> entries;
Asset();
Asset(std::vector<AssetEntry> entries);
void LoadFull(fs::path path);
void LoadHeaders(fs::path path);
void LoadSpecific(fs::path path, std::string entry);
void LoadSpecific(fs::path path, std::vector<std::string> entries);
void LoadSpecific(fs::path path, std::uint32_t entry);
void LoadSpecific(fs::path path, std::vector<std::uint32_t> entries);
AssetLoad(fs::path path);
AssetLoad() = default;
std::vector<char> Load(std::string_view name);
std::vector<char> Load(std::string_view name, uint32_t lenght);
void Load(std::string_view name, void* data);
void Load(std::string_view name, void* data, uint32_t lenght);
std::vector<char> Load(uint32_t index);
std::vector<char> Load(uint32_t index, uint32_t lenght);
void Load(uint32_t index, void* data);
void Load(uint32_t index, void* data, uint32_t lenght);
std::vector<char> Load(const AssetEntry& entry);
std::vector<char> Load(const AssetEntry& entry, uint32_t lenght);
void Load(const AssetEntry& entry, void* data);
void Load(const AssetEntry& entry, void* data, uint32_t lenght);
std::vector<char> LoadOffset(uint32_t offset, uint32_t lenght);
void LoadOffset(uint32_t offset, uint32_t lenght, void* data);
std::vector<char> LoadAll();
private:
uint32_t headerLength;
std::ifstream f;
};
class AssetSave {
public:
std::vector<AssetEntry> entries;
std::vector<char> buffer;
AssetSave() = default;
AssetSave(std::span<AssetEntry const> entries, std::span<char const> buffer);
void AddEntry(std::string_view name, std::string_view type, std::span<char const> data);
void Save(fs::path path);
};
}