From b66147bef15f6cb7fcb9d15f121d1e345a7af970 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Wed, 5 Jul 2023 10:59:24 -0700 Subject: til: describe module name in til_module_setup_randomize() It just happened to be tolerable that the first setting in these randomized settings instances wasn't ever getting described... due to the ad-hoc nature of how rtv used them. But in preparation for rkt_scener which will have "randomize scene" functionality, as well as interactive (re)configuring of the scenes, these settings instances need to be more correct to not break things. It seems awkward to be duplicating this "Renderer module" desc here however. But I just want to make progress on the scene editor for rkt, I suspect this will be revisited in the future. On a high-level it feels like til_module_setup() should be the thing producing that desc, and the randomizer just picking the random settings through that setup func. --- src/til.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/til.c b/src/til.c index bf454ca..66b2b5c 100644 --- a/src/til.c +++ b/src/til.c @@ -538,12 +538,36 @@ int til_module_setup(const til_settings_t *settings, til_setting_t **res_setting int til_module_setup_randomize(const til_module_t *module, til_settings_t *settings, unsigned seed, til_setup_t **res_setup, char **res_arg) { til_setting_t *setting; + const char *name; const til_setting_desc_t *desc; int r = 0; assert(module); assert(settings); + /* This is kind of a silly formality for randomize, since the callers already + * specify the module. But we really need to ensure the first entry is described, + * so the .as_label can be found in situations like rkt_scener's "add randomized scene". + * + * FIXME TODO: what should probably be happening using til_module_setup() as the + * top-level setup_func, to get the module setting described. This is just a quick + * hack to make things usable. + */ + name = til_settings_get_value_by_idx(settings, 0, &setting); + if (!name) + return -EINVAL; /* TODO: add a first setting from module->name? current callers always pass the module name as the setting string */ + + if (!setting->desc) { + r = til_setting_desc_new( settings, + &(til_setting_spec_t){ + .name = "Renderer module", + .preferred = module->name, + .as_label = 1 + }, &setting->desc); + if (r < 0) + return r; + } + if (!module->setup) { til_setup_t *setup; -- cgit v1.2.3