From 984d1fca5048b7ad91940dcea15ea19ef200e143 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Tue, 19 May 2026 20:04:12 +0200 Subject: [PATCH] hotkey: F11 mostra notificacio blava amb 'AppName vX.Y.Z (githash)' --- source/core/input/global_inputs.cpp | 12 ++++++++++++ source/core/input/input.h | 13 ++++++++----- source/core/system/director.cpp | 1 + 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/source/core/input/global_inputs.cpp b/source/core/input/global_inputs.cpp index 805b825..bdbfb06 100644 --- a/source/core/input/global_inputs.cpp +++ b/source/core/input/global_inputs.cpp @@ -7,6 +7,8 @@ #include "core/rendering/notifications.hpp" #include "core/rendering/screen.h" #include "game/options.hpp" +#include "utils/defines.hpp" +#include "version.h" namespace GlobalInputs { @@ -54,6 +56,12 @@ namespace GlobalInputs { Notifications::show(MSG, Notifications::Palette::SUCCESS, Notifications::STANDARD_MS); } + void notifyVersion() { + // Format: " v ()" + const std::string MSG = std::string(Version::APP_NAME) + " v" + Texts::VERSION + " (" + Version::GIT_HASH + ")"; + Notifications::show(MSG, Notifications::Palette::TOGGLE, Notifications::LONG_MS); + } + void onExit() { const Uint32 NOW = SDL_GetTicks(); if (NOW < exit_window_until_ticks) { @@ -94,6 +102,10 @@ namespace GlobalInputs { notifyShaderEnabled(); return true; } + if (Input::get()->checkInput(Input::Action::SHOW_VERSION, Input::Repeat::OFF)) { + notifyVersion(); + return true; + } // F5/F6 només actuen quan el post-procesado està actiu. if (Screen::isShaderEnabled()) { if (Input::get()->checkInput(Input::Action::TOGGLE_SHADER_TYPE, Input::Repeat::OFF)) { diff --git a/source/core/input/input.h b/source/core/input/input.h index 9989bb8..20cf3b8 100644 --- a/source/core/input/input.h +++ b/source/core/input/input.h @@ -50,6 +50,9 @@ class Input { TOGGLE_SHADER, TOGGLE_SHADER_TYPE, + // Diagnostic + SHOW_VERSION, + // 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 { diff --git a/source/core/system/director.cpp b/source/core/system/director.cpp index d077248..7649521 100644 --- a/source/core/system/director.cpp +++ b/source/core/system/director.cpp @@ -232,6 +232,7 @@ void Director::initInput() { Input::get()->bindKey(Input::Action::TOGGLE_SHADER, SDL_SCANCODE_F4); Input::get()->bindKey(Input::Action::TOGGLE_SHADER_TYPE, SDL_SCANCODE_F5); Input::get()->bindKey(Input::Action::NEXT_SHADER_PRESET, SDL_SCANCODE_F6); + Input::get()->bindKey(Input::Action::SHOW_VERSION, SDL_SCANCODE_F11); // Mando - Movimiento del jugador Input::get()->bindGameControllerButton(Input::Action::UP, SDL_GAMEPAD_BUTTON_DPAD_UP);