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.name = SECTION_PROG_LOGO;
section.subsection = SUBSECTION_LOGO_TO_INTRO; 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 // Crea el objeto que controla los ficheros de recursos
asset = new Asset(path.substr(0, path.find_last_of("\\/"))); asset = new Asset(path.substr(0, path.find_last_of("\\/")));

View File

@@ -70,4 +70,19 @@ SDL_Point Item::getPos()
void Item::reLoadTexture() void Item::reLoadTexture()
{ {
texture->reLoad(); 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 // Recarga la textura
void reLoadTexture(); void reLoadTexture();
// Recarga la paleta // Asigna los colores del objeto
void reLoadPalette(palette_e pal); void setColors(color_t col1, color_t col2);
}; };
#endif #endif

View File

@@ -812,7 +812,7 @@ int Room::getSlopeHeight(SDL_Point p, tile_e slope)
debug->add("BASE = " + std::to_string(base)); debug->add("BASE = " + std::to_string(base));
// Calcula cuanto se ha entrado en el tile horizontalmente // 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)); debug->add("POS = " + std::to_string(pos));
// Se resta a la base la cantidad de pixeles pos en funcion de la rampa // 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: case SDL_SCANCODE_F:
screen->switchVideoMode(); screen->switchVideoMode();
texture->reLoad(); reLoadTextures();
break; break;
case SDL_SCANCODE_F1: case SDL_SCANCODE_F1:
screen->setWindowSize(1); screen->setWindowSize(1);
texture->reLoad(); reLoadTextures();
break; break;
case SDL_SCANCODE_F2: case SDL_SCANCODE_F2:
screen->setWindowSize(2); screen->setWindowSize(2);
texture->reLoad(); reLoadTextures();
break; break;
case SDL_SCANCODE_F3: case SDL_SCANCODE_F3:
screen->setWindowSize(3); screen->setWindowSize(3);
texture->reLoad(); reLoadTextures();
break; break;
case SDL_SCANCODE_F4: case SDL_SCANCODE_F4:
screen->setWindowSize(4); screen->setWindowSize(4);
texture->reLoad(); reLoadTextures();
break;
case SDL_SCANCODE_F5:
switchPalette();
reLoadTextures();
break; break;
default: default:
@@ -220,4 +225,34 @@ section_t Title::run()
} }
return section; 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 // Dibuja la marquesina
void renderMarquee(); void renderMarquee();
// Recarga las texturas
void reLoadTextures();
// Cambia la paleta
void switchPalette();
public: public:
// Constructor // Constructor
Title(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options); Title(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options);

View File

@@ -54,6 +54,8 @@ x (B) Así como no necesitar lo de frames per row
x (C) Que no cree la ventana y luego añada el borde x (C) Que no cree la ventana y luego añada el borde
x (A) Las vidas del marcador no estan animadas. No cambian de frame x (A) Las vidas del marcador no estan animadas. No cambian de frame
(A) Mejorar las cintas. no permitir saltar hacia atras (A) Mejorar las cintas. no permitir saltar hacia atras
(A) Cambio de paleta en caliente
(A) Precargar todos los recursos del juego
## TEMAS ## TEMAS