Commit prog.

This commit is contained in:
2023-11-02 10:39:50 -05:00
parent f573ff8366
commit 79b7e235ab
12 changed files with 20 additions and 23 deletions

View File

@ -37,6 +37,10 @@ project(Dawn
# Setup tests # Setup tests
add_executable(dawntests) add_executable(dawntests)
target_link_libraries(dawntests PRIVATE Catch2::Catch2WithMain) target_link_libraries(dawntests PRIVATE Catch2::Catch2WithMain)
target_compile_definitions(dawntests
PUBLIC
DAWN_ASSET_LOCATION="${DAWN_ROOT_DIR}/test/data"
)
# Add tools # Add tools
add_subdirectory(tools) add_subdirectory(tools)

View File

@ -7,12 +7,8 @@
using namespace Dawn; using namespace Dawn;
Asset::Asset(AssetManager *assetManager, std::string name) { Asset::Asset(const std::string name) : name(name) {
assertTrue(name.size() > 0, "Asset::Asset: Name cannot be empty"); assertTrue(name.size() > 0, "Asset::Asset: Name cannot be empty");
assertNotNull(assetManager, "Asset::Asset: AssetManager cannot be null");
this->assetManager = assetManager;
this->name = name;
} }
Asset::~Asset() { Asset::~Asset() {

View File

@ -11,8 +11,7 @@ namespace Dawn {
class Asset { class Asset {
public: public:
AssetManager *assetManager; const std::string name;
std::string name;
bool_t loaded = false; bool_t loaded = false;
Event<> eventLoaded; Event<> eventLoaded;
StateEvent<> event2Loaded; StateEvent<> event2Loaded;
@ -20,10 +19,9 @@ namespace Dawn {
/** /**
* Create an abstract Asset object. * Create an abstract Asset object.
* *
* @param assetManager Asset manager that this asset belongs to.
* @param name Name of the asset. * @param name Name of the asset.
*/ */
Asset(AssetManager *assetManager, std::string name); Asset(const std::string name);
/** /**
* Virtual function that will be called by the asset manager on a * Virtual function that will be called by the asset manager on a

View File

@ -80,7 +80,7 @@ namespace Dawn {
if(existing != this->assets.end()) { if(existing != this->assets.end()) {
return (T*)existing->second; return (T*)existing->second;
} }
auto asset = new T(this, name); auto asset = new T(name);
this->assets[name] = asset; this->assets[name] = asset;
return asset; return asset;
} }

View File

@ -7,8 +7,8 @@
using namespace Dawn; using namespace Dawn;
AudioAsset::AudioAsset(AssetManager *man, std::string name) : AudioAsset::AudioAsset(const std::string name) :
Asset(man, name), Asset(name),
loader(name + ".audio") loader(name + ".audio")
{ {

View File

@ -35,7 +35,7 @@ namespace Dawn {
size_t frameSize; size_t frameSize;
public: public:
AudioAsset(AssetManager *man, std::string name); AudioAsset(const std::string name);
void updateSync() override; void updateSync() override;
void updateAsync() override; void updateAsync() override;

View File

@ -7,8 +7,8 @@
using namespace Dawn; using namespace Dawn;
LanguageAsset::LanguageAsset(AssetManager *man, std::string name) : LanguageAsset::LanguageAsset(const std::string name) :
Asset(man, name), Asset(name),
loader(name + ".language") loader(name + ".language")
{ {

View File

@ -28,7 +28,7 @@ namespace Dawn {
uint8_t buffer[1024]; uint8_t buffer[1024];
public: public:
LanguageAsset(AssetManager *man, std::string name); LanguageAsset(const std::string name);
void updateSync() override; void updateSync() override;
void updateAsync() override; void updateAsync() override;
std::string getValue(std::string key); std::string getValue(std::string key);

View File

@ -8,8 +8,8 @@
using namespace Dawn; using namespace Dawn;
TextureAsset::TextureAsset(AssetManager *assetManager, std::string name) : TextureAsset::TextureAsset(const std::string name) :
Asset(assetManager, name), Asset(name),
loader(name + ".texture"), loader(name + ".texture"),
texture() texture()
{ {

View File

@ -50,10 +50,9 @@ namespace Dawn {
* Constructs a texture asset loader. You should instead use the parent * Constructs a texture asset loader. You should instead use the parent
* asset managers' abstracted load method * asset managers' abstracted load method
* *
* @param assetManager Asset manager this asset belongs to.
* @param name File name asset to load, omitting the extension. * @param name File name asset to load, omitting the extension.
*/ */
TextureAsset(AssetManager *assetManager, std::string name); TextureAsset(const std::string name);
void updateSync() override; void updateSync() override;
void updateAsync() override; void updateAsync() override;

View File

@ -9,8 +9,8 @@
using namespace Dawn; using namespace Dawn;
TrueTypeAsset::TrueTypeAsset(AssetManager *assMan, std::string name) : TrueTypeAsset::TrueTypeAsset(const std::string name) :
Asset(assMan, name), Asset(name),
loader(name + ".truetype") loader(name + ".truetype")
{ {
this->locks.onLockRemoved = [&](usagelockid_t id){ this->locks.onLockRemoved = [&](usagelockid_t id){

View File

@ -44,7 +44,7 @@ namespace Dawn {
std::map<TrueTypeFaceTexture*, std::vector<usagelockid_t>> locksByTexture; std::map<TrueTypeFaceTexture*, std::vector<usagelockid_t>> locksByTexture;
public: public:
TrueTypeAsset(AssetManager *assMan, std::string name); TrueTypeAsset(const std::string name);
void updateSync() override; void updateSync() override;
void updateAsync() override; void updateAsync() override;