JA VA! Nomes s'havia de fer les coses be i no ser un ansias

This commit is contained in:
2025-02-22 00:30:32 +01:00
parent f6098a479b
commit e361d295c1
39 changed files with 1053 additions and 1098 deletions

View File

@@ -10,17 +10,16 @@
#include "texture.h" // for Texture
#include "utils.h" // for color_t, section_t, options_t, stringToC...
#include "asset.h"
#include "options.h"
class Asset; // lines 11-11
// Constructor
Logo::Logo(Resource *resource, options_t *options, section_t *section)
Logo::Logo(Resource *resource)
: screen_(Screen::get()),
renderer_(Screen::get()->getRenderer()),
resource_(resource),
asset_(Asset::get()),
input_(Input::get()),
options_(options),
section_(section)
input_(Input::get())
{
// Reserva memoria para los punteros
event_handler_ = new SDL_Event();
@@ -47,17 +46,17 @@ Logo::Logo(Resource *resource, options_t *options, section_t *section)
}
// Inicializa variables
section->name = SECTION_LOGO;
options.section.name = SECTION_LOGO;
// Inicializa el vector de colores
const std::vector<std::string> vColors = {"black", "blue", "red", "magenta", "green", "cyan", "yellow", "bright_white"};
for (auto v : vColors)
{
color_.push_back(stringToColor(options->palette, v));
color_.push_back(stringToColor(options.palette, v));
}
// Cambia el color del borde
screen_->setBorderColor(stringToColor(options->palette, "black"));
screen_->setBorderColor(stringToColor(options.palette, "black"));
}
// Destructor
@@ -81,7 +80,7 @@ void Logo::checkEvents()
// Evento de salida de la aplicación
if (event_handler_->type == SDL_QUIT)
{
section_->name = SECTION_QUIT;
options.section.name = SECTION_QUIT;
break;
}
}
@@ -92,7 +91,7 @@ void Logo::checkInput()
{
if (input_->checkInput(input_exit, REPEAT_FALSE))
{
section_->name = SECTION_TITLE;
options.section.name = SECTION_TITLE;
}
else if (input_->checkInput(input_toggle_border, REPEAT_FALSE))
@@ -122,7 +121,7 @@ void Logo::checkInput()
else if (input_->checkInput(input_pause, REPEAT_FALSE) || input_->checkInput(input_accept, REPEAT_FALSE) || input_->checkInput(input_jump, REPEAT_FALSE))
{
section_->subsection = SUBSECTION_LOGO_TO_TITLE;
options.section.subsection = SUBSECTION_LOGO_TO_TITLE;
endSection();
}
}
@@ -306,7 +305,7 @@ void Logo::run()
// Detiene la música
JA_StopMusic();
while (section_->name == SECTION_LOGO)
while (options.section.name == SECTION_LOGO)
{
update();
checkEvents();
@@ -317,19 +316,19 @@ void Logo::run()
// Cambia la paleta
void Logo::switchPalette()
{
options_->palette = options_->palette == p_zxspectrum ? p_zxarne : p_zxspectrum;
options.palette = options.palette == p_zxspectrum ? p_zxarne : p_zxspectrum;
}
// Termina la sección
void Logo::endSection()
{
if (section_->subsection == SUBSECTION_LOGO_TO_TITLE)
if (options.section.subsection == SUBSECTION_LOGO_TO_TITLE)
{
section_->name = SECTION_TITLE;
options.section.name = SECTION_TITLE;
}
else if (section_->subsection == SUBSECTION_LOGO_TO_INTRO)
else if (options.section.subsection == SUBSECTION_LOGO_TO_INTRO)
{
section_->name = SECTION_LOADING_SCREEN;
options.section.name = SECTION_LOADING_SCREEN;
}
}