Eliminat tots els options.console
This commit is contained in:
@@ -1,4 +1,7 @@
|
|||||||
#include "animatedsprite.h"
|
#include "animatedsprite.h"
|
||||||
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
// Carga la animación desde un fichero
|
// Carga la animación desde un fichero
|
||||||
animatedSprite_t loadAnimationFromFile(Texture *texture, std::string filePath, bool verbose)
|
animatedSprite_t loadAnimationFromFile(Texture *texture, std::string filePath, bool verbose)
|
||||||
|
|||||||
@@ -2,9 +2,6 @@
|
|||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "movingsprite.h"
|
#include "movingsprite.h"
|
||||||
#include <fstream>
|
|
||||||
#include <iostream>
|
|
||||||
#include <sstream>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ void Director::initInput()
|
|||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
input->setVerbose(true);
|
input->setVerbose(true);
|
||||||
#else
|
#else
|
||||||
input->setVerbose(options.console);
|
input->setVerbose(false);
|
||||||
#endif
|
#endif
|
||||||
// Busca si hay mandos conectados
|
// Busca si hay mandos conectados
|
||||||
input->discoverGameControllers();
|
input->discoverGameControllers();
|
||||||
@@ -216,10 +216,9 @@ bool Director::initSDL()
|
|||||||
// Inicializa SDL
|
// Inicializa SDL
|
||||||
if (SDL_Init(SDL_INIT_EVERYTHING) < 0)
|
if (SDL_Init(SDL_INIT_EVERYTHING) < 0)
|
||||||
{
|
{
|
||||||
if (options.console)
|
#ifdef VERBOSE
|
||||||
{
|
std::cout << "SDL could not initialize!\nSDL Error: " << SDL_GetError() << std::endl;
|
||||||
std::cout << "SDL could not initialize!\nSDL Error: " << SDL_GetError() << std::endl;
|
#endif
|
||||||
}
|
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -227,48 +226,44 @@ bool Director::initSDL()
|
|||||||
// Inicia el generador de numeros aleatorios
|
// Inicia el generador de numeros aleatorios
|
||||||
std::srand(static_cast<unsigned int>(SDL_GetTicks()));
|
std::srand(static_cast<unsigned int>(SDL_GetTicks()));
|
||||||
|
|
||||||
|
#ifdef VERBOSE
|
||||||
// Muestra información de la pantalla
|
// Muestra información de la pantalla
|
||||||
if (options.console)
|
/*std::cout << "\nDisplay modes list:" << std::endl;
|
||||||
|
for (int i = 0; i < SDL_GetNumDisplayModes(0); ++i)
|
||||||
{
|
{
|
||||||
/*std::cout << "\nDisplay modes list:" << std::endl;
|
|
||||||
for (int i = 0; i < SDL_GetNumDisplayModes(0); ++i)
|
|
||||||
{
|
|
||||||
SDL_DisplayMode DM;
|
|
||||||
SDL_GetDisplayMode(0,i,&DM);
|
|
||||||
std::cout << " - " + std::to_string(DM.w) + "x" + std::to_string(DM.h) + " @ " + std::to_string(DM.refresh_rate) + "Hz" << std::endl;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
SDL_DisplayMode DM;
|
SDL_DisplayMode DM;
|
||||||
SDL_GetCurrentDisplayMode(0, &DM);
|
SDL_GetDisplayMode(0,i,&DM);
|
||||||
std::cout << "\nCurrent display mode: " + std::to_string(DM.w) + "x" + std::to_string(DM.h) + " @ " + std::to_string(DM.refresh_rate) + "Hz" << std::endl;
|
std::cout << " - " + std::to_string(DM.w) + "x" + std::to_string(DM.h) + " @ " + std::to_string(DM.refresh_rate) + "Hz" << std::endl;
|
||||||
std::cout << "Window resolution : " + std::to_string(param.game.width) + "x" + std::to_string(param.game.height) + " x" + std::to_string(options.video.window.size) << std::endl;
|
}*/
|
||||||
}
|
|
||||||
|
SDL_DisplayMode DM;
|
||||||
|
SDL_GetCurrentDisplayMode(0, &DM);
|
||||||
|
std::cout << "\nCurrent display mode: " + std::to_string(DM.w) + "x" + std::to_string(DM.h) + " @ " + std::to_string(DM.refresh_rate) + "Hz" << std::endl;
|
||||||
|
std::cout << "Window resolution : " + std::to_string(param.game.width) + "x" + std::to_string(param.game.height) + " x" + std::to_string(options.video.window.size) << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Establece el filtro de la textura
|
// Establece el filtro de la textura
|
||||||
if (!SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, std::to_string(options.video.filter).c_str()))
|
if (!SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, std::to_string(options.video.filter).c_str()))
|
||||||
{
|
{
|
||||||
if (options.console)
|
#ifdef VERBOSE
|
||||||
{
|
std::cout << "Warning: texture filtering not enabled!\n";
|
||||||
std::cout << "Warning: texture filtering not enabled!\n";
|
#endif
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#ifndef NO_SHADERS
|
#ifndef NO_SHADERS
|
||||||
if (!SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl"))
|
if (!SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl"))
|
||||||
{
|
{
|
||||||
if (options.console)
|
#ifdef VERBOSE
|
||||||
{
|
std::cout << "Warning: opengl not enabled!\n";
|
||||||
std::cout << "Warning: opengl not enabled!\n";
|
#endif // VERBOSE
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif // NO_SHADERS
|
||||||
// Crea la ventana
|
// Crea la ventana
|
||||||
window = SDL_CreateWindow(WINDOW_CAPTION, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, param.game.width * options.video.window.size, param.game.height * options.video.window.size, SDL_WINDOW_HIDDEN);
|
window = SDL_CreateWindow(WINDOW_CAPTION, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, param.game.width * options.video.window.size, param.game.height * options.video.window.size, SDL_WINDOW_HIDDEN);
|
||||||
if (window == nullptr)
|
if (window == nullptr)
|
||||||
{
|
{
|
||||||
if (options.console)
|
#ifdef VERBOSE
|
||||||
{
|
std::cout << "Window could not be created!\nSDL Error: " << SDL_GetError() << std::endl;
|
||||||
std::cout << "Window could not be created!\nSDL Error: " << SDL_GetError() << std::endl;
|
#endif
|
||||||
}
|
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -287,10 +282,9 @@ bool Director::initSDL()
|
|||||||
|
|
||||||
if (renderer == nullptr)
|
if (renderer == nullptr)
|
||||||
{
|
{
|
||||||
if (options.console)
|
#ifdef VERBOSE
|
||||||
{
|
std::cout << "Renderer could not be created!\nSDL Error: " << SDL_GetError() << std::endl;
|
||||||
std::cout << "Renderer could not be created!\nSDL Error: " << SDL_GetError() << std::endl;
|
#endif
|
||||||
}
|
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -307,10 +301,9 @@ bool Director::initSDL()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.console)
|
#ifdef VERBOSE
|
||||||
{
|
std::cout << std::endl;
|
||||||
std::cout << std::endl;
|
#endif
|
||||||
}
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -479,11 +472,6 @@ void Director::checkProgramArguments(int argc, char *argv[])
|
|||||||
// Comprueba el resto de parametros
|
// 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)
|
|
||||||
{
|
|
||||||
options.console = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strcmp(argv[i], "--320x240") == 0)
|
if (strcmp(argv[i], "--320x240") == 0)
|
||||||
{
|
{
|
||||||
paramFileArgument = argv[i];
|
paramFileArgument = argv[i];
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "game.h"
|
#include "game.h"
|
||||||
#include "param.h"
|
#include "param.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
#define GAME_OVER_COUNTER 350
|
#define GAME_OVER_COUNTER 350
|
||||||
|
|
||||||
@@ -327,11 +328,10 @@ void Game::init(int playerID)
|
|||||||
// Carga los recursos necesarios para la sección 'Game'
|
// Carga los recursos necesarios para la sección 'Game'
|
||||||
void Game::loadMedia()
|
void Game::loadMedia()
|
||||||
{
|
{
|
||||||
if (options.console)
|
#ifdef VERBOSE
|
||||||
{
|
std::cout << std::endl
|
||||||
std::cout << std::endl
|
<< "** LOADING RESOURCES FOR GAME SECTION" << std::endl;
|
||||||
<< "** LOADING RESOURCES FOR GAME SECTION" << std::endl;
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
playerAnimations.clear();
|
playerAnimations.clear();
|
||||||
balloonAnimations.clear();
|
balloonAnimations.clear();
|
||||||
@@ -520,11 +520,10 @@ void Game::loadMedia()
|
|||||||
stageChangeSound = JA_LoadSound(asset->get("stage_change.wav").c_str());
|
stageChangeSound = JA_LoadSound(asset->get("stage_change.wav").c_str());
|
||||||
coffeeMachineSound = JA_LoadSound(asset->get("title.wav").c_str());
|
coffeeMachineSound = JA_LoadSound(asset->get("title.wav").c_str());
|
||||||
|
|
||||||
if (options.console)
|
#ifdef VERBOSE
|
||||||
{
|
std::cout << "** RESOURCES FOR GAME SECTION LOADED" << std::endl
|
||||||
std::cout << "** RESOURCES FOR GAME SECTION LOADED" << std::endl
|
<< std::endl;
|
||||||
<< std::endl;
|
#endif
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Libera los recursos previamente cargados
|
// Libera los recursos previamente cargados
|
||||||
@@ -650,10 +649,9 @@ bool Game::loadDemoFile(std::string filePath, demoKeys_t (*dataFile)[TOTAL_DEMO_
|
|||||||
SDL_RWops *file = SDL_RWFromFile(filePath.c_str(), "r+b");
|
SDL_RWops *file = SDL_RWFromFile(filePath.c_str(), "r+b");
|
||||||
if (file == nullptr)
|
if (file == nullptr)
|
||||||
{ // El fichero no existe
|
{ // El fichero no existe
|
||||||
if (options.console)
|
#ifdef VERBOSE
|
||||||
{
|
std::cout << "Warning: Unable to open " << fileName.c_str() << " file" << std::endl;
|
||||||
std::cout << "Warning: Unable to open " << fileName.c_str() << " file" << std::endl;
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
// Creamos el fichero para escritura
|
// Creamos el fichero para escritura
|
||||||
file = SDL_RWFromFile(filePath.c_str(), "w+b");
|
file = SDL_RWFromFile(filePath.c_str(), "w+b");
|
||||||
@@ -661,10 +659,9 @@ bool Game::loadDemoFile(std::string filePath, demoKeys_t (*dataFile)[TOTAL_DEMO_
|
|||||||
// Si ha creado el fichero
|
// Si ha creado el fichero
|
||||||
if (file != nullptr)
|
if (file != nullptr)
|
||||||
{
|
{
|
||||||
if (options.console)
|
#ifdef VERBOSE
|
||||||
{
|
std::cout << "New file (" << fileName.c_str() << ") created!" << std::endl;
|
||||||
std::cout << "New file (" << fileName.c_str() << ") created!" << std::endl;
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
// Inicializas los datos y los guarda en el fichero
|
// Inicializas los datos y los guarda en el fichero
|
||||||
for (int i = 0; i < TOTAL_DEMO_DATA; ++i)
|
for (int i = 0; i < TOTAL_DEMO_DATA; ++i)
|
||||||
@@ -685,21 +682,19 @@ bool Game::loadDemoFile(std::string filePath, demoKeys_t (*dataFile)[TOTAL_DEMO_
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // Si no puede crear el fichero
|
{ // Si no puede crear el fichero
|
||||||
if (options.console)
|
#ifdef VERBOSE
|
||||||
{
|
std::cout << "Error: Unable to create file " << fileName.c_str() << std::endl;
|
||||||
std::cout << "Error: Unable to create file " << fileName.c_str() << std::endl;
|
#endif
|
||||||
}
|
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// El fichero existe
|
// El fichero existe
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Mensaje de proceder a la carga de los datos
|
// Mensaje de proceder a la carga de los datos
|
||||||
if (options.console)
|
#ifdef VERBOSE
|
||||||
{
|
std::cout << "Reading file: " << fileName.c_str() << std::endl;
|
||||||
std::cout << "Reading file: " << fileName.c_str() << std::endl;
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
// Lee todos los datos del fichero y los deja en el destino
|
// Lee todos los datos del fichero y los deja en el destino
|
||||||
for (int i = 0; i < TOTAL_DEMO_DATA; ++i)
|
for (int i = 0; i < TOTAL_DEMO_DATA; ++i)
|
||||||
@@ -732,25 +727,23 @@ bool Game::saveDemoFile(std::string filePath)
|
|||||||
SDL_RWwrite(file, &demo.dataFile[0][i], sizeof(demoKeys_t), 1);
|
SDL_RWwrite(file, &demo.dataFile[0][i], sizeof(demoKeys_t), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.console)
|
#ifdef VERBOSE
|
||||||
{
|
std::cout << "Writing file " << filename.c_str() << std::endl;
|
||||||
std::cout << "Writing file " << filename.c_str() << std::endl;
|
#endif // VERBOSE
|
||||||
}
|
|
||||||
|
|
||||||
// Cerramos el fichero
|
// Cerramos el fichero
|
||||||
SDL_RWclose(file);
|
SDL_RWclose(file);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (options.console)
|
#ifdef VERBOSE
|
||||||
{
|
std::cout << "Error: Unable to save " << filename.c_str() << " file! " << SDL_GetError() << std::endl;
|
||||||
std::cout << "Error: Unable to save " << filename.c_str() << " file! " << SDL_GetError() << std::endl;
|
#endif // VERBOSE
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
#endif
|
#endif // RECORDING
|
||||||
|
|
||||||
// Crea una formación de enemigos
|
// Crea una formación de enemigos
|
||||||
void Game::deployEnemyFormation()
|
void Game::deployEnemyFormation()
|
||||||
@@ -2653,10 +2646,10 @@ void Game::loadAnimations(std::string filePath, std::vector<std::string> *buffer
|
|||||||
|
|
||||||
if (file)
|
if (file)
|
||||||
{
|
{
|
||||||
if (options.console)
|
|
||||||
{
|
#ifdef VERBOSE
|
||||||
std::cout << "Animation loaded: " << filePath.substr(filePath.find_last_of("\\/") + 1).c_str() << std::endl;
|
std::cout << "Animation loaded: " << filePath.substr(filePath.find_last_of("\\/") + 1).c_str() << std::endl;
|
||||||
}
|
#endif
|
||||||
while (std::getline(file, line))
|
while (std::getline(file, line))
|
||||||
{
|
{
|
||||||
buffer->push_back(line);
|
buffer->push_back(line);
|
||||||
|
|||||||
@@ -13,13 +13,6 @@ bool setOptions(std::string var, std::string value);
|
|||||||
// Inicializa las opciones del programa
|
// Inicializa las opciones del programa
|
||||||
void initOptions()
|
void initOptions()
|
||||||
{
|
{
|
||||||
// Opciones varias
|
|
||||||
#ifdef VERBOSE
|
|
||||||
options.console = true;
|
|
||||||
#else
|
|
||||||
options.console = false;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Opciones de video
|
// Opciones de video
|
||||||
#ifdef ANBERNIC
|
#ifdef ANBERNIC
|
||||||
options.video.mode = 0;
|
options.video.mode = 0;
|
||||||
@@ -101,10 +94,9 @@ bool loadOptionsFile(std::string filePath)
|
|||||||
if (file.good())
|
if (file.good())
|
||||||
{
|
{
|
||||||
// Procesa el fichero linea a linea
|
// Procesa el fichero linea a linea
|
||||||
if (options.console)
|
#ifdef VERBOSE
|
||||||
{
|
std::cout << "Reading file: " << fileName << std::endl;
|
||||||
std::cout << "Reading file: " << fileName << std::endl;
|
#endif
|
||||||
}
|
|
||||||
std::string line;
|
std::string line;
|
||||||
while (std::getline(file, line))
|
while (std::getline(file, line))
|
||||||
{
|
{
|
||||||
@@ -116,11 +108,10 @@ bool loadOptionsFile(std::string filePath)
|
|||||||
// Procesa las dos subcadenas
|
// Procesa las dos subcadenas
|
||||||
if (!setOptions(line.substr(0, pos), line.substr(pos + 1, line.length())))
|
if (!setOptions(line.substr(0, pos), line.substr(pos + 1, line.length())))
|
||||||
{
|
{
|
||||||
if (options.console)
|
#ifdef VERBOSE
|
||||||
{
|
std::cout << "Warning: file " << fileName << std::endl;
|
||||||
std::cout << "Warning: file " << fileName << std::endl;
|
std::cout << "Unknown parameter " << line.substr(0, pos).c_str() << std::endl;
|
||||||
std::cout << "Unknown parameter " << line.substr(0, pos).c_str() << std::endl;
|
#endif
|
||||||
}
|
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -166,17 +157,15 @@ bool saveOptionsFile(std::string filePath)
|
|||||||
|
|
||||||
if (!file.good())
|
if (!file.good())
|
||||||
{
|
{
|
||||||
if (options.console)
|
#ifdef VERBOSE
|
||||||
{
|
std::cout << fileName << " can't be opened" << std::endl;
|
||||||
std::cout << fileName << " can't be opened" << std::endl;
|
#endif
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.console)
|
#ifdef VERBOSE
|
||||||
{
|
std::cout << "Writing file: " << fileName << std::endl;
|
||||||
std::cout << "Writing file: " << fileName << std::endl;
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
// Opciones de video
|
// Opciones de video
|
||||||
file << "## VIDEO\n";
|
file << "## VIDEO\n";
|
||||||
|
|||||||
@@ -60,8 +60,8 @@ void loadParamsFromFile(std::string filePath)
|
|||||||
initParam();
|
initParam();
|
||||||
|
|
||||||
// Variables para manejar el fichero
|
// Variables para manejar el fichero
|
||||||
std::string line;
|
|
||||||
std::ifstream file(filePath);
|
std::ifstream file(filePath);
|
||||||
|
std::string line;
|
||||||
std::string param1;
|
std::string param1;
|
||||||
std::string param2;
|
std::string param2;
|
||||||
|
|
||||||
|
|||||||
@@ -164,7 +164,6 @@ struct op_notification_t
|
|||||||
// Estructura con todas las opciones de configuración del programa
|
// Estructura con todas las opciones de configuración del programa
|
||||||
struct options_t
|
struct options_t
|
||||||
{
|
{
|
||||||
bool console; // Indica si ha de mostrar información por la consola de texto
|
|
||||||
op_game_t game; // Opciones para el propio juego
|
op_game_t game; // Opciones para el propio juego
|
||||||
op_video_t video; // Opciones relativas a la clase screen
|
op_video_t video; // Opciones relativas a la clase screen
|
||||||
op_audio_t audio; // Opciones para el audio
|
op_audio_t audio; // Opciones para el audio
|
||||||
|
|||||||
Reference in New Issue
Block a user