hotkeys F1–F6: notificacions localitzades, centralitzades a global_inputs
This commit is contained in:
+16
-1
@@ -284,4 +284,19 @@ TAULER DE PUNTS
|
||||
CONNECTAT
|
||||
|
||||
## 95 - NOTIFICACIO COMANDAMENT
|
||||
DESCONNECTAT
|
||||
DESCONNECTAT
|
||||
|
||||
## 96 - NOTIFICACIO HOTKEY
|
||||
Zoom
|
||||
|
||||
## 97 - NOTIFICACIO HOTKEY
|
||||
Pantalla completa
|
||||
|
||||
## 98 - NOTIFICACIO HOTKEY
|
||||
Finestra
|
||||
|
||||
## 99 - NOTIFICACIO HOTKEY
|
||||
Shader
|
||||
|
||||
## 100 - NOTIFICACIO HOTKEY
|
||||
Preset
|
||||
+16
-1
@@ -284,4 +284,19 @@ HISCORE TABLE
|
||||
CONNECTED
|
||||
|
||||
## 95 - GAMEPAD NOTIFICATION
|
||||
DISCONNECTED
|
||||
DISCONNECTED
|
||||
|
||||
## 96 - HOTKEY NOTIFICATION
|
||||
Zoom
|
||||
|
||||
## 97 - HOTKEY NOTIFICATION
|
||||
Fullscreen
|
||||
|
||||
## 98 - HOTKEY NOTIFICATION
|
||||
Window
|
||||
|
||||
## 99 - HOTKEY NOTIFICATION
|
||||
Shader
|
||||
|
||||
## 100 - HOTKEY NOTIFICATION
|
||||
Preset
|
||||
+16
-1
@@ -284,4 +284,19 @@ TABLA DE PUNTUACIONES
|
||||
CONECTADO
|
||||
|
||||
## 95 - NOTIFICACION MANDO
|
||||
DESCONECTADO
|
||||
DESCONECTADO
|
||||
|
||||
## 96 - NOTIFICACION HOTKEY
|
||||
Zoom
|
||||
|
||||
## 97 - NOTIFICACION HOTKEY
|
||||
Pantalla completa
|
||||
|
||||
## 98 - NOTIFICACION HOTKEY
|
||||
Ventana
|
||||
|
||||
## 99 - NOTIFICACION HOTKEY
|
||||
Shader
|
||||
|
||||
## 100 - NOTIFICACION HOTKEY
|
||||
Preset
|
||||
@@ -1,37 +1,94 @@
|
||||
#include "core/input/global_inputs.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "core/input/input.h"
|
||||
#include "core/locale/lang.h"
|
||||
#include "core/rendering/screen.h"
|
||||
#include "game/options.hpp"
|
||||
#include "utils/utils.h"
|
||||
|
||||
namespace GlobalInputs {
|
||||
|
||||
namespace {
|
||||
// Índexs de Lang per a les notificacions de hotkey
|
||||
constexpr int LANG_ZOOM = 96;
|
||||
constexpr int LANG_FULLSCREEN = 97;
|
||||
constexpr int LANG_WINDOW = 98;
|
||||
constexpr int LANG_SHADER = 99;
|
||||
constexpr int LANG_PRESET = 100;
|
||||
|
||||
constexpr Uint32 NOTIFY_MS = 1500;
|
||||
const Color BLACK = {0x00, 0x00, 0x00};
|
||||
const Color CYAN = {0x00, 0xFF, 0xFF};
|
||||
const Color YELLOW = {0xFF, 0xE0, 0x40};
|
||||
const Color MAGENTA = {0xFF, 0x00, 0xFF};
|
||||
const Color GREEN = {0x00, 0xFF, 0x80};
|
||||
|
||||
void notifyZoom() {
|
||||
const std::string MSG = Lang::get()->getText(LANG_ZOOM) + " " + std::to_string(Options::window.zoom) + "x";
|
||||
Screen::get()->notify(MSG, YELLOW, BLACK, NOTIFY_MS);
|
||||
}
|
||||
|
||||
void notifyFullscreen() {
|
||||
const int IDX = Options::video.fullscreen ? LANG_FULLSCREEN : LANG_WINDOW;
|
||||
Screen::get()->notify(Lang::get()->getText(IDX), YELLOW, BLACK, NOTIFY_MS);
|
||||
}
|
||||
|
||||
void notifyShaderEnabled() {
|
||||
const std::string STATE = Screen::isShaderEnabled() ? "ON" : "OFF";
|
||||
const std::string MSG = Lang::get()->getText(LANG_SHADER) + " " + STATE;
|
||||
Screen::get()->notify(MSG, CYAN, BLACK, NOTIFY_MS);
|
||||
}
|
||||
|
||||
void notifyShaderType() {
|
||||
const bool IS_CRTPI = Options::video.shader.current_shader == Rendering::ShaderType::CRTPI;
|
||||
const std::string MSG = Lang::get()->getText(LANG_SHADER) + " " + (IS_CRTPI ? "CRTPI" : "POSTFX");
|
||||
Screen::get()->notify(MSG, MAGENTA, BLACK, NOTIFY_MS);
|
||||
}
|
||||
|
||||
void notifyPreset() {
|
||||
const std::string MSG = Lang::get()->getText(LANG_PRESET) + " " + Screen::get()->getCurrentPresetName();
|
||||
Screen::get()->notify(MSG, GREEN, BLACK, NOTIFY_MS);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
auto handle() -> bool {
|
||||
if (Screen::get() == nullptr || Input::get() == nullptr) { return false; }
|
||||
|
||||
if (Input::get()->checkInput(Input::Action::WINDOW_FULLSCREEN, Input::Repeat::OFF)) {
|
||||
Screen::get()->toggleVideoMode();
|
||||
notifyFullscreen();
|
||||
return true;
|
||||
}
|
||||
if (Input::get()->checkInput(Input::Action::WINDOW_DEC_ZOOM, Input::Repeat::OFF)) {
|
||||
Screen::get()->decWindowZoom();
|
||||
if (Screen::get()->decWindowZoom()) {
|
||||
notifyZoom();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (Input::get()->checkInput(Input::Action::WINDOW_INC_ZOOM, Input::Repeat::OFF)) {
|
||||
Screen::get()->incWindowZoom();
|
||||
if (Screen::get()->incWindowZoom()) {
|
||||
notifyZoom();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (Input::get()->checkInput(Input::Action::TOGGLE_SHADER, Input::Repeat::OFF)) {
|
||||
Screen::get()->toggleShaderEnabled();
|
||||
notifyShaderEnabled();
|
||||
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)) {
|
||||
Screen::get()->toggleActiveShader();
|
||||
notifyShaderType();
|
||||
return true;
|
||||
}
|
||||
if (Input::get()->checkInput(Input::Action::NEXT_SHADER_PRESET, Input::Repeat::OFF)) {
|
||||
Screen::get()->nextPreset();
|
||||
if (Screen::get()->nextPreset()) {
|
||||
notifyPreset();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
|
||||
namespace GlobalInputs {
|
||||
// Gestiona els atalls globals disponibles en qualsevol escena: zoom de
|
||||
// finestra (F1/F2), fullscreen (F3), presets de shader (F8/F9), toggle
|
||||
// shader (F10) i tipus de shader POSTFX↔CRTPI (F11). Retorna true si ha
|
||||
// consumit alguna tecla (per si la capa cridant vol suprimir-la del
|
||||
// processament específic de l'escena).
|
||||
// finestra (F1/F2), fullscreen (F3), toggle shader (F4), tipus de shader
|
||||
// POSTFX↔CRTPI (F5) i següent preset (F6). 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;
|
||||
} // namespace GlobalInputs
|
||||
|
||||
@@ -30,7 +30,7 @@ class Lang {
|
||||
static auto nextLanguage(Code c) -> Code; // Devuelve el siguiente idioma del ciclo
|
||||
|
||||
private:
|
||||
static constexpr int MAX_TEXT_STRINGS = 100;
|
||||
static constexpr int MAX_TEXT_STRINGS = 110;
|
||||
|
||||
std::string text_strings_[MAX_TEXT_STRINGS]; // Vector con los textos
|
||||
|
||||
|
||||
@@ -570,10 +570,6 @@ void Screen::setShaderEnabled(bool enabled) {
|
||||
// Si enabled=false, blit() forçarà POSTFX+zero per frame — no cal tocar
|
||||
// res ara.
|
||||
#endif
|
||||
const Color CYAN = {0x00, 0xFF, 0xFF};
|
||||
const Color BLACK = {0x00, 0x00, 0x00};
|
||||
const Uint32 DUR_MS = 1500;
|
||||
notify(enabled ? "Shader: ON" : "Shader: OFF", CYAN, BLACK, DUR_MS);
|
||||
}
|
||||
|
||||
void Screen::toggleShaderEnabled() {
|
||||
@@ -590,10 +586,6 @@ void Screen::setActiveShader(Rendering::ShaderType type) {
|
||||
if (Options::video.shader.enabled) {
|
||||
applyShaderParams();
|
||||
}
|
||||
const Color MAGENTA = {0xFF, 0x00, 0xFF};
|
||||
const Color BLACK = {0x00, 0x00, 0x00};
|
||||
const Uint32 DUR_MS = 1500;
|
||||
notify(type == Rendering::ShaderType::CRTPI ? "Shader: CRTPI" : "Shader: POSTFX", MAGENTA, BLACK, DUR_MS);
|
||||
}
|
||||
|
||||
auto Screen::getActiveShader() -> Rendering::ShaderType {
|
||||
@@ -706,11 +698,6 @@ auto Screen::nextPreset() -> bool {
|
||||
Options::crtpi_presets[Options::current_crtpi_preset].name;
|
||||
applyCurrentCrtPiPreset();
|
||||
}
|
||||
|
||||
const Color GREEN = {0x00, 0xFF, 0x80};
|
||||
const Color BLACK = {0x00, 0x00, 0x00};
|
||||
const Uint32 DUR_MS = 1500;
|
||||
notify(std::string("Preset: ") + getCurrentPresetName(), GREEN, BLACK, DUR_MS);
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
@@ -737,11 +724,6 @@ auto Screen::prevPreset() -> bool {
|
||||
Options::crtpi_presets[Options::current_crtpi_preset].name;
|
||||
applyCurrentCrtPiPreset();
|
||||
}
|
||||
|
||||
const Color GREEN = {0x00, 0xFF, 0x80};
|
||||
const Color BLACK = {0x00, 0x00, 0x00};
|
||||
const Uint32 DUR_MS = 1500;
|
||||
notify(std::string("Preset: ") + getCurrentPresetName(), GREEN, BLACK, DUR_MS);
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user