forked from jaildesigner-jailgames/jaildoctors_dilemma
Reestructurant la classe Options
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
#include <vector> // Para vector
|
||||
#include <memory> // Para std::make_unique
|
||||
#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 "credits.h" // Para Credits
|
||||
#include "demo.h" // Para Demo
|
||||
@@ -126,22 +126,25 @@ std::string Director::checkProgramArguments(int argc, const char *argv[])
|
||||
|
||||
else if (strcmp(argv[i], "--infiniteLives") == 0)
|
||||
{
|
||||
options.cheat.infiniteLives = true;
|
||||
options.cheats.infinite_lives = Cheat::CheatState::ENABLED;
|
||||
}
|
||||
|
||||
else if (strcmp(argv[i], "--invincible") == 0)
|
||||
{
|
||||
options.cheat.invincible = true;
|
||||
options.cheats.invincible = Cheat::CheatState::ENABLED;
|
||||
;
|
||||
}
|
||||
|
||||
else if (strcmp(argv[i], "--jailEnabled") == 0)
|
||||
{
|
||||
options.cheat.jailEnabled = true;
|
||||
options.cheats.jail_is_open = Cheat::CheatState::ENABLED;
|
||||
;
|
||||
}
|
||||
|
||||
else if (strcmp(argv[i], "--altSkin") == 0)
|
||||
{
|
||||
options.cheat.altSkin = true;
|
||||
options.cheats.alternate_skin = Cheat::CheatState::ENABLED;
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,14 +212,14 @@ void Director::createSystemFolder(const std::string &folder)
|
||||
}
|
||||
|
||||
// Carga los recursos
|
||||
void Director::loadResources(section_t section)
|
||||
void Director::loadResources(SectionState section)
|
||||
{
|
||||
if (options.console)
|
||||
{
|
||||
std::cout << "** LOAD RESOURCES" << std::endl;
|
||||
}
|
||||
|
||||
if (options.section.name == SECTION_LOGO)
|
||||
if (options.section.section == Section::LOGO)
|
||||
{
|
||||
std::vector<std::string> textureList;
|
||||
textureList.push_back("jailgames.png");
|
||||
@@ -225,7 +228,7 @@ void Director::loadResources(section_t section)
|
||||
Resource::get()->loadTextures(textureList);
|
||||
}
|
||||
|
||||
else if (options.section.name == SECTION_LOADING_SCREEN)
|
||||
else if (options.section.section == Section::LOADING_SCREEN)
|
||||
{
|
||||
std::vector<std::string> textureList;
|
||||
textureList.push_back("loading_screen_bn.png");
|
||||
@@ -236,7 +239,7 @@ void Director::loadResources(section_t section)
|
||||
Resource::get()->loadTextures(textureList);
|
||||
}
|
||||
|
||||
else if (options.section.name == SECTION_TITLE)
|
||||
else if (options.section.section == Section::TITLE)
|
||||
{
|
||||
std::vector<std::string> textureList;
|
||||
textureList.push_back("loading_screen_color.png");
|
||||
@@ -256,7 +259,7 @@ void Director::loadResources(section_t section)
|
||||
Resource::get()->loadOffsets(offsetsList);
|
||||
}
|
||||
|
||||
else if (options.section.name == SECTION_CREDITS)
|
||||
else if (options.section.section == Section::CREDITS)
|
||||
{
|
||||
// Texturas
|
||||
std::vector<std::string> textureList;
|
||||
@@ -278,7 +281,7 @@ void Director::loadResources(section_t section)
|
||||
Resource::get()->loadOffsets(offsetsList);
|
||||
}
|
||||
|
||||
else if (options.section.name == SECTION_ENDING)
|
||||
else if (options.section.section == Section::ENDING)
|
||||
{
|
||||
// Texturas
|
||||
std::vector<std::string> textureList;
|
||||
@@ -303,7 +306,7 @@ void Director::loadResources(section_t section)
|
||||
Resource::get()->loadOffsets(offsetsList);
|
||||
}
|
||||
|
||||
else if (options.section.name == SECTION_ENDING2)
|
||||
else if (options.section.section == Section::ENDING2)
|
||||
{
|
||||
// Texturas
|
||||
std::vector<std::string> textureList;
|
||||
@@ -441,7 +444,7 @@ void Director::loadResources(section_t section)
|
||||
Resource::get()->loadOffsets(offsetsList);
|
||||
}
|
||||
|
||||
else if (options.section.name == SECTION_GAME_OVER)
|
||||
else if (options.section.section == Section::GAME_OVER)
|
||||
{
|
||||
// Texturas
|
||||
std::vector<std::string> textureList;
|
||||
@@ -465,20 +468,13 @@ void Director::loadResources(section_t section)
|
||||
Resource::get()->loadOffsets(offsetsList);
|
||||
}
|
||||
|
||||
else if (options.section.name == SECTION_GAME || options.section.name == SECTION_DEMO)
|
||||
else if (options.section.section == Section::GAME || options.section.section == Section::DEMO)
|
||||
{
|
||||
// Texturas
|
||||
std::vector<std::string> textureList;
|
||||
|
||||
// Jugador
|
||||
if (options.cheat.altSkin)
|
||||
{
|
||||
textureList.push_back("player2.png");
|
||||
}
|
||||
else
|
||||
{
|
||||
textureList.push_back("player.png");
|
||||
}
|
||||
textureList.push_back(options.cheats.alternate_skin == Cheat::CheatState::ENABLED ? "player2.png" : "player.png");
|
||||
|
||||
// Tilesets
|
||||
textureList.push_back("standard.png");
|
||||
@@ -556,14 +552,7 @@ void Director::loadResources(section_t section)
|
||||
std::vector<std::string> animationList;
|
||||
|
||||
// Jugador
|
||||
if (options.cheat.altSkin)
|
||||
{
|
||||
animationList.push_back("player2.ani");
|
||||
}
|
||||
else
|
||||
{
|
||||
animationList.push_back("player.ani");
|
||||
}
|
||||
animationList.push_back(options.cheats.alternate_skin == Cheat::CheatState::ENABLED ? "player2.ani" : "player.ani");
|
||||
|
||||
// Enemigos
|
||||
animationList.push_back("abad_bell.ani");
|
||||
@@ -780,7 +769,7 @@ void Director::initInput()
|
||||
Input::get()->discoverGameController();
|
||||
|
||||
// Teclado - Movimiento
|
||||
if (options.keys == ctrl_cursor)
|
||||
if (options.keys == ControlScheme::CURSOR)
|
||||
{
|
||||
Input::get()->bindKey(input_jump, SDL_SCANCODE_UP);
|
||||
Input::get()->bindKey(input_left, SDL_SCANCODE_LEFT);
|
||||
@@ -788,7 +777,7 @@ void Director::initInput()
|
||||
Input::get()->bindKey(input_up, SDL_SCANCODE_UP);
|
||||
Input::get()->bindKey(input_down, SDL_SCANCODE_DOWN);
|
||||
}
|
||||
else if (options.keys == ctrl_opqa)
|
||||
else if (options.keys == ControlScheme::OPQA)
|
||||
{
|
||||
Input::get()->bindKey(input_jump, SDL_SCANCODE_Q);
|
||||
Input::get()->bindKey(input_left, SDL_SCANCODE_O);
|
||||
@@ -796,7 +785,7 @@ void Director::initInput()
|
||||
Input::get()->bindKey(input_up, SDL_SCANCODE_Q);
|
||||
Input::get()->bindKey(input_down, SDL_SCANCODE_A);
|
||||
}
|
||||
else if (options.keys == ctrl_wasd)
|
||||
else if (options.keys == ControlScheme::WASD)
|
||||
{
|
||||
Input::get()->bindKey(input_jump, SDL_SCANCODE_W);
|
||||
Input::get()->bindKey(input_left, SDL_SCANCODE_A);
|
||||
@@ -865,7 +854,7 @@ bool Director::initSDL()
|
||||
std::srand(static_cast<unsigned int>(SDL_GetTicks()));
|
||||
|
||||
// Establece el filtro de la textura a nearest
|
||||
if (!SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, std::to_string(options.filter).c_str()))
|
||||
if (!SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, std::to_string(static_cast<int>(options.video.filter)).c_str()))
|
||||
{
|
||||
if (options.console)
|
||||
{
|
||||
@@ -880,15 +869,10 @@ bool Director::initSDL()
|
||||
}
|
||||
|
||||
// Crea la ventana
|
||||
int incW = 0;
|
||||
int incH = 0;
|
||||
if (options.borderEnabled)
|
||||
{
|
||||
incW = options.borderWidth * 2;
|
||||
incH = options.borderHeight * 2;
|
||||
}
|
||||
options.window.width = options.video.border.enabled ? options.game.width + options.video.border.width * 2 : options.game.width;
|
||||
options.window.height = options.video.border.enabled ? options.game.height + options.video.border.height * 2 : options.game.height;
|
||||
|
||||
window_ = SDL_CreateWindow(WINDOW_CAPTION, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, (options.gameWidth + incW) * options.windowSize, (options.gameHeight + incH) * options.windowSize, SDL_WINDOW_HIDDEN);
|
||||
window_ = SDL_CreateWindow(WINDOW_CAPTION, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, options.window.width, options.window.height, SDL_WINDOW_HIDDEN);
|
||||
if (window_ == nullptr)
|
||||
{
|
||||
if (options.console)
|
||||
@@ -901,7 +885,7 @@ bool Director::initSDL()
|
||||
{
|
||||
// Crea un renderizador para la ventana. El vsync se activa en funcion de las opciones
|
||||
Uint32 flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE;
|
||||
if (options.vSync)
|
||||
if (options.video.vertical_sync)
|
||||
{
|
||||
flags = flags | SDL_RENDERER_PRESENTVSYNC;
|
||||
}
|
||||
@@ -921,7 +905,7 @@ bool Director::initSDL()
|
||||
SDL_SetRenderDrawColor(renderer_, 0x00, 0x00, 0x00, 0xFF);
|
||||
|
||||
// Establece el tamaño del buffer de renderizado
|
||||
SDL_RenderSetLogicalSize(renderer_, options.gameWidth, options.gameHeight);
|
||||
SDL_RenderSetLogicalSize(renderer_, options.game.width, options.game.height);
|
||||
|
||||
// Establece el modo de mezcla
|
||||
SDL_SetRenderDrawBlendMode(renderer_, SDL_BLENDMODE_BLEND);
|
||||
@@ -1421,45 +1405,48 @@ void Director::runGame()
|
||||
int Director::run()
|
||||
{
|
||||
// Bucle principal
|
||||
while (options.section.name != SECTION_QUIT)
|
||||
while (options.section.section != Section::QUIT)
|
||||
{
|
||||
switch (options.section.name)
|
||||
switch (options.section.section)
|
||||
{
|
||||
case SECTION_LOGO:
|
||||
case Section::LOGO:
|
||||
runLogo();
|
||||
break;
|
||||
|
||||
case SECTION_LOADING_SCREEN:
|
||||
case Section::LOADING_SCREEN:
|
||||
runLoadingScreen();
|
||||
break;
|
||||
|
||||
case SECTION_TITLE:
|
||||
case Section::TITLE:
|
||||
runTitle();
|
||||
break;
|
||||
|
||||
case SECTION_CREDITS:
|
||||
case Section::CREDITS:
|
||||
runCredits();
|
||||
break;
|
||||
|
||||
case SECTION_DEMO:
|
||||
case Section::DEMO:
|
||||
runDemo();
|
||||
break;
|
||||
|
||||
case SECTION_GAME:
|
||||
case Section::GAME:
|
||||
runGame();
|
||||
break;
|
||||
|
||||
case SECTION_GAME_OVER:
|
||||
case Section::GAME_OVER:
|
||||
runGameOver();
|
||||
break;
|
||||
|
||||
case SECTION_ENDING:
|
||||
case Section::ENDING:
|
||||
runEnding();
|
||||
break;
|
||||
|
||||
case SECTION_ENDING2:
|
||||
case Section::ENDING2:
|
||||
runEnding2();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user