Asset: passat a unordered_map i carrega desde fitxer
This commit is contained in:
190
data/config/assets.txt
Normal file
190
data/config/assets.txt
Normal file
@@ -0,0 +1,190 @@
|
|||||||
|
# Coffee Crisis - Asset Configuration
|
||||||
|
# Formato: TIPO|RUTA [|OPCIONES]
|
||||||
|
# Opciones: optional, absolute (separadas por comas)
|
||||||
|
# Variables: ${PREFIX}, ${SYSTEM_FOLDER}
|
||||||
|
|
||||||
|
# Archivos de configuración del sistema (absolutos y opcionales)
|
||||||
|
DATA|${SYSTEM_FOLDER}/config.txt|optional,absolute
|
||||||
|
DATA|${SYSTEM_FOLDER}/controllers.json|optional,absolute
|
||||||
|
DATA|${SYSTEM_FOLDER}/score.bin|optional,absolute
|
||||||
|
|
||||||
|
# Archivos de configuración del juego
|
||||||
|
DATA|${PREFIX}/data/config/param_320x240.txt
|
||||||
|
DATA|${PREFIX}/data/config/param_320x256.txt
|
||||||
|
DEMODATA|${PREFIX}/data/config/demo1.bin
|
||||||
|
DEMODATA|${PREFIX}/data/config/demo2.bin
|
||||||
|
DATA|${PREFIX}/data/config/gamecontrollerdb.txt
|
||||||
|
DATA|${PREFIX}/data/config/formations.txt
|
||||||
|
DATA|${PREFIX}/data/config/pools.txt
|
||||||
|
|
||||||
|
# Música
|
||||||
|
MUSIC|${PREFIX}/data/music/intro.ogg
|
||||||
|
MUSIC|${PREFIX}/data/music/playing.ogg
|
||||||
|
MUSIC|${PREFIX}/data/music/title.ogg
|
||||||
|
MUSIC|${PREFIX}/data/music/credits.ogg
|
||||||
|
|
||||||
|
# Sonidos
|
||||||
|
SOUND|${PREFIX}/data/sound/balloon_pop0.wav
|
||||||
|
SOUND|${PREFIX}/data/sound/balloon_pop1.wav
|
||||||
|
SOUND|${PREFIX}/data/sound/balloon_pop2.wav
|
||||||
|
SOUND|${PREFIX}/data/sound/balloon_pop3.wav
|
||||||
|
SOUND|${PREFIX}/data/sound/balloon_bounce0.wav
|
||||||
|
SOUND|${PREFIX}/data/sound/balloon_bounce1.wav
|
||||||
|
SOUND|${PREFIX}/data/sound/balloon_bounce2.wav
|
||||||
|
SOUND|${PREFIX}/data/sound/balloon_bounce3.wav
|
||||||
|
SOUND|${PREFIX}/data/sound/bullet.wav
|
||||||
|
SOUND|${PREFIX}/data/sound/clock.wav
|
||||||
|
SOUND|${PREFIX}/data/sound/coffee_out.wav
|
||||||
|
SOUND|${PREFIX}/data/sound/continue_clock.wav
|
||||||
|
SOUND|${PREFIX}/data/sound/debian_drop.wav
|
||||||
|
SOUND|${PREFIX}/data/sound/debian_pickup.wav
|
||||||
|
SOUND|${PREFIX}/data/sound/hi_score_achieved.wav
|
||||||
|
SOUND|${PREFIX}/data/sound/item_drop.wav
|
||||||
|
SOUND|${PREFIX}/data/sound/item_pickup.wav
|
||||||
|
SOUND|${PREFIX}/data/sound/jump.wav
|
||||||
|
SOUND|${PREFIX}/data/sound/logo.wav
|
||||||
|
SOUND|${PREFIX}/data/sound/notify.wav
|
||||||
|
SOUND|${PREFIX}/data/sound/player_collision.wav
|
||||||
|
SOUND|${PREFIX}/data/sound/power_ball_explosion.wav
|
||||||
|
SOUND|${PREFIX}/data/sound/service_menu_adjust.wav
|
||||||
|
SOUND|${PREFIX}/data/sound/service_menu_move.wav
|
||||||
|
SOUND|${PREFIX}/data/sound/service_menu_select.wav
|
||||||
|
SOUND|${PREFIX}/data/sound/stage_change.wav
|
||||||
|
SOUND|${PREFIX}/data/sound/tabe_hit.wav
|
||||||
|
SOUND|${PREFIX}/data/sound/tabe.wav
|
||||||
|
SOUND|${PREFIX}/data/sound/title.wav
|
||||||
|
SOUND|${PREFIX}/data/sound/voice_aw_aw_aw.wav
|
||||||
|
SOUND|${PREFIX}/data/sound/voice_coffee.wav
|
||||||
|
SOUND|${PREFIX}/data/sound/voice_get_ready.wav
|
||||||
|
SOUND|${PREFIX}/data/sound/voice_no.wav
|
||||||
|
SOUND|${PREFIX}/data/sound/voice_power_up.wav
|
||||||
|
SOUND|${PREFIX}/data/sound/voice_thankyou.wav
|
||||||
|
SOUND|${PREFIX}/data/sound/walk.wav
|
||||||
|
|
||||||
|
# Shaders
|
||||||
|
DATA|${PREFIX}/data/shaders/crtpi_256.glsl
|
||||||
|
DATA|${PREFIX}/data/shaders/crtpi_240.glsl
|
||||||
|
|
||||||
|
# Texturas - Balloons
|
||||||
|
BITMAP|${PREFIX}/data/gfx/balloon/balloon0.png
|
||||||
|
ANIMATION|${PREFIX}/data/gfx/balloon/balloon0.ani
|
||||||
|
BITMAP|${PREFIX}/data/gfx/balloon/balloon1.png
|
||||||
|
ANIMATION|${PREFIX}/data/gfx/balloon/balloon1.ani
|
||||||
|
BITMAP|${PREFIX}/data/gfx/balloon/balloon2.png
|
||||||
|
ANIMATION|${PREFIX}/data/gfx/balloon/balloon2.ani
|
||||||
|
BITMAP|${PREFIX}/data/gfx/balloon/balloon3.png
|
||||||
|
ANIMATION|${PREFIX}/data/gfx/balloon/balloon3.ani
|
||||||
|
|
||||||
|
# Texturas - Explosiones
|
||||||
|
BITMAP|${PREFIX}/data/gfx/balloon/explosion0.png
|
||||||
|
ANIMATION|${PREFIX}/data/gfx/balloon/explosion0.ani
|
||||||
|
BITMAP|${PREFIX}/data/gfx/balloon/explosion1.png
|
||||||
|
ANIMATION|${PREFIX}/data/gfx/balloon/explosion1.ani
|
||||||
|
BITMAP|${PREFIX}/data/gfx/balloon/explosion2.png
|
||||||
|
ANIMATION|${PREFIX}/data/gfx/balloon/explosion2.ani
|
||||||
|
BITMAP|${PREFIX}/data/gfx/balloon/explosion3.png
|
||||||
|
ANIMATION|${PREFIX}/data/gfx/balloon/explosion3.ani
|
||||||
|
|
||||||
|
# Texturas - Power Ball
|
||||||
|
BITMAP|${PREFIX}/data/gfx/balloon/powerball.png
|
||||||
|
ANIMATION|${PREFIX}/data/gfx/balloon/powerball.ani
|
||||||
|
|
||||||
|
# Texturas - Bala
|
||||||
|
BITMAP|${PREFIX}/data/gfx/bullet/bullet.png
|
||||||
|
ANIMATION|${PREFIX}/data/gfx/bullet/bullet.ani
|
||||||
|
|
||||||
|
# Texturas - Tabe
|
||||||
|
BITMAP|${PREFIX}/data/gfx/tabe/tabe.png
|
||||||
|
ANIMATION|${PREFIX}/data/gfx/tabe/tabe.ani
|
||||||
|
|
||||||
|
# Texturas - Juego
|
||||||
|
BITMAP|${PREFIX}/data/gfx/game/game_buildings.png
|
||||||
|
BITMAP|${PREFIX}/data/gfx/game/game_clouds1.png
|
||||||
|
BITMAP|${PREFIX}/data/gfx/game/game_clouds2.png
|
||||||
|
BITMAP|${PREFIX}/data/gfx/game/game_grass.png
|
||||||
|
BITMAP|${PREFIX}/data/gfx/game/game_power_meter.png
|
||||||
|
BITMAP|${PREFIX}/data/gfx/game/game_sky_colors.png
|
||||||
|
BITMAP|${PREFIX}/data/gfx/game/game_sun.png
|
||||||
|
BITMAP|${PREFIX}/data/gfx/game/game_moon.png
|
||||||
|
|
||||||
|
# Texturas - Intro
|
||||||
|
BITMAP|${PREFIX}/data/gfx/intro/intro1.png
|
||||||
|
BITMAP|${PREFIX}/data/gfx/intro/intro2.png
|
||||||
|
BITMAP|${PREFIX}/data/gfx/intro/intro3.png
|
||||||
|
BITMAP|${PREFIX}/data/gfx/intro/intro4.png
|
||||||
|
BITMAP|${PREFIX}/data/gfx/intro/intro5.png
|
||||||
|
BITMAP|${PREFIX}/data/gfx/intro/intro6.png
|
||||||
|
|
||||||
|
# Texturas - Logo
|
||||||
|
BITMAP|${PREFIX}/data/gfx/logo/logo_jailgames.png
|
||||||
|
BITMAP|${PREFIX}/data/gfx/logo/logo_jailgames_mini.png
|
||||||
|
BITMAP|${PREFIX}/data/gfx/logo/logo_since_1998.png
|
||||||
|
|
||||||
|
# Texturas - Items
|
||||||
|
BITMAP|${PREFIX}/data/gfx/item/item_points1_disk.png
|
||||||
|
ANIMATION|${PREFIX}/data/gfx/item/item_points1_disk.ani
|
||||||
|
BITMAP|${PREFIX}/data/gfx/item/item_points2_gavina.png
|
||||||
|
ANIMATION|${PREFIX}/data/gfx/item/item_points2_gavina.ani
|
||||||
|
BITMAP|${PREFIX}/data/gfx/item/item_points3_pacmar.png
|
||||||
|
ANIMATION|${PREFIX}/data/gfx/item/item_points3_pacmar.ani
|
||||||
|
BITMAP|${PREFIX}/data/gfx/item/item_clock.png
|
||||||
|
ANIMATION|${PREFIX}/data/gfx/item/item_clock.ani
|
||||||
|
BITMAP|${PREFIX}/data/gfx/item/item_coffee.png
|
||||||
|
ANIMATION|${PREFIX}/data/gfx/item/item_coffee.ani
|
||||||
|
BITMAP|${PREFIX}/data/gfx/item/item_debian.png
|
||||||
|
ANIMATION|${PREFIX}/data/gfx/item/item_debian.ani
|
||||||
|
BITMAP|${PREFIX}/data/gfx/item/item_coffee_machine.png
|
||||||
|
ANIMATION|${PREFIX}/data/gfx/item/item_coffee_machine.ani
|
||||||
|
|
||||||
|
# Texturas - Titulo
|
||||||
|
BITMAP|${PREFIX}/data/gfx/title/title_bg_tile.png
|
||||||
|
BITMAP|${PREFIX}/data/gfx/title/title_coffee.png
|
||||||
|
BITMAP|${PREFIX}/data/gfx/title/title_crisis.png
|
||||||
|
BITMAP|${PREFIX}/data/gfx/title/title_arcade_edition.png
|
||||||
|
BITMAP|${PREFIX}/data/gfx/title/title_dust.png
|
||||||
|
ANIMATION|${PREFIX}/data/gfx/title/title_dust.ani
|
||||||
|
|
||||||
|
# Texturas - Jugador 1
|
||||||
|
BITMAP|${PREFIX}/data/gfx/player/player1.gif
|
||||||
|
PALETTE|${PREFIX}/data/gfx/player/player1_coffee1.pal
|
||||||
|
PALETTE|${PREFIX}/data/gfx/player/player1_coffee2.pal
|
||||||
|
PALETTE|${PREFIX}/data/gfx/player/player1_invencible.pal
|
||||||
|
BITMAP|${PREFIX}/data/gfx/player/player1_power.png
|
||||||
|
|
||||||
|
# Texturas - Jugador 2
|
||||||
|
BITMAP|${PREFIX}/data/gfx/player/player2.gif
|
||||||
|
PALETTE|${PREFIX}/data/gfx/player/player2_coffee1.pal
|
||||||
|
PALETTE|${PREFIX}/data/gfx/player/player2_coffee2.pal
|
||||||
|
PALETTE|${PREFIX}/data/gfx/player/player2_invencible.pal
|
||||||
|
BITMAP|${PREFIX}/data/gfx/player/player2_power.png
|
||||||
|
|
||||||
|
# Animaciones del jugador
|
||||||
|
ANIMATION|${PREFIX}/data/gfx/player/player.ani
|
||||||
|
ANIMATION|${PREFIX}/data/gfx/player/player_power.ani
|
||||||
|
|
||||||
|
# Texturas - Golpe del jugador
|
||||||
|
BITMAP|${PREFIX}/data/gfx/player/hit.png
|
||||||
|
|
||||||
|
# Fuentes de texto
|
||||||
|
BITMAP|${PREFIX}/data/font/8bithud.png
|
||||||
|
FONT|${PREFIX}/data/font/8bithud.txt
|
||||||
|
BITMAP|${PREFIX}/data/font/aseprite.png
|
||||||
|
FONT|${PREFIX}/data/font/aseprite.txt
|
||||||
|
BITMAP|${PREFIX}/data/font/smb2.png
|
||||||
|
BITMAP|${PREFIX}/data/font/smb2_grad.png
|
||||||
|
FONT|${PREFIX}/data/font/smb2.txt
|
||||||
|
BITMAP|${PREFIX}/data/font/04b_25.png
|
||||||
|
FONT|${PREFIX}/data/font/04b_25.txt
|
||||||
|
BITMAP|${PREFIX}/data/font/04b_25_2x.png
|
||||||
|
FONT|${PREFIX}/data/font/04b_25_2x.txt
|
||||||
|
BITMAP|${PREFIX}/data/font/04b_25_metal.png
|
||||||
|
BITMAP|${PREFIX}/data/font/04b_25_grey.png
|
||||||
|
BITMAP|${PREFIX}/data/font/04b_25_flat.png
|
||||||
|
BITMAP|${PREFIX}/data/font/04b_25_reversed.png
|
||||||
|
BITMAP|${PREFIX}/data/font/04b_25_flat_2x.png
|
||||||
|
BITMAP|${PREFIX}/data/font/04b_25_reversed_2x.png
|
||||||
|
|
||||||
|
# Idiomas
|
||||||
|
LANG|${PREFIX}/data/lang/es_ES.json
|
||||||
|
LANG|${PREFIX}/data/lang/en_UK.json
|
||||||
|
LANG|${PREFIX}/data/lang/ba_BA.json
|
||||||
309
source/asset.cpp
309
source/asset.cpp
@@ -1,85 +1,185 @@
|
|||||||
#include "asset.h"
|
#include "asset.h"
|
||||||
|
|
||||||
#include <SDL3/SDL.h> // Para SDL_LogInfo, SDL_LogCategory, SDL_LogError, SDL_LogWarn
|
#include <SDL3/SDL.h>
|
||||||
|
#include <fstream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
#include <algorithm> // Para max
|
#include "utils.h"
|
||||||
#include <fstream> // Para basic_ifstream, ifstream
|
|
||||||
#include <functional> // Para identity
|
|
||||||
#include <ranges> // Para __find_if_fn, find_if
|
|
||||||
#include <string> // Para allocator, string, operator==, operator+, char_traits, basic_string
|
|
||||||
|
|
||||||
#include "utils.h" // Para getFileName
|
|
||||||
|
|
||||||
// Singleton
|
// Singleton
|
||||||
Asset *Asset::instance = nullptr;
|
Asset *Asset::instance = nullptr;
|
||||||
|
|
||||||
// Inicializa la instancia única del singleton
|
void Asset::init(const std::string &executable_path) {
|
||||||
void Asset::init(const std::string &executable_path) { Asset::instance = new Asset(executable_path); }
|
Asset::instance = new Asset(executable_path);
|
||||||
|
|
||||||
// Libera la instancia
|
|
||||||
void Asset::destroy() { delete Asset::instance; }
|
|
||||||
|
|
||||||
// Obtiene la instancia
|
|
||||||
auto Asset::get() -> Asset * { return Asset::instance; }
|
|
||||||
|
|
||||||
// Añade un elemento a la lista
|
|
||||||
void Asset::add(const std::string &file, AssetType type, bool required, bool absolute) {
|
|
||||||
file_list_.emplace_back(absolute ? file : executable_path_ + file, type, required);
|
|
||||||
longest_name_ = std::max(longest_name_, static_cast<int>(file_list_.back().file.size()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Devuelve la ruta completa a un fichero a partir de una cadena
|
void Asset::destroy() {
|
||||||
auto Asset::get(const std::string &text) const -> std::string {
|
delete Asset::instance;
|
||||||
auto iterator = std::ranges::find_if(file_list_, [&text](const auto &file) {
|
}
|
||||||
return getFileName(file.file) == text;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (iterator != file_list_.end()) {
|
auto Asset::get() -> Asset * {
|
||||||
return iterator->file;
|
return Asset::instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Añade un elemento al mapa (función auxiliar)
|
||||||
|
void Asset::addToMap(const std::string &file_path, Type type, bool required, bool absolute) {
|
||||||
|
std::string full_path = absolute ? file_path : executable_path_ + file_path;
|
||||||
|
std::string filename = getFileName(full_path);
|
||||||
|
|
||||||
|
// Verificar si ya existe el archivo
|
||||||
|
if (file_list_.find(filename) != file_list_.end()) {
|
||||||
|
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Warning: Asset '%s' already exists, overwriting", filename.c_str());
|
||||||
}
|
}
|
||||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "Warning: file %s not found", text.c_str());
|
|
||||||
|
file_list_.emplace(filename, Item{std::move(full_path), type, required});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Añade un elemento a la lista
|
||||||
|
void Asset::add(const std::string &file_path, Type type, bool required, bool absolute) {
|
||||||
|
addToMap(file_path, type, required, absolute);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Carga recursos desde un archivo de configuración con soporte para variables
|
||||||
|
// Carga recursos desde un archivo de configuración con soporte para variables
|
||||||
|
void Asset::loadFromFile(const std::string &config_file_path, const std::string &prefix, const std::string &system_folder) {
|
||||||
|
std::ifstream file(config_file_path);
|
||||||
|
if (!file.is_open()) {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Error: Cannot open config file: %s", config_file_path.c_str());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string line;
|
||||||
|
int line_number = 0;
|
||||||
|
|
||||||
|
while (std::getline(file, line)) {
|
||||||
|
++line_number;
|
||||||
|
|
||||||
|
// Limpiar espacios en blanco al principio y final
|
||||||
|
line.erase(0, line.find_first_not_of(" \t\r"));
|
||||||
|
line.erase(line.find_last_not_of(" \t\r") + 1);
|
||||||
|
|
||||||
|
// DEBUG: mostrar línea leída (opcional, puedes comentar esta línea)
|
||||||
|
// SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Line %d: '%s'", line_number, line.c_str());
|
||||||
|
|
||||||
|
// Ignorar líneas vacías y comentarios
|
||||||
|
if (line.empty() || line[0] == '#' || line[0] == ';') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dividir la línea por el separador '|'
|
||||||
|
std::vector<std::string> parts;
|
||||||
|
std::istringstream iss(line);
|
||||||
|
std::string part;
|
||||||
|
|
||||||
|
while (std::getline(iss, part, '|')) {
|
||||||
|
parts.push_back(part);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verificar que tenemos al menos tipo y ruta
|
||||||
|
if (parts.size() < 2) {
|
||||||
|
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Warning: Malformed line %d in config file (insufficient fields)", line_number);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
std::string type_str = parts[0];
|
||||||
|
std::string path = parts[1];
|
||||||
|
|
||||||
|
// Valores por defecto
|
||||||
|
bool required = true;
|
||||||
|
bool absolute = false;
|
||||||
|
|
||||||
|
// Si hay opciones en el tercer campo, parsearlas
|
||||||
|
if (parts.size() >= 3) {
|
||||||
|
parseOptions(parts[2], required, absolute);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reemplazar variables en la ruta
|
||||||
|
path = replaceVariables(path, prefix, system_folder);
|
||||||
|
|
||||||
|
// Parsear el tipo de asset
|
||||||
|
Type type = parseAssetType(type_str);
|
||||||
|
|
||||||
|
// Añadir al mapa
|
||||||
|
addToMap(path, type, required, absolute);
|
||||||
|
|
||||||
|
} catch (const std::exception &e) {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Error parsing line %d in config file: %s", line_number, e.what());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Loaded %d assets from config file", static_cast<int>(file_list_.size()));
|
||||||
|
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Devuelve la ruta completa a un fichero (búsqueda O(1))
|
||||||
|
auto Asset::get(const std::string &filename) const -> std::string {
|
||||||
|
auto it = file_list_.find(filename);
|
||||||
|
if (it != file_list_.end()) {
|
||||||
|
return it->second.file;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "Warning: file %s not found", filename.c_str());
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Verifica si un recurso existe
|
||||||
|
auto Asset::exists(const std::string &filename) const -> bool {
|
||||||
|
return file_list_.find(filename) != file_list_.end();
|
||||||
|
}
|
||||||
|
|
||||||
// Comprueba que existen todos los elementos
|
// Comprueba que existen todos los elementos
|
||||||
auto Asset::check() const -> bool {
|
auto Asset::check() const -> bool {
|
||||||
bool success = true;
|
bool success = true;
|
||||||
|
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n** CHECKING FILES");
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n** CHECKING FILES");
|
||||||
|
|
||||||
// Comprueba la lista de ficheros clasificándolos por tipo
|
// Agrupar por tipo para mostrar organizado
|
||||||
for (int type = 0; type < static_cast<int>(AssetType::COUNT); ++type) {
|
std::unordered_map<Type, std::vector<const Item*>> by_type;
|
||||||
// Comprueba si hay ficheros de ese tipo
|
|
||||||
bool any = false;
|
for (const auto &[filename, item] : file_list_) {
|
||||||
|
if (item.required) {
|
||||||
for (const auto &file : file_list_) {
|
by_type[item.type].push_back(&item);
|
||||||
if (file.required && file.type == static_cast<AssetType>(type)) {
|
|
||||||
any = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Si hay ficheros de ese tipo, comprueba si existen
|
|
||||||
if (any) {
|
// Verificar por tipo
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n>> %s FILES", getTypeName(static_cast<AssetType>(type)).c_str());
|
for (int type = 0; type < static_cast<int>(Type::SIZE); ++type) {
|
||||||
|
Type asset_type = static_cast<Type>(type);
|
||||||
for (const auto &file : file_list_) {
|
|
||||||
if (file.required && file.type == static_cast<AssetType>(type)) {
|
if (by_type.find(asset_type) != by_type.end()) {
|
||||||
success &= checkFile(file.file);
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"\n>> %s FILES", getTypeName(asset_type).c_str());
|
||||||
|
|
||||||
|
bool type_success = true;
|
||||||
|
for (const auto *item : by_type[asset_type]) {
|
||||||
|
if (!checkFile(item->file)) {
|
||||||
|
success = false;
|
||||||
|
type_success = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (success) {
|
|
||||||
|
if (type_success) {
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, " All files are OK.");
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, " All files are OK.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resultado
|
// Resultado
|
||||||
if (success) {
|
if (success) {
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n** CHECKING FILES COMPLETED.\n");
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n** CHECKING FILES COMPLETED.\n");
|
||||||
} else {
|
} else {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "\n** CHECKING FILES FAILED.\n");
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "\n** CHECKING FILES FAILED.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,49 +188,96 @@ auto Asset::checkFile(const std::string &path) -> bool {
|
|||||||
std::ifstream file(path);
|
std::ifstream file(path);
|
||||||
bool success = file.good();
|
bool success = file.good();
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
if (!success) {
|
if (!success) {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Checking file: %s [ ERROR ]", getFileName(path).c_str());
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Checking file: %s [ ERROR ]", getFileName(path).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Parsea string a Type
|
||||||
|
auto Asset::parseAssetType(const std::string &type_str) -> Type {
|
||||||
|
if (type_str == "BITMAP") return Type::BITMAP;
|
||||||
|
if (type_str == "MUSIC") return Type::MUSIC;
|
||||||
|
if (type_str == "SOUND") return Type::SOUND;
|
||||||
|
if (type_str == "FONT") return Type::FONT;
|
||||||
|
if (type_str == "LANG") return Type::LANG;
|
||||||
|
if (type_str == "DATA") return Type::DATA;
|
||||||
|
if (type_str == "DEMODATA") return Type::DEMODATA;
|
||||||
|
if (type_str == "ANIMATION") return Type::ANIMATION;
|
||||||
|
if (type_str == "PALETTE") return Type::PALETTE;
|
||||||
|
|
||||||
|
throw std::runtime_error("Unknown asset type: " + type_str);
|
||||||
|
}
|
||||||
|
|
||||||
// Devuelve el nombre del tipo de recurso
|
// Devuelve el nombre del tipo de recurso
|
||||||
auto Asset::getTypeName(AssetType type) -> std::string {
|
auto Asset::getTypeName(Type type) -> std::string {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case AssetType::BITMAP:
|
case Type::BITMAP: return "BITMAP";
|
||||||
return "BITMAP";
|
case Type::MUSIC: return "MUSIC";
|
||||||
case AssetType::MUSIC:
|
case Type::SOUND: return "SOUND";
|
||||||
return "MUSIC";
|
case Type::FONT: return "FONT";
|
||||||
case AssetType::SOUND:
|
case Type::LANG: return "LANG";
|
||||||
return "SOUND";
|
case Type::DATA: return "DATA";
|
||||||
case AssetType::FONT:
|
case Type::DEMODATA: return "DEMODATA";
|
||||||
return "FONT";
|
case Type::ANIMATION: return "ANIMATION";
|
||||||
case AssetType::LANG:
|
case Type::PALETTE: return "PALETTE";
|
||||||
return "LANG";
|
default: return "ERROR";
|
||||||
case AssetType::DATA:
|
|
||||||
return "DATA";
|
|
||||||
case AssetType::DEMODATA:
|
|
||||||
return "DEMODATA";
|
|
||||||
case AssetType::ANIMATION:
|
|
||||||
return "ANIMATION";
|
|
||||||
case AssetType::PALETTE:
|
|
||||||
return "PALETTE";
|
|
||||||
default:
|
|
||||||
return "ERROR";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Devuelve la lista de recursos de un tipo
|
// Devuelve la lista de recursos de un tipo
|
||||||
auto Asset::getListByType(AssetType type) const -> std::vector<std::string> {
|
auto Asset::getListByType(Type type) const -> std::vector<std::string> {
|
||||||
std::vector<std::string> list;
|
std::vector<std::string> list;
|
||||||
|
|
||||||
for (auto file : file_list_) {
|
for (const auto &[filename, item] : file_list_) {
|
||||||
if (file.type == type) {
|
if (item.type == type) {
|
||||||
list.push_back(file.file);
|
list.push_back(item.file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reemplaza variables en las rutas
|
||||||
|
auto Asset::replaceVariables(const std::string &path, const std::string &prefix, const std::string &system_folder) -> std::string {
|
||||||
|
std::string result = path;
|
||||||
|
|
||||||
|
// Reemplazar ${PREFIX}
|
||||||
|
size_t pos = 0;
|
||||||
|
while ((pos = result.find("${PREFIX}", pos)) != std::string::npos) {
|
||||||
|
result.replace(pos, 9, prefix); // 9 = longitud de "${PREFIX}"
|
||||||
|
pos += prefix.length();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reemplazar ${SYSTEM_FOLDER}
|
||||||
|
pos = 0;
|
||||||
|
while ((pos = result.find("${SYSTEM_FOLDER}", pos)) != std::string::npos) {
|
||||||
|
result.replace(pos, 16, system_folder); // 16 = longitud de "${SYSTEM_FOLDER}"
|
||||||
|
pos += system_folder.length();
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parsea las opciones de una línea de configuración
|
||||||
|
auto Asset::parseOptions(const std::string &options, bool &required, bool &absolute) -> void {
|
||||||
|
if (options.empty()) return;
|
||||||
|
|
||||||
|
std::istringstream iss(options);
|
||||||
|
std::string option;
|
||||||
|
|
||||||
|
while (std::getline(iss, option, ',')) {
|
||||||
|
// Eliminar espacios
|
||||||
|
option.erase(0, option.find_first_not_of(" \t"));
|
||||||
|
option.erase(option.find_last_not_of(" \t") + 1);
|
||||||
|
|
||||||
|
if (option == "optional") {
|
||||||
|
required = false;
|
||||||
|
} else if (option == "absolute") {
|
||||||
|
absolute = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,64 +1,69 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string> // Para string
|
#include <string>
|
||||||
#include <utility> // Para move
|
#include <unordered_map>
|
||||||
#include <vector> // Para vector
|
#include <vector>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
// Tipos de recursos gestionados por Asset
|
// Clase Asset: gestor optimizado de recursos (singleton)
|
||||||
enum class AssetType : int {
|
class Asset {
|
||||||
BITMAP,
|
|
||||||
MUSIC,
|
|
||||||
SOUND,
|
|
||||||
FONT,
|
|
||||||
LANG,
|
|
||||||
DATA,
|
|
||||||
DEMODATA,
|
|
||||||
ANIMATION,
|
|
||||||
PALETTE,
|
|
||||||
COUNT,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Clase Asset: gestor de recursos (singleton)
|
|
||||||
class Asset { // Gestor de recursos (singleton)
|
|
||||||
public:
|
public:
|
||||||
|
// Tipos de recursos
|
||||||
|
enum class Type : int {
|
||||||
|
BITMAP,
|
||||||
|
MUSIC,
|
||||||
|
SOUND,
|
||||||
|
FONT,
|
||||||
|
LANG,
|
||||||
|
DATA,
|
||||||
|
DEMODATA,
|
||||||
|
ANIMATION,
|
||||||
|
PALETTE,
|
||||||
|
SIZE,
|
||||||
|
};
|
||||||
|
|
||||||
// --- Métodos de singleton ---
|
// --- Métodos de singleton ---
|
||||||
static void init(const std::string &executable_path); // Inicializa el objeto Asset
|
static void init(const std::string &executable_path);
|
||||||
static void destroy(); // Libera el objeto Asset
|
static void destroy();
|
||||||
static auto get() -> Asset *; // Obtiene el puntero al objeto Asset
|
static auto get() -> Asset *;
|
||||||
Asset(const Asset &) = delete; // No se permite copiar
|
Asset(const Asset &) = delete;
|
||||||
auto operator=(const Asset &) -> Asset & = delete; // No se permite asignar
|
auto operator=(const Asset &) -> Asset & = delete;
|
||||||
|
|
||||||
// --- Métodos para la gestión de recursos ---
|
// --- Métodos para la gestión de recursos ---
|
||||||
void add(const std::string &file, AssetType type, bool required = true, bool absolute = false); // Añade un recurso a la lista
|
void add(const std::string &file_path, Type type, bool required = true, bool absolute = false);
|
||||||
[[nodiscard]] auto get(const std::string &text) const -> std::string; // Obtiene la ruta completa de un recurso a partir de su nombre
|
void loadFromFile(const std::string &config_file_path, const std::string &prefix = "", const std::string &system_folder = ""); // Con soporte para variables
|
||||||
[[nodiscard]] auto check() const -> bool; // Verifica la existencia de todos los recursos requeridos
|
[[nodiscard]] auto get(const std::string &filename) const -> std::string; // Mantener nombre original
|
||||||
[[nodiscard]] auto getListByType(AssetType type) const -> std::vector<std::string>; // Devuelve una lista de archivos de un tipo concreto
|
[[nodiscard]] auto check() const -> bool;
|
||||||
|
[[nodiscard]] auto getListByType(Type type) const -> std::vector<std::string>;
|
||||||
|
[[nodiscard]] auto exists(const std::string &filename) const -> bool; // Nueva función para verificar existencia
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// --- Estructura interna para almacenar información de cada recurso ---
|
// --- Estructura interna para almacenar información de cada recurso ---
|
||||||
struct AssetItem { // Estructura para cada recurso
|
struct Item {
|
||||||
std::string file; // Ruta del fichero desde la raíz del directorio
|
std::string file; // Ruta completa del archivo (mantener nombre original)
|
||||||
AssetType type; // Tipo de recurso
|
Type type; // Tipo de recurso
|
||||||
bool required; // Indica si el fichero es obligatorio
|
bool required; // Indica si el archivo es obligatorio
|
||||||
|
|
||||||
AssetItem(std::string file_path, AssetType asset_type, bool is_required)
|
Item(std::string path, Type asset_type, bool is_required)
|
||||||
: file(std::move(file_path)), type(asset_type), required(is_required) {} // Constructor
|
: file(std::move(path)), type(asset_type), required(is_required) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
// --- Variables internas ---
|
// --- Variables internas ---
|
||||||
int longest_name_ = 0; // Longitud del nombre más largo
|
std::unordered_map<std::string, Item> file_list_; // Mapa para búsqueda O(1) (mantener nombre original)
|
||||||
std::vector<AssetItem> file_list_; // Lista con todas las rutas de recursos
|
std::string executable_path_; // Ruta del ejecutable
|
||||||
std::string executable_path_; // Ruta del ejecutable
|
|
||||||
|
|
||||||
// --- Métodos internos ---
|
// --- Métodos internos ---
|
||||||
[[nodiscard]] static auto checkFile(const std::string &path) -> bool; // Verifica si un archivo existe (interno)
|
[[nodiscard]] static auto checkFile(const std::string &path) -> bool;
|
||||||
[[nodiscard]] static auto getTypeName(AssetType type) -> std::string; // Devuelve el nombre textual del tipo de recurso (interno)
|
[[nodiscard]] static auto getTypeName(Type type) -> std::string;
|
||||||
|
[[nodiscard]] static auto parseAssetType(const std::string &type_str) -> Type;
|
||||||
|
void addToMap(const std::string &file_path, Type type, bool required, bool absolute);
|
||||||
|
[[nodiscard]] static auto replaceVariables(const std::string &path, const std::string &prefix, const std::string &system_folder) -> std::string;
|
||||||
|
static auto parseOptions(const std::string &options, bool &required, bool &absolute) -> void;
|
||||||
|
|
||||||
// --- Patrón Singleton ---
|
// --- Patrón Singleton ---
|
||||||
explicit Asset(std::string executable_path)
|
explicit Asset(std::string executable_path)
|
||||||
: executable_path_(std::move(executable_path)) {} // Constructor privado
|
: executable_path_(std::move(executable_path)) {}
|
||||||
~Asset() = default; // Destructor
|
~Asset() = default;
|
||||||
|
|
||||||
// --- Singleton ---
|
static Asset *instance;
|
||||||
static Asset *instance; // Instancia singleton
|
|
||||||
};
|
};
|
||||||
@@ -82,7 +82,7 @@ Director::~Director() {
|
|||||||
void Director::init() {
|
void Director::init() {
|
||||||
// Configuración inicial de parametros
|
// Configuración inicial de parametros
|
||||||
Asset::init(executable_path_); // Inicializa el sistema de gestión de archivos
|
Asset::init(executable_path_); // Inicializa el sistema de gestión de archivos
|
||||||
setFileList(); // Crea el índice de archivos
|
loadAssets(); // Crea el índice de archivos
|
||||||
|
|
||||||
Input::init(
|
Input::init(
|
||||||
Asset::get()->get("gamecontrollerdb.txt"),
|
Asset::get()->get("gamecontrollerdb.txt"),
|
||||||
@@ -152,295 +152,19 @@ void Director::loadScoreFile() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Asigna los botones y teclas al objeto Input
|
// Carga el indice de ficheros desde un fichero
|
||||||
void Director::bindInputs() {
|
void Director::loadAssets() {
|
||||||
/*static auto input = Input::get();
|
|
||||||
|
|
||||||
// Teclado - Movimiento del jugador
|
|
||||||
input->bindKey(Input::Action::UP, SDL_SCANCODE_UP);
|
|
||||||
input->bindKey(Input::Action::DOWN, SDL_SCANCODE_DOWN);
|
|
||||||
input->bindKey(Input::Action::LEFT, SDL_SCANCODE_LEFT);
|
|
||||||
input->bindKey(Input::Action::RIGHT, SDL_SCANCODE_RIGHT);
|
|
||||||
|
|
||||||
// Teclado - Disparo del jugador
|
|
||||||
input->bindKey(Input::Action::FIRE_LEFT, SDL_SCANCODE_Q);
|
|
||||||
input->bindKey(Input::Action::FIRE_CENTER, SDL_SCANCODE_W);
|
|
||||||
input->bindKey(Input::Action::FIRE_RIGHT, SDL_SCANCODE_E);
|
|
||||||
|
|
||||||
// Teclado - Interfaz
|
|
||||||
input->bindKey(Input::Action::START, SDL_SCANCODE_RETURN);
|
|
||||||
|
|
||||||
// Teclado - Menu de servicio
|
|
||||||
input->bindKey(Input::Action::SERVICE, SDL_SCANCODE_0);
|
|
||||||
input->bindKey(Input::Action::SM_SELECT, SDL_SCANCODE_RETURN);
|
|
||||||
input->bindKey(Input::Action::SM_BACK, SDL_SCANCODE_BACKSPACE);
|
|
||||||
|
|
||||||
// Teclado - Control del programa
|
|
||||||
input->bindKey(Input::Action::EXIT, SDL_SCANCODE_ESCAPE);
|
|
||||||
input->bindKey(Input::Action::PAUSE, SDL_SCANCODE_P);
|
|
||||||
input->bindKey(Input::Action::BACK, SDL_SCANCODE_BACKSPACE);
|
|
||||||
|
|
||||||
input->bindKey(Input::Action::WINDOW_DEC_SIZE, SDL_SCANCODE_F1);
|
|
||||||
input->bindKey(Input::Action::WINDOW_INC_SIZE, SDL_SCANCODE_F2);
|
|
||||||
input->bindKey(Input::Action::WINDOW_FULLSCREEN, SDL_SCANCODE_F3);
|
|
||||||
input->bindKey(Input::Action::TOGGLE_VIDEO_SHADERS, SDL_SCANCODE_F4);
|
|
||||||
input->bindKey(Input::Action::TOGGLE_VIDEO_INTEGER_SCALE, SDL_SCANCODE_F5);
|
|
||||||
input->bindKey(Input::Action::TOGGLE_VIDEO_VSYNC, SDL_SCANCODE_F6);
|
|
||||||
|
|
||||||
input->bindKey(Input::Action::TOGGLE_AUDIO, SDL_SCANCODE_F7);
|
|
||||||
input->bindKey(Input::Action::TOGGLE_AUTO_FIRE, SDL_SCANCODE_F8);
|
|
||||||
input->bindKey(Input::Action::CHANGE_LANG, SDL_SCANCODE_F9);
|
|
||||||
|
|
||||||
input->bindKey(Input::Action::RESET, SDL_SCANCODE_F10);
|
|
||||||
input->bindKey(Input::Action::SHOW_INFO, SDL_SCANCODE_F12);
|
|
||||||
|
|
||||||
// Asigna botones a inputs
|
|
||||||
auto gamepads = input->getGamepads();
|
|
||||||
for (auto &gamepad : gamepads) {
|
|
||||||
// Mando - Movimiento del jugador
|
|
||||||
input->bindGameControllerButton(gamepad, Input::Action::UP, SDL_GAMEPAD_BUTTON_DPAD_UP);
|
|
||||||
input->bindGameControllerButton(gamepad, Input::Action::DOWN, SDL_GAMEPAD_BUTTON_DPAD_DOWN);
|
|
||||||
input->bindGameControllerButton(gamepad, Input::Action::LEFT, SDL_GAMEPAD_BUTTON_DPAD_LEFT);
|
|
||||||
input->bindGameControllerButton(gamepad, Input::Action::RIGHT, SDL_GAMEPAD_BUTTON_DPAD_RIGHT);
|
|
||||||
|
|
||||||
// Mando - Disparo del jugador
|
|
||||||
input->bindGameControllerButton(gamepad, Input::Action::FIRE_LEFT, SDL_GAMEPAD_BUTTON_WEST);
|
|
||||||
input->bindGameControllerButton(gamepad, Input::Action::FIRE_CENTER, SDL_GAMEPAD_BUTTON_NORTH);
|
|
||||||
input->bindGameControllerButton(gamepad, Input::Action::FIRE_RIGHT, SDL_GAMEPAD_BUTTON_EAST);
|
|
||||||
|
|
||||||
// Mando - Interfaz
|
|
||||||
input->bindGameControllerButton(gamepad, Input::Action::START, SDL_GAMEPAD_BUTTON_START);
|
|
||||||
input->bindGameControllerButton(gamepad, Input::Action::SERVICE, SDL_GAMEPAD_BUTTON_BACK);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mapea las asignaciones a los botones desde el archivo de configuración, si se da el caso
|
|
||||||
const size_t MAX_CONTROLLERS = std::min(2, NUM_GAMEPADS);
|
|
||||||
for (size_t i = 0; i < MAX_CONTROLLERS; ++i) {
|
|
||||||
for (auto &controller : Options::controllers) {
|
|
||||||
if (input->getControllerName(i) == controller.name) {
|
|
||||||
for (size_t j = 0; j < controller.inputs.size(); ++j) {
|
|
||||||
input->bindGameControllerButton(i, controller.inputs.at(j), controller.buttons.at(j));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Asigna botones a inputs desde otros inputs
|
|
||||||
for (auto &gamepad : gamepads) {
|
|
||||||
// Mando - Menu de servicio
|
|
||||||
input->bindGameControllerButton(gamepad, Input::Action::SM_SELECT, Input::Action::FIRE_LEFT);
|
|
||||||
input->bindGameControllerButton(gamepad, Input::Action::SM_BACK, Input::Action::FIRE_CENTER);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Guarda las asignaciones de botones en las opciones de los dos primeros mandos
|
|
||||||
for (size_t i = 0; i < MAX_CONTROLLERS; ++i) {
|
|
||||||
// Variables asociadas al mando
|
|
||||||
Options::controllers.at(i).index = i;
|
|
||||||
Options::controllers.at(i).name = input->getControllerName(i);
|
|
||||||
Options::controllers.at(i).plugged = true;
|
|
||||||
// Asignaciones de botones
|
|
||||||
for (size_t j = 0; j < Options::controllers.at(i).inputs.size(); ++j) {
|
|
||||||
Options::controllers.at(i).buttons.at(j) = input->getControllerBinding(i, Options::controllers.at(i).inputs.at(j));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Asegura que algún jugador tenga el teclado asignado
|
|
||||||
if (Options::getPlayerWhoUsesKeyboard() == 0) {
|
|
||||||
Options::setKeyboardToPlayer(1);
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
|
|
||||||
// Crea el indice de ficheros
|
|
||||||
void Director::setFileList() {
|
|
||||||
#ifdef MACOS_BUNDLE
|
#ifdef MACOS_BUNDLE
|
||||||
const std::string prefix = "/../Resources";
|
const std::string prefix = "/../Resources";
|
||||||
#else
|
#else
|
||||||
const std::string PREFIX;
|
const std::string prefix = "";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Ficheros de configuración
|
// Cargar la configuración de assets (también aplicar el prefijo al archivo de configuración)
|
||||||
Asset::get()->add(system_folder_ + "/config.txt", AssetType::DATA, false, true);
|
std::string config_path = executable_path_ + prefix + "/data/config/assets.txt";
|
||||||
Asset::get()->add(system_folder_ + "/controllers.json", AssetType::DATA, false, true);
|
Asset::get()->loadFromFile(config_path, prefix, system_folder_);
|
||||||
Asset::get()->add(system_folder_ + "/score.bin", AssetType::DATA, false, true);
|
|
||||||
Asset::get()->add(PREFIX + "/data/config/param_320x240.txt", AssetType::DATA);
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Assets configuration loaded successfully");
|
||||||
Asset::get()->add(PREFIX + "/data/config/param_320x256.txt", AssetType::DATA);
|
|
||||||
Asset::get()->add(PREFIX + "/data/config/demo1.bin", AssetType::DEMODATA);
|
|
||||||
Asset::get()->add(PREFIX + "/data/config/demo2.bin", AssetType::DEMODATA);
|
|
||||||
Asset::get()->add(PREFIX + "/data/config/gamecontrollerdb.txt", AssetType::DATA);
|
|
||||||
Asset::get()->add(PREFIX + "/data/config/formations.txt", AssetType::DATA);
|
|
||||||
Asset::get()->add(PREFIX + "/data/config/pools.txt", AssetType::DATA);
|
|
||||||
|
|
||||||
// Musicas
|
|
||||||
Asset::get()->add(PREFIX + "/data/music/intro.ogg", AssetType::MUSIC);
|
|
||||||
Asset::get()->add(PREFIX + "/data/music/playing.ogg", AssetType::MUSIC);
|
|
||||||
Asset::get()->add(PREFIX + "/data/music/title.ogg", AssetType::MUSIC);
|
|
||||||
Asset::get()->add(PREFIX + "/data/music/credits.ogg", AssetType::MUSIC);
|
|
||||||
|
|
||||||
// Sonidos
|
|
||||||
Asset::get()->add(PREFIX + "/data/sound/balloon_pop0.wav", AssetType::SOUND);
|
|
||||||
Asset::get()->add(PREFIX + "/data/sound/balloon_pop1.wav", AssetType::SOUND);
|
|
||||||
Asset::get()->add(PREFIX + "/data/sound/balloon_pop2.wav", AssetType::SOUND);
|
|
||||||
Asset::get()->add(PREFIX + "/data/sound/balloon_pop3.wav", AssetType::SOUND);
|
|
||||||
Asset::get()->add(PREFIX + "/data/sound/balloon_bounce0.wav", AssetType::SOUND);
|
|
||||||
Asset::get()->add(PREFIX + "/data/sound/balloon_bounce1.wav", AssetType::SOUND);
|
|
||||||
Asset::get()->add(PREFIX + "/data/sound/balloon_bounce2.wav", AssetType::SOUND);
|
|
||||||
Asset::get()->add(PREFIX + "/data/sound/balloon_bounce3.wav", AssetType::SOUND);
|
|
||||||
Asset::get()->add(PREFIX + "/data/sound/bullet.wav", AssetType::SOUND);
|
|
||||||
Asset::get()->add(PREFIX + "/data/sound/clock.wav", AssetType::SOUND);
|
|
||||||
Asset::get()->add(PREFIX + "/data/sound/coffee_out.wav", AssetType::SOUND);
|
|
||||||
Asset::get()->add(PREFIX + "/data/sound/continue_clock.wav", AssetType::SOUND);
|
|
||||||
Asset::get()->add(PREFIX + "/data/sound/debian_drop.wav", AssetType::SOUND);
|
|
||||||
Asset::get()->add(PREFIX + "/data/sound/debian_pickup.wav", AssetType::SOUND);
|
|
||||||
Asset::get()->add(PREFIX + "/data/sound/hi_score_achieved.wav", AssetType::SOUND);
|
|
||||||
Asset::get()->add(PREFIX + "/data/sound/item_drop.wav", AssetType::SOUND);
|
|
||||||
Asset::get()->add(PREFIX + "/data/sound/item_pickup.wav", AssetType::SOUND);
|
|
||||||
Asset::get()->add(PREFIX + "/data/sound/jump.wav", AssetType::SOUND);
|
|
||||||
Asset::get()->add(PREFIX + "/data/sound/logo.wav", AssetType::SOUND);
|
|
||||||
Asset::get()->add(PREFIX + "/data/sound/notify.wav", AssetType::SOUND);
|
|
||||||
Asset::get()->add(PREFIX + "/data/sound/player_collision.wav", AssetType::SOUND);
|
|
||||||
Asset::get()->add(PREFIX + "/data/sound/power_ball_explosion.wav", AssetType::SOUND);
|
|
||||||
Asset::get()->add(PREFIX + "/data/sound/service_menu_adjust.wav", AssetType::SOUND);
|
|
||||||
Asset::get()->add(PREFIX + "/data/sound/service_menu_move.wav", AssetType::SOUND);
|
|
||||||
Asset::get()->add(PREFIX + "/data/sound/service_menu_select.wav", AssetType::SOUND);
|
|
||||||
Asset::get()->add(PREFIX + "/data/sound/stage_change.wav", AssetType::SOUND);
|
|
||||||
Asset::get()->add(PREFIX + "/data/sound/tabe_hit.wav", AssetType::SOUND);
|
|
||||||
Asset::get()->add(PREFIX + "/data/sound/tabe.wav", AssetType::SOUND);
|
|
||||||
Asset::get()->add(PREFIX + "/data/sound/title.wav", AssetType::SOUND);
|
|
||||||
Asset::get()->add(PREFIX + "/data/sound/voice_aw_aw_aw.wav", AssetType::SOUND);
|
|
||||||
Asset::get()->add(PREFIX + "/data/sound/voice_coffee.wav", AssetType::SOUND);
|
|
||||||
Asset::get()->add(PREFIX + "/data/sound/voice_get_ready.wav", AssetType::SOUND);
|
|
||||||
Asset::get()->add(PREFIX + "/data/sound/voice_no.wav", AssetType::SOUND);
|
|
||||||
Asset::get()->add(PREFIX + "/data/sound/voice_power_up.wav", AssetType::SOUND);
|
|
||||||
Asset::get()->add(PREFIX + "/data/sound/voice_thankyou.wav", AssetType::SOUND);
|
|
||||||
Asset::get()->add(PREFIX + "/data/sound/walk.wav", AssetType::SOUND);
|
|
||||||
|
|
||||||
// Shaders
|
|
||||||
Asset::get()->add(PREFIX + "/data/shaders/crtpi_256.glsl", AssetType::DATA);
|
|
||||||
Asset::get()->add(PREFIX + "/data/shaders/crtpi_240.glsl", AssetType::DATA);
|
|
||||||
|
|
||||||
// Texturas - Balloons
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/balloon/balloon0.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/balloon/balloon0.ani", AssetType::ANIMATION);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/balloon/balloon1.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/balloon/balloon1.ani", AssetType::ANIMATION);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/balloon/balloon2.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/balloon/balloon2.ani", AssetType::ANIMATION);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/balloon/balloon3.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/balloon/balloon3.ani", AssetType::ANIMATION);
|
|
||||||
|
|
||||||
// Texturas - Explosiones
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/balloon/explosion0.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/balloon/explosion0.ani", AssetType::ANIMATION);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/balloon/explosion1.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/balloon/explosion1.ani", AssetType::ANIMATION);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/balloon/explosion2.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/balloon/explosion2.ani", AssetType::ANIMATION);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/balloon/explosion3.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/balloon/explosion3.ani", AssetType::ANIMATION);
|
|
||||||
|
|
||||||
// Texturas - Power Ball
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/balloon/powerball.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/balloon/powerball.ani", AssetType::ANIMATION);
|
|
||||||
|
|
||||||
// Texturas - Bala
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/bullet/bullet.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/bullet/bullet.ani", AssetType::ANIMATION);
|
|
||||||
|
|
||||||
// Texturas - Tabe
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/tabe/tabe.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/tabe/tabe.ani", AssetType::ANIMATION);
|
|
||||||
|
|
||||||
// Texturas - Juego
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/game/game_buildings.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/game/game_clouds1.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/game/game_clouds2.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/game/game_grass.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/game/game_power_meter.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/game/game_sky_colors.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/game/game_sun.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/game/game_moon.png", AssetType::BITMAP);
|
|
||||||
|
|
||||||
// Texturas - Intro
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/intro/intro1.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/intro/intro2.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/intro/intro3.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/intro/intro4.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/intro/intro5.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/intro/intro6.png", AssetType::BITMAP);
|
|
||||||
|
|
||||||
// Texturas - Logo
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/logo/logo_jailgames.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/logo/logo_jailgames_mini.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/logo/logo_since_1998.png", AssetType::BITMAP);
|
|
||||||
|
|
||||||
// Texturas - Items
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/item/item_points1_disk.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/item/item_points1_disk.ani", AssetType::ANIMATION);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/item/item_points2_gavina.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/item/item_points2_gavina.ani", AssetType::ANIMATION);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/item/item_points3_pacmar.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/item/item_points3_pacmar.ani", AssetType::ANIMATION);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/item/item_clock.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/item/item_clock.ani", AssetType::ANIMATION);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/item/item_coffee.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/item/item_coffee.ani", AssetType::ANIMATION);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/item/item_debian.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/item/item_debian.ani", AssetType::ANIMATION);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/item/item_coffee_machine.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/item/item_coffee_machine.ani", AssetType::ANIMATION);
|
|
||||||
|
|
||||||
// Texturas - Titulo
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/title/title_bg_tile.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/title/title_coffee.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/title/title_crisis.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/title/title_arcade_edition.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/title/title_dust.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/title/title_dust.ani", AssetType::ANIMATION);
|
|
||||||
|
|
||||||
// Texturas - Jugador 1
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/player/player1.gif", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/player/player1_coffee1.pal", AssetType::PALETTE);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/player/player1_coffee2.pal", AssetType::PALETTE);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/player/player1_invencible.pal", AssetType::PALETTE);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/player/player1_power.png", AssetType::BITMAP);
|
|
||||||
|
|
||||||
// Texturas - Jugador 2
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/player/player2.gif", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/player/player2_coffee1.pal", AssetType::PALETTE);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/player/player2_coffee2.pal", AssetType::PALETTE);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/player/player2_invencible.pal", AssetType::PALETTE);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/player/player2_power.png", AssetType::BITMAP);
|
|
||||||
|
|
||||||
// Animaciones del jugador
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/player/player.ani", AssetType::ANIMATION);
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/player/player_power.ani", AssetType::ANIMATION);
|
|
||||||
|
|
||||||
// Texturas - Golpe del jugador
|
|
||||||
Asset::get()->add(PREFIX + "/data/gfx/player/hit.png", AssetType::BITMAP);
|
|
||||||
|
|
||||||
// Fuentes de texto
|
|
||||||
Asset::get()->add(PREFIX + "/data/font/8bithud.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/font/8bithud.txt", AssetType::FONT);
|
|
||||||
Asset::get()->add(PREFIX + "/data/font/aseprite.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/font/aseprite.txt", AssetType::FONT);
|
|
||||||
Asset::get()->add(PREFIX + "/data/font/smb2.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/font/smb2_grad.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/font/smb2.txt", AssetType::FONT);
|
|
||||||
Asset::get()->add(PREFIX + "/data/font/04b_25.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/font/04b_25.txt", AssetType::FONT);
|
|
||||||
Asset::get()->add(PREFIX + "/data/font/04b_25_2x.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/font/04b_25_2x.txt", AssetType::FONT);
|
|
||||||
Asset::get()->add(PREFIX + "/data/font/04b_25_metal.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/font/04b_25_grey.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/font/04b_25_flat.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/font/04b_25_reversed.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/font/04b_25_flat_2x.png", AssetType::BITMAP);
|
|
||||||
Asset::get()->add(PREFIX + "/data/font/04b_25_reversed_2x.png", AssetType::BITMAP);
|
|
||||||
|
|
||||||
// Textos
|
|
||||||
Asset::get()->add(PREFIX + "/data/lang/es_ES.json", AssetType::LANG);
|
|
||||||
Asset::get()->add(PREFIX + "/data/lang/en_UK.json", AssetType::LANG);
|
|
||||||
Asset::get()->add(PREFIX + "/data/lang/ba_BA.json", AssetType::LANG);
|
|
||||||
|
|
||||||
// Si falta algun fichero, sale del programa
|
// Si falta algun fichero, sale del programa
|
||||||
if (!Asset::get()->check()) {
|
if (!Asset::get()->check()) {
|
||||||
@@ -598,11 +322,7 @@ void Director::reset() {
|
|||||||
Lang::setLanguage(Options::settings.language);
|
Lang::setLanguage(Options::settings.language);
|
||||||
Audio::get()->stopMusic();
|
Audio::get()->stopMusic();
|
||||||
Audio::get()->stopAllSounds();
|
Audio::get()->stopAllSounds();
|
||||||
{
|
Resource::get()->reload();
|
||||||
Resource::get()->reload();
|
|
||||||
}
|
|
||||||
// Input::get()->discoverGameControllers();
|
|
||||||
bindInputs();
|
|
||||||
ServiceMenu::get()->reset();
|
ServiceMenu::get()->reset();
|
||||||
Section::name = Section::Name::LOGO;
|
Section::name = Section::Name::LOGO;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,8 +31,7 @@ class Director {
|
|||||||
void createSystemFolder(const std::string &folder); // Crea la carpeta del sistema
|
void createSystemFolder(const std::string &folder); // Crea la carpeta del sistema
|
||||||
|
|
||||||
// --- Gestión de entrada y archivos ---
|
// --- Gestión de entrada y archivos ---
|
||||||
static void bindInputs(); // Asigna botones y teclas al sistema de entrada
|
void loadAssets(); // Crea el índice de archivos disponibles
|
||||||
void setFileList(); // Crea el índice de archivos disponibles
|
|
||||||
void checkProgramArguments(int argc, std::span<char *> argv); // Verifica los parámetros del programa // NOLINT(modernize-avoid-c-arrays)
|
void checkProgramArguments(int argc, std::span<char *> argv); // Verifica los parámetros del programa // NOLINT(modernize-avoid-c-arrays)
|
||||||
|
|
||||||
// --- Secciones del programa ---
|
// --- Secciones del programa ---
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ auto Resource::getDemoData(int index) -> DemoData & {
|
|||||||
// Carga los sonidos del juego
|
// Carga los sonidos del juego
|
||||||
void Resource::loadSounds() {
|
void Resource::loadSounds() {
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n>> SOUND FILES");
|
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();
|
sounds_.clear();
|
||||||
|
|
||||||
for (const auto &l : list) {
|
for (const auto &l : list) {
|
||||||
@@ -190,7 +190,7 @@ void Resource::loadSounds() {
|
|||||||
// Carga las músicas del juego
|
// Carga las músicas del juego
|
||||||
void Resource::loadMusics() {
|
void Resource::loadMusics() {
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n>> MUSIC FILES");
|
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();
|
musics_.clear();
|
||||||
|
|
||||||
for (const auto &l : list) {
|
for (const auto &l : list) {
|
||||||
@@ -206,7 +206,7 @@ void Resource::loadMusics() {
|
|||||||
// Carga las texturas del juego
|
// Carga las texturas del juego
|
||||||
void Resource::loadTextures() {
|
void Resource::loadTextures() {
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n>> TEXTURES");
|
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();
|
textures_.clear();
|
||||||
|
|
||||||
for (const auto &l : list) {
|
for (const auto &l : list) {
|
||||||
@@ -219,7 +219,7 @@ void Resource::loadTextures() {
|
|||||||
// Carga los ficheros de texto del juego
|
// Carga los ficheros de texto del juego
|
||||||
void Resource::loadTextFiles() {
|
void Resource::loadTextFiles() {
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n>> TEXT FILES");
|
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();
|
text_files_.clear();
|
||||||
|
|
||||||
for (const auto &l : list) {
|
for (const auto &l : list) {
|
||||||
@@ -232,7 +232,7 @@ void Resource::loadTextFiles() {
|
|||||||
// Carga las animaciones del juego
|
// Carga las animaciones del juego
|
||||||
void Resource::loadAnimations() {
|
void Resource::loadAnimations() {
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n>> ANIMATIONS");
|
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();
|
animations_.clear();
|
||||||
|
|
||||||
for (const auto &l : list) {
|
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
|
// Calcula el número total de recursos a cargar y reinicia el contador de carga
|
||||||
void Resource::calculateTotalResources() {
|
void Resource::calculateTotalResources() {
|
||||||
const std::array<AssetType, 6> ASSET_TYPES = {
|
const std::array<Asset::Type, 6> ASSET_TYPES = {
|
||||||
AssetType::SOUND,
|
Asset::Type::SOUND,
|
||||||
AssetType::MUSIC,
|
Asset::Type::MUSIC,
|
||||||
AssetType::BITMAP,
|
Asset::Type::BITMAP,
|
||||||
AssetType::FONT,
|
Asset::Type::FONT,
|
||||||
AssetType::ANIMATION,
|
Asset::Type::ANIMATION,
|
||||||
AssetType::DEMODATA};
|
Asset::Type::DEMODATA};
|
||||||
|
|
||||||
size_t total = 0;
|
size_t total = 0;
|
||||||
for (const auto &asset_type : ASSET_TYPES) {
|
for (const auto &asset_type : ASSET_TYPES) {
|
||||||
|
|||||||
Reference in New Issue
Block a user