Ja funciona la roda de paletes

This commit is contained in:
2025-03-06 11:45:06 +01:00
parent 10debde847
commit 60c926a9c9
3 changed files with 29 additions and 4 deletions

View File

@@ -92,6 +92,9 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer)
// Muestra la ventana
SDL_SetWindowPosition(window_, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
show();
// Extrae el nombre de las paletas desde su ruta
processPaletteList();
}
// Destructor
@@ -130,12 +133,11 @@ void Screen::startDrawOnBorder()
void Screen::render()
{
// Renderiza sobre game_surface_ los overlays
//renderNotifications();
renderNotifications();
// Copia la surface a game_texture_
game_surface_->copyToTexture(renderer_, game_texture_);
// Si está el borde activo, vuelca gameCanvas sobre borderCanvas
if (options.video.border.enabled)
{
@@ -398,4 +400,25 @@ void Screen::nextPalette()
game_surface_->loadPalette(Resource::get()->getPalette(palettes_.at(current_palette_)));
border_surface_->loadPalette(Resource::get()->getPalette(palettes_.at(current_palette_)));
options.video.palette = palettes_.at(current_palette_);
// Eliminar ".gif"
size_t pos = options.video.palette.find(".gif");
if (pos != std::string::npos)
{
options.video.palette.erase(pos, 4);
}
// Convertir a mayúsculas
std::transform(options.video.palette.begin(), options.video.palette.end(), options.video.palette.begin(), ::toupper);
}
// Extrae los nombres de las paletas
void Screen::processPaletteList()
{
for (auto &palette : palettes_)
{
palette = getFileName(palette);
}
}