From 7e46b4b5bb374067345168533de792d52d106175 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Thu, 26 Oct 2023 12:26:03 +0200 Subject: [PATCH] config:: set_value_to for enum settings --- config.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/config.cpp b/config.cpp index 1e45c2cd..6aa0135d 100644 --- a/config.cpp +++ b/config.cpp @@ -122,13 +122,14 @@ namespace anims { template struct enum_setting : list_setting { T *value, last_value, dft, anim_value; int get_value() override { return (int) *value; } - void set_value(int i) override { *value = (T) i; } + hr::function set_value_to; + void set_value(int i) override { set_value_to((T)i); } bool affects(void* v) override { return v == value; } supersaver *make_saver() override; virtual void load_from_raw(const string& s) { int N = isize(options); for(int i=0; i struct enum_setting : list_setting { anim_value = *value; anims::animate_setting(this, s); } + + enum_setting* editable(const vector >& o, string menu_item_name, char key) { + list_setting::editable(o, menu_item_name, key); + return this; + } }; /** transmatrix with equality, so we can construct val_setting */ @@ -777,6 +783,7 @@ template enum_setting *param_enum(T& val, const string p, const stri u->last_value = dft; u->register_saver(); auto f = &*u; + u->set_value_to = [f] (T val) { *f->value = val; }; params[p] = std::move(u); return f; }