From 39e42ba735a8083434d91bb58cfc61d4b799291d Mon Sep 17 00:00:00 2001 From: Quantum Date: Mon, 30 Aug 2021 04:23:09 -0400 Subject: [PATCH] [common] option: change option_dump to option_dump_preset This new function dumps all options marked as preset instead of dumping individual sections. This should allow filter options to not be all grouped into the [eglFilter] section. --- client/renderers/EGL/postprocess.c | 2 +- common/include/common/option.h | 4 ++-- common/src/option.c | 30 ++++++++++++++++++++---------- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/client/renderers/EGL/postprocess.c b/client/renderers/EGL/postprocess.c index c7a67034..a56b3baa 100644 --- a/client/renderers/EGL/postprocess.c +++ b/client/renderers/EGL/postprocess.c @@ -194,7 +194,7 @@ static bool savePreset(struct EGL_PostProcess * this, const char * name) free(path); DEBUG_INFO("Saving preset: %s", name); - option_dump(file, "eglFilter"); + option_dump_preset(file); fclose(file); return true; } diff --git a/common/include/common/option.h b/common/include/common/option.h index 2aeab2e1..36928068 100644 --- a/common/include/common/option.h +++ b/common/include/common/option.h @@ -102,8 +102,8 @@ bool option_validate(void); // print out the options, help, and their current values void option_print(void); -// dump the options in ini format into the file -bool option_dump(FILE * file, const char * module); +// dump preset options in ini format into the file +bool option_dump_preset(FILE * file); // final cleanup void option_free(void); diff --git a/common/src/option.c b/common/src/option.c index 86222532..19504a6b 100644 --- a/common/src/option.c +++ b/common/src/option.c @@ -758,21 +758,31 @@ void option_print(void) } // dump the options in ini format into the file -bool option_dump(FILE * file, const char * module) +bool option_dump_preset(FILE * file) { - fprintf(file, "[%s]\n", module); - - for (int i = 0; i < state.oCount; ++i) + for (int g = 0; g < state.gCount; ++g) { - struct Option * o = state.options[i]; - if (strcasecmp(o->module, module) != 0) + bool hasPreset = false; + for (int i = 0; i < state.groups[g].count; ++i) + hasPreset |= state.groups[g].options[i]->preset; + if (!hasPreset) continue; - char * value = o->toString(o); - fprintf(file, "%s=%s\n", o->name, value); - free(value); + + fprintf(file, "[%s]\n", state.groups[g].module); + + for (int i = 0; i < state.groups[g].count; ++i) + { + struct Option * o = state.groups[g].options[i]; + if (!o->preset) + continue; + + char * value = o->toString(o); + fprintf(file, "%s=%s\n", o->name, value); + free(value); + } + fputc('\n', file); } - fputc('\n', file); return true; }