screen torna llista de paletes i permet canviar a una paleta pel nom
console 2.1 por canviar de paleta pel nom
This commit is contained in:
@@ -482,6 +482,33 @@ auto Screen::findPalette(const std::string& name) -> size_t { // NOLINT(readabi
|
|||||||
return static_cast<size_t>(0);
|
return static_cast<size_t>(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cambia a una paleta por nombre (case-insensitive); devuelve false si no existe
|
||||||
|
bool Screen::setPaletteByName(const std::string& name) {
|
||||||
|
const std::string upper_name = toUpper(name + ".pal");
|
||||||
|
for (size_t i = 0; i < palettes_.size(); ++i) {
|
||||||
|
if (toUpper(getFileName(palettes_[i])) == upper_name) {
|
||||||
|
current_palette_ = static_cast<Uint8>(i);
|
||||||
|
setPalete();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Devuelve los nombres de paletas disponibles (mayúsculas, sin extensión .pal)
|
||||||
|
auto Screen::getPaletteNames() const -> std::vector<std::string> {
|
||||||
|
std::vector<std::string> names;
|
||||||
|
names.reserve(palettes_.size());
|
||||||
|
for (const auto& p : palettes_) {
|
||||||
|
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);
|
||||||
|
names.push_back(std::move(name));
|
||||||
|
}
|
||||||
|
return names;
|
||||||
|
}
|
||||||
|
|
||||||
// Limpia la game_surface_
|
// Limpia la game_surface_
|
||||||
void Screen::clearSurface(Uint8 index) { game_surface_->clear(index); }
|
void Screen::clearSurface(Uint8 index) { game_surface_->clear(index); }
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,8 @@ class Screen {
|
|||||||
void nextPalette(); // Cambia a la siguiente paleta
|
void nextPalette(); // Cambia a la siguiente paleta
|
||||||
void previousPalette(); // Cambia a la paleta anterior
|
void previousPalette(); // Cambia a la paleta anterior
|
||||||
void setPalete(); // Establece la paleta actual
|
void setPalete(); // Establece la paleta actual
|
||||||
|
bool setPaletteByName(const std::string& name); // Cambia a paleta por nombre; false si no existe
|
||||||
|
[[nodiscard]] auto getPaletteNames() const -> std::vector<std::string>; // Nombres disponibles (mayúsculas, sin .pal)
|
||||||
void toggleShaders(); // Activa/desactiva todos los shaders respetando current_shader
|
void toggleShaders(); // Activa/desactiva todos los shaders respetando current_shader
|
||||||
void toggleSupersampling(); // Activa/desactiva el supersampling global
|
void toggleSupersampling(); // Activa/desactiva el supersampling global
|
||||||
void reloadPostFX(); // Recarga el shader del preset actual sin toggle
|
void reloadPostFX(); // Recarga el shader del preset actual sin toggle
|
||||||
|
|||||||
@@ -369,9 +369,9 @@ static const std::vector<ConsoleCommand> COMMANDS = {
|
|||||||
return "Driver: " + driver_lower + " (restart)";
|
return "Driver: " + driver_lower + " (restart)";
|
||||||
}},
|
}},
|
||||||
|
|
||||||
// PALETTE NEXT/PREV — Paleta de colores (F5/F6)
|
// PALETTE NEXT/PREV/<nombre> — Paleta de colores (F5/F6 o por nombre)
|
||||||
{.keyword = "PALETTE", .execute = [](const std::vector<std::string>& args) -> std::string {
|
{.keyword = "PALETTE", .execute = [](const std::vector<std::string>& args) -> std::string {
|
||||||
if (args.empty()) { return "usage: palette [next|prev]"; }
|
if (args.empty()) { return "usage: palette [next|prev|<name>]"; }
|
||||||
if (args[0] == "NEXT") {
|
if (args[0] == "NEXT") {
|
||||||
Screen::get()->nextPalette();
|
Screen::get()->nextPalette();
|
||||||
return "Palette: " + Options::video.palette;
|
return "Palette: " + Options::video.palette;
|
||||||
@@ -380,7 +380,10 @@ static const std::vector<ConsoleCommand> COMMANDS = {
|
|||||||
Screen::get()->previousPalette();
|
Screen::get()->previousPalette();
|
||||||
return "Palette: " + Options::video.palette;
|
return "Palette: " + Options::video.palette;
|
||||||
}
|
}
|
||||||
return "usage: palette [next|prev]";
|
if (!Screen::get()->setPaletteByName(args[0])) {
|
||||||
|
return "Unknown palette: " + args[0];
|
||||||
|
}
|
||||||
|
return "Palette: " + Options::video.palette;
|
||||||
}},
|
}},
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
@@ -1160,7 +1163,6 @@ void Console::handleEvent(const SDL_Event& event) {
|
|||||||
{"INTSCALE", {"ON", "OFF"}},
|
{"INTSCALE", {"ON", "OFF"}},
|
||||||
{"VSYNC", {"ON", "OFF"}},
|
{"VSYNC", {"ON", "OFF"}},
|
||||||
{"DRIVER", {"LIST", "AUTO", "NONE"}},
|
{"DRIVER", {"LIST", "AUTO", "NONE"}},
|
||||||
{"PALETTE", {"NEXT", "PREV"}},
|
|
||||||
{"AUDIO", {"ON", "OFF", "VOL"}},
|
{"AUDIO", {"ON", "OFF", "VOL"}},
|
||||||
{"MUSIC", {"ON", "OFF", "VOL"}},
|
{"MUSIC", {"ON", "OFF", "VOL"}},
|
||||||
{"SOUND", {"ON", "OFF", "VOL"}},
|
{"SOUND", {"ON", "OFF", "VOL"}},
|
||||||
@@ -1180,6 +1182,19 @@ void Console::handleEvent(const SDL_Event& event) {
|
|||||||
};
|
};
|
||||||
const std::string base_cmd = upper.substr(0, space_pos);
|
const std::string base_cmd = upper.substr(0, space_pos);
|
||||||
const std::string sub_prefix = upper.substr(space_pos + 1);
|
const std::string sub_prefix = upper.substr(space_pos + 1);
|
||||||
|
if (base_cmd == "PALETTE" && Screen::get() != nullptr) {
|
||||||
|
// NEXT/PREV primero, luego todos los nombres de paleta disponibles
|
||||||
|
for (const auto sv : {"NEXT", "PREV"}) {
|
||||||
|
if (sub_prefix.empty() || std::string_view{sv}.starts_with(sub_prefix)) {
|
||||||
|
tab_matches_.emplace_back("PALETTE " + std::string(sv));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const auto& name : Screen::get()->getPaletteNames()) {
|
||||||
|
if (sub_prefix.empty() || std::string_view{name}.starts_with(sub_prefix)) {
|
||||||
|
tab_matches_.emplace_back("PALETTE " + name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
for (const auto& [keyword, args] : SUB_ARGS) {
|
for (const auto& [keyword, args] : SUB_ARGS) {
|
||||||
if (keyword == base_cmd) {
|
if (keyword == base_cmd) {
|
||||||
for (const auto& arg : args) {
|
for (const auto& arg : args) {
|
||||||
@@ -1191,6 +1206,7 @@ void Console::handleEvent(const SDL_Event& event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
tab_index_ = -1;
|
tab_index_ = -1;
|
||||||
}
|
}
|
||||||
if (tab_matches_.empty()) { break; }
|
if (tab_matches_.empty()) { break; }
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
namespace Texts {
|
namespace Texts {
|
||||||
constexpr const char* WINDOW_CAPTION = "© 2022 JailDoctor's Dilemma — JailDesigner";
|
constexpr const char* WINDOW_CAPTION = "© 2022 JailDoctor's Dilemma — JailDesigner";
|
||||||
constexpr const char* COPYRIGHT = "@2022 JailDesigner";
|
constexpr const char* COPYRIGHT = "@2022 JailDesigner";
|
||||||
constexpr const char* VERSION = "1.10"; // Versión por defecto
|
constexpr const char* VERSION = "1.11"; // Versión por defecto
|
||||||
} // namespace Texts
|
} // namespace Texts
|
||||||
|
|
||||||
// Tamaño de bloque
|
// Tamaño de bloque
|
||||||
|
|||||||
Reference in New Issue
Block a user