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

@@ -23,12 +23,12 @@ LoadingScreen::LoadingScreen()
input_(Input::get())
{
// Reserva memoria para los punteros
if (options.palette == p_zxspectrum)
if (options.video.palette == Palette::ZXSPECTRUM)
{
mono_loading_screen_texture_ = resource_->getTexture("loading_screen_bn.png");
color_loading_screen_texture_ = resource_->getTexture("loading_screen_color.png");
}
else if (options.palette == p_zxarne)
else if (options.video.palette == Palette::ZXARNE)
{
mono_loading_screen_texture_ = resource_->getTexture("loading_screen_bn_zxarne.png");
color_loading_screen_texture_ = resource_->getTexture("loading_screen_color_zxarne.png");
@@ -40,8 +40,8 @@ LoadingScreen::LoadingScreen()
loading_sound3_ = JA_LoadMusic(asset_->get("loading_sound3.ogg").c_str());
// Inicializa variables
options.section.name = SECTION_LOADING_SCREEN;
options.section.subsection = 0;
options.section.section = Section::LOADING_SCREEN;
options.section.subsection = Subsection::NONE;
// Establece el orden de las lineas para imitar el direccionamiento de memoria del spectrum
for (int i = 0; i < 192; ++i)
@@ -63,7 +63,7 @@ LoadingScreen::LoadingScreen()
}
// Cambia el color del borde
screen_->setBorderColor(stringToColor(options.palette, "black"));
screen_->setBorderColor(stringToColor(options.video.palette, "black"));
}
// Destructor
@@ -133,8 +133,8 @@ void LoadingScreen::updateLoad()
// Comprueba si ha terminado la intro
if (load_counter_ >= 768)
{
options.section.name = SECTION_TITLE;
options.section.subsection = SUBSECTION_TITLE_WITH_LOADING_SCREEN;
options.section.section = Section::TITLE;
options.section.subsection = Subsection::TITLE_WITH_LOADING_SCREEN;
JA_StopMusic();
}
}
@@ -161,23 +161,16 @@ void LoadingScreen::renderLoad()
void LoadingScreen::renderBorder()
{
// Pinta el borde de colro azul
color_t color = stringToColor(options.palette, "blue");
Color color = stringToColor(options.video.palette, "blue");
SDL_SetRenderDrawColor(renderer_, color.r, color.g, color.b, 0xFF);
SDL_RenderClear(renderer_);
// Añade lineas amarillas
color = stringToColor(options.palette, "yellow");
color = stringToColor(options.video.palette, "yellow");
SDL_SetRenderDrawColor(renderer_, color.r, color.g, color.b, 0xFF);
const int width = GAMECANVAS_WIDTH + (options.borderWidth * 2);
const int height = GAMECANVAS_HEIGHT + (options.borderHeight * 2);
const int width = GAMECANVAS_WIDTH + (options.video.border.width * 2);
const int height = GAMECANVAS_HEIGHT + (options.video.border.height * 2);
bool drawEnabled = rand() % 2 == 0 ? true : false;
// Para (int i = 0; i < height; ++i)
//{
// if (rand() % 2 == 0)
// {
// SDL_RenderDrawLine(renderer, 0, i, width, i);
// }
// }
int row = 0;
int rowSize = 1;
while (row < height)
@@ -218,7 +211,7 @@ void LoadingScreen::update()
// Dibuja en pantalla
void LoadingScreen::render()
{
if (options.borderEnabled)
if (options.video.border.enabled)
{
// Prepara para empezar a dibujar en la textura del borde
screen_->startDrawOnBorder();
@@ -249,7 +242,7 @@ void LoadingScreen::run()
screen_->clean();
screen_->render();
while (options.section.name == SECTION_LOADING_SCREEN)
while (options.section.section == Section::LOADING_SCREEN)
{
update();
checkEvents();
@@ -259,25 +252,6 @@ void LoadingScreen::run()
JA_SetVolume(128);
}
// Cambia la paleta
void LoadingScreen::switchPalette()
{
if (options.palette == p_zxspectrum)
{
options.palette = p_zxarne;
mono_loading_screen_sprite_->setTexture(resource_->getTexture("loading_screen_bn_zxarne.png"));
color_loading_screen_sprite_->setTexture(resource_->getTexture("loading_screen_color_zxarne.png"));
}
else
{
options.palette = p_zxspectrum;
mono_loading_screen_sprite_->setTexture(resource_->getTexture("loading_screen_bn.png"));
color_loading_screen_sprite_->setTexture(resource_->getTexture("loading_screen_color.png"));
}
recreateLoadingScreen();
}
// Reconstruye la pantalla de carga
void LoadingScreen::recreateLoadingScreen()
{