refactor: Add enable/disableControl methods to GUI class

This commit is contained in:
Vsevolod Kremianskii 2020-10-10 15:55:35 +07:00
parent e530440b2a
commit 735f8a38b5
3 changed files with 11 additions and 1 deletions

View file

@ -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) {

View file

@ -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); });
}

View file

@ -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);