diff --git a/src/api/feature/setting/Setting.h b/src/api/feature/setting/Setting.h index 8a152705..a324ba1a 100644 --- a/src/api/feature/setting/Setting.h +++ b/src/api/feature/setting/Setting.h @@ -378,11 +378,16 @@ class Setting : public Feature { std::optional> callback; + std::optional> userUpdateCallback; void update() { if (callback) callback.value()(*this); } + void userUpdate() { + if (userUpdateCallback) userUpdateCallback.value()(*this); + } + EnumData* enumData = nullptr; ValueType* value = nullptr; diff --git a/src/client/Latite.cpp b/src/client/Latite.cpp index 970063c3..ee9b2750 100644 --- a/src/client/Latite.cpp +++ b/src/client/Latite.cpp @@ -823,7 +823,7 @@ void Latite::initLanguageSetting() { L"The client's language."); set->enumData = &this->clientLanguage; set->value = set->enumData->getValue(); - set->callback = [](Setting&) { + set->userUpdateCallback = [](Setting&) { Latite::getClientMessageQueue().push(util::WFormat(LocalizeString::get("client.message.languageSwitchHelper.name"))); }; diff --git a/src/client/screen/impl/ClickGUI.cpp b/src/client/screen/impl/ClickGUI.cpp index 382a9713..cfe0a5ae 100644 --- a/src/client/screen/impl/ClickGUI.cpp +++ b/src/client/screen/impl/ClickGUI.cpp @@ -758,6 +758,7 @@ void ClickGUI::onRender(Event&) { auto d2dCol = d2d::Color(util::HSVToColor(colorPicker.pickerColor)).asAlpha(colorPicker.opacityMod); *colorPicker.selectedColor = { d2dCol.r, d2dCol.g, d2dCol.b, d2dCol.a }; colorPicker.setting->update(); + colorPicker.setting->userUpdate(); colorPicker = ColorPicker(); } } @@ -939,6 +940,7 @@ float ClickGUI::drawSetting(Setting* set, SettingGroup*, Vec2 const& pos, D2DUti if (contains && justClicked[0]) { std::get(*set->value) = !std::get(*set->value); set->update(); + set->userUpdate(); playClickSound(); } @@ -1013,6 +1015,7 @@ float ClickGUI::drawSetting(Setting* set, SettingGroup*, Vec2 const& pos, D2DUti if (activeSetting == set && this->capturedKey > 0) { std::get(*set->value) = capturedKey; set->update(); + set->userUpdate(); activeSetting = 0; capturedKey = 0; } @@ -1039,6 +1042,7 @@ float ClickGUI::drawSetting(Setting* set, SettingGroup*, Vec2 const& pos, D2DUti activeSetting = nullptr; std::get(*set->value) = 0; set->update(); + set->userUpdate(); playClickSound(); } } @@ -1103,6 +1107,7 @@ float ClickGUI::drawSetting(Setting* set, SettingGroup*, Vec2 const& pos, D2DUti // cycle set->enumData->next(); set->update(); + set->userUpdate(); playClickSound(); } } @@ -1231,6 +1236,7 @@ float ClickGUI::drawSetting(Setting* set, SettingGroup*, Vec2 const& pos, D2DUti std::get(*set->value) = newVal; set->update(); + set->userUpdate(); } }