forked from jaildesigner-jailgames/jaildoctors_dilemma
Ja carrega la ultima paleta seleccionada
This commit is contained in:
@@ -270,7 +270,7 @@ bool setOptions(const std::string &var, const std::string &value)
|
||||
}
|
||||
else
|
||||
{
|
||||
options.video.palette = DEFAULT_PALETTE;
|
||||
options.video.palette = val;
|
||||
}
|
||||
}}};
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer)
|
||||
// Ajusta los tamaños
|
||||
adjustGameCanvasRect();
|
||||
adjustWindowSize();
|
||||
current_palette_ = findPalette(options.video.palette);
|
||||
|
||||
// Define el color del borde para el modo de pantalla completa
|
||||
border_color_ = 1;
|
||||
@@ -77,11 +78,11 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer)
|
||||
|
||||
// Crea la surface donde se dibujan los graficos del juego
|
||||
game_surface_ = std::make_shared<Surface>(options.game.width, options.game.height);
|
||||
game_surface_->loadPalette(palettes_.front());
|
||||
game_surface_->loadPalette(palettes_.at(current_palette_));
|
||||
|
||||
// Crea la surface donde se dibujan los graficos del juego
|
||||
border_surface_ = std::make_shared<Surface>(options.game.width + options.video.border.width * 2, options.game.height + options.video.border.height * 2);
|
||||
border_surface_->loadPalette(palettes_.front());
|
||||
border_surface_->loadPalette(palettes_.at(current_palette_));
|
||||
|
||||
// Establece la surface que actuará como renderer para recibir las llamadas a render()
|
||||
renderer_surface_ = std::make_shared<std::shared_ptr<Surface>>(game_surface_);
|
||||
@@ -403,4 +404,19 @@ void Screen::textureToRenderer()
|
||||
void Screen::renderOverlays()
|
||||
{
|
||||
renderNotifications();
|
||||
}
|
||||
}
|
||||
|
||||
// Localiza la paleta dentro del vector de paletas
|
||||
size_t Screen::findPalette(const std::string &name)
|
||||
{
|
||||
std::string upper_name = toUpper(name + ".gif");
|
||||
|
||||
for (size_t i = 0; i < palettes_.size(); ++i)
|
||||
{
|
||||
if (toUpper(getFileName(palettes_[i])) == upper_name)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return static_cast<size_t>(0);
|
||||
}
|
||||
|
||||
@@ -70,6 +70,9 @@ private:
|
||||
// Renderiza todos los overlays
|
||||
void renderOverlays();
|
||||
|
||||
// Localiza la paleta dentro del vector de paletas
|
||||
size_t findPalette(const std::string& name);
|
||||
|
||||
// Constructor
|
||||
Screen(SDL_Window *window, SDL_Renderer *renderer);
|
||||
|
||||
|
||||
@@ -431,30 +431,20 @@ bool colorAreEqual(Color color1, Color color2)
|
||||
return (r && g && b);
|
||||
}
|
||||
|
||||
// Convierte una cadena a minúsculas
|
||||
std::string toLower(std::string str)
|
||||
// Función para convertir un string a minúsculas
|
||||
std::string toLower(const std::string &str)
|
||||
{
|
||||
for (char &c : str)
|
||||
{
|
||||
if (c >= 'A' && c <= 'Z')
|
||||
{
|
||||
c += 32; // Convierte a minúscula
|
||||
}
|
||||
}
|
||||
return str;
|
||||
std::string lower_str = str;
|
||||
std::transform(lower_str.begin(), lower_str.end(), lower_str.begin(), ::tolower);
|
||||
return lower_str;
|
||||
}
|
||||
|
||||
// Convierte una cadena a mayúsculas
|
||||
std::string toUpper(std::string str)
|
||||
// Función para convertir un string a mayúsculas
|
||||
std::string toUpper(const std::string &str)
|
||||
{
|
||||
for (char &c : str)
|
||||
{
|
||||
if (c >= 'a' && c <= 'z')
|
||||
{
|
||||
c -= 32; // Convierte a mayúscula
|
||||
}
|
||||
}
|
||||
return str;
|
||||
std::string upper_str = str;
|
||||
std::transform(upper_str.begin(), upper_str.end(), upper_str.begin(), ::toupper);
|
||||
return upper_str;
|
||||
}
|
||||
|
||||
// Obtiene el nombre de un fichero a partir de una ruta completa
|
||||
|
||||
@@ -105,10 +105,10 @@ std::string boolToString(bool value);
|
||||
bool colorAreEqual(Color color1, Color color2);
|
||||
|
||||
// Convierte una cadena a minusculas
|
||||
std::string toLower(std::string str);
|
||||
std::string toLower(const std::string& str);
|
||||
|
||||
// Convierte una cadena a mayúsculas
|
||||
std::string toUpper(std::string str);
|
||||
std::string toUpper(const std::string& str);
|
||||
|
||||
// Obtiene el nombre de un fichero a partir de una ruta
|
||||
std::string getFileName(const std::string &path);
|
||||
|
||||
Reference in New Issue
Block a user