Eliminat el punter a "section"

This commit is contained in:
2024-09-28 09:28:22 +02:00
parent 0a8d0479a0
commit 8d263931b2
19 changed files with 191 additions and 172 deletions

View File

@@ -3,13 +3,12 @@
#include "options.h"
// Constructor
Title::Title(Screen *screen, Asset *asset, Input *input, section_t *section, JA_Music_t *music)
Title::Title(Screen *screen, Asset *asset, Input *input, JA_Music_t *music)
{
// Copia las direcciones de los punteros y objetos
this->screen = screen;
this->input = input;
this->asset = asset;
this->section = section;
this->music = music;
SDL_Renderer *renderer = screen->getRenderer();
@@ -30,7 +29,7 @@ Title::Title(Screen *screen, Asset *asset, Input *input, section_t *section, JA_
gameLogo = new GameLogo(renderer, screen, asset, param.game.gameArea.centerX, param.title.titleCCPosition);
gameLogo->enable();
defineButtons = new DefineButtons(input, text2, section);
defineButtons = new DefineButtons(input, text2);
// Inicializa los valores
init();
@@ -58,9 +57,9 @@ Title::~Title()
void Title::init()
{
// Inicializa variables
section->options = SECTION_OPTIONS_TITLE_1;
section::options = section::OPTIONS_TITLE_1;
counter = 0;
nextSection.name = SECTION_PROG_GAME;
nextSection.name = section::NAME_GAME;
postFade = 0;
ticks = 0;
ticksSpeed = 15;
@@ -92,28 +91,28 @@ void Title::update()
{
if (postFade == -1)
{
section->name = SECTION_PROG_GAME_DEMO;
section::name = section::NAME_GAME_DEMO;
}
else
{
section->name = SECTION_PROG_GAME;
section->options = postFade;
section::name = section::NAME_GAME;
section::options = postFade == 1 ? section::OPTIONS_GAME_PLAY_1P : section::OPTIONS_GAME_PLAY_2P;
JA_StopMusic();
}
}
// Sección 1 - Titulo animandose
if (section->options == SECTION_OPTIONS_TITLE_1)
if (section::options == section::OPTIONS_TITLE_1)
{
gameLogo->update();
if (gameLogo->hasFinished())
{
section->options = SECTION_OPTIONS_TITLE_2;
section::options = section::OPTIONS_TITLE_2;
}
}
// Sección 2 - La pantalla con el titulo, el fondo animado y la música
else if (section->options == SECTION_OPTIONS_TITLE_2)
else if (section::options == section::OPTIONS_TITLE_2)
{
// El contador solo sube si no estamos definiendo botones
if (!defineButtons->isEnabled())
@@ -161,7 +160,7 @@ void Title::render()
// Dibuja el logo con el título del juego
gameLogo->render();
if (section->options == SECTION_OPTIONS_TITLE_2)
if (section::options == section::OPTIONS_TITLE_2)
{
const color_t shadow = {0x14, 0x87, 0xc4};
// 'PULSA 1P o 2P PARA JUGAR'
@@ -202,7 +201,7 @@ void Title::checkEvents()
// Evento de salida de la aplicación
if (eventHandler->type == SDL_QUIT)
{
section->name = SECTION_PROG_QUIT;
section::name = section::NAME_QUIT;
break;
}
@@ -251,14 +250,14 @@ void Title::checkInput()
// Comprueba si se sale con el teclado
if (input->checkInput(input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD))
{
quit(SECTION_OPTIONS_QUIT_NORMAL);
quit(section::OPTIONS_QUIT_NORMAL);
return;
}
// Comprueba el teclado para empezar a jugar
if (input->checkInput(input_start, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD))
{
if (section->options == SECTION_OPTIONS_TITLE_2 || ALLOW_TITLE_ANIMATION_SKIP)
if (section::options == section::OPTIONS_TITLE_2 || ALLOW_TITLE_ANIMATION_SKIP)
{
fade->activate();
postFade = options.controller[0].playerId;
@@ -275,14 +274,14 @@ void Title::checkInput()
// Comprueba si se sale con el mando
if (input->checkModInput(input_service, input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
{
quit(SECTION_OPTIONS_QUIT_SHUTDOWN);
quit(section::OPTIONS_QUIT_SHUTDOWN);
return;
}
// Comprueba si se va a resetear el juego
if (input->checkModInput(input_service, input_reset, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
{
section->name = SECTION_PROG_LOGO;
section::name = section::NAME_LOGO;
screen->showNotification("Reset");
return;
}
@@ -314,7 +313,7 @@ void Title::checkInput()
// Comprueba el botón de START de los mandos
if (input->checkInput(input_start, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
{
if (section->options == SECTION_OPTIONS_TITLE_2 || ALLOW_TITLE_ANIMATION_SKIP)
if (section::options == section::OPTIONS_TITLE_2 || ALLOW_TITLE_ANIMATION_SKIP)
{
fade->activate();
postFade = options.controller[i].playerId;
@@ -332,7 +331,7 @@ void Title::checkInput()
// Bucle para el titulo del juego
void Title::run()
{
while (section->name == SECTION_PROG_TITLE)
while (section::name == section::NAME_TITLE)
{
checkInput();
update();
@@ -398,12 +397,12 @@ void Title::swapControllers()
}
// Termina
void Title::quit(int code)
void Title::quit(section::options_e code)
{
if (screen->notificationsAreActive())
{
section->name = SECTION_PROG_QUIT;
section->options = code;
section::name = section::NAME_QUIT;
section::options = code;
}
else
{