fix: entrar i eixir al mode debug manté l'estat previ del jugador
This commit is contained in:
@@ -80,9 +80,17 @@ Game::Game(Mode mode)
|
|||||||
Options::stats.items = count;
|
Options::stats.items = count;
|
||||||
};
|
};
|
||||||
GameControl::toggle_debug_mode = [this]() -> void {
|
GameControl::toggle_debug_mode = [this]() -> void {
|
||||||
|
const bool ENTERING_DEBUG = !Debug::get()->isEnabled();
|
||||||
|
if (ENTERING_DEBUG) {
|
||||||
|
invincible_before_debug_ = (Options::cheats.invincible == Options::Cheat::State::ENABLED);
|
||||||
|
}
|
||||||
Debug::get()->toggleEnabled();
|
Debug::get()->toggleEnabled();
|
||||||
room_->redrawMap();
|
room_->redrawMap();
|
||||||
Options::cheats.invincible = static_cast<Options::Cheat::State>(Debug::get()->isEnabled());
|
if (Debug::get()->isEnabled()) {
|
||||||
|
Options::cheats.invincible = Options::Cheat::State::ENABLED;
|
||||||
|
} else {
|
||||||
|
Options::cheats.invincible = invincible_before_debug_ ? Options::Cheat::State::ENABLED : Options::Cheat::State::DISABLED;
|
||||||
|
}
|
||||||
player_->setColor();
|
player_->setColor();
|
||||||
scoreboard_data_->music = !Debug::get()->isEnabled();
|
scoreboard_data_->music = !Debug::get()->isEnabled();
|
||||||
scoreboard_data_->music ? Audio::get()->resumeMusic() : Audio::get()->pauseMusic();
|
scoreboard_data_->music ? Audio::get()->resumeMusic() : Audio::get()->pauseMusic();
|
||||||
@@ -512,15 +520,24 @@ void Game::handleDebugEvents(const SDL_Event& event) { // NOLINT(readability-co
|
|||||||
Notifier::get()->show({Locale::get()->get("achievements.header"), Locale::get()->get("achievements.c11")}, Notifier::Style::CHEEVO, -1, false, "F7"); // NOLINT(readability-static-accessed-through-instance)
|
Notifier::get()->show({Locale::get()->get("achievements.header"), Locale::get()->get("achievements.c11")}, Notifier::Style::CHEEVO, -1, false, "F7"); // NOLINT(readability-static-accessed-through-instance)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDLK_0:
|
case SDLK_0: {
|
||||||
|
const bool ENTERING_DEBUG = !Debug::get()->isEnabled();
|
||||||
|
if (ENTERING_DEBUG) {
|
||||||
|
invincible_before_debug_ = (Options::cheats.invincible == Options::Cheat::State::ENABLED);
|
||||||
|
}
|
||||||
Debug::get()->toggleEnabled();
|
Debug::get()->toggleEnabled();
|
||||||
Notifier::get()->show({Debug::get()->isEnabled() ? Locale::get()->get("game.debug_enabled") : Locale::get()->get("game.debug_disabled")}); // NOLINT(readability-static-accessed-through-instance)
|
Notifier::get()->show({Debug::get()->isEnabled() ? Locale::get()->get("game.debug_enabled") : Locale::get()->get("game.debug_disabled")}); // NOLINT(readability-static-accessed-through-instance)
|
||||||
room_->redrawMap();
|
room_->redrawMap();
|
||||||
Options::cheats.invincible = static_cast<Options::Cheat::State>(Debug::get()->isEnabled());
|
if (Debug::get()->isEnabled()) {
|
||||||
|
Options::cheats.invincible = Options::Cheat::State::ENABLED;
|
||||||
|
} else {
|
||||||
|
Options::cheats.invincible = invincible_before_debug_ ? Options::Cheat::State::ENABLED : Options::Cheat::State::DISABLED;
|
||||||
|
}
|
||||||
player_->setColor();
|
player_->setColor();
|
||||||
scoreboard_data_->music = !Debug::get()->isEnabled();
|
scoreboard_data_->music = !Debug::get()->isEnabled();
|
||||||
scoreboard_data_->music ? Audio::get()->resumeMusic() : Audio::get()->pauseMusic();
|
scoreboard_data_->music ? Audio::get()->resumeMusic() : Audio::get()->pauseMusic();
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -130,5 +130,7 @@ class Game {
|
|||||||
// Variables de debug para arrastre con ratón
|
// Variables de debug para arrastre con ratón
|
||||||
bool debug_dragging_player_{false}; // Indica si estamos arrastrando al jugador con el ratón
|
bool debug_dragging_player_{false}; // Indica si estamos arrastrando al jugador con el ratón
|
||||||
float debug_drag_speed_{0.0F}; // Velocidad actual del arrastre (ease-in)
|
float debug_drag_speed_{0.0F}; // Velocidad actual del arrastre (ease-in)
|
||||||
|
// Estado previo de invencibilidad antes de entrar en modo debug
|
||||||
|
bool invincible_before_debug_{false};
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user