Arreglado el cambio de paleta en el titulo

This commit is contained in:
2022-10-26 09:19:46 +02:00
parent 0f443b38bc
commit 57e8c0cb56
7 changed files with 67 additions and 9 deletions

View File

@@ -9,7 +9,7 @@ Director::Director(std::string path)
section.name = SECTION_PROG_LOGO;
section.subsection = SUBSECTION_LOGO_TO_INTRO;
section.name = SECTION_PROG_LOGO;
section.name = SECTION_PROG_TITLE;
// Crea el objeto que controla los ficheros de recursos
asset = new Asset(path.substr(0, path.find_last_of("\\/")));

View File

@@ -70,4 +70,19 @@ SDL_Point Item::getPos()
void Item::reLoadTexture()
{
texture->reLoad();
}
// Asigna los colores del objeto
void Item::setColors(color_t col1, color_t col2)
{
// Reinicializa el vector de colores
color.clear();
// Añade el primer color
color.push_back(col1);
color.push_back(col1);
// Añade el segundo color
color.push_back(col2);
color.push_back(col2);
}

View File

@@ -59,8 +59,8 @@ public:
// Recarga la textura
void reLoadTexture();
// Recarga la paleta
void reLoadPalette(palette_e pal);
// Asigna los colores del objeto
void setColors(color_t col1, color_t col2);
};
#endif

View File

@@ -812,7 +812,7 @@ int Room::getSlopeHeight(SDL_Point p, tile_e slope)
debug->add("BASE = " + std::to_string(base));
// Calcula cuanto se ha entrado en el tile horizontalmente
const int pos = (p.x % tileSize); // esto da un valor entre 0 y 7
const int pos = (p.x % tileSize); // Esto da un valor entre 0 y 7
debug->add("POS = " + std::to_string(pos));
// Se resta a la base la cantidad de pixeles pos en funcion de la rampa

View File

@@ -82,27 +82,32 @@ void Title::checkEventHandler()
case SDL_SCANCODE_F:
screen->switchVideoMode();
texture->reLoad();
reLoadTextures();
break;
case SDL_SCANCODE_F1:
screen->setWindowSize(1);
texture->reLoad();
reLoadTextures();
break;
case SDL_SCANCODE_F2:
screen->setWindowSize(2);
texture->reLoad();
reLoadTextures();
break;
case SDL_SCANCODE_F3:
screen->setWindowSize(3);
texture->reLoad();
reLoadTextures();
break;
case SDL_SCANCODE_F4:
screen->setWindowSize(4);
texture->reLoad();
reLoadTextures();
break;
case SDL_SCANCODE_F5:
switchPalette();
reLoadTextures();
break;
default:
@@ -220,4 +225,34 @@ section_t Title::run()
}
return section;
}
// Recarga las texturas
void Title::reLoadTextures()
{
// Carga la textura adecuada
if (options->palette == p_zxspectrum)
{
texture->loadFromFile(asset->get("loading_screen_color.png"), renderer);
}
else if (options->palette == p_zxarne)
{
texture->loadFromFile(asset->get("loading_screen_color_zxarne.png"), renderer);
}
}
// Cambia la paleta
void Title::switchPalette()
{
if (options->palette == p_zxspectrum)
{
options->palette = p_zxarne;
}
else
{
options->palette = p_zxspectrum;
}
// Cambia el color del borde
screen->setBorderColor(stringToColor(options->palette, "bright_blue"));
}

View File

@@ -56,6 +56,12 @@ private:
// Dibuja la marquesina
void renderMarquee();
// Recarga las texturas
void reLoadTextures();
// Cambia la paleta
void switchPalette();
public:
// Constructor
Title(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options);