update assets errors handling & add 'atlases' to preload

This commit is contained in:
MihailRis
2024-07-23 19:27:46 +03:00
parent ed60bdc333
commit f9df873382
7 changed files with 112 additions and 51 deletions
+36
View File
@@ -14,6 +14,16 @@
class Assets;
enum class AssetType {
TEXTURE,
SHADER,
FONT,
ATLAS,
LAYOUT,
SOUND,
MODEL
};
namespace assetload {
/// @brief final work to do in the main thread
using postfunc = std::function<void(Assets*)>;
@@ -22,6 +32,32 @@ namespace assetload {
template<class T>
void assets_setup(const Assets*);
class error : public std::runtime_error {
AssetType type;
std::string filename;
std::string reason;
public:
error(
AssetType type, std::string filename, std::string reason
) : std::runtime_error(filename + ": " + reason),
type(type),
filename(std::move(filename)),
reason(std::move(reason)) {
}
AssetType getAssetType() const {
return type;
}
const std::string& getFilename() const {
return filename;
}
const std::string& getReason() const {
return reason;
}
};
}
class Assets {