#pragma once #include // for string, basic_string #include // for vector enum assetType { t_bitmap, t_music, t_sound, t_font, t_lang, t_data, t_room, t_enemy, t_item, t_maxAssetType }; // Clase Asset class Asset { public: // Estructura para definir un item struct item_t { std::string file; // Ruta del fichero desde la raiz del directorio enum assetType type; // Indica el tipo de recurso bool required; // Indica si es un fichero que debe de existir }; private: // Variables int longestName; // Contiene la longitud del nombre de fichero mas largo std::vector fileList; // Listado con todas las rutas a los ficheros std::string executablePath; // Ruta al ejecutable bool verbose; // Indica si ha de mostrar información por pantalla // Comprueba que existe un fichero bool checkFile(const std::string &executablePath); // Devuelve el nombre del tipo de recurso std::string getTypeName(int type); // Constructor privado (usar Asset::init) explicit Asset(const std::string &path); // Instancia única static Asset *instance; public: // Singleton API static void init(const std::string &executablePath); // Crea la instancia static void destroy(); // Libera la instancia static auto get() -> Asset *; // Obtiene el puntero a la instancia // Añade un elemento a la lista void add(const std::string &file, enum assetType type, bool required = true, bool absolute = false); // Devuelve un elemento de la lista a partir de una cadena std::string get(const std::string &text); // Devuelve toda la lista de items registrados const std::vector &getAll() const { return fileList; } // Comprueba que existen todos los elementos bool check(); // Establece si ha de mostrar texto por pantalla void setVerbose(bool value); };