claude: arreglos d'estil
This commit is contained in:
@@ -1,25 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <string> // Para string
|
||||
#include <unordered_map> // Para unordered_map
|
||||
#include <utility> // Para move
|
||||
#include <vector> // Para vector
|
||||
|
||||
// Clase Asset: gestor optimizado de recursos (singleton)
|
||||
// --- Clase Asset: gestor optimizado de recursos (singleton) ---
|
||||
class Asset {
|
||||
public:
|
||||
// Tipos de recursos
|
||||
// --- Enums ---
|
||||
enum class Type : int {
|
||||
BITMAP,
|
||||
MUSIC,
|
||||
SOUND,
|
||||
FONT,
|
||||
LANG,
|
||||
DATA,
|
||||
DEMODATA,
|
||||
ANIMATION,
|
||||
PALETTE,
|
||||
SIZE,
|
||||
BITMAP, // Imágenes
|
||||
MUSIC, // Música
|
||||
SOUND, // Sonidos
|
||||
FONT, // Fuentes
|
||||
LANG, // Idiomas
|
||||
DATA, // Datos
|
||||
DEMODATA, // Datos de demo
|
||||
ANIMATION, // Animaciones
|
||||
PALETTE, // Paletas
|
||||
SIZE, // Tamaño
|
||||
};
|
||||
|
||||
// --- Métodos de singleton ---
|
||||
@@ -38,9 +38,9 @@ class Asset {
|
||||
[[nodiscard]] auto exists(const std::string &filename) const -> bool; // Nueva función para verificar existencia
|
||||
|
||||
private:
|
||||
// --- Estructura interna para almacenar información de cada recurso ---
|
||||
// --- Estructuras privadas ---
|
||||
struct Item {
|
||||
std::string file; // Ruta completa del archivo (mantener nombre original)
|
||||
std::string file; // Ruta completa del archivo
|
||||
Type type; // Tipo de recurso
|
||||
bool required; // Indica si el archivo es obligatorio
|
||||
|
||||
@@ -49,21 +49,22 @@ class Asset {
|
||||
};
|
||||
|
||||
// --- Variables internas ---
|
||||
std::unordered_map<std::string, Item> file_list_; // Mapa para búsqueda O(1) (mantener nombre original)
|
||||
std::unordered_map<std::string, Item> file_list_; // Mapa para búsqueda O(1)
|
||||
std::string executable_path_; // Ruta del ejecutable
|
||||
|
||||
// --- Métodos internos ---
|
||||
[[nodiscard]] static auto checkFile(const std::string &path) -> bool;
|
||||
[[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;
|
||||
[[nodiscard]] static auto checkFile(const std::string &path) -> bool; // Verifica si un archivo existe
|
||||
[[nodiscard]] static auto getTypeName(Type type) -> std::string; // Obtiene el nombre del tipo
|
||||
[[nodiscard]] static auto parseAssetType(const std::string &type_str) -> Type; // Convierte string a tipo
|
||||
void addToMap(const std::string &file_path, Type type, bool required, bool absolute); // Añade archivo al mapa
|
||||
[[nodiscard]] static auto replaceVariables(const std::string &path, const std::string &prefix, const std::string &system_folder) -> std::string; // Reemplaza variables en la ruta
|
||||
static auto parseOptions(const std::string &options, bool &required, bool &absolute) -> void; // Parsea opciones
|
||||
|
||||
// --- Patrón Singleton ---
|
||||
explicit Asset(std::string executable_path)
|
||||
// --- Constructores y destructor privados (singleton) ---
|
||||
explicit Asset(std::string executable_path) // Constructor privado
|
||||
: executable_path_(std::move(executable_path)) {}
|
||||
~Asset() = default;
|
||||
~Asset() = default; // Destructor privado
|
||||
|
||||
static Asset *instance;
|
||||
// --- Instancia singleton ---
|
||||
static Asset *instance; // Instancia única de Asset
|
||||
};
|
||||
Reference in New Issue
Block a user