migrat, amb ajuda de claude, a sdl3gpu (postfx i crtpi) igual que el JDD
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
#include <string> // Para string
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "difficulty.hpp" // Para Code, init
|
||||
#include "difficulty.hpp" // Para Code, init
|
||||
#include "external/fkyaml_node.hpp" // Para fkyaml::node
|
||||
#include "input.hpp" // Para Input
|
||||
#include "lang.hpp" // Para getText, Code
|
||||
@@ -24,16 +24,17 @@ namespace Options {
|
||||
GamepadManager gamepad_manager; // Opciones de mando para cada jugador
|
||||
Keyboard keyboard; // Opciones para el teclado
|
||||
PendingChanges pending_changes; // Opciones que se aplican al cerrar
|
||||
std::vector<PostFXPreset> postfx_presets = { // Lista de presets de PostFX
|
||||
{"CRT", 0.6F, 0.7F, 0.15F, 0.5F, 0.5F, 0.0F, 0.0F, 0.0F},
|
||||
{"NTSC", 0.4F, 0.5F, 0.2F, 0.3F, 0.3F, 0.0F, 0.6F, 0.0F},
|
||||
{"CURVED", 0.5F, 0.6F, 0.1F, 0.4F, 0.4F, 0.8F, 0.0F, 0.0F},
|
||||
{"SCANLINES", 0.0F, 0.8F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F},
|
||||
{"SUBTLE", 0.3F, 0.4F, 0.05F, 0.0F, 0.2F, 0.0F, 0.0F, 0.0F},
|
||||
{"CRT LIVE", 0.5F, 0.6F, 0.3F, 0.3F, 0.4F, 0.3F, 0.4F, 0.8F},
|
||||
std::vector<PostFXPreset> postfx_presets = {
|
||||
{"CRT", 0.6F, 0.7F, 0.15F, 0.5F, 0.5F, 0.0F, 0.0F, 0.0F},
|
||||
{"NTSC", 0.4F, 0.5F, 0.2F, 0.3F, 0.3F, 0.0F, 0.6F, 0.0F},
|
||||
{"CURVED", 0.5F, 0.6F, 0.1F, 0.4F, 0.4F, 0.8F, 0.0F, 0.0F},
|
||||
{"SCANLINES", 0.0F, 0.8F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F},
|
||||
{"SUBTLE", 0.3F, 0.4F, 0.05F, 0.0F, 0.2F, 0.0F, 0.0F, 0.0F},
|
||||
{"CRT LIVE", 0.5F, 0.6F, 0.3F, 0.3F, 0.4F, 0.3F, 0.4F, 0.8F},
|
||||
};
|
||||
int current_postfx_preset = 0; // Índice del preset PostFX activo
|
||||
std::string postfx_file_path; // Ruta al fichero de presets PostFX
|
||||
std::string postfx_file_path;
|
||||
std::vector<CrtPiPreset> crtpi_presets;
|
||||
std::string crtpi_file_path;
|
||||
|
||||
// Establece el fichero de configuración
|
||||
void setConfigFile(const std::string& file_path) { settings.config_file = file_path; }
|
||||
@@ -44,6 +45,9 @@ namespace Options {
|
||||
// Establece la ruta del fichero de PostFX
|
||||
void setPostFXFile(const std::string& path) { postfx_file_path = path; }
|
||||
|
||||
// Establece la ruta del fichero de CrtPi
|
||||
void setCrtPiFile(const std::string& path) { crtpi_file_path = path; }
|
||||
|
||||
// Helper: extrae un campo float de un nodo YAML si existe, ignorando errores de conversión
|
||||
static void parseFloatField(const fkyaml::node& node, const std::string& key, float& target) {
|
||||
if (node.contains(key)) {
|
||||
@@ -89,11 +93,21 @@ namespace Options {
|
||||
}
|
||||
|
||||
if (!postfx_presets.empty()) {
|
||||
current_postfx_preset = std::clamp(
|
||||
current_postfx_preset, 0,
|
||||
// Resolver nombre → índice
|
||||
if (!video.shader.current_postfx_preset_name.empty()) {
|
||||
for (int i = 0; i < static_cast<int>(postfx_presets.size()); ++i) {
|
||||
if (postfx_presets[static_cast<size_t>(i)].name == video.shader.current_postfx_preset_name) {
|
||||
video.shader.current_postfx_preset = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
video.shader.current_postfx_preset = std::clamp(
|
||||
video.shader.current_postfx_preset,
|
||||
0,
|
||||
static_cast<int>(postfx_presets.size()) - 1);
|
||||
} else {
|
||||
current_postfx_preset = 0;
|
||||
video.shader.current_postfx_preset = 0;
|
||||
}
|
||||
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "PostFX file loaded: %zu preset(s)", postfx_presets.size());
|
||||
@@ -190,17 +204,141 @@ namespace Options {
|
||||
|
||||
// Cargar los presets recién escritos
|
||||
postfx_presets.clear();
|
||||
postfx_presets.push_back({"CRT", 0.6F, 0.7F, 0.15F, 0.5F, 0.5F, 0.0F, 0.0F, 0.0F});
|
||||
postfx_presets.push_back({"NTSC", 0.4F, 0.5F, 0.2F, 0.3F, 0.3F, 0.0F, 0.6F, 0.0F});
|
||||
postfx_presets.push_back({"CURVED", 0.5F, 0.6F, 0.1F, 0.4F, 0.4F, 0.8F, 0.0F, 0.0F});
|
||||
postfx_presets.push_back({"SCANLINES", 0.0F, 0.8F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F});
|
||||
postfx_presets.push_back({"SUBTLE", 0.3F, 0.4F, 0.05F, 0.0F, 0.2F, 0.0F, 0.0F, 0.0F});
|
||||
postfx_presets.push_back({"CRT LIVE", 0.5F, 0.6F, 0.3F, 0.3F, 0.4F, 0.3F, 0.4F, 0.8F});
|
||||
current_postfx_preset = 0;
|
||||
postfx_presets.push_back({"CRT", 0.6F, 0.7F, 0.15F, 0.5F, 0.5F, 0.0F, 0.0F, 0.0F});
|
||||
postfx_presets.push_back({"NTSC", 0.4F, 0.5F, 0.2F, 0.3F, 0.3F, 0.0F, 0.6F, 0.0F});
|
||||
postfx_presets.push_back({"CURVED", 0.5F, 0.6F, 0.1F, 0.4F, 0.4F, 0.8F, 0.0F, 0.0F});
|
||||
postfx_presets.push_back({"SCANLINES", 0.0F, 0.8F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F});
|
||||
postfx_presets.push_back({"SUBTLE", 0.3F, 0.4F, 0.05F, 0.0F, 0.2F, 0.0F, 0.0F, 0.0F});
|
||||
postfx_presets.push_back({"CRT LIVE", 0.5F, 0.6F, 0.3F, 0.3F, 0.4F, 0.3F, 0.4F, 0.8F});
|
||||
video.shader.current_postfx_preset = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Helper: extrae un campo bool de un nodo YAML si existe, ignorando errores
|
||||
static void parseBoolField(const fkyaml::node& node, const std::string& key, bool& target) {
|
||||
if (node.contains(key)) {
|
||||
try {
|
||||
target = node[key].get_value<bool>();
|
||||
} catch (...) {}
|
||||
}
|
||||
}
|
||||
|
||||
// Helper: extrae un campo int de un nodo YAML si existe, ignorando errores
|
||||
static void parseIntField(const fkyaml::node& node, const std::string& key, int& target) {
|
||||
if (node.contains(key)) {
|
||||
try {
|
||||
target = node[key].get_value<int>();
|
||||
} catch (...) {}
|
||||
}
|
||||
}
|
||||
|
||||
// Rellena los presets CrtPi por defecto
|
||||
static void populateDefaultCrtPiPresets() {
|
||||
crtpi_presets.clear();
|
||||
crtpi_presets.push_back({"DEFAULT", 6.0F, 0.12F, 3.5F, 2.4F, 2.2F, 0.80F, 0.05F, 0.10F, 2, true, true, true, false, false});
|
||||
crtpi_presets.push_back({"CURVED", 6.0F, 0.12F, 3.5F, 2.4F, 2.2F, 0.80F, 0.05F, 0.10F, 2, true, true, true, true, false});
|
||||
crtpi_presets.push_back({"SHARP", 6.0F, 0.12F, 3.5F, 2.4F, 2.2F, 0.80F, 0.05F, 0.10F, 2, true, false, true, false, true});
|
||||
crtpi_presets.push_back({"MINIMAL", 8.0F, 0.05F, 2.0F, 2.4F, 2.2F, 1.00F, 0.0F, 0.0F, 0, true, false, false, false, false});
|
||||
}
|
||||
|
||||
// Escribe los presets CrtPi por defecto al fichero
|
||||
static auto saveCrtPiDefaults() -> bool {
|
||||
if (crtpi_file_path.empty()) { return false; }
|
||||
std::ofstream file(crtpi_file_path);
|
||||
if (!file.is_open()) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error: %s can't be opened for writing", crtpi_file_path.c_str());
|
||||
return false;
|
||||
}
|
||||
file << "# Coffee Crisis Arcade Edition - CrtPi Shader Presets\n";
|
||||
file << "# scanline_weight: gaussian adjustment (higher = narrower scanlines, default 6.0)\n";
|
||||
file << "# scanline_gap_brightness: min brightness between scanlines (0.0-1.0, default 0.12)\n";
|
||||
file << "# bloom_factor: brightness for bright areas (default 3.5)\n";
|
||||
file << "# input_gamma: input gamma - linearization (default 2.4)\n";
|
||||
file << "# output_gamma: output gamma - encoding (default 2.2)\n";
|
||||
file << "# mask_brightness: sub-pixel brightness (default 0.80)\n";
|
||||
file << "# curvature_x/y: barrel CRT distortion (0.0 = flat)\n";
|
||||
file << "# mask_type: 0=none, 1=green/magenta, 2=RGB phosphor\n";
|
||||
file << "# enable_scanlines/multisample/gamma/curvature/sharper: true/false\n";
|
||||
file << "\npresets:\n";
|
||||
file << " - name: \"DEFAULT\"\n scanline_weight: 6.0\n scanline_gap_brightness: 0.12\n bloom_factor: 3.5\n input_gamma: 2.4\n output_gamma: 2.2\n mask_brightness: 0.80\n curvature_x: 0.05\n curvature_y: 0.10\n mask_type: 2\n enable_scanlines: true\n enable_multisample: true\n enable_gamma: true\n enable_curvature: false\n enable_sharper: false\n";
|
||||
file << " - name: \"CURVED\"\n scanline_weight: 6.0\n scanline_gap_brightness: 0.12\n bloom_factor: 3.5\n input_gamma: 2.4\n output_gamma: 2.2\n mask_brightness: 0.80\n curvature_x: 0.05\n curvature_y: 0.10\n mask_type: 2\n enable_scanlines: true\n enable_multisample: true\n enable_gamma: true\n enable_curvature: true\n enable_sharper: false\n";
|
||||
file << " - name: \"SHARP\"\n scanline_weight: 6.0\n scanline_gap_brightness: 0.12\n bloom_factor: 3.5\n input_gamma: 2.4\n output_gamma: 2.2\n mask_brightness: 0.80\n curvature_x: 0.05\n curvature_y: 0.10\n mask_type: 2\n enable_scanlines: true\n enable_multisample: false\n enable_gamma: true\n enable_curvature: false\n enable_sharper: true\n";
|
||||
file << " - name: \"MINIMAL\"\n scanline_weight: 8.0\n scanline_gap_brightness: 0.05\n bloom_factor: 2.0\n input_gamma: 2.4\n output_gamma: 2.2\n mask_brightness: 1.00\n curvature_x: 0.0\n curvature_y: 0.0\n mask_type: 0\n enable_scanlines: true\n enable_multisample: false\n enable_gamma: false\n enable_curvature: false\n enable_sharper: false\n";
|
||||
file.close();
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "CrtPi file created with defaults: %s", crtpi_file_path.c_str());
|
||||
populateDefaultCrtPiPresets();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Carga los presets de CrtPi desde el fichero
|
||||
auto loadCrtPiFromFile() -> bool {
|
||||
crtpi_presets.clear();
|
||||
|
||||
std::ifstream file(crtpi_file_path);
|
||||
if (!file.good()) {
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "CrtPi file not found, creating default: %s", crtpi_file_path.c_str());
|
||||
return saveCrtPiDefaults();
|
||||
}
|
||||
|
||||
std::string content((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
|
||||
file.close();
|
||||
|
||||
try {
|
||||
auto yaml = fkyaml::node::deserialize(content);
|
||||
|
||||
if (yaml.contains("presets")) {
|
||||
const auto& presets = yaml["presets"];
|
||||
for (const auto& p : presets) {
|
||||
CrtPiPreset preset;
|
||||
if (p.contains("name")) {
|
||||
preset.name = p["name"].get_value<std::string>();
|
||||
}
|
||||
parseFloatField(p, "scanline_weight", preset.scanline_weight);
|
||||
parseFloatField(p, "scanline_gap_brightness", preset.scanline_gap_brightness);
|
||||
parseFloatField(p, "bloom_factor", preset.bloom_factor);
|
||||
parseFloatField(p, "input_gamma", preset.input_gamma);
|
||||
parseFloatField(p, "output_gamma", preset.output_gamma);
|
||||
parseFloatField(p, "mask_brightness", preset.mask_brightness);
|
||||
parseFloatField(p, "curvature_x", preset.curvature_x);
|
||||
parseFloatField(p, "curvature_y", preset.curvature_y);
|
||||
parseIntField(p, "mask_type", preset.mask_type);
|
||||
parseBoolField(p, "enable_scanlines", preset.enable_scanlines);
|
||||
parseBoolField(p, "enable_multisample", preset.enable_multisample);
|
||||
parseBoolField(p, "enable_gamma", preset.enable_gamma);
|
||||
parseBoolField(p, "enable_curvature", preset.enable_curvature);
|
||||
parseBoolField(p, "enable_sharper", preset.enable_sharper);
|
||||
crtpi_presets.push_back(preset);
|
||||
}
|
||||
}
|
||||
|
||||
if (!crtpi_presets.empty()) {
|
||||
// Resolver nombre → índice
|
||||
if (!video.shader.current_crtpi_preset_name.empty()) {
|
||||
for (int i = 0; i < static_cast<int>(crtpi_presets.size()); ++i) {
|
||||
if (crtpi_presets[static_cast<size_t>(i)].name == video.shader.current_crtpi_preset_name) {
|
||||
video.shader.current_crtpi_preset = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
video.shader.current_crtpi_preset = std::clamp(
|
||||
video.shader.current_crtpi_preset,
|
||||
0,
|
||||
static_cast<int>(crtpi_presets.size()) - 1);
|
||||
} else {
|
||||
video.shader.current_crtpi_preset = 0;
|
||||
}
|
||||
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "CrtPi file loaded: %zu preset(s)", crtpi_presets.size());
|
||||
return true;
|
||||
|
||||
} catch (const fkyaml::exception& e) {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "Error parsing CrtPi YAML: %s. Recreating defaults.", e.what());
|
||||
return saveCrtPiDefaults();
|
||||
}
|
||||
}
|
||||
|
||||
// Inicializa las opciones del programa
|
||||
void init() {
|
||||
// Dificultades
|
||||
@@ -234,55 +372,109 @@ namespace Options {
|
||||
const auto& vid = yaml["video"];
|
||||
|
||||
if (vid.contains("fullscreen")) {
|
||||
try { video.fullscreen = vid["fullscreen"].get_value<bool>(); } catch (...) {}
|
||||
try {
|
||||
video.fullscreen = vid["fullscreen"].get_value<bool>();
|
||||
} catch (...) {}
|
||||
}
|
||||
if (vid.contains("scale_mode")) {
|
||||
try { video.scale_mode = static_cast<SDL_ScaleMode>(vid["scale_mode"].get_value<int>()); } catch (...) {}
|
||||
try {
|
||||
video.scale_mode = static_cast<SDL_ScaleMode>(vid["scale_mode"].get_value<int>());
|
||||
} catch (...) {}
|
||||
}
|
||||
if (vid.contains("vsync")) {
|
||||
try { video.vsync = vid["vsync"].get_value<bool>(); } catch (...) {}
|
||||
try {
|
||||
video.vsync = vid["vsync"].get_value<bool>();
|
||||
} catch (...) {}
|
||||
}
|
||||
if (vid.contains("integer_scale")) {
|
||||
try { video.integer_scale = vid["integer_scale"].get_value<bool>(); } catch (...) {}
|
||||
try {
|
||||
video.integer_scale = vid["integer_scale"].get_value<bool>();
|
||||
} catch (...) {}
|
||||
}
|
||||
if (vid.contains("postfx")) {
|
||||
try { video.postfx = vid["postfx"].get_value<bool>(); } catch (...) {}
|
||||
}
|
||||
// Nuevo formato: supersampling (bool) + supersampling_amount (int)
|
||||
// Backward compat: si solo existe supersampling como int, también funciona
|
||||
{
|
||||
bool ss_enabled = false;
|
||||
int ss_amount = 3;
|
||||
if (vid.contains("supersampling")) {
|
||||
|
||||
// --- GPU ---
|
||||
if (vid.contains("gpu")) {
|
||||
const auto& gpu_node = vid["gpu"];
|
||||
if (gpu_node.contains("acceleration")) {
|
||||
try {
|
||||
const auto& node = vid["supersampling"];
|
||||
if (node.is_boolean()) {
|
||||
ss_enabled = node.get_value<bool>();
|
||||
video.gpu.acceleration = gpu_node["acceleration"].get_value<bool>();
|
||||
} catch (...) {}
|
||||
}
|
||||
if (gpu_node.contains("preferred_driver")) {
|
||||
try {
|
||||
video.gpu.preferred_driver = gpu_node["preferred_driver"].get_value<std::string>();
|
||||
} catch (...) {}
|
||||
}
|
||||
}
|
||||
|
||||
// --- Shader config ---
|
||||
if (vid.contains("shader")) {
|
||||
const auto& sh = vid["shader"];
|
||||
if (sh.contains("enabled")) {
|
||||
try {
|
||||
video.shader.enabled = sh["enabled"].get_value<bool>();
|
||||
} catch (...) {}
|
||||
}
|
||||
if (sh.contains("current_shader")) {
|
||||
try {
|
||||
auto s = sh["current_shader"].get_value<std::string>();
|
||||
video.shader.current_shader = (s == "crtpi") ? Rendering::ShaderType::CRTPI : Rendering::ShaderType::POSTFX;
|
||||
} catch (...) {}
|
||||
}
|
||||
if (sh.contains("postfx_preset")) {
|
||||
try {
|
||||
video.shader.current_postfx_preset_name = sh["postfx_preset"].get_value<std::string>();
|
||||
} catch (...) {}
|
||||
}
|
||||
if (sh.contains("crtpi_preset")) {
|
||||
try {
|
||||
video.shader.current_crtpi_preset_name = sh["crtpi_preset"].get_value<std::string>();
|
||||
} catch (...) {}
|
||||
}
|
||||
} else if (vid.contains("postfx")) {
|
||||
// Backward compat: formato antiguo plano
|
||||
try {
|
||||
video.shader.enabled = vid["postfx"].get_value<bool>();
|
||||
} catch (...) {}
|
||||
if (vid.contains("postfx_preset")) {
|
||||
try {
|
||||
int preset = vid["postfx_preset"].get_value<int>();
|
||||
if (preset >= 0) { video.shader.current_postfx_preset = preset; }
|
||||
} catch (...) {}
|
||||
}
|
||||
}
|
||||
|
||||
// --- Supersampling ---
|
||||
if (vid.contains("supersampling")) {
|
||||
const auto& ss_node = vid["supersampling"];
|
||||
if (ss_node.is_mapping()) {
|
||||
// Nuevo formato anidado
|
||||
if (ss_node.contains("enabled")) {
|
||||
try {
|
||||
video.supersampling.enabled = ss_node["enabled"].get_value<bool>();
|
||||
} catch (...) {}
|
||||
}
|
||||
if (ss_node.contains("linear_upscale")) {
|
||||
try {
|
||||
video.supersampling.linear_upscale = ss_node["linear_upscale"].get_value<bool>();
|
||||
} catch (...) {}
|
||||
}
|
||||
if (ss_node.contains("downscale_algo")) {
|
||||
try {
|
||||
video.supersampling.downscale_algo = ss_node["downscale_algo"].get_value<int>();
|
||||
} catch (...) {}
|
||||
}
|
||||
} else {
|
||||
// Backward compat: bool o int
|
||||
try {
|
||||
if (ss_node.is_boolean()) {
|
||||
video.supersampling.enabled = ss_node.get_value<bool>();
|
||||
} else {
|
||||
// Formato antiguo: int directamente
|
||||
int factor = node.get_value<int>();
|
||||
ss_enabled = factor >= 2;
|
||||
ss_amount = (factor >= 2) ? factor : 3;
|
||||
int factor = ss_node.get_value<int>();
|
||||
video.supersampling.enabled = factor >= 2;
|
||||
}
|
||||
} catch (...) {}
|
||||
}
|
||||
if (vid.contains("supersampling_amount")) {
|
||||
try {
|
||||
int amount = vid["supersampling_amount"].get_value<int>();
|
||||
if (amount >= 2) { ss_amount = amount; }
|
||||
} catch (...) {}
|
||||
}
|
||||
video.supersampling = ss_enabled ? ss_amount : 1;
|
||||
}
|
||||
if (vid.contains("postfx_preset")) {
|
||||
try {
|
||||
int preset = vid["postfx_preset"].get_value<int>();
|
||||
// No validamos contra postfx_presets.size() aquí porque postfx.yaml
|
||||
// aún no se ha cargado. El clamp se hace en loadPostFXFromFile().
|
||||
if (preset >= 0) {
|
||||
current_postfx_preset = preset;
|
||||
}
|
||||
} catch (...) {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -291,27 +483,39 @@ namespace Options {
|
||||
const auto& aud = yaml["audio"];
|
||||
|
||||
if (aud.contains("enabled")) {
|
||||
try { audio.enabled = aud["enabled"].get_value<bool>(); } catch (...) {}
|
||||
try {
|
||||
audio.enabled = aud["enabled"].get_value<bool>();
|
||||
} catch (...) {}
|
||||
}
|
||||
if (aud.contains("volume")) {
|
||||
try { audio.volume = std::clamp(aud["volume"].get_value<int>(), 0, 100); } catch (...) {}
|
||||
try {
|
||||
audio.volume = std::clamp(aud["volume"].get_value<int>(), 0, 100);
|
||||
} catch (...) {}
|
||||
}
|
||||
if (aud.contains("music")) {
|
||||
const auto& mus = aud["music"];
|
||||
if (mus.contains("enabled")) {
|
||||
try { audio.music.enabled = mus["enabled"].get_value<bool>(); } catch (...) {}
|
||||
try {
|
||||
audio.music.enabled = mus["enabled"].get_value<bool>();
|
||||
} catch (...) {}
|
||||
}
|
||||
if (mus.contains("volume")) {
|
||||
try { audio.music.volume = std::clamp(mus["volume"].get_value<int>(), 0, 100); } catch (...) {}
|
||||
try {
|
||||
audio.music.volume = std::clamp(mus["volume"].get_value<int>(), 0, 100);
|
||||
} catch (...) {}
|
||||
}
|
||||
}
|
||||
if (aud.contains("sound")) {
|
||||
const auto& snd = aud["sound"];
|
||||
if (snd.contains("enabled")) {
|
||||
try { audio.sound.enabled = snd["enabled"].get_value<bool>(); } catch (...) {}
|
||||
try {
|
||||
audio.sound.enabled = snd["enabled"].get_value<bool>();
|
||||
} catch (...) {}
|
||||
}
|
||||
if (snd.contains("volume")) {
|
||||
try { audio.sound.volume = std::clamp(snd["volume"].get_value<int>(), 0, 100); } catch (...) {}
|
||||
try {
|
||||
audio.sound.volume = std::clamp(snd["volume"].get_value<int>(), 0, 100);
|
||||
} catch (...) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -338,13 +542,19 @@ namespace Options {
|
||||
} catch (...) {}
|
||||
}
|
||||
if (game.contains("autofire")) {
|
||||
try { settings.autofire = game["autofire"].get_value<bool>(); } catch (...) {}
|
||||
try {
|
||||
settings.autofire = game["autofire"].get_value<bool>();
|
||||
} catch (...) {}
|
||||
}
|
||||
if (game.contains("shutdown_enabled")) {
|
||||
try { settings.shutdown_enabled = game["shutdown_enabled"].get_value<bool>(); } catch (...) {}
|
||||
try {
|
||||
settings.shutdown_enabled = game["shutdown_enabled"].get_value<bool>();
|
||||
} catch (...) {}
|
||||
}
|
||||
if (game.contains("params_file")) {
|
||||
try { settings.params_file = game["params_file"].get_value<std::string>(); } catch (...) {}
|
||||
try {
|
||||
settings.params_file = game["params_file"].get_value<std::string>();
|
||||
} catch (...) {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -356,10 +566,14 @@ namespace Options {
|
||||
for (const auto& ctrl : controllers) {
|
||||
if (i >= GamepadManager::size()) { break; }
|
||||
if (ctrl.contains("name")) {
|
||||
try { gamepad_manager[i].name = ctrl["name"].get_value<std::string>(); } catch (...) {}
|
||||
try {
|
||||
gamepad_manager[i].name = ctrl["name"].get_value<std::string>();
|
||||
} catch (...) {}
|
||||
}
|
||||
if (ctrl.contains("path")) {
|
||||
try { gamepad_manager[i].path = ctrl["path"].get_value<std::string>(); } catch (...) {}
|
||||
try {
|
||||
gamepad_manager[i].path = ctrl["path"].get_value<std::string>();
|
||||
} catch (...) {}
|
||||
}
|
||||
if (ctrl.contains("player")) {
|
||||
try {
|
||||
@@ -379,7 +593,9 @@ namespace Options {
|
||||
if (!yaml.contains("keyboard")) { return; }
|
||||
const auto& kb = yaml["keyboard"];
|
||||
if (kb.contains("player")) {
|
||||
try { keyboard.player_id = static_cast<Player::Id>(kb["player"].get_value<int>()); } catch (...) {}
|
||||
try {
|
||||
keyboard.player_id = static_cast<Player::Id>(kb["player"].get_value<int>());
|
||||
} catch (...) {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -452,10 +668,26 @@ namespace Options {
|
||||
file << " scale_mode: " << static_cast<int>(video.scale_mode) << " # " << static_cast<int>(SDL_ScaleMode::SDL_SCALEMODE_NEAREST) << ": nearest, " << static_cast<int>(SDL_ScaleMode::SDL_SCALEMODE_LINEAR) << ": linear\n";
|
||||
file << " vsync: " << boolToString(video.vsync) << "\n";
|
||||
file << " integer_scale: " << boolToString(video.integer_scale) << "\n";
|
||||
file << " postfx: " << boolToString(video.postfx) << "\n";
|
||||
file << " postfx_preset: " << current_postfx_preset << "\n";
|
||||
file << " supersampling: " << boolToString(video.supersampling > 1) << "\n";
|
||||
file << " supersampling_amount: " << std::max(2, video.supersampling) << "\n";
|
||||
file << " gpu:\n";
|
||||
file << " acceleration: " << boolToString(video.gpu.acceleration) << "\n";
|
||||
file << " preferred_driver: \"" << video.gpu.preferred_driver << "\"\n";
|
||||
file << " shader:\n";
|
||||
file << " enabled: " << boolToString(video.shader.enabled) << "\n";
|
||||
file << " current_shader: " << (video.shader.current_shader == Rendering::ShaderType::CRTPI ? "crtpi" : "postfx") << "\n";
|
||||
{
|
||||
std::string postfx_name = (!postfx_presets.empty() && video.shader.current_postfx_preset < static_cast<int>(postfx_presets.size()))
|
||||
? postfx_presets[static_cast<size_t>(video.shader.current_postfx_preset)].name
|
||||
: "";
|
||||
std::string crtpi_name = (!crtpi_presets.empty() && video.shader.current_crtpi_preset < static_cast<int>(crtpi_presets.size()))
|
||||
? crtpi_presets[static_cast<size_t>(video.shader.current_crtpi_preset)].name
|
||||
: "";
|
||||
file << " postfx_preset: \"" << postfx_name << "\"\n";
|
||||
file << " crtpi_preset: \"" << crtpi_name << "\"\n";
|
||||
}
|
||||
file << " supersampling:\n";
|
||||
file << " enabled: " << boolToString(video.supersampling.enabled) << "\n";
|
||||
file << " linear_upscale: " << boolToString(video.supersampling.linear_upscale) << "\n";
|
||||
file << " downscale_algo: " << video.supersampling.downscale_algo << "\n";
|
||||
file << "\n";
|
||||
|
||||
// AUDIO
|
||||
|
||||
Reference in New Issue
Block a user