2021-01-22 18:01:39 +01:00
|
|
|
#include <hex/plugin.hpp>
|
|
|
|
|
|
|
|
namespace hex::plugin::builtin {
|
|
|
|
|
|
|
|
void registerSettings() {
|
|
|
|
|
2021-02-10 18:17:09 +01:00
|
|
|
ContentRegistry::Settings::add("Interface", "Color theme", 0, [](nlohmann::json &setting) {
|
|
|
|
static int selection = setting;
|
2021-02-11 23:09:45 +01:00
|
|
|
if (ImGui::Combo("Color theme", &selection, "Dark\0Light\0Classic\0")) {
|
2021-02-10 18:17:09 +01:00
|
|
|
setting = selection;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
ContentRegistry::Settings::add("Interface", "Language", "en-US", [](nlohmann::json &setting) {
|
|
|
|
auto &languages = LangEntry::getSupportedLanguages();
|
|
|
|
|
|
|
|
static int selection = [&]() -> int {
|
|
|
|
u16 index = 0;
|
2021-02-11 00:35:30 +01:00
|
|
|
for (auto &[languageCode, languageName] : languages){
|
|
|
|
if (languageCode == setting)
|
2021-02-10 18:17:09 +01:00
|
|
|
return index;
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}();
|
|
|
|
|
|
|
|
static auto languageNames = [&]() {
|
|
|
|
std::vector<const char*> result;
|
2021-02-11 00:35:30 +01:00
|
|
|
for (auto &[languageCode, languageName] : languages)
|
2021-02-10 18:17:09 +01:00
|
|
|
result.push_back(languageName.c_str());
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}();
|
|
|
|
|
|
|
|
|
2021-02-11 23:09:45 +01:00
|
|
|
if (ImGui::Combo("Language", &selection, languageNames.data(), languageNames.size())) {
|
2021-02-10 18:17:09 +01:00
|
|
|
|
|
|
|
u16 index = 0;
|
2021-02-11 00:35:30 +01:00
|
|
|
for (auto &[languageCode, languageName] : languages){
|
2021-02-10 18:17:09 +01:00
|
|
|
if (selection == index) {
|
2021-02-11 00:35:30 +01:00
|
|
|
setting = languageCode;
|
2021-02-10 18:17:09 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2021-01-22 18:01:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|