Added some extra functions for managing assets.
This commit is contained in:
@ -50,6 +50,16 @@ void AssetManager::removeExisting(const std::string filename) {
|
||||
}
|
||||
}
|
||||
|
||||
bool_t AssetManager::isEverythingLoaded() {
|
||||
return pendingAssetLoaders.size() == 0;
|
||||
}
|
||||
|
||||
bool_t AssetManager::isLoaded(const std::string filename) {
|
||||
auto existing = this->getExisting<AssetLoader>(filename);
|
||||
if(existing) return existing->loaded;
|
||||
return false;
|
||||
}
|
||||
|
||||
template<>
|
||||
std::shared_ptr<Texture> AssetManager::get<Texture>(
|
||||
const std::string filename
|
||||
|
@ -60,6 +60,22 @@ namespace Dawn {
|
||||
*/
|
||||
void update();
|
||||
|
||||
/**
|
||||
* Returns whether the asset manager has loaded all of the currently
|
||||
* managed assets.
|
||||
*
|
||||
* @return True if all assets have been loaded.
|
||||
*/
|
||||
bool_t isEverythingLoaded();
|
||||
|
||||
/**
|
||||
* Returns whether the asset manager has loaded the given asset.
|
||||
*
|
||||
* @param filename The filename of the asset to check.
|
||||
* @return True if the asset has been loaded.
|
||||
*/
|
||||
bool_t isLoaded(const std::string filename);
|
||||
|
||||
/**
|
||||
* Returns the asset loader for the given asset.
|
||||
*
|
||||
|
@ -20,6 +20,10 @@ std::shared_ptr<TrueTypeTexture> texture;
|
||||
void Dawn::helloWorldScene(Scene &s) {
|
||||
texture = s.getGame()->assetManager.get<TrueTypeTexture>("ysabeau_regular", 12);
|
||||
|
||||
while(!s.getGame()->assetManager.isLoaded("ysabeau_regular")) {
|
||||
s.getGame()->assetManager.update();
|
||||
}
|
||||
|
||||
auto cameraItem = s.createSceneItem();
|
||||
auto camera = cameraItem->addComponent<Camera>();
|
||||
cameraItem->lookAt({ 5, 5, 5 }, { 0, 0, 0 }, { 0, 1, 0 });
|
||||
|
Reference in New Issue
Block a user