presets en postfx
This commit is contained in:
@@ -329,11 +329,11 @@ void loadBasicVideoFieldsFromYaml(const fkyaml::node& vid) {
|
||||
}
|
||||
}
|
||||
|
||||
if (vid.contains("shaders")) {
|
||||
if (vid.contains("postfx")) {
|
||||
try {
|
||||
video.shaders = vid["shaders"].get_value<bool>();
|
||||
video.postfx = vid["postfx"].get_value<bool>();
|
||||
} catch (...) {
|
||||
video.shaders = Defaults::Video::SHADERS;
|
||||
video.postfx = Defaults::Video::POSTFX;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -606,7 +606,7 @@ auto saveToFile() -> bool {
|
||||
file << "video:\n";
|
||||
file << " fullscreen: " << (video.fullscreen ? "true" : "false") << "\n";
|
||||
file << " filter: " << filterToString(video.filter) << " # filter: nearest (pixel perfect) | linear (smooth)\n";
|
||||
file << " shaders: " << (video.shaders ? "true" : "false") << "\n";
|
||||
file << " postfx: " << (video.postfx ? "true" : "false") << "\n";
|
||||
file << " vertical_sync: " << (video.vertical_sync ? "true" : "false") << "\n";
|
||||
file << " integer_scale: " << (video.integer_scale ? "true" : "false") << "\n";
|
||||
file << " keep_aspect: " << (video.keep_aspect ? "true" : "false") << "\n";
|
||||
@@ -649,4 +649,97 @@ auto saveToFile() -> bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Establece la ruta del fichero de PostFX
|
||||
void setPostFXFile(const std::string& path) {
|
||||
postfx_file_path = path;
|
||||
}
|
||||
|
||||
// Carga los presets de PostFX desde el fichero
|
||||
auto loadPostFXFromFile() -> bool {
|
||||
postfx_presets.clear();
|
||||
current_postfx_preset = 0;
|
||||
|
||||
std::ifstream file(postfx_file_path);
|
||||
if (!file.good()) {
|
||||
if (console) {
|
||||
std::cout << "PostFX file not found, creating default: " << postfx_file_path << '\n';
|
||||
}
|
||||
return savePostFXToFile();
|
||||
}
|
||||
|
||||
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 (size_t i = 0; i < presets.size(); ++i) {
|
||||
const auto& p = presets[i];
|
||||
PostFXPreset preset;
|
||||
if (p.contains("name")) {
|
||||
preset.name = p["name"].get_value<std::string>();
|
||||
}
|
||||
if (p.contains("vertex")) {
|
||||
preset.vertex = p["vertex"].get_value<std::string>();
|
||||
}
|
||||
if (p.contains("fragment")) {
|
||||
preset.fragment = p["fragment"].get_value<std::string>();
|
||||
}
|
||||
postfx_presets.push_back(preset);
|
||||
}
|
||||
}
|
||||
|
||||
if (console) {
|
||||
std::cout << "PostFX file loaded: " << postfx_presets.size() << " preset(s)\n";
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} catch (const fkyaml::exception& e) {
|
||||
if (console) {
|
||||
std::cerr << "Error parsing PostFX YAML: " << e.what() << '\n';
|
||||
}
|
||||
return savePostFXToFile();
|
||||
}
|
||||
}
|
||||
|
||||
// Guarda los presets de PostFX por defecto
|
||||
auto savePostFXToFile() -> bool {
|
||||
if (postfx_file_path.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::ofstream file(postfx_file_path);
|
||||
if (!file.is_open()) {
|
||||
if (console) {
|
||||
std::cerr << "Error: Unable to open file " << postfx_file_path << " for writing\n";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
file << "# JailDoctor's Dilemma - PostFX Presets\n";
|
||||
file << "# Add or modify presets to customize post-processing effects.\n";
|
||||
file << "# vertex and fragment reference shader filenames from the shaders directory.\n";
|
||||
file << "\n";
|
||||
file << "presets:\n";
|
||||
file << " - name: \"CRT\"\n";
|
||||
file << " vertex: \"crtpi_vertex.glsl\"\n";
|
||||
file << " fragment: \"crtpi_fragment.glsl\"\n";
|
||||
|
||||
file.close();
|
||||
|
||||
if (console) {
|
||||
std::cout << "PostFX file created with defaults: " << postfx_file_path << '\n';
|
||||
}
|
||||
|
||||
// Cargar los presets recién creados
|
||||
postfx_presets.clear();
|
||||
postfx_presets.push_back({"CRT", "crtpi_vertex.glsl", "crtpi_fragment.glsl"});
|
||||
current_postfx_preset = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace Options
|
||||
|
||||
Reference in New Issue
Block a user