summaryrefslogtreecommitdiff
path: root/src/til.c
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-07-05 10:59:24 -0700
committerVito Caputo <vcaputo@pengaru.com>2023-07-05 11:05:34 -0700
commitb66147bef15f6cb7fcb9d15f121d1e345a7af970 (patch)
tree982bfa8e27b110ea10b071c5fe1cad2c03c78b87 /src/til.c
parent02cb290db43a2c6761083328d408dca63ed3d3b6 (diff)
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.
Diffstat (limited to 'src/til.c')
-rw-r--r--src/til.c24
1 files changed, 24 insertions, 0 deletions
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;
© All Rights Reserved