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
add_executable(dawntests)
target_link_libraries(dawntests PRIVATE Catch2::Catch2WithMain)
target_compile_definitions(dawntests
PUBLIC
DAWN_ASSET_LOCATION="${DAWN_ROOT_DIR}/test/data"
)
# Add tools
add_subdirectory(tools)

View File

@ -7,12 +7,8 @@
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");
assertNotNull(assetManager, "Asset::Asset: AssetManager cannot be null");
this->assetManager = assetManager;
this->name = name;
}
Asset::~Asset() {

View File

@ -11,8 +11,7 @@ namespace Dawn {
class Asset {
public:
AssetManager *assetManager;
std::string name;
const std::string name;
bool_t loaded = false;
Event<> eventLoaded;
StateEvent<> event2Loaded;
@ -20,10 +19,9 @@ namespace Dawn {
/**
* Create an abstract Asset object.
*
* @param assetManager Asset manager that this asset belongs to.
* @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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -50,10 +50,9 @@ namespace Dawn {
* Constructs a texture asset loader. You should instead use the parent
* asset managers' abstracted load method
*
* @param assetManager Asset manager this asset belongs to.
* @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 updateAsync() override;

View File

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

View File

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