Acabat amb els singletones, de moment
Arreglat els checkEvents
This commit is contained in:
@@ -8,6 +8,27 @@
|
|||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include <fstream> // Para fstream
|
#include <fstream> // Para fstream
|
||||||
|
|
||||||
|
// [SINGLETON]
|
||||||
|
Cheevos *Cheevos::cheevos_ = nullptr;
|
||||||
|
|
||||||
|
// [SINGLETON] Crearemos el objeto con esta función estática
|
||||||
|
void Cheevos::init(const std::string &file)
|
||||||
|
{
|
||||||
|
Cheevos::cheevos_ = new Cheevos(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
// [SINGLETON] Destruiremos el objeto con esta función estática
|
||||||
|
void Cheevos::destroy()
|
||||||
|
{
|
||||||
|
delete Cheevos::cheevos_;
|
||||||
|
}
|
||||||
|
|
||||||
|
// [SINGLETON] Con este método obtenemos el objeto y podemos trabajar con él
|
||||||
|
Cheevos *Cheevos::get()
|
||||||
|
{
|
||||||
|
return Cheevos::cheevos_;
|
||||||
|
}
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Cheevos::Cheevos(const std::string &file)
|
Cheevos::Cheevos(const std::string &file)
|
||||||
: file_(file)
|
: file_(file)
|
||||||
@@ -25,27 +46,27 @@ Cheevos::~Cheevos()
|
|||||||
// Inicializa los logros
|
// Inicializa los logros
|
||||||
void Cheevos::init()
|
void Cheevos::init()
|
||||||
{
|
{
|
||||||
cheevos_.clear();
|
cheevos_list_.clear();
|
||||||
cheevos_.emplace_back(1, "SHINY THINGS", "Get 25% of the items", 2);
|
cheevos_list_.emplace_back(1, "SHINY THINGS", "Get 25% of the items", 2);
|
||||||
cheevos_.emplace_back(2, "HALF THE WORK", "Get 50% of the items", 2);
|
cheevos_list_.emplace_back(2, "HALF THE WORK", "Get 50% of the items", 2);
|
||||||
cheevos_.emplace_back(3, "GETTING THERE", "Get 75% of the items", 2);
|
cheevos_list_.emplace_back(3, "GETTING THERE", "Get 75% of the items", 2);
|
||||||
cheevos_.emplace_back(4, "THE COLLECTOR", "Get 100% of the items", 2);
|
cheevos_list_.emplace_back(4, "THE COLLECTOR", "Get 100% of the items", 2);
|
||||||
cheevos_.emplace_back(5, "WANDERING AROUND", "Visit 20 rooms", 2);
|
cheevos_list_.emplace_back(5, "WANDERING AROUND", "Visit 20 rooms", 2);
|
||||||
cheevos_.emplace_back(6, "I GOT LOST", "Visit 40 rooms", 2);
|
cheevos_list_.emplace_back(6, "I GOT LOST", "Visit 40 rooms", 2);
|
||||||
cheevos_.emplace_back(7, "I LIKE TO EXPLORE", "Visit all rooms", 2);
|
cheevos_list_.emplace_back(7, "I LIKE TO EXPLORE", "Visit all rooms", 2);
|
||||||
cheevos_.emplace_back(8, "FINISH THE GAME", "Complete the game", 2);
|
cheevos_list_.emplace_back(8, "FINISH THE GAME", "Complete the game", 2);
|
||||||
cheevos_.emplace_back(9, "I WAS SUCKED BY A HOLE", "Complete the game without entering the jail", 2);
|
cheevos_list_.emplace_back(9, "I WAS SUCKED BY A HOLE", "Complete the game without entering the jail", 2);
|
||||||
cheevos_.emplace_back(10, "MY LITTLE PROJECTS", "Complete the game with all items", 2);
|
cheevos_list_.emplace_back(10, "MY LITTLE PROJECTS", "Complete the game with all items", 2);
|
||||||
cheevos_.emplace_back(11, "I LIKE MY MULTICOLOURED FRIENDS", "Complete the game without dying", 2);
|
cheevos_list_.emplace_back(11, "I LIKE MY MULTICOLOURED FRIENDS", "Complete the game without dying", 2);
|
||||||
cheevos_.emplace_back(12, "SHIT PROJECTS DONE FAST", "Complete the game in under 30 minutes", 2);
|
cheevos_list_.emplace_back(12, "SHIT PROJECTS DONE FAST", "Complete the game in under 30 minutes", 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Busca un logro por id y devuelve el indice
|
// Busca un logro por id y devuelve el indice
|
||||||
int Cheevos::find(int id)
|
int Cheevos::find(int id)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < (int)cheevos_.size(); ++i)
|
for (int i = 0; i < (int)cheevos_list_.size(); ++i)
|
||||||
{
|
{
|
||||||
if (cheevos_[i].id == id)
|
if (cheevos_list_[i].id == id)
|
||||||
{
|
{
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@@ -60,15 +81,15 @@ void Cheevos::unlock(int id)
|
|||||||
const int index = find(id);
|
const int index = find(id);
|
||||||
|
|
||||||
// Si el índice es inválido, el logro no es válido, ya está completado o el sistema de logros no está habilitado, no hacemos nada
|
// Si el índice es inválido, el logro no es válido, ya está completado o el sistema de logros no está habilitado, no hacemos nada
|
||||||
if (index == -1 || !cheevos_.at(index).valid || cheevos_.at(index).completed || !enabled_)
|
if (index == -1 || !cheevos_list_.at(index).valid || cheevos_list_.at(index).completed || !enabled_)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Marcar el logro como completado
|
// Marcar el logro como completado
|
||||||
cheevos_.at(index).completed = true;
|
cheevos_list_.at(index).completed = true;
|
||||||
// Mostrar notificación en la pantalla
|
// Mostrar notificación en la pantalla
|
||||||
Notifier::get()->show("ACHIEVEMENT UNLOCKED!", cheevos_.at(index).caption, cheevos_.at(index).icon);
|
Notifier::get()->show("ACHIEVEMENT UNLOCKED!", cheevos_list_.at(index).caption, cheevos_list_.at(index).icon);
|
||||||
// Guardar el estado de los logros
|
// Guardar el estado de los logros
|
||||||
saveToFile();
|
saveToFile();
|
||||||
}
|
}
|
||||||
@@ -81,7 +102,7 @@ void Cheevos::invalidate(int id)
|
|||||||
// Si el índice es válido, se invalida el logro
|
// Si el índice es válido, se invalida el logro
|
||||||
if (index != -1)
|
if (index != -1)
|
||||||
{
|
{
|
||||||
cheevos_.at(index).valid = false;
|
cheevos_list_.at(index).valid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +130,7 @@ void Cheevos::loadFromFile()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Guarda la información
|
// Guarda la información
|
||||||
for (const auto &cheevo : cheevos_)
|
for (const auto &cheevo : cheevos_list_)
|
||||||
{
|
{
|
||||||
newFile.write(reinterpret_cast<const char *>(&cheevo.completed), sizeof(bool));
|
newFile.write(reinterpret_cast<const char *>(&cheevo.completed), sizeof(bool));
|
||||||
}
|
}
|
||||||
@@ -131,7 +152,7 @@ void Cheevos::loadFromFile()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Carga los datos
|
// Carga los datos
|
||||||
for (auto &cheevo : cheevos_)
|
for (auto &cheevo : cheevos_list_)
|
||||||
{
|
{
|
||||||
file.read(reinterpret_cast<char *>(&cheevo.completed), sizeof(bool));
|
file.read(reinterpret_cast<char *>(&cheevo.completed), sizeof(bool));
|
||||||
}
|
}
|
||||||
@@ -146,9 +167,9 @@ void Cheevos::saveToFile()
|
|||||||
if (file != NULL)
|
if (file != NULL)
|
||||||
{
|
{
|
||||||
// Guarda la información
|
// Guarda la información
|
||||||
for (int i = 0; i < (int)cheevos_.size(); ++i)
|
for (int i = 0; i < (int)cheevos_list_.size(); ++i)
|
||||||
{
|
{
|
||||||
SDL_RWwrite(file, &cheevos_[i].completed, sizeof(bool), 1);
|
SDL_RWwrite(file, &cheevos_list_[i].completed, sizeof(bool), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cierra el fichero
|
// Cierra el fichero
|
||||||
@@ -167,7 +188,7 @@ void Cheevos::saveToFile()
|
|||||||
int Cheevos::unlocked()
|
int Cheevos::unlocked()
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (auto cheevo : cheevos_)
|
for (auto cheevo : cheevos_list_)
|
||||||
{
|
{
|
||||||
if (cheevo.completed)
|
if (cheevo.completed)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,10 +25,13 @@ struct Achievement
|
|||||||
class Cheevos
|
class Cheevos
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
// [SINGLETON] Objeto privado
|
||||||
|
static Cheevos *cheevos_;
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
std::vector<Achievement> cheevos_; // Listado de logros
|
std::vector<Achievement> cheevos_list_; // Listado de logros
|
||||||
bool enabled_ = true; // Indica si los logros se pueden obtener
|
bool enabled_ = true; // Indica si los logros se pueden obtener
|
||||||
std::string file_; // Fichero donde leer/almacenar el estado de los logros
|
std::string file_; // Fichero donde leer/almacenar el estado de los logros
|
||||||
|
|
||||||
// Inicializa los logros
|
// Inicializa los logros
|
||||||
void init();
|
void init();
|
||||||
@@ -42,13 +45,22 @@ private:
|
|||||||
// Guarda el estado de los logros en un fichero
|
// Guarda el estado de los logros en un fichero
|
||||||
void saveToFile();
|
void saveToFile();
|
||||||
|
|
||||||
public:
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Cheevos(const std::string &file);
|
Cheevos(const std::string &file);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Cheevos();
|
~Cheevos();
|
||||||
|
|
||||||
|
public:
|
||||||
|
// [SINGLETON] Crearemos el objeto con esta función estática
|
||||||
|
static void init(const std::string &file);
|
||||||
|
|
||||||
|
// [SINGLETON] Destruiremos el objeto con esta función estática
|
||||||
|
static void destroy();
|
||||||
|
|
||||||
|
// [SINGLETON] Con este método obtenemos el objeto y podemos trabajar con él
|
||||||
|
static Cheevos *get();
|
||||||
|
|
||||||
// Desbloquea un logro
|
// Desbloquea un logro
|
||||||
void unlock(int id);
|
void unlock(int id);
|
||||||
|
|
||||||
@@ -59,11 +71,11 @@ public:
|
|||||||
void enable(bool value) { enabled_ = value; }
|
void enable(bool value) { enabled_ = value; }
|
||||||
|
|
||||||
// Lista los logros
|
// Lista los logros
|
||||||
std::vector<Achievement> list() { return cheevos_; }
|
std::vector<Achievement> list() { return cheevos_list_; }
|
||||||
|
|
||||||
// Devuelve el número total de logros desbloqueados
|
// Devuelve el número total de logros desbloqueados
|
||||||
int unlocked();
|
int unlocked();
|
||||||
|
|
||||||
// Devuelve el número total de logros
|
// Devuelve el número total de logros
|
||||||
int count() { return cheevos_.size(); }
|
int count() { return cheevos_list_.size(); }
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ Credits::Credits()
|
|||||||
input_(Input::get())
|
input_(Input::get())
|
||||||
{
|
{
|
||||||
// Reserva memoria para los punteros
|
// Reserva memoria para los punteros
|
||||||
event_handler_ = new SDL_Event();
|
|
||||||
text_ = new Text(resource_->getOffset("smb2.txt"), resource_->getTexture("smb2.png"), renderer_);
|
text_ = new Text(resource_->getOffset("smb2.txt"), resource_->getTexture("smb2.png"), renderer_);
|
||||||
sprite_ = new AnimatedSprite(renderer_, resource_->getAnimation("shine.ani"));
|
sprite_ = new AnimatedSprite(renderer_, resource_->getAnimation("shine.ani"));
|
||||||
|
|
||||||
@@ -66,7 +65,6 @@ Credits::Credits()
|
|||||||
// Destructor
|
// Destructor
|
||||||
Credits::~Credits()
|
Credits::~Credits()
|
||||||
{
|
{
|
||||||
delete event_handler_;
|
|
||||||
delete text_;
|
delete text_;
|
||||||
delete sprite_;
|
delete sprite_;
|
||||||
SDL_DestroyTexture(text_texture_);
|
SDL_DestroyTexture(text_texture_);
|
||||||
@@ -76,11 +74,11 @@ Credits::~Credits()
|
|||||||
// Comprueba el manejador de eventos
|
// Comprueba el manejador de eventos
|
||||||
void Credits::checkEvents()
|
void Credits::checkEvents()
|
||||||
{
|
{
|
||||||
// Comprueba los eventos que hay en la cola
|
SDL_Event event;
|
||||||
while (SDL_PollEvent(event_handler_) != 0)
|
while (SDL_PollEvent(&event))
|
||||||
{
|
{
|
||||||
// Evento de salida de la aplicación
|
// Evento de salida de la aplicación
|
||||||
if (event_handler_->type == SDL_QUIT)
|
if (event.type == SDL_QUIT)
|
||||||
{
|
{
|
||||||
options.section.name = SECTION_QUIT;
|
options.section.name = SECTION_QUIT;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ private:
|
|||||||
Resource *resource_; // Objeto con los recursos
|
Resource *resource_; // Objeto con los recursos
|
||||||
Asset *asset_; // Objeto con los ficheros de recursos
|
Asset *asset_; // Objeto con los ficheros de recursos
|
||||||
Input *input_; // Objeto pata gestionar la entrada
|
Input *input_; // Objeto pata gestionar la entrada
|
||||||
SDL_Event *event_handler_; // Manejador de eventos
|
|
||||||
Text *text_; // Objeto para escribir texto en pantalla
|
Text *text_; // Objeto para escribir texto en pantalla
|
||||||
SDL_Texture *text_texture_; // Textura para dibujar el texto
|
SDL_Texture *text_texture_; // Textura para dibujar el texto
|
||||||
SDL_Texture *cover_texture_; // Textura para cubrir el texto
|
SDL_Texture *cover_texture_; // Textura para cubrir el texto
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ Demo::Demo()
|
|||||||
itemTracker = new ItemTracker();
|
itemTracker = new ItemTracker();
|
||||||
scoreboard = new Scoreboard(&board);
|
scoreboard = new Scoreboard(&board);
|
||||||
room = new Room(resource->getRoom(currentRoom), itemTracker, &board.items, false);
|
room = new Room(resource->getRoom(currentRoom), itemTracker, &board.items, false);
|
||||||
eventHandler = new SDL_Event();
|
|
||||||
text = new Text(resource->getOffset("smb2.txt"), resource->getTexture("smb2.png"), renderer);
|
text = new Text(resource->getOffset("smb2.txt"), resource->getTexture("smb2.png"), renderer);
|
||||||
|
|
||||||
// Inicializa el resto de variables
|
// Inicializa el resto de variables
|
||||||
@@ -66,18 +65,17 @@ Demo::~Demo()
|
|||||||
delete itemTracker;
|
delete itemTracker;
|
||||||
delete scoreboard;
|
delete scoreboard;
|
||||||
delete room;
|
delete room;
|
||||||
delete eventHandler;
|
|
||||||
delete text;
|
delete text;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba los eventos de la cola
|
// Comprueba los eventos de la cola
|
||||||
void Demo::checkEvents()
|
void Demo::checkEvents()
|
||||||
{
|
{
|
||||||
// Comprueba los eventos que hay en la cola
|
SDL_Event event;
|
||||||
while (SDL_PollEvent(eventHandler) != 0)
|
while (SDL_PollEvent(&event))
|
||||||
{
|
{
|
||||||
// Evento de salida de la aplicación
|
// Evento de salida de la aplicación
|
||||||
if (eventHandler->type == SDL_QUIT)
|
if (event.type == SDL_QUIT)
|
||||||
{
|
{
|
||||||
options.section.name = SECTION_QUIT;
|
options.section.name = SECTION_QUIT;
|
||||||
screen->setBorderColor(stringToColor(options.palette, "black"));
|
screen->setBorderColor(stringToColor(options.palette, "black"));
|
||||||
@@ -89,7 +87,6 @@ void Demo::checkEvents()
|
|||||||
// Comprueba las entradas
|
// Comprueba las entradas
|
||||||
void Demo::checkInput()
|
void Demo::checkInput()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (input->checkInput(input_exit, REPEAT_FALSE))
|
if (input->checkInput(input_exit, REPEAT_FALSE))
|
||||||
{
|
{
|
||||||
options.section.name = SECTION_QUIT;
|
options.section.name = SECTION_QUIT;
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ private:
|
|||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
Screen *screen; // Objeto encargado de manejar el renderizador
|
Screen *screen; // Objeto encargado de manejar el renderizador
|
||||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||||
SDL_Event *eventHandler; // Manejador de eventos
|
|
||||||
Room *room; // Objeto encargado de gestionar cada habitación del juego
|
Room *room; // Objeto encargado de gestionar cada habitación del juego
|
||||||
Resource *resource; // Objeto con los recursos
|
Resource *resource; // Objeto con los recursos
|
||||||
Asset *asset; // Objeto con la ruta a todos los ficheros de recursos
|
Asset *asset; // Objeto con la ruta a todos los ficheros de recursos
|
||||||
|
|||||||
@@ -18,26 +18,27 @@
|
|||||||
#include <iostream> // Para basic_ostream, operator<<, cout
|
#include <iostream> // Para basic_ostream, operator<<, cout
|
||||||
#include <string> // Para basic_string, operator+, char_...
|
#include <string> // Para basic_string, operator+, char_...
|
||||||
#include <vector> // Para vector
|
#include <vector> // Para vector
|
||||||
#include <memory>
|
#include <memory> // Para std::make_unique
|
||||||
#include "asset.h" // Para Asset, assetType
|
#include "asset.h" // Para Asset, assetType
|
||||||
#include "const.h" // Para SECTION_LOGO, SECTION_TITLE
|
#include "const.h" // Para SECTION_LOGO, SECTION_TITLE
|
||||||
#include "debug.h" // Para Debug
|
#include "debug.h" // Para Debug
|
||||||
#include "credits.h" // Para Credits
|
#include "credits.h" // Para Credits
|
||||||
#include "demo.h" // Para Demo
|
#include "demo.h" // Para Demo
|
||||||
#include "ending.h" // Para Ending
|
#include "ending.h" // Para Ending
|
||||||
#include "ending2.h" // Para Ending2
|
#include "ending2.h" // Para Ending2
|
||||||
#include "game.h" // Para Game
|
#include "game.h" // Para Game
|
||||||
#include "game_over.h" // Para GameOver
|
#include "game_over.h" // Para GameOver
|
||||||
#include "loading_screen.h" // Para LoadingScreen
|
#include "loading_screen.h" // Para LoadingScreen
|
||||||
#include "logo.h" // Para Logo
|
#include "logo.h" // Para Logo
|
||||||
#include "title.h" // Para Title
|
#include "title.h" // Para Title
|
||||||
#include "input.h" // Para Input, inputs_e
|
#include "input.h" // Para Input, inputs_e
|
||||||
#include "jail_audio.h" // Para JA_GetMusicState, JA_DeleteMusic
|
#include "jail_audio.h" // Para JA_GetMusicState, JA_DeleteMusic
|
||||||
#include "resource.h" // Para Resource
|
#include "resource.h" // Para Resource
|
||||||
#include "screen.h" // Para Screen, FILTER_NEAREST, FILTER...
|
#include "screen.h" // Para Screen, FILTER_NEAREST, FILTER...
|
||||||
#include "utils.h" // Para options_t, section_t, op_notif...
|
#include "utils.h" // Para options_t, section_t, op_notif...
|
||||||
#include "notifier.h"
|
#include "notifier.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
|
#include "cheevos.h"
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
@@ -52,7 +53,7 @@ Director::Director(int argc, const char *argv[])
|
|||||||
initOptions();
|
initOptions();
|
||||||
|
|
||||||
// Comprueba los parametros del programa
|
// Comprueba los parametros del programa
|
||||||
checkProgramArguments(argc, argv);
|
executable_path_ = checkProgramArguments(argc, argv);
|
||||||
|
|
||||||
// Crea el objeto que controla los ficheros de recursos
|
// Crea el objeto que controla los ficheros de recursos
|
||||||
Asset::init(executable_path_);
|
Asset::init(executable_path_);
|
||||||
@@ -60,11 +61,7 @@ Director::Director(int argc, const char *argv[])
|
|||||||
|
|
||||||
// Crea la carpeta del sistema donde guardar datos
|
// Crea la carpeta del sistema donde guardar datos
|
||||||
createSystemFolder("jailgames");
|
createSystemFolder("jailgames");
|
||||||
#ifndef DEBUG
|
|
||||||
createSystemFolder("jailgames/jaildoctors_dilemma");
|
createSystemFolder("jailgames/jaildoctors_dilemma");
|
||||||
#else
|
|
||||||
createSystemFolder("jailgames/jaildoctors_dilemma_debug");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Si falta algún fichero no inicia el programa
|
// Si falta algún fichero no inicia el programa
|
||||||
if (!setFileList())
|
if (!setFileList())
|
||||||
@@ -90,12 +87,13 @@ Director::Director(int argc, const char *argv[])
|
|||||||
initInput();
|
initInput();
|
||||||
Debug::init();
|
Debug::init();
|
||||||
title_music_ = JA_LoadMusic(Asset::get()->get("title.ogg").c_str());
|
title_music_ = JA_LoadMusic(Asset::get()->get("title.ogg").c_str());
|
||||||
|
Cheevos::init(Asset::get()->get("cheevos.bin"));
|
||||||
}
|
}
|
||||||
|
|
||||||
Director::~Director()
|
Director::~Director()
|
||||||
{
|
{
|
||||||
// Guarda las opciones a un fichero
|
// Guarda las opciones a un fichero
|
||||||
saveOptionsFromFile(Asset::get()->get("config.txt"));
|
saveOptionsToFile(Asset::get()->get("config.txt"));
|
||||||
|
|
||||||
// Destruye los singletones
|
// Destruye los singletones
|
||||||
Asset::destroy();
|
Asset::destroy();
|
||||||
@@ -104,6 +102,7 @@ Director::~Director()
|
|||||||
Notifier::destroy();
|
Notifier::destroy();
|
||||||
Debug::destroy();
|
Debug::destroy();
|
||||||
Resource::destroy();
|
Resource::destroy();
|
||||||
|
Cheevos::destroy();
|
||||||
|
|
||||||
JA_DeleteMusic(title_music_);
|
JA_DeleteMusic(title_music_);
|
||||||
|
|
||||||
@@ -115,12 +114,9 @@ Director::~Director()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba los parametros del programa
|
// Comprueba los parametros del programa
|
||||||
void Director::checkProgramArguments(int argc, const char *argv[])
|
std::string Director::checkProgramArguments(int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
// Establece la ruta del programa
|
// Comprueba los parametros
|
||||||
executable_path_ = argv[0];
|
|
||||||
|
|
||||||
// Comprueba el resto de parametros
|
|
||||||
for (int i = 1; i < argc; ++i)
|
for (int i = 1; i < argc; ++i)
|
||||||
{
|
{
|
||||||
if (strcmp(argv[i], "--console") == 0)
|
if (strcmp(argv[i], "--console") == 0)
|
||||||
@@ -148,6 +144,8 @@ void Director::checkProgramArguments(int argc, const char *argv[])
|
|||||||
options.cheat.altSkin = true;
|
options.cheat.altSkin = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return argv[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Crea la carpeta del sistema donde guardar datos
|
// Crea la carpeta del sistema donde guardar datos
|
||||||
@@ -902,7 +900,7 @@ bool Director::initSDL()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Crea un renderizador para la ventana. El vsync se activa en funcion de las opciones
|
// Crea un renderizador para la ventana. El vsync se activa en funcion de las opciones
|
||||||
Uint32 flags = 0;
|
Uint32 flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE;
|
||||||
if (options.vSync)
|
if (options.vSync)
|
||||||
{
|
{
|
||||||
flags = flags | SDL_RENDERER_PRESENTVSYNC;
|
flags = flags | SDL_RENDERER_PRESENTVSYNC;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ private:
|
|||||||
std::string system_folder_; // Carpeta del sistema donde guardar datos
|
std::string system_folder_; // Carpeta del sistema donde guardar datos
|
||||||
|
|
||||||
// Comprueba los parametros del programa
|
// Comprueba los parametros del programa
|
||||||
void checkProgramArguments(int argc, const char *argv[]);
|
std::string checkProgramArguments(int argc, const char *argv[]);
|
||||||
|
|
||||||
// Crea la carpeta del sistema donde guardar datos
|
// Crea la carpeta del sistema donde guardar datos
|
||||||
void createSystemFolder(const std::string &folder);
|
void createSystemFolder(const std::string &folder);
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ Ending::Ending()
|
|||||||
input(Input::get())
|
input(Input::get())
|
||||||
{
|
{
|
||||||
// Reserva memoria para los punteros a objetos
|
// Reserva memoria para los punteros a objetos
|
||||||
eventHandler = new SDL_Event();
|
|
||||||
text = new Text(resource->getOffset("smb2.txt"), resource->getTexture("smb2.png"), renderer);
|
text = new Text(resource->getOffset("smb2.txt"), resource->getTexture("smb2.png"), renderer);
|
||||||
music = JA_LoadMusic(asset->get("ending1.ogg").c_str());
|
music = JA_LoadMusic(asset->get("ending1.ogg").c_str());
|
||||||
|
|
||||||
@@ -72,7 +71,6 @@ Ending::Ending()
|
|||||||
Ending::~Ending()
|
Ending::~Ending()
|
||||||
{
|
{
|
||||||
// Libera la memoria de los objetos
|
// Libera la memoria de los objetos
|
||||||
delete eventHandler;
|
|
||||||
delete text;
|
delete text;
|
||||||
SDL_DestroyTexture(coverTexture);
|
SDL_DestroyTexture(coverTexture);
|
||||||
|
|
||||||
@@ -159,11 +157,11 @@ void Ending::render()
|
|||||||
// Comprueba el manejador de eventos
|
// Comprueba el manejador de eventos
|
||||||
void Ending::checkEvents()
|
void Ending::checkEvents()
|
||||||
{
|
{
|
||||||
// Comprueba los eventos que hay en la cola
|
SDL_Event event;
|
||||||
while (SDL_PollEvent(eventHandler) != 0)
|
while (SDL_PollEvent(&event))
|
||||||
{
|
{
|
||||||
// Evento de salida de la aplicación
|
// Evento de salida de la aplicación
|
||||||
if (eventHandler->type == SDL_QUIT)
|
if (event.type == SDL_QUIT)
|
||||||
{
|
{
|
||||||
options.section.name = SECTION_QUIT;
|
options.section.name = SECTION_QUIT;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ private:
|
|||||||
Resource *resource; // Objeto con los recursos
|
Resource *resource; // Objeto con los recursos
|
||||||
Asset *asset; // Objeto con los ficheros de recursos
|
Asset *asset; // Objeto con los ficheros de recursos
|
||||||
Input *input; // Objeto pata gestionar la entrada
|
Input *input; // Objeto pata gestionar la entrada
|
||||||
SDL_Event *eventHandler; // Manejador de eventos
|
|
||||||
Text *text; // Objeto para escribir texto en pantalla
|
Text *text; // Objeto para escribir texto en pantalla
|
||||||
SDL_Texture *coverTexture; // Textura para cubrir el texto
|
SDL_Texture *coverTexture; // Textura para cubrir el texto
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ Ending2::Ending2()
|
|||||||
input(Input::get())
|
input(Input::get())
|
||||||
{
|
{
|
||||||
// Reserva memoria para los punteros a objetos
|
// Reserva memoria para los punteros a objetos
|
||||||
eventHandler = new SDL_Event();
|
|
||||||
text = new Text(resource->getOffset("smb2.txt"), resource->getTexture("smb2.png"), renderer);
|
text = new Text(resource->getOffset("smb2.txt"), resource->getTexture("smb2.png"), renderer);
|
||||||
music = JA_LoadMusic(asset->get("ending2.ogg").c_str());
|
music = JA_LoadMusic(asset->get("ending2.ogg").c_str());
|
||||||
|
|
||||||
@@ -73,7 +72,6 @@ Ending2::Ending2()
|
|||||||
Ending2::~Ending2()
|
Ending2::~Ending2()
|
||||||
{
|
{
|
||||||
// Libera la memoria de los objetos
|
// Libera la memoria de los objetos
|
||||||
delete eventHandler;
|
|
||||||
delete text;
|
delete text;
|
||||||
JA_DeleteMusic(music);
|
JA_DeleteMusic(music);
|
||||||
|
|
||||||
@@ -189,11 +187,11 @@ void Ending2::render()
|
|||||||
// Comprueba el manejador de eventos
|
// Comprueba el manejador de eventos
|
||||||
void Ending2::checkEvents()
|
void Ending2::checkEvents()
|
||||||
{
|
{
|
||||||
// Comprueba los eventos que hay en la cola
|
SDL_Event event;
|
||||||
while (SDL_PollEvent(eventHandler) != 0)
|
while (SDL_PollEvent(&event))
|
||||||
{
|
{
|
||||||
// Evento de salida de la aplicación
|
// Evento de salida de la aplicación
|
||||||
if (eventHandler->type == SDL_QUIT)
|
if (event.type == SDL_QUIT)
|
||||||
{
|
{
|
||||||
options.section.name = SECTION_QUIT;
|
options.section.name = SECTION_QUIT;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ private:
|
|||||||
Resource *resource; // Objeto con los recursos
|
Resource *resource; // Objeto con los recursos
|
||||||
Asset *asset; // Objeto con los ficheros de recursos
|
Asset *asset; // Objeto con los ficheros de recursos
|
||||||
Input *input; // Objeto pata gestionar la entrada
|
Input *input; // Objeto pata gestionar la entrada
|
||||||
SDL_Event *eventHandler; // Manejador de eventos
|
|
||||||
Text *text; // Objeto para escribir texto en pantalla
|
Text *text; // Objeto para escribir texto en pantalla
|
||||||
std::vector<AnimatedSprite *> sprites; // Vector con todos los sprites a dibujar
|
std::vector<AnimatedSprite *> sprites; // Vector con todos los sprites a dibujar
|
||||||
std::vector<MovingSprite *> spriteTexts; // Vector con los sprites de texto de los sprites
|
std::vector<MovingSprite *> spriteTexts; // Vector con los sprites de texto de los sprites
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ Game::Game()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Crea los objetos
|
// Crea los objetos
|
||||||
cheevos_ = new Cheevos(asset_->get("cheevos.bin"));
|
cheevos_ = Cheevos::get();
|
||||||
scoreboard_ = new Scoreboard(&board_);
|
scoreboard_ = new Scoreboard(&board_);
|
||||||
item_tracker_ = new ItemTracker();
|
item_tracker_ = new ItemTracker();
|
||||||
room_tracker_ = new RoomTracker();
|
room_tracker_ = new RoomTracker();
|
||||||
@@ -56,8 +56,7 @@ Game::Game()
|
|||||||
const std::string playerPNG = options.cheat.altSkin ? "player2.png" : "player.png";
|
const std::string playerPNG = options.cheat.altSkin ? "player2.png" : "player.png";
|
||||||
const std::string playerANI = options.cheat.altSkin ? "player2.ani" : "player.ani";
|
const std::string playerANI = options.cheat.altSkin ? "player2.ani" : "player.ani";
|
||||||
const player_t player = {spawn_point_, playerPNG, playerANI, room_};
|
const player_t player = {spawn_point_, playerPNG, playerANI, room_};
|
||||||
this->player_ = new Player(player);
|
player_ = new Player(player);
|
||||||
event_handler_ = new SDL_Event();
|
|
||||||
text_ = new Text(resource_->getOffset("smb2.txt"), resource_->getTexture("smb2.png"), renderer_);
|
text_ = new Text(resource_->getOffset("smb2.txt"), resource_->getTexture("smb2.png"), renderer_);
|
||||||
music_ = JA_LoadMusic(asset_->get("game.ogg").c_str());
|
music_ = JA_LoadMusic(asset_->get("game.ogg").c_str());
|
||||||
death_sound_ = JA_LoadSound(asset_->get("death.wav").c_str());
|
death_sound_ = JA_LoadSound(asset_->get("death.wav").c_str());
|
||||||
@@ -111,13 +110,11 @@ Game::Game()
|
|||||||
Game::~Game()
|
Game::~Game()
|
||||||
{
|
{
|
||||||
// Libera la memoria de los objetos
|
// Libera la memoria de los objetos
|
||||||
delete cheevos_;
|
|
||||||
delete scoreboard_;
|
delete scoreboard_;
|
||||||
delete item_tracker_;
|
delete item_tracker_;
|
||||||
delete room_tracker_;
|
delete room_tracker_;
|
||||||
delete room_;
|
delete room_;
|
||||||
delete player_;
|
delete player_;
|
||||||
delete event_handler_;
|
|
||||||
delete text_;
|
delete text_;
|
||||||
delete stats_;
|
delete stats_;
|
||||||
|
|
||||||
@@ -130,25 +127,25 @@ Game::~Game()
|
|||||||
// Comprueba los eventos de la cola
|
// Comprueba los eventos de la cola
|
||||||
void Game::checkEvents()
|
void Game::checkEvents()
|
||||||
{
|
{
|
||||||
// Comprueba los eventos que hay en la cola
|
SDL_Event event;
|
||||||
while (SDL_PollEvent(event_handler_) != 0)
|
while (SDL_PollEvent(&event))
|
||||||
{
|
{
|
||||||
// Evento de salida de la aplicación
|
// Evento de salida de la aplicación
|
||||||
if (event_handler_->type == SDL_QUIT)
|
if (event.type == SDL_QUIT)
|
||||||
{
|
{
|
||||||
options.section.name = SECTION_QUIT;
|
options.section.name = SECTION_QUIT;
|
||||||
screen_->setBorderColor(stringToColor(options.palette, "black"));
|
screen_->setBorderColor(stringToColor(options.palette, "black"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event_handler_->type == SDL_RENDER_DEVICE_RESET || event_handler_->type == SDL_RENDER_TARGETS_RESET)
|
if (event.type == SDL_RENDER_DEVICE_RESET || event.type == SDL_RENDER_TARGETS_RESET)
|
||||||
{
|
{
|
||||||
reLoadTextures();
|
reLoadTextures();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event_handler_->type == SDL_KEYDOWN && event_handler_->key.repeat == 0)
|
if (event.type == SDL_KEYDOWN && event.key.repeat == 0)
|
||||||
{
|
{
|
||||||
switch (event_handler_->key.keysym.scancode)
|
switch (event.key.keysym.scancode)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
case SDL_SCANCODE_G:
|
case SDL_SCANCODE_G:
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ private:
|
|||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
Screen *screen_; // Objeto encargado de manejar el renderizador
|
Screen *screen_; // Objeto encargado de manejar el renderizador
|
||||||
SDL_Renderer *renderer_; // El renderizador de la ventana
|
SDL_Renderer *renderer_; // El renderizador de la ventana
|
||||||
SDL_Event *event_handler_; // Manejador de eventos
|
|
||||||
Room *room_; // Objeto encargado de gestionar cada habitación del juego
|
Room *room_; // Objeto encargado de gestionar cada habitación del juego
|
||||||
Player *player_; // Objeto con el jugador
|
Player *player_; // Objeto con el jugador
|
||||||
ItemTracker *item_tracker_; // Lleva el control de los objetos recogidos
|
ItemTracker *item_tracker_; // Lleva el control de los objetos recogidos
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ GameOver::GameOver()
|
|||||||
input(Input::get())
|
input(Input::get())
|
||||||
{
|
{
|
||||||
// Reserva memoria para los punteros a objetos
|
// Reserva memoria para los punteros a objetos
|
||||||
eventHandler = new SDL_Event();
|
|
||||||
text = new Text(resource->getOffset("smb2.txt"), resource->getTexture("smb2.png"), renderer);
|
text = new Text(resource->getOffset("smb2.txt"), resource->getTexture("smb2.png"), renderer);
|
||||||
playerSprite = new AnimatedSprite(renderer, resource->getAnimation("player_game_over.ani"));
|
playerSprite = new AnimatedSprite(renderer, resource->getAnimation("player_game_over.ani"));
|
||||||
tvSprite = new AnimatedSprite(renderer, resource->getAnimation("tv.ani"));
|
tvSprite = new AnimatedSprite(renderer, resource->getAnimation("tv.ani"));
|
||||||
@@ -56,7 +55,6 @@ GameOver::GameOver()
|
|||||||
GameOver::~GameOver()
|
GameOver::~GameOver()
|
||||||
{
|
{
|
||||||
// Libera la memoria de los objetos
|
// Libera la memoria de los objetos
|
||||||
delete eventHandler;
|
|
||||||
delete text;
|
delete text;
|
||||||
delete playerSprite;
|
delete playerSprite;
|
||||||
delete tvSprite;
|
delete tvSprite;
|
||||||
@@ -125,11 +123,11 @@ void GameOver::render()
|
|||||||
// Comprueba el manejador de eventos
|
// Comprueba el manejador de eventos
|
||||||
void GameOver::checkEvents()
|
void GameOver::checkEvents()
|
||||||
{
|
{
|
||||||
// Comprueba los eventos que hay en la cola
|
SDL_Event event;
|
||||||
while (SDL_PollEvent(eventHandler) != 0)
|
while (SDL_PollEvent(&event))
|
||||||
{
|
{
|
||||||
// Evento de salida de la aplicación
|
// Evento de salida de la aplicación
|
||||||
if (eventHandler->type == SDL_QUIT)
|
if (event.type == SDL_QUIT)
|
||||||
{
|
{
|
||||||
options.section.name = SECTION_QUIT;
|
options.section.name = SECTION_QUIT;
|
||||||
options.section.subsection = 0;
|
options.section.subsection = 0;
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ private:
|
|||||||
Resource *resource; // Objeto con los recursos
|
Resource *resource; // Objeto con los recursos
|
||||||
Asset *asset; // Objeto con los ficheros de recursos
|
Asset *asset; // Objeto con los ficheros de recursos
|
||||||
Input *input; // Objeto pata gestionar la entrada
|
Input *input; // Objeto pata gestionar la entrada
|
||||||
SDL_Event *eventHandler; // Manejador de eventos
|
|
||||||
Text *text; // Objeto para escribir texto en pantalla
|
Text *text; // Objeto para escribir texto en pantalla
|
||||||
AnimatedSprite *playerSprite; // Sprite con el jugador
|
AnimatedSprite *playerSprite; // Sprite con el jugador
|
||||||
AnimatedSprite *tvSprite; // Sprite con el televisor
|
AnimatedSprite *tvSprite; // Sprite con el televisor
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
#ifndef NO_SHADERS
|
|
||||||
|
|
||||||
#include "jail_shader.h"
|
#include "jail_shader.h"
|
||||||
#include <SDL2/SDL_rect.h> // para SDL_Point
|
#include <SDL2/SDL_rect.h> // para SDL_Point
|
||||||
#include <stdlib.h> // para NULL, free, malloc, exit
|
#include <stdlib.h> // para NULL, free, malloc, exit
|
||||||
@@ -247,5 +245,4 @@ namespace shader
|
|||||||
SDL_RenderPresent(renderer);
|
SDL_RenderPresent(renderer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
@@ -21,7 +21,6 @@ LoadingScreen::LoadingScreen()
|
|||||||
input_(Input::get())
|
input_(Input::get())
|
||||||
{
|
{
|
||||||
// Reserva memoria para los punteros
|
// Reserva memoria para los punteros
|
||||||
eventHandler = new SDL_Event();
|
|
||||||
if (options.palette == p_zxspectrum)
|
if (options.palette == p_zxspectrum)
|
||||||
{
|
{
|
||||||
mono_loading_screen_texture_ = resource_->getTexture("loading_screen_bn.png");
|
mono_loading_screen_texture_ = resource_->getTexture("loading_screen_bn.png");
|
||||||
@@ -70,7 +69,6 @@ LoadingScreen::~LoadingScreen()
|
|||||||
{
|
{
|
||||||
delete mono_loading_screen_sprite_;
|
delete mono_loading_screen_sprite_;
|
||||||
delete color_loading_screen_sprite_;
|
delete color_loading_screen_sprite_;
|
||||||
delete eventHandler;
|
|
||||||
JA_DeleteMusic(loading_sound1_);
|
JA_DeleteMusic(loading_sound1_);
|
||||||
JA_DeleteMusic(loading_sound2_);
|
JA_DeleteMusic(loading_sound2_);
|
||||||
JA_DeleteMusic(loading_sound3_);
|
JA_DeleteMusic(loading_sound3_);
|
||||||
@@ -79,11 +77,11 @@ LoadingScreen::~LoadingScreen()
|
|||||||
// Comprueba el manejador de eventos
|
// Comprueba el manejador de eventos
|
||||||
void LoadingScreen::checkEvents()
|
void LoadingScreen::checkEvents()
|
||||||
{
|
{
|
||||||
// Comprueba los eventos que hay en la cola
|
SDL_Event event;
|
||||||
while (SDL_PollEvent(eventHandler) != 0)
|
while (SDL_PollEvent(&event))
|
||||||
{
|
{
|
||||||
// Evento de salida de la aplicación
|
// Evento de salida de la aplicación
|
||||||
if (eventHandler->type == SDL_QUIT)
|
if (event.type == SDL_QUIT)
|
||||||
{
|
{
|
||||||
options.section.name = SECTION_QUIT;
|
options.section.name = SECTION_QUIT;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ private:
|
|||||||
Input *input_; // Objeto pata gestionar la entrada
|
Input *input_; // Objeto pata gestionar la entrada
|
||||||
Texture *mono_loading_screen_texture_; // Textura con la pantalla de carga en blanco y negro
|
Texture *mono_loading_screen_texture_; // Textura con la pantalla de carga en blanco y negro
|
||||||
Texture *color_loading_screen_texture_; // Textura con la pantalla de carga en color
|
Texture *color_loading_screen_texture_; // Textura con la pantalla de carga en color
|
||||||
SDL_Event *eventHandler; // Manejador de eventos
|
|
||||||
Sprite *mono_loading_screen_sprite_; // Sprite para manejar la textura loadingScreenTexture1
|
Sprite *mono_loading_screen_sprite_; // Sprite para manejar la textura loadingScreenTexture1
|
||||||
Sprite *color_loading_screen_sprite_; // Sprite para manejar la textura loadingScreenTexture2
|
Sprite *color_loading_screen_sprite_; // Sprite para manejar la textura loadingScreenTexture2
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ Logo::Logo()
|
|||||||
input_(Input::get())
|
input_(Input::get())
|
||||||
{
|
{
|
||||||
// Reserva memoria para los punteros
|
// Reserva memoria para los punteros
|
||||||
event_handler_ = new SDL_Event();
|
|
||||||
jailgames_texture_ = resource_->getTexture("jailgames.png");
|
jailgames_texture_ = resource_->getTexture("jailgames.png");
|
||||||
since_1998_texture_ = resource_->getTexture("since_1998.png");
|
since_1998_texture_ = resource_->getTexture("since_1998.png");
|
||||||
since_1998_sprite_ = new Sprite((256 - since_1998_texture_->getWidth()) / 2, 83 + jailgames_texture_->getHeight() + 5, since_1998_texture_->getWidth(), since_1998_texture_->getHeight(), since_1998_texture_, renderer_);
|
since_1998_sprite_ = new Sprite((256 - since_1998_texture_->getWidth()) / 2, 83 + jailgames_texture_->getHeight() + 5, since_1998_texture_->getWidth(), since_1998_texture_->getHeight(), since_1998_texture_, renderer_);
|
||||||
@@ -68,17 +67,16 @@ Logo::~Logo()
|
|||||||
}
|
}
|
||||||
|
|
||||||
delete since_1998_sprite_;
|
delete since_1998_sprite_;
|
||||||
delete event_handler_;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba el manejador de eventos
|
// Comprueba el manejador de eventos
|
||||||
void Logo::checkEvents()
|
void Logo::checkEvents()
|
||||||
{
|
{
|
||||||
// Comprueba los eventos que hay en la cola
|
SDL_Event event;
|
||||||
while (SDL_PollEvent(event_handler_) != 0)
|
while (SDL_PollEvent(&event))
|
||||||
{
|
{
|
||||||
// Evento de salida de la aplicación
|
// Evento de salida de la aplicación
|
||||||
if (event_handler_->type == SDL_QUIT)
|
if (event.type == SDL_QUIT)
|
||||||
{
|
{
|
||||||
options.section.name = SECTION_QUIT;
|
options.section.name = SECTION_QUIT;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ private:
|
|||||||
Input *input_; // Objeto pata gestionar la entrada
|
Input *input_; // Objeto pata gestionar la entrada
|
||||||
Texture *jailgames_texture_; // Textura con los graficos "JAILGAMES"
|
Texture *jailgames_texture_; // Textura con los graficos "JAILGAMES"
|
||||||
Texture *since_1998_texture_; // Textura con los graficos "Since 1998"
|
Texture *since_1998_texture_; // Textura con los graficos "Since 1998"
|
||||||
SDL_Event *event_handler_; // Manejador de eventos
|
|
||||||
std::vector<Sprite *> jailgames_sprite_; // Vector con los sprites de cada linea que forman el bitmap JAILGAMES
|
std::vector<Sprite *> jailgames_sprite_; // Vector con los sprites de cada linea que forman el bitmap JAILGAMES
|
||||||
Sprite *since_1998_sprite_; // Sprite para manejar la textura2
|
Sprite *since_1998_sprite_; // Sprite para manejar la textura2
|
||||||
|
|
||||||
|
|||||||
@@ -115,14 +115,14 @@ bool loadOptionsFromFile(const std::string &file_path)
|
|||||||
// El fichero no existe
|
// El fichero no existe
|
||||||
else
|
else
|
||||||
{ // Crea el fichero con los valores por defecto
|
{ // Crea el fichero con los valores por defecto
|
||||||
saveOptionsFromFile(file_path);
|
saveOptionsToFile(file_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Si la versión de fichero no coincide, crea un fichero nuevo con los valores por defecto
|
// Si la versión de fichero no coincide, crea un fichero nuevo con los valores por defecto
|
||||||
if (configVersion != options.configVersion)
|
if (configVersion != options.configVersion)
|
||||||
{
|
{
|
||||||
initOptions();
|
initOptions();
|
||||||
saveOptionsFromFile(file_path);
|
saveOptionsToFile(file_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normaliza los valores
|
// Normaliza los valores
|
||||||
@@ -142,7 +142,7 @@ bool loadOptionsFromFile(const std::string &file_path)
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool saveOptionsFromFile(const std::string &file_path)
|
bool saveOptionsToFile(const std::string &file_path)
|
||||||
{
|
{
|
||||||
bool success = true;
|
bool success = true;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL_rect.h> // Para SDL_Rect, SDL_Point
|
#include <SDL2/SDL_rect.h> // Para SDL_Rect, SDL_Point
|
||||||
#include <SDL2/SDL_stdinc.h> // Para Uint8, Uint32
|
#include <SDL2/SDL_stdinc.h> // Para Uint8, Uint32
|
||||||
@@ -98,4 +98,4 @@ void initOptions();
|
|||||||
bool loadOptionsFromFile(const std::string &file_path);
|
bool loadOptionsFromFile(const std::string &file_path);
|
||||||
|
|
||||||
// Guarda las opciones a un fichero
|
// Guarda las opciones a un fichero
|
||||||
bool saveOptionsFromFile(const std::string &file_path);
|
bool saveOptionsToFile(const std::string &file_path);
|
||||||
@@ -25,8 +25,6 @@ Title::Title()
|
|||||||
input_(Input::get())
|
input_(Input::get())
|
||||||
{
|
{
|
||||||
// Reserva memoria para los punteros
|
// Reserva memoria para los punteros
|
||||||
event_handler_ = new SDL_Event();
|
|
||||||
cheevos_ = std::make_unique<Cheevos>(Asset::get()->get("cheevos.bin"));
|
|
||||||
if (options.palette == p_zxspectrum)
|
if (options.palette == p_zxspectrum)
|
||||||
{
|
{
|
||||||
texture_ = resource_->getTexture("title_logo.png");
|
texture_ = resource_->getTexture("title_logo.png");
|
||||||
@@ -75,7 +73,6 @@ Title::Title()
|
|||||||
// Destructor
|
// Destructor
|
||||||
Title::~Title()
|
Title::~Title()
|
||||||
{
|
{
|
||||||
delete event_handler_;
|
|
||||||
delete sprite_;
|
delete sprite_;
|
||||||
delete cheevos_sprite_;
|
delete cheevos_sprite_;
|
||||||
delete cheevos_texture_;
|
delete cheevos_texture_;
|
||||||
@@ -104,22 +101,22 @@ void Title::initMarquee()
|
|||||||
// Comprueba el manejador de eventos
|
// Comprueba el manejador de eventos
|
||||||
void Title::checkEvents()
|
void Title::checkEvents()
|
||||||
{
|
{
|
||||||
// Comprueba los eventos que hay en la cola
|
SDL_Event event;
|
||||||
while (SDL_PollEvent(event_handler_) != 0)
|
while (SDL_PollEvent(&event))
|
||||||
{
|
{
|
||||||
// Evento de salida de la aplicación
|
// Evento de salida de la aplicación
|
||||||
if (event_handler_->type == SDL_QUIT)
|
if (event.type == SDL_QUIT)
|
||||||
{
|
{
|
||||||
options.section.name = SECTION_QUIT;
|
options.section.name = SECTION_QUIT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Solo se comprueban estas teclas si no está activo el menu de logros
|
// Solo se comprueban estas teclas si no está activo el menu de logros
|
||||||
if (event_handler_->type == SDL_KEYDOWN)
|
if (event.type == SDL_KEYDOWN)
|
||||||
{
|
{
|
||||||
if (!show_cheevos_)
|
if (!show_cheevos_)
|
||||||
{
|
{
|
||||||
switch (event_handler_->key.keysym.scancode)
|
switch (event.key.keysym.scancode)
|
||||||
{
|
{
|
||||||
case SDL_SCANCODE_1:
|
case SDL_SCANCODE_1:
|
||||||
options.section.name = SECTION_GAME;
|
options.section.name = SECTION_GAME;
|
||||||
@@ -446,7 +443,7 @@ void Title::fillTexture()
|
|||||||
void Title::createCheevosTexture()
|
void Title::createCheevosTexture()
|
||||||
{
|
{
|
||||||
// Crea la textura con el listado de logros
|
// Crea la textura con el listado de logros
|
||||||
const auto cheevosList = cheevos_->list();
|
const auto cheevosList = Cheevos::get()->list();
|
||||||
const int cheevosTextureWidth = 200;
|
const int cheevosTextureWidth = 200;
|
||||||
const int cheevosTextureViewHeight = 110;
|
const int cheevosTextureViewHeight = 110;
|
||||||
const int cheevosTexturePosY = 73;
|
const int cheevosTexturePosY = 73;
|
||||||
@@ -465,7 +462,7 @@ void Title::createCheevosTexture()
|
|||||||
|
|
||||||
// Escribe la lista de logros en la textura
|
// Escribe la lista de logros en la textura
|
||||||
const std::string cheevosOwner = "LOCAL ACHIEVEMENTS";
|
const std::string cheevosOwner = "LOCAL ACHIEVEMENTS";
|
||||||
const std::string cheevosListCaption = cheevosOwner + " (" + std::to_string(cheevos_->unlocked()) + " / " + std::to_string(cheevos_->count()) + ")";
|
const std::string cheevosListCaption = cheevosOwner + " (" + std::to_string(Cheevos::get()->unlocked()) + " / " + std::to_string(Cheevos::get()->count()) + ")";
|
||||||
int pos = 2;
|
int pos = 2;
|
||||||
info_text_->writeDX(TXT_CENTER | TXT_COLOR, cheevos_texture_->getWidth() / 2, pos, cheevosListCaption, 1, stringToColor(options.palette, "bright_green"));
|
info_text_->writeDX(TXT_CENTER | TXT_COLOR, cheevos_texture_->getWidth() / 2, pos, cheevosListCaption, 1, stringToColor(options.palette, "bright_green"));
|
||||||
pos += info_text_->getCharacterSize();
|
pos += info_text_->getCharacterSize();
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ private:
|
|||||||
SDL_Renderer *renderer_; // El renderizador de la ventana
|
SDL_Renderer *renderer_; // El renderizador de la ventana
|
||||||
Resource *resource_; // Objeto con los recursos
|
Resource *resource_; // Objeto con los recursos
|
||||||
Input *input_; // Objeto pata gestionar la entrada
|
Input *input_; // Objeto pata gestionar la entrada
|
||||||
SDL_Event *event_handler_; // Manejador de eventos
|
|
||||||
Texture *texture_; // Textura con los graficos
|
Texture *texture_; // Textura con los graficos
|
||||||
Sprite *sprite_; // Sprite para manejar la textura
|
Sprite *sprite_; // Sprite para manejar la textura
|
||||||
SDL_Texture *bg_texture_; // Textura para dibujar el fondo de la pantalla
|
SDL_Texture *bg_texture_; // Textura para dibujar el fondo de la pantalla
|
||||||
@@ -49,7 +48,6 @@ private:
|
|||||||
Text *info_text_; // Objeto para escribir texto en pantalla
|
Text *info_text_; // Objeto para escribir texto en pantalla
|
||||||
Texture *cheevos_texture_; // Textura con la lista de logros
|
Texture *cheevos_texture_; // Textura con la lista de logros
|
||||||
Sprite *cheevos_sprite_; // Sprite para manejar la textura con la lista de logros
|
Sprite *cheevos_sprite_; // Sprite para manejar la textura con la lista de logros
|
||||||
std::unique_ptr<Cheevos> cheevos_; // Objeto encargado de gestionar los logros del juego
|
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
int counter_ = 0; // Contador
|
int counter_ = 0; // Contador
|
||||||
|
|||||||
Reference in New Issue
Block a user