pausa
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include "core/input/global_inputs.hpp"
|
||||
#include "core/input/key_remap.hpp"
|
||||
#include "core/input/mouse.hpp"
|
||||
#include "core/jail/jail_audio.hpp"
|
||||
#include "core/jail/jgame.hpp"
|
||||
#include "core/jail/jinput.hpp"
|
||||
#include "core/rendering/menu.hpp"
|
||||
@@ -37,6 +38,15 @@ auto Director::get() -> Director* {
|
||||
return instance_;
|
||||
}
|
||||
|
||||
void Director::togglePause() {
|
||||
paused_ = !paused_;
|
||||
if (paused_) {
|
||||
JA_PauseMusic();
|
||||
} else {
|
||||
JA_ResumeMusic();
|
||||
}
|
||||
}
|
||||
|
||||
void Director::run() {
|
||||
// Llança el game thread
|
||||
game_thread_ = std::thread(&Director::gameThreadFunc, this);
|
||||
@@ -64,9 +74,10 @@ void Director::run() {
|
||||
esc_blocked_ = false;
|
||||
}
|
||||
|
||||
// Consumeix un frame nou si n'hi ha un disponible (no bloqueja)
|
||||
// Consumeix un frame nou si n'hi ha un disponible (no bloqueja).
|
||||
// Si estem en pausa, no consumim: el game thread es queda bloquejat a publishFrame.
|
||||
bool new_frame = false;
|
||||
{
|
||||
if (!paused_) {
|
||||
std::lock_guard lock(mutex_);
|
||||
if (frame_ready_ && latest_frame_ != nullptr) {
|
||||
memcpy(game_frame, latest_frame_, sizeof(game_frame));
|
||||
@@ -131,6 +142,14 @@ void Director::handleEvents() {
|
||||
menu_keys_held_[event.key.scancode] = true;
|
||||
continue;
|
||||
}
|
||||
// Pausa: F11 (o tecla configurada) pausa/reprén la simulació
|
||||
if (event.type == SDL_EVENT_KEY_DOWN && !event.key.repeat &&
|
||||
event.key.scancode == Options::keys_gui.pause_toggle) {
|
||||
togglePause();
|
||||
Overlay::showNotification(paused_ ? "PAUSA" : "REPRES");
|
||||
menu_keys_held_[event.key.scancode] = true;
|
||||
continue;
|
||||
}
|
||||
// Menú: F12 (o tecla configurada) obre/tanca el menú flotant
|
||||
if (event.type == SDL_EVENT_KEY_DOWN && !event.key.repeat &&
|
||||
event.key.scancode == Options::keys_gui.menu_toggle) {
|
||||
|
||||
Reference in New Issue
Block a user