mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-30 21:05:56 -05:00
fix: Language setting not defaulting to English anymore
This commit is contained in:
@@ -190,7 +190,7 @@ namespace hex {
|
||||
};
|
||||
class DropDown : public Widget {
|
||||
public:
|
||||
explicit DropDown(const std::vector<std::string> &items, const std::vector<nlohmann::json> &settingsValues) : m_items(items), m_settingsValues(settingsValues) { }
|
||||
explicit DropDown(const std::vector<std::string> &items, const std::vector<nlohmann::json> &settingsValues, const nlohmann::json &defaultItem) : m_items(items), m_settingsValues(settingsValues), m_defaultItem(defaultItem) { }
|
||||
|
||||
bool draw(const std::string &name) override;
|
||||
|
||||
@@ -203,6 +203,8 @@ namespace hex {
|
||||
private:
|
||||
std::vector<std::string> m_items;
|
||||
std::vector<nlohmann::json> m_settingsValues;
|
||||
nlohmann::json m_defaultItem;
|
||||
|
||||
int m_value = 0;
|
||||
};
|
||||
class TextBox : public Widget {
|
||||
|
||||
@@ -289,15 +289,22 @@ namespace hex {
|
||||
void DropDown::load(const nlohmann::json &data) {
|
||||
this->m_value = 0;
|
||||
|
||||
int defaultItemIndex = 0;
|
||||
|
||||
int index = 0;
|
||||
for (const auto &item : this->m_settingsValues) {
|
||||
if (item == this->m_defaultItem)
|
||||
defaultItemIndex = index;
|
||||
|
||||
if (item == data) {
|
||||
this->m_value = index;
|
||||
break;
|
||||
return;
|
||||
}
|
||||
|
||||
index += 1;
|
||||
}
|
||||
|
||||
this->m_value = defaultItemIndex;
|
||||
}
|
||||
|
||||
nlohmann::json DropDown::store() {
|
||||
|
||||
Reference in New Issue
Block a user