forked from jaildesigner-jailgames/jaildoctors_dilemma
Añadida la clase asset
This commit is contained in:
20
source/asset.cpp
Normal file
20
source/asset.cpp
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#include "asset.h"
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
Asset::Asset(std::string path)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
Asset::~Asset()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// Añade un elemento a la lista
|
||||||
|
void Asset::add(std::string file, enum assetType type)
|
||||||
|
{
|
||||||
|
item_t temp;
|
||||||
|
temp.file = file;
|
||||||
|
temp.type = type;
|
||||||
|
mFileList.push_back(temp);
|
||||||
|
}
|
||||||
42
source/asset.h
Normal file
42
source/asset.h
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "ifdefs.h"
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#ifndef ASSET_H
|
||||||
|
#define ASSET_H
|
||||||
|
|
||||||
|
enum assetType {bitmap, music, sound, data, font, lang};
|
||||||
|
|
||||||
|
#define ASSET_TYPE_BITMAP 0
|
||||||
|
#define ASSET_TYPE_MUSIC 1
|
||||||
|
#define ASSET_TYPE_SOUND 2
|
||||||
|
#define ASSET_TYPE_DATA 3
|
||||||
|
#define ASSET_TYPE_FONT 4
|
||||||
|
#define ASSET_TYPE_LANG 5
|
||||||
|
|
||||||
|
// Clase Asset
|
||||||
|
class Asset
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
// Estructura para definir un item
|
||||||
|
struct item_t
|
||||||
|
{
|
||||||
|
std::string file;
|
||||||
|
enum assetType type;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::vector<item_t> mFileList;
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Constructor
|
||||||
|
Asset(std::string path);
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
~Asset();
|
||||||
|
|
||||||
|
// Añade un elemento a la lista
|
||||||
|
void add(std::string file, enum assetType type);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -13,6 +13,9 @@ Director::Director(std::string path)
|
|||||||
// Establece la lista de ficheros
|
// Establece la lista de ficheros
|
||||||
setFileList();
|
setFileList();
|
||||||
|
|
||||||
|
// Crea el objeto que controla los ficheros de recursos
|
||||||
|
mAsset = new Asset(mExecutablePath);
|
||||||
|
|
||||||
// Si falta algún fichero no inicies el programa
|
// Si falta algún fichero no inicies el programa
|
||||||
Uint8 section = PROG_SECTION_GAME;
|
Uint8 section = PROG_SECTION_GAME;
|
||||||
if (!checkFileList())
|
if (!checkFileList())
|
||||||
@@ -66,6 +69,9 @@ Director::~Director()
|
|||||||
delete mOptions;
|
delete mOptions;
|
||||||
mOptions = nullptr;
|
mOptions = nullptr;
|
||||||
|
|
||||||
|
delete mAsset;
|
||||||
|
mAsset = nullptr;
|
||||||
|
|
||||||
SDL_DestroyRenderer(mRenderer);
|
SDL_DestroyRenderer(mRenderer);
|
||||||
SDL_DestroyWindow(mWindow);
|
SDL_DestroyWindow(mWindow);
|
||||||
mRenderer = nullptr;
|
mRenderer = nullptr;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "fade.h"
|
#include "fade.h"
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
|
#include "asset.h"
|
||||||
#include "lang.h"
|
#include "lang.h"
|
||||||
|
|
||||||
#ifndef DIRECTOR_H
|
#ifndef DIRECTOR_H
|
||||||
@@ -29,8 +30,8 @@ private:
|
|||||||
Input *mInput; // Objeto Input para gestionar las entradas
|
Input *mInput; // Objeto Input para gestionar las entradas
|
||||||
Lang *mLang; // Objeto para gestionar los textos en diferentes idiomas
|
Lang *mLang; // Objeto para gestionar los textos en diferentes idiomas
|
||||||
Game *mGame; // Objeto para la sección del juego
|
Game *mGame; // Objeto para la sección del juego
|
||||||
|
Asset *mAsset; // Objeto que gestiona todos los ficheros de recursos
|
||||||
|
|
||||||
std::string mFileList[MAX_FILE_LIST]; // Vector con las rutas a los ficheros de recursos
|
|
||||||
struct options_t *mOptions; // Variable con todas las opciones del programa
|
struct options_t *mOptions; // Variable con todas las opciones del programa
|
||||||
|
|
||||||
std::string mExecutablePath; // Path del ejecutable
|
std::string mExecutablePath; // Path del ejecutable
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ private:
|
|||||||
SDL_Renderer *mRenderer; // El renderizador de la ventana
|
SDL_Renderer *mRenderer; // El renderizador de la ventana
|
||||||
Screen *mScreen; // El objeto encargado de manejar el renderizador
|
Screen *mScreen; // El objeto encargado de manejar el renderizador
|
||||||
SDL_Event *mEventHandler; // Manejador de eventos
|
SDL_Event *mEventHandler; // Manejador de eventos
|
||||||
std::string *mFileList; // Lista de ficheros con los recursos
|
|
||||||
Lang *mLang; // Objeto para gestionar los textos en diferentes idiomas
|
Lang *mLang; // Objeto para gestionar los textos en diferentes idiomas
|
||||||
Input *mInput; // Manejador de entrada
|
Input *mInput; // Manejador de entrada
|
||||||
Text *mText; // Fuente para los textos del juego
|
Text *mText; // Fuente para los textos del juego
|
||||||
|
|||||||
Reference in New Issue
Block a user