les tecles de funcio ja no arriben a jinput
This commit is contained in:
@@ -14,7 +14,9 @@ namespace GlobalInputs {
|
||||
static bool inc_zoom_was_pressed = false;
|
||||
static bool fullscreen_was_pressed = false;
|
||||
|
||||
void handle() {
|
||||
auto handle() -> bool {
|
||||
bool consumed = false;
|
||||
|
||||
// Decrement zoom
|
||||
bool dec_zoom = JI_KeyPressed(Options::keys_gui.dec_zoom);
|
||||
if (dec_zoom && !dec_zoom_was_pressed) {
|
||||
@@ -22,7 +24,9 @@ namespace GlobalInputs {
|
||||
char msg[32];
|
||||
snprintf(msg, sizeof(msg), "ZOOM %dx", Screen::get()->getZoom());
|
||||
Overlay::showNotification(msg);
|
||||
consumed = true;
|
||||
}
|
||||
if (dec_zoom) consumed = true; // Mentres estiga polsada, consumir-la
|
||||
dec_zoom_was_pressed = dec_zoom;
|
||||
|
||||
// Increment zoom
|
||||
@@ -32,7 +36,9 @@ namespace GlobalInputs {
|
||||
char msg[32];
|
||||
snprintf(msg, sizeof(msg), "ZOOM %dx", Screen::get()->getZoom());
|
||||
Overlay::showNotification(msg);
|
||||
consumed = true;
|
||||
}
|
||||
if (inc_zoom) consumed = true;
|
||||
inc_zoom_was_pressed = inc_zoom;
|
||||
|
||||
// Toggle fullscreen
|
||||
@@ -40,8 +46,12 @@ namespace GlobalInputs {
|
||||
if (fullscreen && !fullscreen_was_pressed) {
|
||||
Screen::get()->toggleFullscreen();
|
||||
Overlay::showNotification(Screen::get()->isFullscreen() ? "FULLSCREEN" : "WINDOWED");
|
||||
consumed = true;
|
||||
}
|
||||
if (fullscreen) consumed = true;
|
||||
fullscreen_was_pressed = fullscreen;
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
} // namespace GlobalInputs
|
||||
|
||||
@@ -2,5 +2,6 @@
|
||||
|
||||
namespace GlobalInputs {
|
||||
// Comprovar una vegada per frame, després de JI_Update()
|
||||
void handle();
|
||||
// Retorna true si ha consumit alguna tecla (per suprimir-la de la capa de joc)
|
||||
auto handle() -> bool;
|
||||
} // namespace GlobalInputs
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "core/input/global_inputs.hpp"
|
||||
#include "core/jail/jgame.hpp"
|
||||
#include "game/options.hpp"
|
||||
|
||||
const bool* keystates; // = SDL_GetKeyboardState( NULL );
|
||||
SDL_Event event;
|
||||
@@ -11,6 +12,13 @@ Uint8 cheat[5];
|
||||
bool key_pressed = false;
|
||||
int waitTime = 0;
|
||||
|
||||
// Comprova si un scancode pertany a les tecles reservades per a la GUI
|
||||
static bool isGuiKey(SDL_Scancode sc) {
|
||||
return sc == Options::keys_gui.dec_zoom ||
|
||||
sc == Options::keys_gui.inc_zoom ||
|
||||
sc == Options::keys_gui.fullscreen;
|
||||
}
|
||||
|
||||
void JI_DisableKeyboard(Uint32 time) {
|
||||
waitTime = time;
|
||||
}
|
||||
@@ -32,11 +40,15 @@ void JI_Update() {
|
||||
while (SDL_PollEvent(&event)) {
|
||||
if (event.type == SDL_EVENT_QUIT) JG_QuitSignal();
|
||||
if (event.type == SDL_EVENT_KEY_UP) {
|
||||
key_pressed = true;
|
||||
JI_moveCheats(event.key.scancode);
|
||||
// Si és una tecla GUI, no la passem al joc legacy
|
||||
if (!isGuiKey(event.key.scancode)) {
|
||||
key_pressed = true;
|
||||
JI_moveCheats(event.key.scancode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// GlobalInputs processa les tecles GUI per polling
|
||||
GlobalInputs::handle();
|
||||
}
|
||||
|
||||
|
||||
@@ -13,14 +13,14 @@ namespace Overlay {
|
||||
|
||||
// --- Aspecte de la notificació ---
|
||||
static constexpr Uint32 NOTIF_BG_COLOR = 0xFF2E1A1A; // Fons blau fosc (ABGR)
|
||||
static constexpr Uint32 NOTIF_TEXT_COLOR = 0xFFFFFF00; // Text cyan (ABGR)
|
||||
static constexpr int NOTIF_PADDING_H = 8; // Padding horitzontal (esquerra/dreta dins la caixa)
|
||||
static constexpr int NOTIF_PADDING_V = 4; // Padding vertical (dalt/baix dins la caixa)
|
||||
static constexpr int NOTIF_MARGIN_X = 4; // Offset des de la vora esquerra de la pantalla
|
||||
static constexpr int NOTIF_MARGIN_Y = 4; // Offset des de la vora superior de la pantalla
|
||||
static constexpr Uint32 NOTIF_TEXT_COLOR = 0xFFFFFF00; // Text cyan (ABGR)
|
||||
static constexpr int NOTIF_PADDING_H = 8; // Padding horitzontal (esquerra/dreta dins la caixa)
|
||||
static constexpr int NOTIF_PADDING_V = 4; // Padding vertical (dalt/baix dins la caixa)
|
||||
static constexpr int NOTIF_MARGIN_X = 4; // Offset des de la vora esquerra de la pantalla
|
||||
static constexpr int NOTIF_MARGIN_Y = 4; // Offset des de la vora superior de la pantalla
|
||||
|
||||
// --- Animació ---
|
||||
static constexpr float SLIDE_SPEED = 4.0F; // Velocitat de l'animació (unitats/segon)
|
||||
static constexpr float SLIDE_SPEED = 4.0F; // Velocitat de l'animació (unitats/segon)
|
||||
|
||||
// --- Pantalla ---
|
||||
static constexpr int SCREEN_W = 320;
|
||||
@@ -28,16 +28,19 @@ namespace Overlay {
|
||||
|
||||
// --- Estat de les notificacions ---
|
||||
|
||||
enum class Status { RISING, STAY, VANISHING, FINISHED };
|
||||
enum class Status { RISING,
|
||||
STAY,
|
||||
VANISHING,
|
||||
FINISHED };
|
||||
|
||||
struct Notification {
|
||||
std::string message;
|
||||
Status status{Status::RISING};
|
||||
float anim{0.0F}; // 0 = fora de pantalla, 1 = posició final
|
||||
float anim{0.0F}; // 0 = fora de pantalla, 1 = posició final
|
||||
float timer{0.0F};
|
||||
float duration{2.0F};
|
||||
int box_w{0}; // Ample de la caixa (calculat al crear)
|
||||
int box_h{0}; // Alçada de la caixa (calculat al crear)
|
||||
int box_w{0}; // Ample de la caixa (calculat al crear)
|
||||
int box_h{0}; // Alçada de la caixa (calculat al crear)
|
||||
};
|
||||
|
||||
static std::vector<Notification> notifications_;
|
||||
@@ -119,8 +122,7 @@ namespace Overlay {
|
||||
|
||||
// Elimina les acabades
|
||||
notifications_.erase(
|
||||
std::remove_if(notifications_.begin(), notifications_.end(),
|
||||
[](const Notification& n) { return n.status == Status::FINISHED; }),
|
||||
std::remove_if(notifications_.begin(), notifications_.end(), [](const Notification& n) { return n.status == Status::FINISHED; }),
|
||||
notifications_.end());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user