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:
@@ -10,13 +10,15 @@ DATA|${SYSTEM_FOLDER}/postfx.yaml|optional,absolute
|
||||
DATA|${SYSTEM_FOLDER}/crtpi.yaml|optional,absolute
|
||||
DATA|${SYSTEM_FOLDER}/score.bin|optional,absolute
|
||||
|
||||
# Archivos de configuración del juego (viatgen dins el pack)
|
||||
DATA|/data/config/formations.txt
|
||||
DATA|/data/config/param_320x240.txt
|
||||
DATA|/data/config/param_320x256.txt
|
||||
DATA|/data/config/param_red.txt
|
||||
DATA|/data/config/pools.txt
|
||||
DATA|/data/config/stages.txt
|
||||
# Dades de gameplay (viatgen dins el pack)
|
||||
DATA|/data/config/gameplay/formations.txt
|
||||
DATA|/data/config/gameplay/pools.txt
|
||||
DATA|/data/config/gameplay/stages.txt
|
||||
|
||||
# Presets de paràmetres (viatgen dins el pack)
|
||||
DATA|/data/config/presets/classic.txt
|
||||
DATA|/data/config/presets/arcade.txt
|
||||
DATA|/data/config/presets/red.txt
|
||||
|
||||
# Archivos con los datos de la demo
|
||||
DEMODATA|/data/demo/demo1.bin
|
||||
|
||||
@@ -105,6 +105,10 @@
|
||||
"[SERVICE_MENU] EASY": "Facil",
|
||||
"[SERVICE_MENU] NORMAL": "Normal",
|
||||
"[SERVICE_MENU] HARD": "Dificil",
|
||||
"[SERVICE_MENU] GAME_PRESET": "Perfil",
|
||||
"[SERVICE_MENU] PRESET_CLASSIC": "Classic",
|
||||
"[SERVICE_MENU] PRESET_ARCADE": "Arcade",
|
||||
"[SERVICE_MENU] PRESET_RED": "Roig",
|
||||
"[SERVICE_MENU] NEED_RESTART_MESSAGE": "Reiniciar per aplicar canvis",
|
||||
"[SERVICE_MENU] ENABLE_SHUTDOWN": "Permetre apagar el sistema",
|
||||
"[SERVICE_MENU] CONTROLS": "Controls",
|
||||
|
||||
@@ -104,6 +104,10 @@
|
||||
"[SERVICE_MENU] EASY": "Easy",
|
||||
"[SERVICE_MENU] NORMAL": "Normal",
|
||||
"[SERVICE_MENU] HARD": "Hard",
|
||||
"[SERVICE_MENU] GAME_PRESET": "Preset",
|
||||
"[SERVICE_MENU] PRESET_CLASSIC": "Classic",
|
||||
"[SERVICE_MENU] PRESET_ARCADE": "Arcade",
|
||||
"[SERVICE_MENU] PRESET_RED": "Red",
|
||||
"[SERVICE_MENU] NEED_RESTART_MESSAGE": "Restart to apply changes",
|
||||
"[SERVICE_MENU] ENABLE_SHUTDOWN": "Allow system shutdown",
|
||||
"[SERVICE_MENU] CONTROLS": "Controls",
|
||||
|
||||
@@ -104,6 +104,10 @@
|
||||
"[SERVICE_MENU] EASY": "Facil",
|
||||
"[SERVICE_MENU] NORMAL": "Normal",
|
||||
"[SERVICE_MENU] HARD": "Dificil",
|
||||
"[SERVICE_MENU] GAME_PRESET": "Perfil",
|
||||
"[SERVICE_MENU] PRESET_CLASSIC": "Clasico",
|
||||
"[SERVICE_MENU] PRESET_ARCADE": "Arcade",
|
||||
"[SERVICE_MENU] PRESET_RED": "Rojo",
|
||||
"[SERVICE_MENU] NEED_RESTART_MESSAGE": "Reiniciar para aplicar cambios",
|
||||
"[SERVICE_MENU] ENABLE_SHUTDOWN": "Permitir apagar el sistema",
|
||||
"[SERVICE_MENU] CONTROLS": "Controles",
|
||||
|
||||
@@ -211,7 +211,7 @@ namespace Defaults::Audio {
|
||||
namespace Defaults::Settings {
|
||||
constexpr bool AUTOFIRE = true;
|
||||
constexpr bool SHUTDOWN_ENABLED = false;
|
||||
constexpr const char* PARAMS_FILE = "param_320x256.txt";
|
||||
constexpr const char* PARAMS_PRESET = "arcade"; // Identificador intern del preset (correspon a data/config/<preset>.txt)
|
||||
} // namespace Defaults::Settings
|
||||
|
||||
namespace Defaults::Loading {
|
||||
|
||||
@@ -241,9 +241,9 @@ void Director::close() {
|
||||
void Director::loadParams() {
|
||||
// Carga los parametros para configurar el juego
|
||||
#ifdef ANBERNIC
|
||||
const std::string PARAM_FILE_PATH = Asset::get()->getPath("param_320x240.txt");
|
||||
const std::string PARAM_FILE_PATH = Asset::get()->getPath("classic.txt");
|
||||
#else
|
||||
const std::string PARAM_FILE_PATH = Asset::get()->getPath(Options::settings.params_file);
|
||||
const std::string PARAM_FILE_PATH = Asset::get()->getPath(Options::settings.params_preset + ".txt");
|
||||
#endif
|
||||
loadParamsFromFile(PARAM_FILE_PATH);
|
||||
}
|
||||
|
||||
+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
|
||||
|
||||
+14
-4
@@ -126,7 +126,7 @@ namespace Options {
|
||||
std::vector<int> glowing_entries = {ManageHiScoreTable::NO_ENTRY, ManageHiScoreTable::NO_ENTRY}; // Últimas posiciones de entrada en la tabla
|
||||
std::string config_file; // Ruta al fichero donde guardar la configuración y las opciones del juego
|
||||
std::string controllers_file; // Ruta al fichero con las configuraciones de los mandos
|
||||
std::string params_file = Defaults::Settings::PARAMS_FILE; // Ruta al fichero de parámetros del juego
|
||||
std::string params_preset = Defaults::Settings::PARAMS_PRESET; // Identificador del preset de parámetros (classic/arcade/red)
|
||||
|
||||
// Reinicia las últimas entradas de puntuación
|
||||
void clearLastHiScoreEntries() {
|
||||
@@ -329,11 +329,21 @@ namespace Options {
|
||||
};
|
||||
|
||||
struct PendingChanges {
|
||||
Lang::Code new_language = Lang::Code::VALENCIAN; // Idioma en espera de aplicar
|
||||
Difficulty::Code new_difficulty = Difficulty::Code::NORMAL; // Dificultad en espera de aplicar
|
||||
bool has_pending_changes = false; // Indica si hay cambios pendientes
|
||||
Lang::Code new_language = Lang::Code::VALENCIAN; // Idioma en espera de aplicar
|
||||
Difficulty::Code new_difficulty = Difficulty::Code::NORMAL; // Dificultad en espera de aplicar
|
||||
std::string new_params_preset = Defaults::Settings::PARAMS_PRESET; // Preset de parámetros en espera de aplicar (requiere reinicio)
|
||||
bool has_pending_changes = false; // Indica si hay cambios pendientes
|
||||
};
|
||||
|
||||
// Lista d'identificadors de presets de paràmetres disponibles. Cada nom es correspon
|
||||
// amb el .txt al pack (data/config/<id>.txt). L'ordre marca el cicle al service menu.
|
||||
inline const std::vector<std::string> PARAMS_PRESETS = {"classic", "arcade", "red"};
|
||||
|
||||
// Tradueix l'identificador intern a la cadena visible (localitzada).
|
||||
auto getParamsPresetDisplayName(const std::string& preset_id) -> std::string;
|
||||
// Tradueix la cadena visible al seu identificador intern.
|
||||
auto getParamsPresetIdFromDisplay(const std::string& display_name) -> std::string;
|
||||
|
||||
// --- Variables ---
|
||||
extern Window window; // Opciones de la ventana
|
||||
extern Settings settings; // Opciones del juego
|
||||
|
||||
@@ -541,6 +541,22 @@ void ServiceMenu::addSettingsOptions() {
|
||||
Options::checkPendingChanges();
|
||||
}));
|
||||
|
||||
// Preset de paràmetres (requereix reinici): cicla classic/arcade/red
|
||||
std::vector<std::string> preset_display_names;
|
||||
preset_display_names.reserve(Options::PARAMS_PRESETS.size());
|
||||
std::ranges::transform(Options::PARAMS_PRESETS, std::back_inserter(preset_display_names), Options::getParamsPresetDisplayName);
|
||||
options_.push_back(std::make_unique<ListOption>(
|
||||
Lang::getText("[SERVICE_MENU] GAME_PRESET"),
|
||||
SettingsGroup::SETTINGS,
|
||||
preset_display_names,
|
||||
[]() -> std::string {
|
||||
return Options::getParamsPresetDisplayName(Options::pending_changes.new_params_preset);
|
||||
},
|
||||
[](const std::string& val) -> void {
|
||||
Options::pending_changes.new_params_preset = Options::getParamsPresetIdFromDisplay(val);
|
||||
Options::checkPendingChanges();
|
||||
}));
|
||||
|
||||
options_.push_back(std::make_unique<BoolOption>(
|
||||
Lang::getText("[SERVICE_MENU] ENABLE_SHUTDOWN"),
|
||||
SettingsGroup::SETTINGS,
|
||||
|
||||
Reference in New Issue
Block a user