hotkeys F1–F6: notificacions localitzades, centralitzades a global_inputs
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user