Skip to content

Commit

Permalink
Fix Language setting message
Browse files Browse the repository at this point in the history
  • Loading branch information
Imrglop committed Oct 11, 2024
1 parent 33ba35b commit c0289b6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/api/feature/setting/Setting.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,11 +378,16 @@ class Setting : public Feature {


std::optional<std::function<void(Setting&)>> callback;
std::optional<std::function<void(Setting&)>> userUpdateCallback;

void update() {
if (callback) callback.value()(*this);
}

void userUpdate() {
if (userUpdateCallback) userUpdateCallback.value()(*this);
}

EnumData* enumData = nullptr;
ValueType* value = nullptr;

Expand Down
2 changes: 1 addition & 1 deletion src/client/Latite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")));
};

Expand Down
6 changes: 6 additions & 0 deletions src/client/screen/impl/ClickGUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down Expand Up @@ -939,6 +940,7 @@ float ClickGUI::drawSetting(Setting* set, SettingGroup*, Vec2 const& pos, D2DUti
if (contains && justClicked[0]) {
std::get<BoolValue>(*set->value) = !std::get<BoolValue>(*set->value);
set->update();
set->userUpdate();
playClickSound();
}

Expand Down Expand Up @@ -1013,6 +1015,7 @@ float ClickGUI::drawSetting(Setting* set, SettingGroup*, Vec2 const& pos, D2DUti
if (activeSetting == set && this->capturedKey > 0) {
std::get<KeyValue>(*set->value) = capturedKey;
set->update();
set->userUpdate();
activeSetting = 0;
capturedKey = 0;
}
Expand All @@ -1039,6 +1042,7 @@ float ClickGUI::drawSetting(Setting* set, SettingGroup*, Vec2 const& pos, D2DUti
activeSetting = nullptr;
std::get<KeyValue>(*set->value) = 0;
set->update();
set->userUpdate();
playClickSound();
}
}
Expand Down Expand Up @@ -1103,6 +1107,7 @@ float ClickGUI::drawSetting(Setting* set, SettingGroup*, Vec2 const& pos, D2DUti
// cycle
set->enumData->next();
set->update();
set->userUpdate();
playClickSound();
}
}
Expand Down Expand Up @@ -1231,6 +1236,7 @@ float ClickGUI::drawSetting(Setting* set, SettingGroup*, Vec2 const& pos, D2DUti

std::get<FloatValue>(*set->value) = newVal;
set->update();
set->userUpdate();
}
}

Expand Down

0 comments on commit c0289b6

Please sign in to comment.