skins: SkinManager + hot-swap (F7), classic/nes a data/skins/

This commit is contained in:
2026-05-17 19:54:07 +02:00
parent a40931c7ca
commit ebfcad6f22
125 changed files with 962 additions and 76 deletions
+16
View File
@@ -5,6 +5,8 @@
#include "core/input/input.h"
#include "core/locale/lang.h"
#include "core/rendering/screen.h"
#include "core/resources/resource.h"
#include "core/resources/skin_manager.hpp"
#include "game/options.hpp"
#include "utils/utils.h"
@@ -18,6 +20,7 @@ namespace GlobalInputs {
constexpr int LANG_SHADER = 99;
constexpr int LANG_PRESET = 100;
constexpr int LANG_EXIT_CONFIRM = 101;
constexpr int LANG_SKIN = 102;
constexpr Uint32 NOTIFY_MS = 1500;
constexpr Uint32 EXIT_CONFIRM_MS = 2000;
@@ -63,6 +66,11 @@ namespace GlobalInputs {
Screen::get()->notify(MSG, GREEN, BLACK, NOTIFY_MS);
}
void notifySkin() {
const std::string MSG = Lang::get()->getText(LANG_SKIN) + " " + SkinManager::get()->currentDisplayName();
Screen::get()->notify(MSG, CYAN, BLACK, NOTIFY_MS);
}
void onExit() {
const Uint32 NOW = SDL_GetTicks();
if (NOW < exit_window_until_ticks) {
@@ -117,6 +125,14 @@ namespace GlobalInputs {
return true;
}
}
if (Input::get()->checkInput(Input::Action::NEXT_SKIN, Input::Repeat::OFF)) {
const std::string NEXT_ID = SkinManager::get()->nextSkinId();
if (NEXT_ID != SkinManager::get()->current()) {
Resource::get()->reloadForSkin(NEXT_ID);
}
notifySkin();
return true;
}
return false;
}
+5 -5
View File
@@ -3,11 +3,11 @@
namespace GlobalInputs {
// Gestiona els atalls globals disponibles en qualsevol escena: zoom de
// finestra (F1/F2), fullscreen (F3), toggle shader (F4), tipus de shader
// POSTFX↔CRTPI (F5), següent preset (F6) i la confirmació d'eixida amb
// ESC (Action::EXIT) en dues pulsacions. Cada hotkey emet una
// notificació localitzada. Retorna true si ha consumit alguna tecla (per
// si la capa cridant vol suprimir-la del processament específic de
// l'escena).
// POSTFX↔CRTPI (F5), següent preset (F6), següent skin (F7) i la
// confirmació d'eixida amb ESC (Action::EXIT) en dues pulsacions. Cada
// hotkey emet una notificació localitzada. Retorna true si ha consumit
// alguna tecla (per si la capa cridant vol suprimir-la del processament
// específic de l'escena).
auto handle() -> bool;
// True si la doble pulsació d'ESC s'ha confirmat. Director consulta açò
+8 -5
View File
@@ -50,6 +50,9 @@ class Input {
TOGGLE_SHADER,
TOGGLE_SHADER_TYPE,
// Skins
NEXT_SKIN,
// Centinela final (usar para sizing)
NUMBER_OF_INPUTS
};
@@ -61,12 +64,12 @@ class Input {
~Input(); // Destructor
void update(); // Actualiza el estado del objeto
void update(); // Actualiza el estado del objeto
void bindKey(Action input, SDL_Scancode code); // Asigna inputs a teclas
void bindGameControllerButton(Action input, SDL_GamepadButton button); // Asigna inputs a botones del mando
auto checkInput(Action input, Repeat repeat = Repeat::ON, Device device = Device::ANY, int index = 0) -> bool; // Comprueba si un input esta activo
auto checkAnyInput(Device device = Device::ANY, int index = 0) -> bool; // Comprueba si hay almenos un input activo
auto checkAnyInput(Device device = Device::ANY, int index = 0) -> bool; // Comprueba si hay almenos un input activo
auto discoverGameController() -> bool; // Busca si hay un mando conectado
@@ -82,9 +85,9 @@ class Input {
[[nodiscard]] auto getNumControllers() const -> int; // Obten el numero de mandos conectados
auto getControllerName(int index) -> std::string; // Obten el nombre de un mando de juego
void setVerbose(bool value); // Establece si ha de mostrar mensajes
void disableUntil(Disable value); // Deshabilita las entradas durante un periodo de tiempo
void enable(); // Hablita las entradas
void setVerbose(bool value); // Establece si ha de mostrar mensajes
void disableUntil(Disable value); // Deshabilita las entradas durante un periodo de tiempo
void enable(); // Hablita las entradas
private:
struct KeyBindings {