forked from jaildesigner-jailgames/jaildoctors_dilemma
- afegides noves paletes
- ordenades les paletes que tenien els color mal ubicats - eliminades responsabilitats a Options sobre les paletes - "pretty" name per a les paletes (canvia els "-" per " ") - nova tool/ en python per a reordenar paletes
This commit is contained in:
@@ -119,12 +119,12 @@ namespace GlobalInputs {
|
||||
|
||||
void handleNextPalette() {
|
||||
Screen::get()->nextPalette();
|
||||
Notifier::get()->show({Locale::get()->get("ui.palette") + " " + Options::video.palette}); // NOLINT(readability-static-accessed-through-instance)
|
||||
Notifier::get()->show({Locale::get()->get("ui.palette") + " " + toUpper(Screen::get()->getPalettePrettyName())}); // NOLINT(readability-static-accessed-through-instance)
|
||||
}
|
||||
|
||||
void handlePreviousPalette() {
|
||||
Screen::get()->previousPalette();
|
||||
Notifier::get()->show({Locale::get()->get("ui.palette") + " " + Options::video.palette}); // NOLINT(readability-static-accessed-through-instance)
|
||||
Notifier::get()->show({Locale::get()->get("ui.palette") + " " + toUpper(Screen::get()->getPalettePrettyName())}); // NOLINT(readability-static-accessed-through-instance)
|
||||
}
|
||||
|
||||
void handleToggleIntegerScale() {
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "core/rendering/surface.hpp"
|
||||
#include "core/resources/resource_cache.hpp"
|
||||
#include "game/defaults.hpp"
|
||||
#include "game/options.hpp"
|
||||
#include "utils/utils.hpp"
|
||||
|
||||
@@ -44,9 +45,9 @@ void PaletteManager::previous() {
|
||||
}
|
||||
|
||||
auto PaletteManager::setByName(const std::string& name) -> bool {
|
||||
const std::string upper_name = toUpper(name + ".pal");
|
||||
const std::string lower_name = toLower(name + ".pal");
|
||||
for (size_t i = 0; i < palettes_.size(); ++i) {
|
||||
if (toUpper(palettes_[i]) == upper_name) {
|
||||
if (toLower(palettes_[i]) == lower_name) {
|
||||
current_ = i;
|
||||
apply();
|
||||
return true;
|
||||
@@ -62,7 +63,7 @@ auto PaletteManager::getNames() const -> std::vector<std::string> {
|
||||
std::string name = p;
|
||||
const size_t pos = name.find(".pal");
|
||||
if (pos != std::string::npos) { name.erase(pos, 4); }
|
||||
std::ranges::transform(name, name.begin(), ::toupper);
|
||||
std::ranges::transform(name, name.begin(), ::tolower);
|
||||
names.push_back(std::move(name));
|
||||
}
|
||||
return names;
|
||||
@@ -72,7 +73,13 @@ auto PaletteManager::getCurrentName() const -> std::string {
|
||||
std::string name = palettes_.at(current_);
|
||||
const size_t pos = name.find(".pal");
|
||||
if (pos != std::string::npos) { name.erase(pos, 4); }
|
||||
std::ranges::transform(name, name.begin(), ::toupper);
|
||||
std::ranges::transform(name, name.begin(), ::tolower);
|
||||
return name;
|
||||
}
|
||||
|
||||
auto PaletteManager::getPrettyName() const -> std::string {
|
||||
std::string name = getCurrentName();
|
||||
std::ranges::replace(name, '-', ' ');
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -88,9 +95,16 @@ void PaletteManager::apply() {
|
||||
}
|
||||
|
||||
auto PaletteManager::findIndex(const std::string& name) const -> size_t {
|
||||
const std::string upper_name = toUpper(name + ".pal");
|
||||
const std::string lower_name = toLower(name + ".pal");
|
||||
for (size_t i = 0; i < palettes_.size(); ++i) {
|
||||
if (toUpper(getFileName(palettes_[i])) == upper_name) {
|
||||
if (toLower(getFileName(palettes_[i])) == lower_name) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
// Fallback: buscar la paleta por defecto
|
||||
const std::string default_name = toLower(std::string(Defaults::Video::PALETTE_NAME) + ".pal");
|
||||
for (size_t i = 0; i < palettes_.size(); ++i) {
|
||||
if (toLower(getFileName(palettes_[i])) == default_name) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,8 +21,9 @@ class PaletteManager {
|
||||
void next(); // Avanza a la siguiente paleta
|
||||
void previous(); // Retrocede a la paleta anterior
|
||||
auto setByName(const std::string& name) -> bool; // Cambia a paleta por nombre; false si no existe
|
||||
[[nodiscard]] auto getNames() const -> std::vector<std::string>; // Nombres disponibles (mayúsculas, sin .pal)
|
||||
[[nodiscard]] auto getCurrentName() const -> std::string; // Nombre de la paleta actual (mayúsculas, sin .pal)
|
||||
[[nodiscard]] auto getNames() const -> std::vector<std::string>; // Nombres disponibles (minúsculas, sin .pal)
|
||||
[[nodiscard]] auto getCurrentName() const -> std::string; // Nombre de la paleta actual (minúsculas, sin .pal)
|
||||
[[nodiscard]] auto getPrettyName() const -> std::string; // Nombre actual con guiones sustituidos por espacios
|
||||
|
||||
private:
|
||||
void apply(); // Aplica la paleta actual a ambas surfaces
|
||||
|
||||
@@ -446,8 +446,9 @@ void Screen::renderOverlays() {
|
||||
// Cambia a una paleta por nombre (case-insensitive); devuelve false si no existe
|
||||
auto Screen::setPaletteByName(const std::string& name) -> bool { return palette_manager_->setByName(name); }
|
||||
|
||||
// Devuelve los nombres de paletas disponibles (mayúsculas, sin extensión .pal)
|
||||
// Devuelve los nombres de paletas disponibles (minúsculas, sin extensión .pal)
|
||||
auto Screen::getPaletteNames() const -> std::vector<std::string> { return palette_manager_->getNames(); }
|
||||
auto Screen::getPalettePrettyName() const -> std::string { return palette_manager_->getPrettyName(); }
|
||||
|
||||
// Limpia la game_surface_
|
||||
void Screen::clearSurface(Uint8 index) { game_surface_->clear(index); }
|
||||
|
||||
@@ -57,7 +57,8 @@ class Screen {
|
||||
void nextPalette(); // Cambia a la siguiente paleta
|
||||
void previousPalette(); // Cambia a la paleta anterior
|
||||
auto setPaletteByName(const std::string& name) -> bool; // Cambia a paleta por nombre; false si no existe
|
||||
[[nodiscard]] auto getPaletteNames() const -> std::vector<std::string>; // Nombres disponibles (mayúsculas, sin .pal)
|
||||
[[nodiscard]] auto getPaletteNames() const -> std::vector<std::string>; // Nombres disponibles (minúsculas, sin .pal)
|
||||
[[nodiscard]] auto getPalettePrettyName() const -> std::string; // Nombre actual con guiones sustituidos por espacios
|
||||
void toggleShaders(); // Activa/desactiva todos los shaders respetando current_shader
|
||||
void toggleSupersampling(); // Activa/desactiva el supersampling global
|
||||
void reloadPostFX(); // Recarga el shader del preset actual sin toggle
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "core/input/input_types.hpp" // Para BUTTON_TO_STRING, STRING_TO_BUTTON
|
||||
#include "external/fkyaml_node.hpp" // Para fkyaml::node
|
||||
#include "game/defaults.hpp" // Para GameDefaults::VERSION
|
||||
#include "utils/utils.hpp" // Para toLower
|
||||
|
||||
namespace Options {
|
||||
|
||||
@@ -177,24 +178,6 @@ namespace Options {
|
||||
{"LEFT_STICK_LEFT", 200},
|
||||
{"LEFT_STICK_RIGHT", 201}};
|
||||
|
||||
// Lista de paletas válidas
|
||||
const std::vector<std::string> VALID_PALETTES = {
|
||||
"black-and-white",
|
||||
"green-phosphor",
|
||||
"island-joy-16",
|
||||
"lost-century",
|
||||
"na16",
|
||||
"orange-screen",
|
||||
"pico-8",
|
||||
"ruzx-spectrum",
|
||||
"ruzx-spectrum-revision-2",
|
||||
"steam-lords",
|
||||
"sweetie-16",
|
||||
"sweetie-16_bona",
|
||||
"zx-spectrum",
|
||||
"zx-spectrum-adjusted",
|
||||
"zxarne-5-2"};
|
||||
|
||||
// Funciones helper de conversión
|
||||
auto filterToString(Screen::Filter filter) -> std::string {
|
||||
auto it = FILTER_TO_STRING.find(filter);
|
||||
@@ -257,12 +240,6 @@ namespace Options {
|
||||
}
|
||||
}
|
||||
|
||||
auto isValidPalette(const std::string& palette) -> bool {
|
||||
std::string lower_palette = palette;
|
||||
std::ranges::transform(lower_palette, lower_palette.begin(), ::tolower);
|
||||
return std::ranges::any_of(VALID_PALETTES, [&lower_palette](const auto& valid) { return valid == lower_palette; });
|
||||
}
|
||||
|
||||
// --- Funciones helper para loadFromFile() ---
|
||||
|
||||
// Carga configuración de ventana desde YAML
|
||||
@@ -309,12 +286,12 @@ namespace Options {
|
||||
}
|
||||
}
|
||||
|
||||
// Helper: carga el campo palette con validación extra
|
||||
// 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 = isValidPalette(palette_str) ? palette_str : Defaults::Video::PALETTE_NAME;
|
||||
video.palette = toLower(palette_str);
|
||||
} catch (...) {
|
||||
video.palette = Defaults::Video::PALETTE_NAME;
|
||||
}
|
||||
|
||||
@@ -401,9 +401,7 @@ static const std::vector<ConsoleCommand> COMMANDS = {
|
||||
// PALETTE NEXT/PREV/<nombre> — Paleta de colores (F5/F6 o por nombre)
|
||||
{.keyword = "PALETTE", .execute = [](const std::vector<std::string>& args) -> std::string {
|
||||
const auto palName = []() -> std::string {
|
||||
std::string name = Options::video.palette;
|
||||
std::ranges::transform(name, name.begin(), ::tolower);
|
||||
return name;
|
||||
return Screen::get()->getPalettePrettyName();
|
||||
};
|
||||
if (args.empty()) { return "usage: palette [next|prev|<name>]"; }
|
||||
if (args[0] == "NEXT") {
|
||||
|
||||
Reference in New Issue
Block a user