Cambiado el nombre de la carpeta utils a common

This commit is contained in:
2022-10-19 08:50:56 +02:00
parent 07a9ba5b87
commit ddd54fdd3f
44 changed files with 83 additions and 86 deletions

64
source/common/asset.h Normal file
View File

@@ -0,0 +1,64 @@
#pragma once
#include <SDL2/SDL.h>
#include <string>
#include <vector>
#ifndef ASSET_H
#define ASSET_H
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
{
private:
// 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
};
int longestName; // Contiene la longitud del nombre de fichero mas largo
std::vector<item_t> fileList;
std::string executablePath;
// Comprueba que existe un fichero
bool checkFile(std::string path);
// Devuelve el nombre del tipo de recurso
std::string getTypeName(int type);
public:
// Constructor
Asset(std::string path);
// Destructor
~Asset();
// Añade un elemento a la lista
void add(std::string file, enum assetType type, bool required = true);
// Devuelve un elemento de la lista a partir de una cadena
std::string get(std::string text);
// Comprueba que existen todos los elementos
bool check();
};
#endif