refactor: Add enable/disableControl methods to GUI class
This commit is contained in:
parent
e530440b2a
commit
735f8a38b5
3 changed files with 11 additions and 1 deletions
|
@ -39,7 +39,7 @@ QuickOrCustom::QuickOrCustom(GameVersion version, const GraphicsOptions &opts) :
|
|||
void QuickOrCustom::load() {
|
||||
GUI::load();
|
||||
|
||||
setControlDisabled("CUST_CHAR_BTN", true);
|
||||
disableControl("CUST_CHAR_BTN");
|
||||
}
|
||||
|
||||
void QuickOrCustom::onClick(const string &control) {
|
||||
|
|
|
@ -283,6 +283,14 @@ void GUI::hideControl(const string &tag) {
|
|||
configureControl(tag, [](Control &ctrl) { ctrl.setVisible(false); });
|
||||
}
|
||||
|
||||
void GUI::enableControl(const string &tag) {
|
||||
configureControl(tag, [](Control &ctrl) { ctrl.setDisabled(false); });
|
||||
}
|
||||
|
||||
void GUI::disableControl(const string &tag) {
|
||||
configureControl(tag, [](Control &ctrl) { ctrl.setDisabled(true); });
|
||||
}
|
||||
|
||||
void GUI::setControlFocusable(const string &tag, bool focusable) {
|
||||
configureControl(tag, [&focusable](Control &ctrl) { ctrl.setFocusable(focusable); });
|
||||
}
|
||||
|
|
|
@ -51,6 +51,8 @@ public:
|
|||
void configureControl(const std::string &tag, const std::function<void(Control &)> &fn);
|
||||
void showControl(const std::string &tag);
|
||||
void hideControl(const std::string &tag);
|
||||
void enableControl(const std::string &tag);
|
||||
void disableControl(const std::string &tag);
|
||||
|
||||
void setControlFocusable(const std::string &tag, bool focusable);
|
||||
void setControlDisabled(const std::string &tag, bool disabled);
|
||||
|
|
Loading…
Reference in a new issue