- restaurades les paletes amb la ordenacio original

- afegida opció de reordenar les paletes automaticament per luminositat o paregut a la paleta d'spectrum
This commit is contained in:
2026-04-02 07:59:30 +02:00
parent 3bd13b72cd
commit 015a9cc4e1
32 changed files with 595 additions and 354 deletions

View File

@@ -30,6 +30,7 @@ namespace Defaults::Video {
constexpr bool INTEGER_SCALE = true; // Escalado entero activado por defecto
constexpr bool KEEP_ASPECT = true; // Mantener aspecto activado por defecto
constexpr const char* PALETTE_NAME = "zx-spectrum"; // Paleta por defecto
constexpr const char* PALETTE_SORT = "original"; // Modo de ordenación de paleta por defecto
constexpr bool LINEAR_UPSCALE = false; // Upscale NEAREST por defecto
constexpr int DOWNSCALE_ALGO = 1; // Downscale Lanczos2 por defecto
constexpr bool GPU_ACCELERATION = true; // Aceleración GPU activada por defecto

View File

@@ -288,12 +288,20 @@ namespace Options {
// Helper: carga el campo palette; PaletteManager hará el fallback si el nombre no existe
void loadPaletteFromYaml(const fkyaml::node& vid) {
if (!vid.contains("palette")) { return; }
try {
auto palette_str = vid["palette"].get_value<std::string>();
video.palette = toLower(palette_str);
} catch (...) {
video.palette = Defaults::Video::PALETTE_NAME;
if (vid.contains("palette")) {
try {
auto palette_str = vid["palette"].get_value<std::string>();
video.palette = toLower(palette_str);
} catch (...) {
video.palette = Defaults::Video::PALETTE_NAME;
}
}
if (vid.contains("palette_sort")) {
try {
video.palette_sort = toLower(vid["palette_sort"].get_value<std::string>());
} catch (...) {
video.palette_sort = Defaults::Video::PALETTE_SORT;
}
}
}
@@ -748,6 +756,7 @@ namespace Options {
file << " keep_aspect: " << (video.keep_aspect ? "true" : "false") << "\n";
file << " filter: " << filterToString(video.filter) << " # filter: nearest (pixel perfect) | linear (smooth)\n";
file << " palette: " << video.palette << "\n";
file << " palette_sort: " << video.palette_sort << "\n";
file << " border:\n";
file << " enabled: " << (video.border.enabled ? "true" : "false") << "\n";
file << " width: " << video.border.width << "\n";

View File

@@ -100,17 +100,18 @@ namespace Options {
// Estructura para las opciones de video
struct Video {
bool fullscreen{Defaults::Video::FULLSCREEN}; // Contiene el valor del modo de pantalla completa
Screen::Filter filter{Defaults::Video::FILTER}; // Filtro usado para el escalado de la imagen
bool vertical_sync{Defaults::Video::VERTICAL_SYNC}; // Indica si se quiere usar vsync o no
bool integer_scale{Defaults::Video::INTEGER_SCALE}; // Indica si el escalado de la imagen ha de ser entero en el modo a pantalla completa
bool keep_aspect{Defaults::Video::KEEP_ASPECT}; // Indica si se ha de mantener la relación de aspecto al poner el modo a pantalla completa
std::string palette{Defaults::Video::PALETTE_NAME}; // Paleta de colores a usar en el juego
std::string info; // Información sobre el modo de vídeo
Border border{}; // Borde de la pantalla
GPU gpu{}; // Opciones de aceleración GPU
Supersampling supersampling{}; // Opciones de supersampling
ShaderConfig shader{}; // Opciones de shader post-procesado
bool fullscreen{Defaults::Video::FULLSCREEN}; // Contiene el valor del modo de pantalla completa
Screen::Filter filter{Defaults::Video::FILTER}; // Filtro usado para el escalado de la imagen
bool vertical_sync{Defaults::Video::VERTICAL_SYNC}; // Indica si se quiere usar vsync o no
bool integer_scale{Defaults::Video::INTEGER_SCALE}; // Indica si el escalado de la imagen ha de ser entero en el modo a pantalla completa
bool keep_aspect{Defaults::Video::KEEP_ASPECT}; // Indica si se ha de mantener la relación de aspecto al poner el modo a pantalla completa
std::string palette{Defaults::Video::PALETTE_NAME}; // Paleta de colores a usar en el juego
std::string palette_sort{Defaults::Video::PALETTE_SORT}; // Modo de ordenación de la paleta (original/luminance/spectrum)
std::string info; // Información sobre el modo de vídeo
Border border{}; // Borde de la pantalla
GPU gpu{}; // Opciones de aceleración GPU
Supersampling supersampling{}; // Opciones de supersampling
ShaderConfig shader{}; // Opciones de shader post-procesado
};
// Estructura para las opciones de musica

View File

@@ -333,12 +333,12 @@ static auto cmd_driver(const std::vector<std::string>& args) -> std::string {
return "Driver: " + driver_lower + " (restart)";
}
// PALETTE NEXT/PREV/<name>
// PALETTE NEXT/PREV/SORT/DEFAULT/<name>
static auto cmd_palette(const std::vector<std::string>& args) -> std::string {
const auto palName = []() -> std::string {
return Screen::get()->getPalettePrettyName();
};
if (args.empty()) { return "usage: palette [next|prev|<name>]"; }
if (args.empty()) { return "usage: palette [next|prev|sort [original|luminance|spectrum]|default|<name>]"; }
if (args[0] == "NEXT") {
Screen::get()->nextPalette();
return "Palette: " + palName();
@@ -347,6 +347,26 @@ static auto cmd_palette(const std::vector<std::string>& args) -> std::string {
Screen::get()->previousPalette();
return "Palette: " + palName();
}
if (args[0] == "DEFAULT") {
Screen::get()->setPaletteByName(Defaults::Video::PALETTE_NAME);
return "Palette: " + palName();
}
if (args[0] == "SORT") {
if (args.size() == 1) {
Screen::get()->nextPaletteSortMode();
return "Palette sort: " + Screen::get()->getPaletteSortModeName();
}
if (args[1] == "ORIGINAL") {
Screen::get()->setPaletteSortMode(PaletteSortMode::ORIGINAL);
} else if (args[1] == "LUMINANCE") {
Screen::get()->setPaletteSortMode(PaletteSortMode::LUMINANCE);
} else if (args[1] == "SPECTRUM") {
Screen::get()->setPaletteSortMode(PaletteSortMode::SPECTRUM);
} else {
return "Unknown sort mode. Use: original, luminance, spectrum";
}
return "Palette sort: " + Screen::get()->getPaletteSortModeName();
}
if (!Screen::get()->setPaletteByName(args[0])) {
std::string arg_lower = args[0];
std::ranges::transform(arg_lower, arg_lower.begin(), ::tolower);
@@ -815,7 +835,7 @@ void CommandRegistry::registerHandlers() {
// Proveedores de completions dinámicas
// PALETTE: NEXT, PREV + nombres de paletas disponibles (UPPERCASE)
dynamic_providers_["PALETTE"] = []() -> std::vector<std::string> {
std::vector<std::string> result = {"NEXT", "PREV"};
std::vector<std::string> result = {"NEXT", "PREV", "SORT", "DEFAULT"};
if (Screen::get() != nullptr) {
for (const auto& name : Screen::get()->getPaletteNames()) {
result.push_back(toUpper(name));