Reestructurant la classe Options

This commit is contained in:
2025-02-23 18:12:02 +01:00
parent 3ba4293e8a
commit 2ee0c70319
48 changed files with 898 additions and 984 deletions

View File

@@ -31,12 +31,12 @@ Credits::Credits()
sprite_ = new AnimatedSprite(renderer_, resource_->getAnimation("shine.ani"));
// Inicializa variables
options.section.name = SECTION_CREDITS;
options.section.subsection = 0;
options.section.section = Section::CREDITS;
options.section.subsection = Subsection::NONE;
sprite_->setRect({194, 174, 8, 8});
// Cambia el color del borde
screen_->setBorderColor(stringToColor(options.palette, "black"));
screen_->setBorderColor(stringToColor(options.video.palette, "black"));
// Crea la textura para el texto que se escribe en pantalla
text_texture_ = SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT);
@@ -93,11 +93,11 @@ void Credits::checkInput()
void Credits::iniTexts()
{
std::string keys = "";
if (options.keys == ctrl_cursor)
if (options.keys == ControlScheme::CURSOR)
{
keys = "CURSORS";
}
else if (options.keys == ctrl_opqa)
else if (options.keys == ControlScheme::OPQA)
{
keys = "O,P AND Q";
}
@@ -108,62 +108,62 @@ void Credits::iniTexts()
#ifndef GAME_CONSOLE
texts_.clear();
texts_.push_back({"", stringToColor(options.palette, "white")});
texts_.push_back({"INSTRUCTIONS:", stringToColor(options.palette, "yellow")});
texts_.push_back({"", stringToColor(options.palette, "white")});
texts_.push_back({"HELP JAILDOC TO GET BACK ALL", stringToColor(options.palette, "white")});
texts_.push_back({"HIS PROJECTS AND GO TO THE", stringToColor(options.palette, "white")});
texts_.push_back({"JAIL TO FINISH THEM", stringToColor(options.palette, "white")});
texts_.push_back({"", stringToColor(options.palette, "white")});
texts_.push_back({"", stringToColor(options.palette, "white")});
texts_.push_back({"", stringToColor(options.video.palette, "white")});
texts_.push_back({"INSTRUCTIONS:", stringToColor(options.video.palette, "yellow")});
texts_.push_back({"", stringToColor(options.video.palette, "white")});
texts_.push_back({"HELP JAILDOC TO GET BACK ALL", stringToColor(options.video.palette, "white")});
texts_.push_back({"HIS PROJECTS AND GO TO THE", stringToColor(options.video.palette, "white")});
texts_.push_back({"JAIL TO FINISH THEM", stringToColor(options.video.palette, "white")});
texts_.push_back({"", stringToColor(options.video.palette, "white")});
texts_.push_back({"", stringToColor(options.video.palette, "white")});
texts_.push_back({"KEYS:", stringToColor(options.palette, "yellow")});
texts_.push_back({"", stringToColor(options.palette, "white")});
texts_.push_back({keys + " TO MOVE AND JUMP", stringToColor(options.palette, "white")});
texts_.push_back({"M TO SWITCH THE MUSIC", stringToColor(options.palette, "white")});
texts_.push_back({"H TO PAUSE THE GAME", stringToColor(options.palette, "white")});
texts_.push_back({"F1-F2 TO CHANGE WINDOWS SIZE", stringToColor(options.palette, "white")});
texts_.push_back({"F3 TO SWITCH TO FULLSCREEN", stringToColor(options.palette, "white")});
texts_.push_back({"B TO TOOGLE THE BORDER SCREEN", stringToColor(options.palette, "white")});
texts_.push_back({"", stringToColor(options.palette, "white")});
texts_.push_back({"", stringToColor(options.palette, "white")});
texts_.push_back({"KEYS:", stringToColor(options.video.palette, "yellow")});
texts_.push_back({"", stringToColor(options.video.palette, "white")});
texts_.push_back({keys + " TO MOVE AND JUMP", stringToColor(options.video.palette, "white")});
texts_.push_back({"M TO SWITCH THE MUSIC", stringToColor(options.video.palette, "white")});
texts_.push_back({"H TO PAUSE THE GAME", stringToColor(options.video.palette, "white")});
texts_.push_back({"F1-F2 TO CHANGE WINDOWS SIZE", stringToColor(options.video.palette, "white")});
texts_.push_back({"F3 TO SWITCH TO FULLSCREEN", stringToColor(options.video.palette, "white")});
texts_.push_back({"B TO TOOGLE THE BORDER SCREEN", stringToColor(options.video.palette, "white")});
texts_.push_back({"", stringToColor(options.video.palette, "white")});
texts_.push_back({"", stringToColor(options.video.palette, "white")});
texts_.push_back({"A GAME BY JAILDESIGNER", stringToColor(options.palette, "yellow")});
texts_.push_back({"MADE ON SUMMER/FALL 2022", stringToColor(options.palette, "yellow")});
texts_.push_back({"", stringToColor(options.palette, "white")});
texts_.push_back({"", stringToColor(options.palette, "white")});
texts_.push_back({"A GAME BY JAILDESIGNER", stringToColor(options.video.palette, "yellow")});
texts_.push_back({"MADE ON SUMMER/FALL 2022", stringToColor(options.video.palette, "yellow")});
texts_.push_back({"", stringToColor(options.video.palette, "white")});
texts_.push_back({"", stringToColor(options.video.palette, "white")});
texts_.push_back({"I LOVE JAILGAMES! ", stringToColor(options.palette, "white")});
texts_.push_back({"", stringToColor(options.palette, "white")});
texts_.push_back({"I LOVE JAILGAMES! ", stringToColor(options.video.palette, "white")});
texts_.push_back({"", stringToColor(options.video.palette, "white")});
#else
texts.clear();
texts.push_back({"", stringToColor(options.palette, "white")});
texts.push_back({"INSTRUCTIONS:", stringToColor(options.palette, "yellow")});
texts.push_back({"", stringToColor(options.palette, "white")});
texts.push_back({"HELP JAILDOC TO GET BACK ALL", stringToColor(options.palette, "white")});
texts.push_back({"HIS PROJECTS AND GO TO THE", stringToColor(options.palette, "white")});
texts.push_back({"JAIL TO FINISH THEM", stringToColor(options.palette, "white")});
texts.push_back({"", stringToColor(options.palette, "white")});
texts.push_back({"", stringToColor(options.palette, "white")});
texts.push_back({"", stringToColor(options.video.palette, "white")});
texts.push_back({"INSTRUCTIONS:", stringToColor(options.video.palette, "yellow")});
texts.push_back({"", stringToColor(options.video.palette, "white")});
texts.push_back({"HELP JAILDOC TO GET BACK ALL", stringToColor(options.video.palette, "white")});
texts.push_back({"HIS PROJECTS AND GO TO THE", stringToColor(options.video.palette, "white")});
texts.push_back({"JAIL TO FINISH THEM", stringToColor(options.video.palette, "white")});
texts.push_back({"", stringToColor(options.video.palette, "white")});
texts.push_back({"", stringToColor(options.video.palette, "white")});
texts.push_back({"KEYS:", stringToColor(options.palette, "yellow")});
texts.push_back({"", stringToColor(options.palette, "white")});
texts.push_back({"B TO JUMP", stringToColor(options.palette, "white")});
texts.push_back({"R TO SWITCH THE MUSIC", stringToColor(options.palette, "white")});
texts.push_back({"L TO SWAP THE COLOR PALETTE", stringToColor(options.palette, "white")});
texts.push_back({"START TO PAUSE", stringToColor(options.palette, "white")});
texts.push_back({"SELECT TO EXIT", stringToColor(options.palette, "white")});
texts.push_back({"", stringToColor(options.palette, "white")});
texts.push_back({"", stringToColor(options.palette, "white")});
texts.push_back({"", stringToColor(options.palette, "white")});
texts.push_back({"KEYS:", stringToColor(options.video.palette, "yellow")});
texts.push_back({"", stringToColor(options.video.palette, "white")});
texts.push_back({"B TO JUMP", stringToColor(options.video.palette, "white")});
texts.push_back({"R TO SWITCH THE MUSIC", stringToColor(options.video.palette, "white")});
texts.push_back({"L TO SWAP THE COLOR PALETTE", stringToColor(options.video.palette, "white")});
texts.push_back({"START TO PAUSE", stringToColor(options.video.palette, "white")});
texts.push_back({"SELECT TO EXIT", stringToColor(options.video.palette, "white")});
texts.push_back({"", stringToColor(options.video.palette, "white")});
texts.push_back({"", stringToColor(options.video.palette, "white")});
texts.push_back({"", stringToColor(options.video.palette, "white")});
texts.push_back({"A GAME BY JAILDESIGNER", stringToColor(options.palette, "yellow")});
texts.push_back({"MADE ON SUMMER/FALL 2022", stringToColor(options.palette, "yellow")});
texts.push_back({"", stringToColor(options.palette, "white")});
texts.push_back({"", stringToColor(options.palette, "white")});
texts.push_back({"A GAME BY JAILDESIGNER", stringToColor(options.video.palette, "yellow")});
texts.push_back({"MADE ON SUMMER/FALL 2022", stringToColor(options.video.palette, "yellow")});
texts.push_back({"", stringToColor(options.video.palette, "white")});
texts.push_back({"", stringToColor(options.video.palette, "white")});
texts.push_back({"I LOVE JAILGAMES! ", stringToColor(options.palette, "white")});
texts.push_back({"", stringToColor(options.palette, "white")});
texts.push_back({"I LOVE JAILGAMES! ", stringToColor(options.video.palette, "white")});
texts.push_back({"", stringToColor(options.video.palette, "white")});
#endif
}
@@ -175,7 +175,7 @@ void Credits::fillTexture()
// Rellena la textura de texto
SDL_SetRenderTarget(renderer_, text_texture_);
color_t c = stringToColor(options.palette, "black");
Color c = stringToColor(options.video.palette, "black");
SDL_SetRenderDrawColor(renderer_, c.r, c.g, c.b, 0xFF);
SDL_RenderClear(renderer_);
@@ -192,7 +192,7 @@ void Credits::fillTexture()
// Escribe el corazón
const int textLenght = text_->lenght(texts_[22].label, 1) - text_->lenght(" ", 1); // Se resta el ultimo caracter que es un espacio
const int posX = ((PLAY_AREA_WIDTH - textLenght) / 2) + textLenght;
text_->writeColored(posX, 176, "}", stringToColor(options.palette, "bright_red"));
text_->writeColored(posX, 176, "}", stringToColor(options.video.palette, "bright_red"));
// Recoloca el sprite del brillo
sprite_->setPosX(posX + 2);
@@ -249,7 +249,7 @@ void Credits::updateCounter()
// Comprueba si ha terminado la sección
if (counter_ > 1200)
{
options.section.name = SECTION_DEMO;
options.section.section = Section::DEMO;
}
}
@@ -309,7 +309,7 @@ void Credits::render()
// Bucle para el logo del juego
void Credits::run()
{
while (options.section.name == SECTION_CREDITS)
while (options.section.section == Section::CREDITS)
{
update();
checkEvents();
@@ -320,6 +320,6 @@ void Credits::run()
// Cambia la paleta
void Credits::switchPalette()
{
options.palette = options.palette == p_zxspectrum ? p_zxarne : p_zxspectrum;
options.video.palette = options.video.palette == Palette::ZXSPECTRUM ? Palette::ZXARNE : Palette::ZXSPECTRUM;
fillTexture();
}