Options: afegida opció per a permetre apagar el sistema

This commit is contained in:
2025-06-12 20:11:07 +02:00
parent d2be756741
commit 6c707fa178
9 changed files with 27 additions and 12 deletions

View File

@@ -61,6 +61,8 @@
"[NOTIFICATIONS] 14": "Sincronisme vertical", "[NOTIFICATIONS] 14": "Sincronisme vertical",
"[NOTIFICATIONS] 15": "Reiniciar", "[NOTIFICATIONS] 15": "Reiniciar",
"[RESOURCE] LOADING": "Carregant",
"[SERVICE_MENU] TITLE": "Menu de servei", "[SERVICE_MENU] TITLE": "Menu de servei",
"[SERVICE_MENU] RESET": "Reiniciar", "[SERVICE_MENU] RESET": "Reiniciar",
"[SERVICE_MENU] QUIT": "Eixir del joc", "[SERVICE_MENU] QUIT": "Eixir del joc",

View File

@@ -61,6 +61,8 @@
"[NOTIFICATIONS] 14": "Vertical Sync", "[NOTIFICATIONS] 14": "Vertical Sync",
"[NOTIFICATIONS] 15": "Reset", "[NOTIFICATIONS] 15": "Reset",
"[RESOURCE] LOADING": "Loading",
"[SERVICE_MENU] TITLE": "Service Menu", "[SERVICE_MENU] TITLE": "Service Menu",
"[SERVICE_MENU] RESET": "Reset", "[SERVICE_MENU] RESET": "Reset",
"[SERVICE_MENU] QUIT": "Quit Game", "[SERVICE_MENU] QUIT": "Quit Game",

View File

@@ -61,6 +61,8 @@
"[NOTIFICATIONS] 14": "Sincronismo vertical", "[NOTIFICATIONS] 14": "Sincronismo vertical",
"[NOTIFICATIONS] 15": "Reiniciar", "[NOTIFICATIONS] 15": "Reiniciar",
"[RESOURCE] LOADING": "Cargando",
"[SERVICE_MENU] TITLE": "Menu de servicio", "[SERVICE_MENU] TITLE": "Menu de servicio",
"[SERVICE_MENU] RESET": "Reiniciar", "[SERVICE_MENU] RESET": "Reiniciar",
"[SERVICE_MENU] QUIT": "Salir del juego", "[SERVICE_MENU] QUIT": "Salir del juego",

View File

@@ -51,7 +51,7 @@ HiScoreTable::HiScoreTable()
HiScoreTable::~HiScoreTable() HiScoreTable::~HiScoreTable()
{ {
SDL_DestroyTexture(backbuffer_); SDL_DestroyTexture(backbuffer_);
options.game.clear_last_hi_score_entries(); options.game.clearLastHiScoreEntries();
} }
// Actualiza las variables // Actualiza las variables

View File

@@ -39,7 +39,8 @@ void initOptions()
options.game.difficulty = GameDifficulty::NORMAL; options.game.difficulty = GameDifficulty::NORMAL;
options.game.language = lang::Code::VALENCIAN; options.game.language = lang::Code::VALENCIAN;
options.game.autofire = true; options.game.autofire = true;
options.game.clear_last_hi_score_entries(); options.game.shutdown_enabled = false;
options.game.clearLastHiScoreEntries();
// Opciones de control // Opciones de control
options.controllers.clear(); options.controllers.clear();
@@ -155,6 +156,7 @@ bool saveOptionsFile(std::string file_path)
file << "game.language=" << static_cast<int>(options.game.language) << "\n"; file << "game.language=" << static_cast<int>(options.game.language) << "\n";
file << "game.difficulty=" << static_cast<int>(options.game.difficulty) << "\n"; file << "game.difficulty=" << static_cast<int>(options.game.difficulty) << "\n";
file << "game.autofire=" << boolToString(options.game.autofire) << "\n"; file << "game.autofire=" << boolToString(options.game.autofire) << "\n";
file << "game.shutdown_enabled=" << boolToString(options.game.shutdown_enabled) << "\n";
// Opciones de mandos // Opciones de mandos
file << "\n\n## CONTROLLERS\n"; file << "\n\n## CONTROLLERS\n";
@@ -255,6 +257,10 @@ bool setOptions(const std::string &var, const std::string &value)
{ {
options.game.autofire = stringToBool(value); options.game.autofire = stringToBool(value);
} }
else if (var == "game.shutdown_enabled")
{
options.game.shutdown_enabled = stringToBool(value);
}
// Opciones de mandos // Opciones de mandos
else if (var == "controller.0.name") else if (var == "controller.0.name")
@@ -379,10 +385,10 @@ int getPlayerWhoUsesKeyboard()
// Aplica los cambios pendientes copiando los valores a sus variables // Aplica los cambios pendientes copiando los valores a sus variables
void applyPendingChanges() void applyPendingChanges()
{ {
if (options.pending_changes.has_pending_changes) if (options.pending_changes.has_pending_changes)
{ {
options.game.language = options.pending_changes.new_language; options.game.language = options.pending_changes.new_language;
options.game.difficulty = options.pending_changes.new_difficulty; options.game.difficulty = options.pending_changes.new_difficulty;
options.pending_changes.has_pending_changes = false; options.pending_changes.has_pending_changes = false;
} }
} }

View File

@@ -68,11 +68,12 @@ struct GameOptions
GameDifficulty difficulty; // Dificultad del juego GameDifficulty difficulty; // Dificultad del juego
lang::Code language; // Idioma usado en el juego lang::Code language; // Idioma usado en el juego
bool autofire; // Indicador de autofire bool autofire; // Indicador de autofire
bool shutdown_enabled; // Especifica si se puede apagar el sistema
std::vector<HiScoreEntry> hi_score_table; // Tabla de mejores puntuaciones std::vector<HiScoreEntry> hi_score_table; // Tabla de mejores puntuaciones
std::vector<int> last_hi_score_entry = {-1, -1}; // Últimas posiciones de entrada en la tabla std::vector<int> last_hi_score_entry = {-1, -1}; // Últimas posiciones de entrada en la tabla
// Reinicia las últimas entradas de puntuación // Reinicia las últimas entradas de puntuación
void clear_last_hi_score_entries() void clearLastHiScoreEntries()
{ {
last_hi_score_entry[0] = -1; last_hi_score_entry[0] = -1;
last_hi_score_entry[1] = -1; last_hi_score_entry[1] = -1;

View File

@@ -450,7 +450,7 @@ void Resource::renderProgress()
loading_text_->write( loading_text_->write(
loading_wired_rect_.x, loading_wired_rect_.x,
loading_wired_rect_.y - 9, loading_wired_rect_.y - 9,
"Loading : " + loading_resource_name_ lang::getText("[RESOURCE] LOADING") + " : " + loading_resource_name_
); );
// Renderiza el frame en pantalla // Renderiza el frame en pantalla

View File

@@ -327,7 +327,8 @@ void ServiceMenu::initializeOptions()
// System // System
options_.emplace_back(lang::getText("[SERVICE_MENU] RESET"), SettingsGroup::SYSTEM, OptionBehavior::SELECT, nullptr, ValueType::NONE); options_.emplace_back(lang::getText("[SERVICE_MENU] RESET"), SettingsGroup::SYSTEM, OptionBehavior::SELECT, nullptr, ValueType::NONE);
options_.emplace_back(lang::getText("[SERVICE_MENU] QUIT"), SettingsGroup::SYSTEM, OptionBehavior::SELECT, nullptr, ValueType::NONE); options_.emplace_back(lang::getText("[SERVICE_MENU] QUIT"), SettingsGroup::SYSTEM, OptionBehavior::SELECT, nullptr, ValueType::NONE);
options_.emplace_back(lang::getText("[SERVICE_MENU] SHUTDOWN"), SettingsGroup::SYSTEM, OptionBehavior::SELECT, nullptr, ValueType::NONE); if (options.game.shutdown_enabled)
options_.emplace_back(lang::getText("[SERVICE_MENU] SHUTDOWN"), SettingsGroup::SYSTEM, OptionBehavior::SELECT, nullptr, ValueType::NONE);
// Menu principal // Menu principal
options_.emplace_back(lang::getText("[SERVICE_MENU] VIDEO"), SettingsGroup::MAIN, OptionBehavior::SELECT, SettingsGroup::VIDEO); options_.emplace_back(lang::getText("[SERVICE_MENU] VIDEO"), SettingsGroup::MAIN, OptionBehavior::SELECT, SettingsGroup::VIDEO);

View File

@@ -117,7 +117,8 @@ bool checkCollision(const SDL_FPoint &p, const SDL_FRect &r)
// Convierte una cadena en un valor booleano // Convierte una cadena en un valor booleano
bool stringToBool(const std::string &str) bool stringToBool(const std::string &str)
{ {
return str == "true"; std::string s = trim(toLower(str));
return (s == "true" || s == "1" || s == "yes" || s == "on");
} }
// Convierte un valor booleano en una cadena // Convierte un valor booleano en una cadena