mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-02-10 08:00:11 +00:00
more parameter improvements and fixes
This commit is contained in:
parent
5057f10358
commit
234a691ab6
44
config.cpp
44
config.cpp
@ -144,6 +144,14 @@ template<class T> struct val_setting : public setting {
|
|||||||
|
|
||||||
virtual bool anim_unchanged() { return *value == anim_value; }
|
virtual bool anim_unchanged() { return *value == anim_value; }
|
||||||
virtual void anim_restore() { *value = anim_value; if(reaction) reaction(); }
|
virtual void anim_restore() { *value = anim_value; if(reaction) reaction(); }
|
||||||
|
|
||||||
|
virtual void load_from_raw(const string& s) { throw hr_exception("load_from_raw not defined"); }
|
||||||
|
|
||||||
|
void load_from(const string& s) override {
|
||||||
|
auto bak = *value;
|
||||||
|
load_from_raw(s);
|
||||||
|
if(*value != bak && reaction) reaction();
|
||||||
|
}
|
||||||
bool load_from_animation(const string& s) override {
|
bool load_from_animation(const string& s) override {
|
||||||
if(anim_value != *value) return false;
|
if(anim_value != *value) return false;
|
||||||
load_from(s);
|
load_from(s);
|
||||||
@ -174,7 +182,7 @@ struct float_setting : public val_setting<ld> {
|
|||||||
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; }
|
||||||
supersaver *make_saver() override;
|
supersaver *make_saver() override;
|
||||||
void show_edit_option(int key) override;
|
void show_edit_option(int key) override;
|
||||||
void load_from(const string& s) override;
|
void load_from_raw(const string& s) override { *value = parseld(s); }
|
||||||
virtual cld get_cld() override { return *value; }
|
virtual cld get_cld() override { return *value; }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -204,9 +212,7 @@ struct int_setting : public val_setting<int> {
|
|||||||
|
|
||||||
virtual cld get_cld() override { return *value; }
|
virtual cld get_cld() override { return *value; }
|
||||||
|
|
||||||
void load_from(const string& s) override {
|
void load_from_raw(const string& s) override { *value = parseint(s); }
|
||||||
*value = parseint(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void check_change() {
|
virtual void check_change() {
|
||||||
if(*value != last_value) {
|
if(*value != last_value) {
|
||||||
@ -228,9 +234,7 @@ struct color_setting : public val_setting<color_t> {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void load_from(const string& s) override {
|
void load_from_raw(const string& s) override { sscanf(s.c_str(), "%x", value); }
|
||||||
sscanf(s.c_str(), "%x", value);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct matrix_setting : public val_setting<trans23> {
|
struct matrix_setting : public val_setting<trans23> {
|
||||||
@ -244,15 +248,15 @@ struct matrix_setting : public val_setting<trans23> {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void load_from(const string& s) override;
|
void load_from_raw(const string& s) override { *value = parsematrix23(s); }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct char_setting : public val_setting<char> {
|
struct char_setting : public val_setting<char> {
|
||||||
supersaver *make_saver() override;
|
supersaver *make_saver() override;
|
||||||
void show_edit_option(int key) override;
|
void show_edit_option(int key) override;
|
||||||
|
|
||||||
void load_from(const string& s) override {
|
void load_from_raw(const string& s) override {
|
||||||
if(s == "\\0") value = 0;
|
if(s == "\\0") *value = 0;
|
||||||
else sscanf(s.c_str(), "%c", value);
|
else sscanf(s.c_str(), "%c", value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -265,9 +269,9 @@ struct bool_setting : public val_setting<bool> {
|
|||||||
menu_item_name = cap; default_key = key; return this;
|
menu_item_name = cap; default_key = key; return this;
|
||||||
}
|
}
|
||||||
void show_edit_option(int key) override;
|
void show_edit_option(int key) override;
|
||||||
void load_from(const string& s) override {
|
|
||||||
*value = parseint(s);
|
void load_from_raw(const string& s) override { *value = parseint(s); }
|
||||||
}
|
|
||||||
virtual cld get_cld() override { return *value; }
|
virtual cld get_cld() override { return *value; }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -490,20 +494,6 @@ supersaver *bool_setting::make_saver() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void float_setting::load_from(const string& s) {
|
|
||||||
auto res = parseld(s);
|
|
||||||
auto bak = *value;
|
|
||||||
*value = res;
|
|
||||||
if(res != bak && reaction) reaction();
|
|
||||||
}
|
|
||||||
|
|
||||||
void matrix_setting::load_from(const string& s) {
|
|
||||||
auto res = parsematrix23(s);
|
|
||||||
auto bak = *value;
|
|
||||||
*value = res;
|
|
||||||
if(res != bak && reaction) reaction();
|
|
||||||
}
|
|
||||||
|
|
||||||
void non_editable() {
|
void non_editable() {
|
||||||
dialog::addHelp("Warning: editing this value through this menu may not work correctly");
|
dialog::addHelp("Warning: editing this value through this menu may not work correctly");
|
||||||
}
|
}
|
||||||
|
@ -1101,7 +1101,7 @@ EX namespace dialog {
|
|||||||
if(ne.intval) *ne.intval = ldtoint(*ne.editwhat);
|
if(ne.intval) *ne.intval = ldtoint(*ne.editwhat);
|
||||||
#if CAP_ANIMATIONS
|
#if CAP_ANIMATIONS
|
||||||
if(ne.animatable) {
|
if(ne.animatable) {
|
||||||
auto p = anims::find_param(ne.editwhat);
|
auto p = anims::find_param(ne.intval ? (void*) ne.intval : (void*) ne.editwhat);
|
||||||
if(p) p->load_as_animation(ne.s);
|
if(p) p->load_as_animation(ne.s);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -1388,7 +1388,7 @@ EX namespace dialog {
|
|||||||
EX void editNumber(int& x, int vmin, int vmax, ld step, int dft, string title, string help) {
|
EX void editNumber(int& x, int vmin, int vmax, ld step, int dft, string title, string help) {
|
||||||
editNumber(ne.intbuf, vmin, vmax, step, dft, title, help);
|
editNumber(ne.intbuf, vmin, vmax, step, dft, title, help);
|
||||||
ne.intbuf = x; ne.intval = &x; ne.s = its(x);
|
ne.intbuf = x; ne.intval = &x; ne.s = its(x);
|
||||||
ne.animatable = false;
|
ne.animatable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
EX void helpToEdit(int& x, int vmin, int vmax, int step, int dft) {
|
EX void helpToEdit(int& x, int vmin, int vmax, int step, int dft) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user