mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-06-28 16:02:53 +00:00
config:: pre reactions
This commit is contained in:
parent
ab0ca74328
commit
0d5723dd69
12
config.cpp
12
config.cpp
@ -24,9 +24,8 @@ EX bool use_bool_dialog;
|
|||||||
|
|
||||||
EX string param_esc(string s);
|
EX string param_esc(string s);
|
||||||
|
|
||||||
EX void non_editable_reaction() {
|
EX void non_editable_pre() { if(game_active) stop_game(); };
|
||||||
if(game_active) { stop_game(); if(!delayed_start) start_game(); }
|
EX void non_editable_post() { if(!delayed_start) start_game(); };
|
||||||
}
|
|
||||||
|
|
||||||
#if HDR
|
#if HDR
|
||||||
|
|
||||||
@ -51,7 +50,7 @@ struct parameter : public std::enable_shared_from_this<parameter> {
|
|||||||
string menu_item_name;
|
string menu_item_name;
|
||||||
bool menu_item_name_modified;
|
bool menu_item_name_modified;
|
||||||
string help_text;
|
string help_text;
|
||||||
reaction_t reaction;
|
reaction_t pre_reaction, reaction;
|
||||||
char default_key;
|
char default_key;
|
||||||
bool is_editable;
|
bool is_editable;
|
||||||
bool needs_confirm;
|
bool needs_confirm;
|
||||||
@ -66,7 +65,8 @@ struct parameter : public std::enable_shared_from_this<parameter> {
|
|||||||
}
|
}
|
||||||
explicit parameter() { restrict = auto_restrict; is_editable = false; needs_confirm = false; }
|
explicit parameter() { restrict = auto_restrict; is_editable = false; needs_confirm = false; }
|
||||||
void be_non_editable() {
|
void be_non_editable() {
|
||||||
reaction = non_editable_reaction;
|
pre_reaction = non_editable_pre;
|
||||||
|
reaction = non_editable_post;
|
||||||
}
|
}
|
||||||
virtual void check_change() { }
|
virtual void check_change() { }
|
||||||
reaction_t sets;
|
reaction_t sets;
|
||||||
@ -173,6 +173,7 @@ template<class T> struct enum_parameter : list_parameter {
|
|||||||
void load(const string& s) override {
|
void load(const string& s) override {
|
||||||
auto bak = *value;
|
auto bak = *value;
|
||||||
load_from_raw(s);
|
load_from_raw(s);
|
||||||
|
if(*value != bak && pre_reaction) { swap(*value, bak); pre_reaction(); swap(*value, bak); }
|
||||||
if(*value != bak && reaction) reaction();
|
if(*value != bak && reaction) reaction();
|
||||||
}
|
}
|
||||||
bool load_from_animation(const string& s) override {
|
bool load_from_animation(const string& s) override {
|
||||||
@ -228,6 +229,7 @@ template<class T> struct val_parameter : public parameter {
|
|||||||
void load(const string& s) override {
|
void load(const string& s) override {
|
||||||
auto bak = *value;
|
auto bak = *value;
|
||||||
load_from_raw(s);
|
load_from_raw(s);
|
||||||
|
if(*value != bak && pre_reaction) { swap(*value, bak); pre_reaction(); swap(*value, bak); }
|
||||||
if(*value != bak && reaction) reaction();
|
if(*value != bak && reaction) reaction();
|
||||||
}
|
}
|
||||||
bool load_from_animation(const string& s) override {
|
bool load_from_animation(const string& s) override {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user