ServiceMenu: afegida opció per a canviar el idioma

This commit is contained in:
2025-06-12 13:50:05 +02:00
parent e6f4e27fbd
commit f9b576ea25
14 changed files with 307 additions and 109 deletions

View File

@@ -47,6 +47,11 @@ void initOptions()
options.controllers.at(0).player_id = 1;
options.controllers.at(1).player_id = 2;
setKeyboardToPlayer(1);
// Opciones pendientes
options.pending_changes.new_language = options.game.language;
options.pending_changes.new_difficulty = options.game.difficulty;
options.pending_changes.has_pending_changes = false;
}
// Carga el fichero de configuración
@@ -115,6 +120,8 @@ bool saveOptionsFile(std::string file_path)
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Writing file: %s", getFileName(file_path).c_str());
applyPendingChanges();
// Opciones de video
file << "## VIDEO\n";
file << "## video.scale_mode [" << static_cast<int>(SDL_ScaleMode::SDL_SCALEMODE_NEAREST) << ": nearest, " << static_cast<int>(SDL_ScaleMode::SDL_SCALEMODE_LINEAR) << ": lineal]\n";
@@ -237,10 +244,12 @@ bool setOptions(const std::string &var, const std::string &value)
else if (var == "game.language")
{
options.game.language = static_cast<lang::Code>(std::stoi(value));
options.pending_changes.new_language = options.game.language;
}
else if (var == "game.difficulty")
{
options.game.difficulty = static_cast<GameDifficulty>(std::stoi(value));
options.pending_changes.new_difficulty = options.game.difficulty;
}
else if (var == "game.autofire")
{
@@ -365,4 +374,15 @@ int getPlayerWhoUsesKeyboard()
}
}
return 0;
}
}
// Aplica los cambios pendientes copiando los valores a sus variables
void applyPendingChanges()
{
if (options.pending_changes.has_pending_changes)
{
options.game.language = options.pending_changes.new_language;
options.game.difficulty = options.pending_changes.new_difficulty;
options.pending_changes.has_pending_changes = false;
}
}