opció de preset al service menu (params_file → params_preset)
Defaults::Settings::PARAMS_FILE passa a PARAMS_PRESET (id intern: classic/arcade/red); director concatena .txt al carregar. Nou ListOption "GAME_PRESET" al service menu amb les tres opcions localitzades (cal reinici per aplicar). Validació al parser del YAML: si el preset desat no existeix, cau al default.
This commit is contained in:
+28
-5
@@ -333,6 +333,7 @@ namespace Options {
|
||||
// Opciones de cambios pendientes
|
||||
pending_changes.new_language = settings.language;
|
||||
pending_changes.new_difficulty = settings.difficulty;
|
||||
pending_changes.new_params_preset = settings.params_preset;
|
||||
pending_changes.has_pending_changes = false;
|
||||
}
|
||||
|
||||
@@ -423,8 +424,8 @@ namespace Options {
|
||||
parseField(game, "language", lang_int);
|
||||
const auto LANG = static_cast<Lang::Code>(lang_int);
|
||||
settings.language = (LANG == Lang::Code::ENGLISH || LANG == Lang::Code::VALENCIAN || LANG == Lang::Code::SPANISH)
|
||||
? LANG
|
||||
: Lang::Code::ENGLISH;
|
||||
? LANG
|
||||
: Lang::Code::ENGLISH;
|
||||
pending_changes.new_language = settings.language;
|
||||
}
|
||||
if (game.contains("difficulty")) {
|
||||
@@ -435,7 +436,12 @@ namespace Options {
|
||||
}
|
||||
parseField(game, "autofire", settings.autofire);
|
||||
parseField(game, "shutdown_enabled", settings.shutdown_enabled);
|
||||
parseField(game, "params_file", settings.params_file);
|
||||
parseField(game, "params_preset", settings.params_preset);
|
||||
// Validar que el preset llegit existeix; si no, caure al default
|
||||
if (std::ranges::find(PARAMS_PRESETS, settings.params_preset) == PARAMS_PRESETS.end()) {
|
||||
settings.params_preset = Defaults::Settings::PARAMS_PRESET;
|
||||
}
|
||||
pending_changes.new_params_preset = settings.params_preset;
|
||||
}
|
||||
|
||||
void loadControllersFromYaml(const fkyaml::node& yaml) {
|
||||
@@ -592,7 +598,7 @@ namespace Options {
|
||||
file << " difficulty: " << static_cast<int>(settings.difficulty) << " # " << static_cast<int>(Difficulty::Code::EASY) << ": easy, " << static_cast<int>(Difficulty::Code::NORMAL) << ": normal, " << static_cast<int>(Difficulty::Code::HARD) << ": hard\n";
|
||||
file << " autofire: " << boolToString(settings.autofire) << "\n";
|
||||
file << " shutdown_enabled: " << boolToString(settings.shutdown_enabled) << "\n";
|
||||
file << " params_file: " << settings.params_file << "\n";
|
||||
file << " params_preset: " << settings.params_preset << "\n";
|
||||
file << "\n";
|
||||
|
||||
// CONTROLLERS
|
||||
@@ -635,13 +641,30 @@ namespace Options {
|
||||
if (pending_changes.has_pending_changes) {
|
||||
settings.language = pending_changes.new_language;
|
||||
settings.difficulty = pending_changes.new_difficulty;
|
||||
settings.params_preset = pending_changes.new_params_preset;
|
||||
pending_changes.has_pending_changes = false;
|
||||
}
|
||||
}
|
||||
|
||||
void checkPendingChanges() {
|
||||
pending_changes.has_pending_changes = settings.language != pending_changes.new_language ||
|
||||
settings.difficulty != pending_changes.new_difficulty;
|
||||
settings.difficulty != pending_changes.new_difficulty ||
|
||||
settings.params_preset != pending_changes.new_params_preset;
|
||||
}
|
||||
|
||||
// --- Presets de paràmetres ---
|
||||
auto getParamsPresetDisplayName(const std::string& preset_id) -> std::string {
|
||||
if (preset_id == "classic") { return Lang::getText("[SERVICE_MENU] PRESET_CLASSIC"); }
|
||||
if (preset_id == "arcade") { return Lang::getText("[SERVICE_MENU] PRESET_ARCADE"); }
|
||||
if (preset_id == "red") { return Lang::getText("[SERVICE_MENU] PRESET_RED"); }
|
||||
return preset_id;
|
||||
}
|
||||
|
||||
auto getParamsPresetIdFromDisplay(const std::string& display_name) -> std::string {
|
||||
const auto IT = std::ranges::find_if(PARAMS_PRESETS, [&](const std::string& id) {
|
||||
return getParamsPresetDisplayName(id) == display_name;
|
||||
});
|
||||
return IT != PARAMS_PRESETS.end() ? *IT : Defaults::Settings::PARAMS_PRESET;
|
||||
}
|
||||
|
||||
// Buscar y asignar un mando disponible por nombre
|
||||
|
||||
Reference in New Issue
Block a user