Asset: passat a unordered_map i carrega desde fitxer

This commit is contained in:
2025-08-09 14:30:59 +02:00
parent c7f5fed797
commit 5a02518de3
6 changed files with 489 additions and 428 deletions

View File

@@ -174,7 +174,7 @@ auto Resource::getDemoData(int index) -> DemoData & {
// Carga los sonidos del juego
void Resource::loadSounds() {
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n>> SOUND FILES");
auto list = Asset::get()->getListByType(AssetType::SOUND);
auto list = Asset::get()->getListByType(Asset::Type::SOUND);
sounds_.clear();
for (const auto &l : list) {
@@ -190,7 +190,7 @@ void Resource::loadSounds() {
// Carga las músicas del juego
void Resource::loadMusics() {
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n>> MUSIC FILES");
auto list = Asset::get()->getListByType(AssetType::MUSIC);
auto list = Asset::get()->getListByType(Asset::Type::MUSIC);
musics_.clear();
for (const auto &l : list) {
@@ -206,7 +206,7 @@ void Resource::loadMusics() {
// Carga las texturas del juego
void Resource::loadTextures() {
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n>> TEXTURES");
auto list = Asset::get()->getListByType(AssetType::BITMAP);
auto list = Asset::get()->getListByType(Asset::Type::BITMAP);
textures_.clear();
for (const auto &l : list) {
@@ -219,7 +219,7 @@ void Resource::loadTextures() {
// Carga los ficheros de texto del juego
void Resource::loadTextFiles() {
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n>> TEXT FILES");
auto list = Asset::get()->getListByType(AssetType::FONT);
auto list = Asset::get()->getListByType(Asset::Type::FONT);
text_files_.clear();
for (const auto &l : list) {
@@ -232,7 +232,7 @@ void Resource::loadTextFiles() {
// Carga las animaciones del juego
void Resource::loadAnimations() {
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n>> ANIMATIONS");
auto list = Asset::get()->getListByType(AssetType::ANIMATION);
auto list = Asset::get()->getListByType(Asset::Type::ANIMATION);
animations_.clear();
for (const auto &l : list) {
@@ -373,13 +373,13 @@ void Resource::clearMusics() {
// Calcula el número total de recursos a cargar y reinicia el contador de carga
void Resource::calculateTotalResources() {
const std::array<AssetType, 6> ASSET_TYPES = {
AssetType::SOUND,
AssetType::MUSIC,
AssetType::BITMAP,
AssetType::FONT,
AssetType::ANIMATION,
AssetType::DEMODATA};
const std::array<Asset::Type, 6> ASSET_TYPES = {
Asset::Type::SOUND,
Asset::Type::MUSIC,
Asset::Type::BITMAP,
Asset::Type::FONT,
Asset::Type::ANIMATION,
Asset::Type::DEMODATA};
size_t total = 0;
for (const auto &asset_type : ASSET_TYPES) {