fix: tidy gamepad/overlay/jfile (statics sense sufix, locals UPPER_CASE)
This commit is contained in:
@@ -11,8 +11,8 @@
|
|||||||
|
|
||||||
namespace Gamepad {
|
namespace Gamepad {
|
||||||
|
|
||||||
static SDL_Gamepad* pad_ = nullptr;
|
static SDL_Gamepad* pad = nullptr;
|
||||||
static SDL_JoystickID pad_id_ = 0;
|
static SDL_JoystickID pad_id = 0;
|
||||||
|
|
||||||
// Emscripten-only: SDL 3.4+ ja no casa el GUID dels mandos web (el gamepad.id
|
// Emscripten-only: SDL 3.4+ ja no casa el GUID dels mandos web (el gamepad.id
|
||||||
// de Chrome/Android no porta Vendor/Product, el parser extreu valors
|
// de Chrome/Android no porta Vendor/Product, el parser extreu valors
|
||||||
@@ -54,9 +54,9 @@ namespace Gamepad {
|
|||||||
// elimina espais finals i talla a 25 caràcters.
|
// elimina espais finals i talla a 25 caràcters.
|
||||||
static auto prettyName(const char* raw) -> std::string {
|
static auto prettyName(const char* raw) -> std::string {
|
||||||
std::string name = ((raw != nullptr) && (*raw != 0)) ? raw : "Gamepad";
|
std::string name = ((raw != nullptr) && (*raw != 0)) ? raw : "Gamepad";
|
||||||
const auto pos = name.find_first_of("([");
|
const auto POS = name.find_first_of("([");
|
||||||
if (pos != std::string::npos) {
|
if (POS != std::string::npos) {
|
||||||
name.erase(pos);
|
name.erase(POS);
|
||||||
}
|
}
|
||||||
while (!name.empty() && name.back() == ' ') {
|
while (!name.empty() && name.back() == ' ') {
|
||||||
name.pop_back();
|
name.pop_back();
|
||||||
@@ -74,16 +74,16 @@ namespace Gamepad {
|
|||||||
static constexpr Sint16 STICK_DEADZONE = 12000;
|
static constexpr Sint16 STICK_DEADZONE = 12000;
|
||||||
|
|
||||||
// Estat previ per a detecció de flanc (edge-triggered)
|
// Estat previ per a detecció de flanc (edge-triggered)
|
||||||
static bool prev_up_ = false;
|
static bool prev_up = false;
|
||||||
static bool prev_down_ = false;
|
static bool prev_down = false;
|
||||||
static bool prev_left_ = false;
|
static bool prev_left = false;
|
||||||
static bool prev_right_ = false;
|
static bool prev_right = false;
|
||||||
static bool prev_south_ = false;
|
static bool prev_south = false;
|
||||||
static bool prev_east_ = false;
|
static bool prev_east = false;
|
||||||
static bool prev_west_ = false;
|
static bool prev_west = false;
|
||||||
static bool prev_north_ = false;
|
static bool prev_north = false;
|
||||||
static bool prev_start_ = false;
|
static bool prev_start = false;
|
||||||
static bool prev_back_ = false;
|
static bool prev_back = false;
|
||||||
|
|
||||||
static void notify(const std::string& name, const char* status_key) {
|
static void notify(const std::string& name, const char* status_key) {
|
||||||
std::string msg = name.empty() ? "Gamepad" : name;
|
std::string msg = name.empty() ? "Gamepad" : name;
|
||||||
@@ -106,10 +106,10 @@ namespace Gamepad {
|
|||||||
if (!SDL_IsGamepad(ids[i])) {
|
if (!SDL_IsGamepad(ids[i])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
pad_ = SDL_OpenGamepad(ids[i]);
|
pad = SDL_OpenGamepad(ids[i]);
|
||||||
if (pad_ != nullptr) {
|
if (pad != nullptr) {
|
||||||
pad_id_ = ids[i];
|
pad_id = ids[i];
|
||||||
SDL_Log("Gamepad connectat: %s", SDL_GetGamepadName(pad_));
|
SDL_Log("Gamepad connectat: %s", SDL_GetGamepadName(pad));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -132,16 +132,16 @@ namespace Gamepad {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void destroy() {
|
void destroy() {
|
||||||
if (pad_ != nullptr) {
|
if (pad != nullptr) {
|
||||||
SDL_CloseGamepad(pad_);
|
SDL_CloseGamepad(pad);
|
||||||
pad_ = nullptr;
|
pad = nullptr;
|
||||||
pad_id_ = 0;
|
pad_id = 0;
|
||||||
}
|
}
|
||||||
SDL_QuitSubSystem(SDL_INIT_GAMEPAD);
|
SDL_QuitSubSystem(SDL_INIT_GAMEPAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto isConnected() -> bool {
|
auto isConnected() -> bool {
|
||||||
return pad_ != nullptr;
|
return pad != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleEvent(const SDL_Event& event) {
|
void handleEvent(const SDL_Event& event) {
|
||||||
@@ -149,27 +149,27 @@ namespace Gamepad {
|
|||||||
// GAMEPAD_ADDED) perquè SDL no reconeix el GUID. Escoltem els dos i
|
// GAMEPAD_ADDED) perquè SDL no reconeix el GUID. Escoltem els dos i
|
||||||
// injectem el mapping estàndard abans d'obrir el mando.
|
// injectem el mapping estàndard abans d'obrir el mando.
|
||||||
if (event.type == SDL_EVENT_GAMEPAD_ADDED || event.type == SDL_EVENT_JOYSTICK_ADDED) {
|
if (event.type == SDL_EVENT_GAMEPAD_ADDED || event.type == SDL_EVENT_JOYSTICK_ADDED) {
|
||||||
if (pad_ == nullptr) {
|
if (pad == nullptr) {
|
||||||
SDL_JoystickID jid = event.jdevice.which;
|
SDL_JoystickID jid = event.jdevice.which;
|
||||||
installWebStandardMapping(jid);
|
installWebStandardMapping(jid);
|
||||||
if (!SDL_IsGamepad(jid)) {
|
if (!SDL_IsGamepad(jid)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pad_ = SDL_OpenGamepad(jid);
|
pad = SDL_OpenGamepad(jid);
|
||||||
if (pad_ != nullptr) {
|
if (pad != nullptr) {
|
||||||
pad_id_ = jid;
|
pad_id = jid;
|
||||||
std::string name = prettyName(SDL_GetGamepadName(pad_));
|
std::string name = prettyName(SDL_GetGamepadName(pad));
|
||||||
SDL_Log("Gamepad connectat: %s", name.c_str());
|
SDL_Log("Gamepad connectat: %s", name.c_str());
|
||||||
notifyConnected(name);
|
notifyConnected(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (event.type == SDL_EVENT_GAMEPAD_REMOVED || event.type == SDL_EVENT_JOYSTICK_REMOVED) {
|
} else if (event.type == SDL_EVENT_GAMEPAD_REMOVED || event.type == SDL_EVENT_JOYSTICK_REMOVED) {
|
||||||
if ((pad_ != nullptr) && event.jdevice.which == pad_id_) {
|
if ((pad != nullptr) && event.jdevice.which == pad_id) {
|
||||||
std::string saved_name = prettyName(SDL_GetGamepadName(pad_));
|
std::string saved_name = prettyName(SDL_GetGamepadName(pad));
|
||||||
SDL_Log("Gamepad desconnectat: %s", saved_name.c_str());
|
SDL_Log("Gamepad desconnectat: %s", saved_name.c_str());
|
||||||
SDL_CloseGamepad(pad_);
|
SDL_CloseGamepad(pad);
|
||||||
pad_ = nullptr;
|
pad = nullptr;
|
||||||
pad_id_ = 0;
|
pad_id = 0;
|
||||||
// Neteja qualsevol tecla virtual que poguera estar premuda
|
// Neteja qualsevol tecla virtual que poguera estar premuda
|
||||||
JI_SetVirtualKey(SDL_SCANCODE_UP, JI_VSRC_GAMEPAD, false);
|
JI_SetVirtualKey(SDL_SCANCODE_UP, JI_VSRC_GAMEPAD, false);
|
||||||
JI_SetVirtualKey(SDL_SCANCODE_DOWN, JI_VSRC_GAMEPAD, false);
|
JI_SetVirtualKey(SDL_SCANCODE_DOWN, JI_VSRC_GAMEPAD, false);
|
||||||
@@ -196,19 +196,19 @@ namespace Gamepad {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void update() {
|
void update() {
|
||||||
if (pad_ == nullptr) {
|
if (pad == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// D-pad
|
// D-pad
|
||||||
bool dup = SDL_GetGamepadButton(pad_, SDL_GAMEPAD_BUTTON_DPAD_UP);
|
bool dup = SDL_GetGamepadButton(pad, SDL_GAMEPAD_BUTTON_DPAD_UP);
|
||||||
bool ddn = SDL_GetGamepadButton(pad_, SDL_GAMEPAD_BUTTON_DPAD_DOWN);
|
bool ddn = SDL_GetGamepadButton(pad, SDL_GAMEPAD_BUTTON_DPAD_DOWN);
|
||||||
bool dlt = SDL_GetGamepadButton(pad_, SDL_GAMEPAD_BUTTON_DPAD_LEFT);
|
bool dlt = SDL_GetGamepadButton(pad, SDL_GAMEPAD_BUTTON_DPAD_LEFT);
|
||||||
bool drt = SDL_GetGamepadButton(pad_, SDL_GAMEPAD_BUTTON_DPAD_RIGHT);
|
bool drt = SDL_GetGamepadButton(pad, SDL_GAMEPAD_BUTTON_DPAD_RIGHT);
|
||||||
|
|
||||||
// Stick esquerre amb dead-zone
|
// Stick esquerre amb dead-zone
|
||||||
Sint16 lx = SDL_GetGamepadAxis(pad_, SDL_GAMEPAD_AXIS_LEFTX);
|
Sint16 lx = SDL_GetGamepadAxis(pad, SDL_GAMEPAD_AXIS_LEFTX);
|
||||||
Sint16 ly = SDL_GetGamepadAxis(pad_, SDL_GAMEPAD_AXIS_LEFTY);
|
Sint16 ly = SDL_GetGamepadAxis(pad, SDL_GAMEPAD_AXIS_LEFTY);
|
||||||
bool sup = ly < -STICK_DEADZONE;
|
bool sup = ly < -STICK_DEADZONE;
|
||||||
bool sdn = ly > STICK_DEADZONE;
|
bool sdn = ly > STICK_DEADZONE;
|
||||||
bool slt = lx < -STICK_DEADZONE;
|
bool slt = lx < -STICK_DEADZONE;
|
||||||
@@ -220,41 +220,41 @@ namespace Gamepad {
|
|||||||
bool rt = drt || srt;
|
bool rt = drt || srt;
|
||||||
|
|
||||||
// Botons frontals (layout SDL: SOUTH=A/Cross, EAST=B/Circle, WEST=X/Square, NORTH=Y/Triangle)
|
// Botons frontals (layout SDL: SOUTH=A/Cross, EAST=B/Circle, WEST=X/Square, NORTH=Y/Triangle)
|
||||||
bool south = SDL_GetGamepadButton(pad_, SDL_GAMEPAD_BUTTON_SOUTH);
|
bool south = SDL_GetGamepadButton(pad, SDL_GAMEPAD_BUTTON_SOUTH);
|
||||||
bool east = SDL_GetGamepadButton(pad_, SDL_GAMEPAD_BUTTON_EAST);
|
bool east = SDL_GetGamepadButton(pad, SDL_GAMEPAD_BUTTON_EAST);
|
||||||
bool west = SDL_GetGamepadButton(pad_, SDL_GAMEPAD_BUTTON_WEST);
|
bool west = SDL_GetGamepadButton(pad, SDL_GAMEPAD_BUTTON_WEST);
|
||||||
bool north = SDL_GetGamepadButton(pad_, SDL_GAMEPAD_BUTTON_NORTH);
|
bool north = SDL_GetGamepadButton(pad, SDL_GAMEPAD_BUTTON_NORTH);
|
||||||
bool start = SDL_GetGamepadButton(pad_, SDL_GAMEPAD_BUTTON_START);
|
bool start = SDL_GetGamepadButton(pad, SDL_GAMEPAD_BUTTON_START);
|
||||||
bool back = SDL_GetGamepadButton(pad_, SDL_GAMEPAD_BUTTON_BACK);
|
bool back = SDL_GetGamepadButton(pad, SDL_GAMEPAD_BUTTON_BACK);
|
||||||
|
|
||||||
// Select (Back) → obre/tanca menú de servei (flanc)
|
// Select (Back) → obre/tanca menú de servei (flanc)
|
||||||
if (back && !prev_back_) {
|
if (back && !prev_back) {
|
||||||
pushKey(KeyConfig::scancode("menu_toggle"));
|
pushKey(KeyConfig::scancode("menu_toggle"));
|
||||||
}
|
}
|
||||||
// Start → pausa (flanc)
|
// Start → pausa (flanc)
|
||||||
if (start && !prev_start_) {
|
if (start && !prev_start) {
|
||||||
pushKey(KeyConfig::scancode("pause_toggle"));
|
pushKey(KeyConfig::scancode("pause_toggle"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Menu::isOpen()) {
|
if (Menu::isOpen()) {
|
||||||
// Navegació del menú per flanc
|
// Navegació del menú per flanc
|
||||||
if (up && !prev_up_) {
|
if (up && !prev_up) {
|
||||||
pushKey(SDL_SCANCODE_UP);
|
pushKey(SDL_SCANCODE_UP);
|
||||||
}
|
}
|
||||||
if (dn && !prev_down_) {
|
if (dn && !prev_down) {
|
||||||
pushKey(SDL_SCANCODE_DOWN);
|
pushKey(SDL_SCANCODE_DOWN);
|
||||||
}
|
}
|
||||||
if (lt && !prev_left_) {
|
if (lt && !prev_left) {
|
||||||
pushKey(SDL_SCANCODE_LEFT);
|
pushKey(SDL_SCANCODE_LEFT);
|
||||||
}
|
}
|
||||||
if (rt && !prev_right_) {
|
if (rt && !prev_right) {
|
||||||
pushKey(SDL_SCANCODE_RIGHT);
|
pushKey(SDL_SCANCODE_RIGHT);
|
||||||
}
|
}
|
||||||
// EAST accepta, SOUTH cancela / endarrere
|
// EAST accepta, SOUTH cancela / endarrere
|
||||||
if (east && !prev_east_) {
|
if (east && !prev_east) {
|
||||||
pushKey(SDL_SCANCODE_RETURN);
|
pushKey(SDL_SCANCODE_RETURN);
|
||||||
}
|
}
|
||||||
if (south && !prev_south_) {
|
if (south && !prev_south) {
|
||||||
pushKey(SDL_SCANCODE_BACKSPACE);
|
pushKey(SDL_SCANCODE_BACKSPACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,22 +270,22 @@ namespace Gamepad {
|
|||||||
JI_SetVirtualKey(SDL_SCANCODE_LEFT, JI_VSRC_GAMEPAD, lt);
|
JI_SetVirtualKey(SDL_SCANCODE_LEFT, JI_VSRC_GAMEPAD, lt);
|
||||||
JI_SetVirtualKey(SDL_SCANCODE_RIGHT, JI_VSRC_GAMEPAD, rt);
|
JI_SetVirtualKey(SDL_SCANCODE_RIGHT, JI_VSRC_GAMEPAD, rt);
|
||||||
// Qualsevol dels 4 botons frontals avança escenes (JI_AnyKey via Enter sintètic)
|
// Qualsevol dels 4 botons frontals avança escenes (JI_AnyKey via Enter sintètic)
|
||||||
if ((south && !prev_south_) || (east && !prev_east_) ||
|
if ((south && !prev_south) || (east && !prev_east) ||
|
||||||
(west && !prev_west_) || (north && !prev_north_)) {
|
(west && !prev_west) || (north && !prev_north)) {
|
||||||
pushKey(SDL_SCANCODE_RETURN);
|
pushKey(SDL_SCANCODE_RETURN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
prev_up_ = up;
|
prev_up = up;
|
||||||
prev_down_ = dn;
|
prev_down = dn;
|
||||||
prev_left_ = lt;
|
prev_left = lt;
|
||||||
prev_right_ = rt;
|
prev_right = rt;
|
||||||
prev_south_ = south;
|
prev_south = south;
|
||||||
prev_east_ = east;
|
prev_east = east;
|
||||||
prev_west_ = west;
|
prev_west = west;
|
||||||
prev_north_ = north;
|
prev_north = north;
|
||||||
prev_start_ = start;
|
prev_start = start;
|
||||||
prev_back_ = back;
|
prev_back = back;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Gamepad
|
} // namespace Gamepad
|
||||||
|
|||||||
+26
-26
@@ -15,36 +15,36 @@
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
struct keyvalue {
|
struct Keyvalue {
|
||||||
std::string key;
|
std::string key;
|
||||||
std::string value;
|
std::string value;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<keyvalue> config;
|
std::vector<Keyvalue> config;
|
||||||
std::string resource_folder;
|
std::string resource_folder;
|
||||||
std::string config_folder;
|
std::string config_folder;
|
||||||
|
|
||||||
void load_config_values() {
|
void loadConfigValues() {
|
||||||
config.clear();
|
config.clear();
|
||||||
const std::string config_file = config_folder + "/config.txt";
|
const std::string CONFIG_FILE = config_folder + "/config.txt";
|
||||||
std::ifstream fi(config_file);
|
std::ifstream fi(CONFIG_FILE);
|
||||||
if (!fi.is_open()) {
|
if (!fi.is_open()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string line;
|
std::string line;
|
||||||
while (std::getline(fi, line)) {
|
while (std::getline(fi, line)) {
|
||||||
const auto eq = line.find('=');
|
const auto EQ = line.find('=');
|
||||||
if (eq == std::string::npos) {
|
if (EQ == std::string::npos) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
config.push_back({line.substr(0, eq), line.substr(eq + 1)});
|
config.push_back({line.substr(0, EQ), line.substr(EQ + 1)});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void save_config_values() {
|
void saveConfigValues() {
|
||||||
const std::string config_file = config_folder + "/config.txt";
|
const std::string CONFIG_FILE = config_folder + "/config.txt";
|
||||||
std::ofstream fo(config_file);
|
std::ofstream fo(CONFIG_FILE);
|
||||||
if (!fo.is_open()) {
|
if (!fo.is_open()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -103,34 +103,34 @@ void file_setconfigfolder(const char* foldername) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto file_getconfigfolder() -> const char* {
|
auto file_getconfigfolder() -> const char* {
|
||||||
thread_local std::string folder;
|
thread_local std::string folder_;
|
||||||
folder = config_folder + "/";
|
folder_ = config_folder + "/";
|
||||||
return folder.c_str();
|
return folder_.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto file_getconfigvalue(const char* key) -> const char* {
|
auto file_getconfigvalue(const char* key) -> const char* {
|
||||||
if (config.empty()) {
|
if (config.empty()) {
|
||||||
load_config_values();
|
loadConfigValues();
|
||||||
}
|
}
|
||||||
const auto it = std::find_if(config.begin(), config.end(), [key](const keyvalue& pair) { return pair.key == key; });
|
const auto IT = std::find_if(config.begin(), config.end(), [key](const Keyvalue& pair) { return pair.key == key; });
|
||||||
if (it != config.end()) {
|
if (IT != config.end()) {
|
||||||
thread_local std::string value_cache;
|
thread_local std::string value_cache_;
|
||||||
value_cache = it->value;
|
value_cache_ = IT->value;
|
||||||
return value_cache.c_str();
|
return value_cache_.c_str();
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void file_setconfigvalue(const char* key, const char* value) {
|
void file_setconfigvalue(const char* key, const char* value) {
|
||||||
if (config.empty()) {
|
if (config.empty()) {
|
||||||
load_config_values();
|
loadConfigValues();
|
||||||
}
|
}
|
||||||
const auto it = std::find_if(config.begin(), config.end(), [key](const keyvalue& pair) { return pair.key == key; });
|
const auto IT = std::find_if(config.begin(), config.end(), [key](const Keyvalue& pair) { return pair.key == key; });
|
||||||
if (it != config.end()) {
|
if (IT != config.end()) {
|
||||||
it->value = value;
|
IT->value = value;
|
||||||
save_config_values();
|
saveConfigValues();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
config.push_back({std::string(key), std::string(value)});
|
config.push_back({std::string(key), std::string(value)});
|
||||||
save_config_values();
|
saveConfigValues();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
namespace Overlay {
|
namespace Overlay {
|
||||||
|
|
||||||
static std::unique_ptr<Text> font_;
|
static std::unique_ptr<Text> font;
|
||||||
|
|
||||||
// --- Aspecte de la notificació ---
|
// --- Aspecte de la notificació ---
|
||||||
static constexpr Uint32 NOTIF_BG_COLOR = 0xFF2E1A1A; // Fons blau fosc (ABGR)
|
static constexpr Uint32 NOTIF_BG_COLOR = 0xFF2E1A1A; // Fons blau fosc (ABGR)
|
||||||
@@ -52,12 +52,12 @@ namespace Overlay {
|
|||||||
int box_h{0}; // Alçada de la caixa (calculat al crear)
|
int box_h{0}; // Alçada de la caixa (calculat al crear)
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::vector<Notification> notifications_;
|
static std::vector<Notification> notifications;
|
||||||
static Uint32 last_ticks_ = 0;
|
static Uint32 last_ticks = 0;
|
||||||
|
|
||||||
// --- Render info ---
|
// --- Render info ---
|
||||||
static Options::RenderInfoPosition info_visible_pos_ = Options::RenderInfoPosition::OFF;
|
static Options::RenderInfoPosition info_visible_pos = Options::RenderInfoPosition::OFF;
|
||||||
static float info_anim_ = 0.0F; // 0 = fora de pantalla, 1 = posició final
|
static float info_anim = 0.0F; // 0 = fora de pantalla, 1 = posició final
|
||||||
static constexpr float INFO_SLIDE_SPEED = 5.0F;
|
static constexpr float INFO_SLIDE_SPEED = 5.0F;
|
||||||
|
|
||||||
// Segments del render info — cadascú amb la seva pròpia visibilitat animada
|
// Segments del render info — cadascú amb la seva pròpia visibilitat animada
|
||||||
@@ -69,7 +69,7 @@ namespace Overlay {
|
|||||||
bool visible{false};
|
bool visible{false};
|
||||||
bool mono_digits{false}; // si true, dígits amb amplada fixa (la resta natural)
|
bool mono_digits{false}; // si true, dígits amb amplada fixa (la resta natural)
|
||||||
};
|
};
|
||||||
static InfoSegment info_segments_[INFO_SEGMENT_COUNT];
|
static InfoSegment info_segments[INFO_SEGMENT_COUNT];
|
||||||
|
|
||||||
// --- Crèdits cinematogràfics ---
|
// --- Crèdits cinematogràfics ---
|
||||||
// Usen el sistema de notificacions en posició TOP_CENTER_DROP.
|
// Usen el sistema de notificacions en posició TOP_CENTER_DROP.
|
||||||
@@ -78,8 +78,8 @@ namespace Overlay {
|
|||||||
PLAYING_1,
|
PLAYING_1,
|
||||||
GAP,
|
GAP,
|
||||||
PLAYING_2 };
|
PLAYING_2 };
|
||||||
static CreditsPhase credits_phase_ = CreditsPhase::IDLE;
|
static CreditsPhase credits_phase = CreditsPhase::IDLE;
|
||||||
static float credits_timer_ = 0.0F; // segons dins la phase actual
|
static float credits_timer = 0.0F; // segons dins la phase actual
|
||||||
static constexpr float CREDITS_DELAY = 2.0F;
|
static constexpr float CREDITS_DELAY = 2.0F;
|
||||||
static constexpr float CREDITS_GAP = 0.4F;
|
static constexpr float CREDITS_GAP = 0.4F;
|
||||||
static constexpr float CREDITS_HOLD = 7.5F;
|
static constexpr float CREDITS_HOLD = 7.5F;
|
||||||
@@ -87,16 +87,16 @@ namespace Overlay {
|
|||||||
static constexpr Uint32 CREDITS_FG = NOTIF_TEXT_COLOR; // mateix cian
|
static constexpr Uint32 CREDITS_FG = NOTIF_TEXT_COLOR; // mateix cian
|
||||||
|
|
||||||
// --- Doble ESC per a eixir ---
|
// --- Doble ESC per a eixir ---
|
||||||
static bool esc_waiting_ = false;
|
static bool esc_waiting = false;
|
||||||
|
|
||||||
void init() {
|
void init() {
|
||||||
font_ = std::make_unique<Text>("fonts/8bithud.fnt", "fonts/8bithud.gif");
|
font = std::make_unique<Text>("fonts/8bithud.fnt", "fonts/8bithud.gif");
|
||||||
last_ticks_ = SDL_GetTicks();
|
last_ticks = SDL_GetTicks();
|
||||||
}
|
}
|
||||||
|
|
||||||
void destroy() {
|
void destroy() {
|
||||||
font_.reset();
|
font.reset();
|
||||||
notifications_.clear();
|
notifications.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pinta un rectangle sòlid dins els límits de la pantalla
|
// Pinta un rectangle sòlid dins els límits de la pantalla
|
||||||
@@ -115,17 +115,17 @@ namespace Overlay {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void render(Uint32* pixel_data) {
|
void render(Uint32* pixel_data) {
|
||||||
if (!font_ || (pixel_data == nullptr)) {
|
if (!font || (pixel_data == nullptr)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calcula delta time
|
// Calcula delta time
|
||||||
Uint32 now = SDL_GetTicks();
|
Uint32 now = SDL_GetTicks();
|
||||||
float dt = static_cast<float>(now - last_ticks_) / 1000.0F;
|
float dt = static_cast<float>(now - last_ticks) / 1000.0F;
|
||||||
last_ticks_ = now;
|
last_ticks = now;
|
||||||
|
|
||||||
// Actualitza i pinta cada notificació
|
// Actualitza i pinta cada notificació
|
||||||
for (auto& notif : notifications_) {
|
for (auto& notif : notifications) {
|
||||||
switch (notif.status) {
|
switch (notif.status) {
|
||||||
case Status::RISING:
|
case Status::RISING:
|
||||||
notif.anim += SLIDE_SPEED * dt;
|
notif.anim += SLIDE_SPEED * dt;
|
||||||
@@ -184,52 +184,52 @@ namespace Overlay {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Pinta el text línia a línia (amb ombra o contorn segons style)
|
// Pinta el text línia a línia (amb ombra o contorn segons style)
|
||||||
int line_h = font_->charHeight();
|
int line_h = font->charHeight();
|
||||||
int line_y = box_y + NOTIF_PADDING_V;
|
int line_y = box_y + NOTIF_PADDING_V;
|
||||||
for (const auto& line : notif.lines) {
|
for (const auto& line : notif.lines) {
|
||||||
int line_w = font_->width(line.c_str());
|
int line_w = font->width(line.c_str());
|
||||||
int line_x = box_x + ((notif.box_w - line_w) / 2); // centrat dins la caixa
|
int line_x = box_x + ((notif.box_w - line_w) / 2); // centrat dins la caixa
|
||||||
if (notif.style == NotifStyle::SHADOW) {
|
if (notif.style == NotifStyle::SHADOW) {
|
||||||
font_->draw(pixel_data, line_x + 1, line_y + 1, line.c_str(), notif.accent_color);
|
font->draw(pixel_data, line_x + 1, line_y + 1, line.c_str(), notif.accent_color);
|
||||||
} else if (notif.style == NotifStyle::OUTLINE) {
|
} else if (notif.style == NotifStyle::OUTLINE) {
|
||||||
// Contorn 4-direccional (N, S, E, W)
|
// Contorn 4-direccional (N, S, E, W)
|
||||||
font_->draw(pixel_data, line_x, line_y - 1, line.c_str(), notif.accent_color);
|
font->draw(pixel_data, line_x, line_y - 1, line.c_str(), notif.accent_color);
|
||||||
font_->draw(pixel_data, line_x, line_y + 1, line.c_str(), notif.accent_color);
|
font->draw(pixel_data, line_x, line_y + 1, line.c_str(), notif.accent_color);
|
||||||
font_->draw(pixel_data, line_x - 1, line_y, line.c_str(), notif.accent_color);
|
font->draw(pixel_data, line_x - 1, line_y, line.c_str(), notif.accent_color);
|
||||||
font_->draw(pixel_data, line_x + 1, line_y, line.c_str(), notif.accent_color);
|
font->draw(pixel_data, line_x + 1, line_y, line.c_str(), notif.accent_color);
|
||||||
}
|
}
|
||||||
font_->draw(pixel_data, line_x, line_y, line.c_str(), notif.text_color);
|
font->draw(pixel_data, line_x, line_y, line.c_str(), notif.text_color);
|
||||||
line_y += line_h + 1;
|
line_y += line_h + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render info (FPS, driver, shader) — animat amb slide vertical
|
// Render info (FPS, driver, shader) — animat amb slide vertical
|
||||||
// State machine: visible_pos s'actualitza cap a desired quan anim arriba a 0
|
// State machine: visible_pos s'actualitza cap a DESIRED quan anim arriba a 0
|
||||||
{
|
{
|
||||||
const auto desired = Options::render_info.position;
|
const auto DESIRED = Options::render_info.position;
|
||||||
if (desired == info_visible_pos_) {
|
if (DESIRED == info_visible_pos) {
|
||||||
// Mateix lloc: entra fins a 1
|
// Mateix lloc: entra fins a 1
|
||||||
if (info_anim_ < 1.0F) {
|
if (info_anim < 1.0F) {
|
||||||
info_anim_ += INFO_SLIDE_SPEED * dt;
|
info_anim += INFO_SLIDE_SPEED * dt;
|
||||||
info_anim_ = std::min(info_anim_, 1.0F);
|
info_anim = std::min(info_anim, 1.0F);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Canvi: si visible_pos està OFF, commuta directament
|
// Canvi: si visible_pos està OFF, commuta directament
|
||||||
if (info_visible_pos_ == Options::RenderInfoPosition::OFF) {
|
if (info_visible_pos == Options::RenderInfoPosition::OFF) {
|
||||||
info_visible_pos_ = desired;
|
info_visible_pos = DESIRED;
|
||||||
info_anim_ = 0.0F;
|
info_anim = 0.0F;
|
||||||
} else {
|
} else {
|
||||||
// Ix del lloc actual
|
// Ix del lloc actual
|
||||||
info_anim_ -= INFO_SLIDE_SPEED * dt;
|
info_anim -= INFO_SLIDE_SPEED * dt;
|
||||||
if (info_anim_ <= 0.0F) {
|
if (info_anim <= 0.0F) {
|
||||||
info_anim_ = 0.0F;
|
info_anim = 0.0F;
|
||||||
info_visible_pos_ = desired;
|
info_visible_pos = DESIRED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualitza animacions individuals dels segments
|
// Actualitza animacions individuals dels segments
|
||||||
for (auto& seg : info_segments_) {
|
for (auto& seg : info_segments) {
|
||||||
float target = seg.visible ? 1.0F : 0.0F;
|
float target = seg.visible ? 1.0F : 0.0F;
|
||||||
if (seg.anim < target) {
|
if (seg.anim < target) {
|
||||||
seg.anim += SEG_SPEED * dt;
|
seg.anim += SEG_SPEED * dt;
|
||||||
@@ -241,25 +241,25 @@ namespace Overlay {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Render si hi ha alguna cosa visible
|
// Render si hi ha alguna cosa visible
|
||||||
if (info_visible_pos_ != Options::RenderInfoPosition::OFF && info_anim_ > 0.0F) {
|
if (info_visible_pos != Options::RenderInfoPosition::OFF && info_anim > 0.0F) {
|
||||||
const int DIGIT_CELL = font_->charBoxWidth() - 1; // amplada uniforme per dígit
|
const int DIGIT_CELL = font->charBoxWidth() - 1; // amplada uniforme per dígit
|
||||||
|
|
||||||
// Calcula amplada total interpolant cada segment per la seva anim
|
// Calcula amplada total interpolant cada segment per la seva anim
|
||||||
float total_w = 0.0F;
|
float total_w = 0.0F;
|
||||||
for (const auto& seg : info_segments_) {
|
for (const auto& seg : info_segments) {
|
||||||
if (seg.anim > 0.0F && !seg.text.empty()) {
|
if (seg.anim > 0.0F && !seg.text.empty()) {
|
||||||
int w = seg.mono_digits
|
int w = seg.mono_digits
|
||||||
? font_->widthMonoDigits(seg.text.c_str(), DIGIT_CELL)
|
? font->widthMonoDigits(seg.text.c_str(), DIGIT_CELL)
|
||||||
: font_->width(seg.text.c_str());
|
: font->width(seg.text.c_str());
|
||||||
total_w += w * Easing::outQuad(seg.anim);
|
total_w += w * Easing::outQuad(seg.anim);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (total_w > 0.0F) {
|
if (total_w > 0.0F) {
|
||||||
float eased_y = Easing::outQuad(info_anim_);
|
float eased_y = Easing::outQuad(info_anim);
|
||||||
int ch = font_->charHeight();
|
int ch = font->charHeight();
|
||||||
int final_y;
|
int final_y;
|
||||||
int start_y;
|
int start_y;
|
||||||
if (info_visible_pos_ == Options::RenderInfoPosition::TOP) {
|
if (info_visible_pos == Options::RenderInfoPosition::TOP) {
|
||||||
final_y = 1;
|
final_y = 1;
|
||||||
start_y = -ch - 1;
|
start_y = -ch - 1;
|
||||||
} else {
|
} else {
|
||||||
@@ -270,18 +270,18 @@ namespace Overlay {
|
|||||||
|
|
||||||
// Dibuixa cada segment en la seva posició x acumulada
|
// Dibuixa cada segment en la seva posició x acumulada
|
||||||
float cur_x = (SCREEN_W - total_w) / 2.0F;
|
float cur_x = (SCREEN_W - total_w) / 2.0F;
|
||||||
for (const auto& seg : info_segments_) {
|
for (const auto& seg : info_segments) {
|
||||||
if (seg.anim > 0.01F && !seg.text.empty()) {
|
if (seg.anim > 0.01F && !seg.text.empty()) {
|
||||||
int xi = static_cast<int>(cur_x);
|
int xi = static_cast<int>(cur_x);
|
||||||
int seg_w = seg.mono_digits
|
int seg_w = seg.mono_digits
|
||||||
? font_->widthMonoDigits(seg.text.c_str(), DIGIT_CELL)
|
? font->widthMonoDigits(seg.text.c_str(), DIGIT_CELL)
|
||||||
: font_->width(seg.text.c_str());
|
: font->width(seg.text.c_str());
|
||||||
if (seg.mono_digits) {
|
if (seg.mono_digits) {
|
||||||
font_->drawMonoDigits(pixel_data, xi + 1, info_y + 1, seg.text.c_str(), Options::render_info.shadow_color, DIGIT_CELL);
|
font->drawMonoDigits(pixel_data, xi + 1, info_y + 1, seg.text.c_str(), Options::render_info.shadow_color, DIGIT_CELL);
|
||||||
font_->drawMonoDigits(pixel_data, xi, info_y, seg.text.c_str(), Options::render_info.text_color, DIGIT_CELL);
|
font->drawMonoDigits(pixel_data, xi, info_y, seg.text.c_str(), Options::render_info.text_color, DIGIT_CELL);
|
||||||
} else {
|
} else {
|
||||||
font_->draw(pixel_data, xi + 1, info_y + 1, seg.text.c_str(), Options::render_info.shadow_color);
|
font->draw(pixel_data, xi + 1, info_y + 1, seg.text.c_str(), Options::render_info.shadow_color);
|
||||||
font_->draw(pixel_data, xi, info_y, seg.text.c_str(), Options::render_info.text_color);
|
font->draw(pixel_data, xi, info_y, seg.text.c_str(), Options::render_info.text_color);
|
||||||
}
|
}
|
||||||
cur_x += seg_w * Easing::outQuad(seg.anim);
|
cur_x += seg_w * Easing::outQuad(seg.anim);
|
||||||
}
|
}
|
||||||
@@ -291,34 +291,34 @@ namespace Overlay {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Elimina les acabades
|
// Elimina les acabades
|
||||||
std::erase_if(notifications_, [](const Notification& n) { return n.status == Status::FINISHED; });
|
std::erase_if(notifications, [](const Notification& n) { return n.status == Status::FINISHED; });
|
||||||
|
|
||||||
// Si la notificació d'ESC ha desaparegut, reseteja l'estat
|
// Si la notificació d'ESC ha desaparegut, reseteja l'estat
|
||||||
if (esc_waiting_ && notifications_.empty()) {
|
if (esc_waiting && notifications.empty()) {
|
||||||
esc_waiting_ = false;
|
esc_waiting = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Indicador de pausa persistent (cantó superior dret)
|
// Indicador de pausa persistent (cantó superior dret)
|
||||||
if ((Director::get() != nullptr) && Director::get()->isPaused()) {
|
if ((Director::get() != nullptr) && Director::get()->isPaused()) {
|
||||||
const char* pause_text = Locale::get("notifications.pause");
|
const char* pause_text = Locale::get("notifications.pause");
|
||||||
int w = font_->width(pause_text);
|
int w = font->width(pause_text);
|
||||||
int x = SCREEN_W - w - 4;
|
int x = SCREEN_W - w - 4;
|
||||||
int y = 4;
|
int y = 4;
|
||||||
// Contorn blanc 4-direccional
|
// Contorn blanc 4-direccional
|
||||||
font_->draw(pixel_data, x, y - 1, pause_text, 0xFFFFFFFF);
|
font->draw(pixel_data, x, y - 1, pause_text, 0xFFFFFFFF);
|
||||||
font_->draw(pixel_data, x, y + 1, pause_text, 0xFFFFFFFF);
|
font->draw(pixel_data, x, y + 1, pause_text, 0xFFFFFFFF);
|
||||||
font_->draw(pixel_data, x - 1, y, pause_text, 0xFFFFFFFF);
|
font->draw(pixel_data, x - 1, y, pause_text, 0xFFFFFFFF);
|
||||||
font_->draw(pixel_data, x + 1, y, pause_text, 0xFFFFFFFF);
|
font->draw(pixel_data, x + 1, y, pause_text, 0xFFFFFFFF);
|
||||||
// Text en roig
|
// Text en roig
|
||||||
font_->draw(pixel_data, x, y, pause_text, 0xFF0000FF);
|
font->draw(pixel_data, x, y, pause_text, 0xFF0000FF);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Crèdits seqüencials — dispara notificacions TOP_CENTER_DROP una darrere l'altra.
|
// Crèdits seqüencials — dispara notificacions TOP_CENTER_DROP una darrere l'altra.
|
||||||
if (credits_phase_ != CreditsPhase::IDLE) {
|
if (credits_phase != CreditsPhase::IDLE) {
|
||||||
credits_timer_ += dt;
|
credits_timer += dt;
|
||||||
switch (credits_phase_) {
|
switch (credits_phase) {
|
||||||
case CreditsPhase::DELAY:
|
case CreditsPhase::DELAY:
|
||||||
if (credits_timer_ >= CREDITS_DELAY) {
|
if (credits_timer >= CREDITS_DELAY) {
|
||||||
showNotification(
|
showNotification(
|
||||||
{std::string(Locale::get("credits.port_role")),
|
{std::string(Locale::get("credits.port_role")),
|
||||||
std::string(Locale::get("credits.port_name"))},
|
std::string(Locale::get("credits.port_name"))},
|
||||||
@@ -327,18 +327,18 @@ namespace Overlay {
|
|||||||
NotifStyle::OUTLINE,
|
NotifStyle::OUTLINE,
|
||||||
CREDITS_BG,
|
CREDITS_BG,
|
||||||
CREDITS_FG);
|
CREDITS_FG);
|
||||||
credits_phase_ = CreditsPhase::PLAYING_1;
|
credits_phase = CreditsPhase::PLAYING_1;
|
||||||
credits_timer_ = 0.0F;
|
credits_timer = 0.0F;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CreditsPhase::PLAYING_1:
|
case CreditsPhase::PLAYING_1:
|
||||||
if (notifications_.empty()) {
|
if (notifications.empty()) {
|
||||||
credits_phase_ = CreditsPhase::GAP;
|
credits_phase = CreditsPhase::GAP;
|
||||||
credits_timer_ = 0.0F;
|
credits_timer = 0.0F;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CreditsPhase::GAP:
|
case CreditsPhase::GAP:
|
||||||
if (credits_timer_ >= CREDITS_GAP) {
|
if (credits_timer >= CREDITS_GAP) {
|
||||||
showNotification(
|
showNotification(
|
||||||
{std::string(Locale::get("credits.modern_role")),
|
{std::string(Locale::get("credits.modern_role")),
|
||||||
std::string(Locale::get("credits.modern_name"))},
|
std::string(Locale::get("credits.modern_name"))},
|
||||||
@@ -347,14 +347,14 @@ namespace Overlay {
|
|||||||
NotifStyle::OUTLINE,
|
NotifStyle::OUTLINE,
|
||||||
CREDITS_BG,
|
CREDITS_BG,
|
||||||
CREDITS_FG);
|
CREDITS_FG);
|
||||||
credits_phase_ = CreditsPhase::PLAYING_2;
|
credits_phase = CreditsPhase::PLAYING_2;
|
||||||
credits_timer_ = 0.0F;
|
credits_timer = 0.0F;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CreditsPhase::PLAYING_2:
|
case CreditsPhase::PLAYING_2:
|
||||||
if (notifications_.empty()) {
|
if (notifications.empty()) {
|
||||||
credits_phase_ = CreditsPhase::IDLE;
|
credits_phase = CreditsPhase::IDLE;
|
||||||
credits_timer_ = 0.0F;
|
credits_timer = 0.0F;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CreditsPhase::IDLE:
|
case CreditsPhase::IDLE:
|
||||||
@@ -363,7 +363,7 @@ namespace Overlay {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Neteja notificacions finalitzades
|
// Neteja notificacions finalitzades
|
||||||
std::erase_if(notifications_, [](const Notification& n) { return n.status == Status::FINISHED; });
|
std::erase_if(notifications, [](const Notification& n) { return n.status == Status::FINISHED; });
|
||||||
|
|
||||||
// Menú flotant per damunt de tot (isVisible inclou l'animació de tancament)
|
// Menú flotant per damunt de tot (isVisible inclou l'animació de tancament)
|
||||||
if (Menu::isVisible()) {
|
if (Menu::isVisible()) {
|
||||||
@@ -382,7 +382,7 @@ namespace Overlay {
|
|||||||
Uint32 accent_color,
|
Uint32 accent_color,
|
||||||
Uint32 text_color) {
|
Uint32 text_color) {
|
||||||
// Reemplaça la notificació anterior
|
// Reemplaça la notificació anterior
|
||||||
notifications_.clear();
|
notifications.clear();
|
||||||
|
|
||||||
Notification notif;
|
Notification notif;
|
||||||
notif.lines = lines;
|
notif.lines = lines;
|
||||||
@@ -395,15 +395,15 @@ namespace Overlay {
|
|||||||
// Calcula l'amplada màxima de les línies
|
// Calcula l'amplada màxima de les línies
|
||||||
int max_w = 0;
|
int max_w = 0;
|
||||||
for (const auto& line : lines) {
|
for (const auto& line : lines) {
|
||||||
int w = font_->width(line.c_str());
|
int w = font->width(line.c_str());
|
||||||
max_w = std::max(w, max_w);
|
max_w = std::max(w, max_w);
|
||||||
}
|
}
|
||||||
notif.box_w = max_w + NOTIF_PADDING_H * 2;
|
notif.box_w = max_w + NOTIF_PADDING_H * 2;
|
||||||
int line_h = font_->charHeight();
|
int line_h = font->charHeight();
|
||||||
int line_count = static_cast<int>(lines.size());
|
int line_count = static_cast<int>(lines.size());
|
||||||
notif.box_h = line_count * line_h + (line_count - 1) * 1 + NOTIF_PADDING_V * 2;
|
notif.box_h = line_count * line_h + (line_count - 1) * 1 + NOTIF_PADDING_V * 2;
|
||||||
|
|
||||||
notifications_.push_back(notif);
|
notifications.push_back(notif);
|
||||||
}
|
}
|
||||||
|
|
||||||
void toggleRenderInfo() { cycleRenderInfo(+1); }
|
void toggleRenderInfo() { cycleRenderInfo(+1); }
|
||||||
@@ -418,47 +418,47 @@ namespace Overlay {
|
|||||||
void setRenderInfoSegments(const char* s0, const char* s1, const char* s2, const char* s3, unsigned int mono_mask) {
|
void setRenderInfoSegments(const char* s0, const char* s1, const char* s2, const char* s3, unsigned int mono_mask) {
|
||||||
const char* segs[INFO_SEGMENT_COUNT] = {s0, s1, s2, s3};
|
const char* segs[INFO_SEGMENT_COUNT] = {s0, s1, s2, s3};
|
||||||
for (int i = 0; i < INFO_SEGMENT_COUNT; i++) {
|
for (int i = 0; i < INFO_SEGMENT_COUNT; i++) {
|
||||||
info_segments_[i].mono_digits = (((mono_mask >> i) & 1U) != 0U);
|
info_segments[i].mono_digits = (((mono_mask >> i) & 1U) != 0U);
|
||||||
if (segs[i] != nullptr && *segs[i] != '\0') {
|
if (segs[i] != nullptr && *segs[i] != '\0') {
|
||||||
info_segments_[i].text = segs[i];
|
info_segments[i].text = segs[i];
|
||||||
info_segments_[i].visible = true;
|
info_segments[i].visible = true;
|
||||||
} else {
|
} else {
|
||||||
info_segments_[i].visible = false;
|
info_segments[i].visible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void startCredits() {
|
void startCredits() {
|
||||||
if (credits_phase_ != CreditsPhase::IDLE) {
|
if (credits_phase != CreditsPhase::IDLE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
credits_phase_ = CreditsPhase::DELAY;
|
credits_phase = CreditsPhase::DELAY;
|
||||||
credits_timer_ = 0.0F;
|
credits_timer = 0.0F;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cancelCredits() {
|
void cancelCredits() {
|
||||||
credits_phase_ = CreditsPhase::IDLE;
|
credits_phase = CreditsPhase::IDLE;
|
||||||
credits_timer_ = 0.0F;
|
credits_timer = 0.0F;
|
||||||
notifications_.clear();
|
notifications.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto creditsActive() -> bool {
|
auto creditsActive() -> bool {
|
||||||
return credits_phase_ != CreditsPhase::IDLE;
|
return credits_phase != CreditsPhase::IDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto isEscConsumed() -> bool {
|
auto isEscConsumed() -> bool {
|
||||||
return esc_waiting_;
|
return esc_waiting;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto handleEscape() -> bool {
|
auto handleEscape() -> bool {
|
||||||
if (!esc_waiting_) {
|
if (!esc_waiting) {
|
||||||
// Primera pulsació: mostra avís i consumeix
|
// Primera pulsació: mostra avís i consumeix
|
||||||
esc_waiting_ = true;
|
esc_waiting = true;
|
||||||
showNotification(Locale::get("notifications.exit_double_esc"), 2.0F);
|
showNotification(Locale::get("notifications.exit_double_esc"), 2.0F);
|
||||||
return true; // Consumit
|
return true; // Consumit
|
||||||
}
|
}
|
||||||
// Segona pulsació: deixa passar
|
// Segona pulsació: deixa passar
|
||||||
esc_waiting_ = false;
|
esc_waiting = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user