mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-11-10 15:59:53 +00:00
config:: moved sets() to setting::
This commit is contained in:
parent
4f87697392
commit
016569bb35
26
config.cpp
26
config.cpp
@ -60,9 +60,21 @@ struct setting {
|
|||||||
add_to_changed(this);
|
add_to_changed(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
reaction_t sets;
|
||||||
|
setting *set_sets(const reaction_t& s) { sets = s; return this; }
|
||||||
|
setting *set_extra(const reaction_t& r);
|
||||||
|
setting *set_reaction(const reaction_t& r);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
setting *setting::set_extra(const reaction_t& r) {
|
||||||
|
auto s = sets; set_sets([s, r] { s(); dialog::extra_options = r; }); return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
setting *setting::set_reaction(const reaction_t& r) {
|
||||||
|
auto s = sets; set_sets([s, r] { s(); dialog::reaction = r; }); return this;
|
||||||
|
}
|
||||||
|
|
||||||
EX map<string, std::unique_ptr<setting>> params;
|
EX map<string, std::unique_ptr<setting>> params;
|
||||||
|
|
||||||
EX void show_edit_option_enum(char* value, const string& name, const vector<pair<string, string>>& options, char key, setting *s);
|
EX void show_edit_option_enum(char* value, const string& name, const vector<pair<string, string>>& options, char key, setting *s);
|
||||||
@ -105,11 +117,7 @@ struct float_setting : public setting {
|
|||||||
default_key = key;
|
default_key = key;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
reaction_t extra, reaction, sets;
|
|
||||||
function<void(float_setting*)> modify_me;
|
function<void(float_setting*)> modify_me;
|
||||||
float_setting *set_extra(const reaction_t& r) { extra = r; return this; }
|
|
||||||
float_setting *set_reaction(const reaction_t& r) { reaction = r; return this; }
|
|
||||||
float_setting *set_sets(const reaction_t& s) { sets = s; return this; }
|
|
||||||
float_setting *modif(const function<void(float_setting*)>& r) { modify_me = r; return this; }
|
float_setting *modif(const function<void(float_setting*)>& r) { modify_me = r; return this; }
|
||||||
void add_as_saver();
|
void add_as_saver();
|
||||||
virtual bool affects(void *v) override { return v == value; }
|
virtual bool affects(void *v) override { return v == value; }
|
||||||
@ -122,12 +130,8 @@ struct int_setting : public setting {
|
|||||||
int dft;
|
int dft;
|
||||||
int min_value, max_value, step;
|
int min_value, max_value, step;
|
||||||
void add_as_saver();
|
void add_as_saver();
|
||||||
reaction_t extra, reaction, sets;
|
|
||||||
function<void(int_setting*)> modify_me;
|
function<void(int_setting*)> modify_me;
|
||||||
int_setting *set_extra(const reaction_t& r) { extra = r; return this; }
|
|
||||||
int_setting *set_reaction(const reaction_t& r) { reaction = r; return this; }
|
|
||||||
int_setting *modif(const function<void(int_setting*)>& r) { modify_me = r; return this; }
|
int_setting *modif(const function<void(int_setting*)>& r) { modify_me = r; return this; }
|
||||||
int_setting *set_sets(const reaction_t& s) { sets = s; return this; }
|
|
||||||
virtual bool affects(void *v) override { return v == value; }
|
virtual bool affects(void *v) override { return v == value; }
|
||||||
virtual void show_edit_option(char key) override;
|
virtual void show_edit_option(char key) override;
|
||||||
virtual cld get_cld() { return *value; }
|
virtual cld get_cld() { return *value; }
|
||||||
@ -288,8 +292,6 @@ void float_setting::show_edit_option(char key) {
|
|||||||
add_to_changed(this);
|
add_to_changed(this);
|
||||||
dialog::editNumber(*value, min_value, max_value, step, dft, XLAT(menu_item_name), help_text);
|
dialog::editNumber(*value, min_value, max_value, step, dft, XLAT(menu_item_name), help_text);
|
||||||
if(sets) sets();
|
if(sets) sets();
|
||||||
if(reaction) dialog::reaction = reaction;
|
|
||||||
if(extra) dialog::extra_options = extra;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,8 +302,6 @@ void int_setting::show_edit_option(char key) {
|
|||||||
add_to_changed(this);
|
add_to_changed(this);
|
||||||
dialog::editNumber(*value, min_value, max_value, step, dft, XLAT(menu_item_name), help_text);
|
dialog::editNumber(*value, min_value, max_value, step, dft, XLAT(menu_item_name), help_text);
|
||||||
if(sets) sets();
|
if(sets) sets();
|
||||||
if(reaction) dialog::reaction = reaction;
|
|
||||||
if(extra) dialog::extra_options = extra;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -309,7 +309,7 @@ void bool_setting::show_edit_option(char key) {
|
|||||||
dialog::addBoolItem(XLAT(menu_item_name), *value, key);
|
dialog::addBoolItem(XLAT(menu_item_name), *value, key);
|
||||||
dialog::add_action([this] () {
|
dialog::add_action([this] () {
|
||||||
add_to_changed(this);
|
add_to_changed(this);
|
||||||
switcher();
|
switcher(); if(sets) sets();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user