feature: User now can add custom directories (#444)

* feat: user directories

* ux: show setting categories in order they were created

* feat: add descriptable setting categories
This commit is contained in:
Lukas Cone
2022-02-18 22:34:54 +01:00
committed by GitHub
parent 60a717365c
commit 26f998ecb6
6 changed files with 164 additions and 20 deletions

View File

@@ -30,13 +30,29 @@ namespace hex::plugin::builtin {
if (ImGui::BeginPopupModal(View::toWindowName("hex.builtin.view.settings.name").c_str(), &this->getWindowOpenState(), ImGuiWindowFlags_NoResize)) {
if (ImGui::BeginTabBar("settings")) {
for (auto &[category, entries] : ContentRegistry::Settings::getEntries()) {
auto &entries = ContentRegistry::Settings::getEntries();
std::vector<std::decay_t<decltype(entries)>::const_iterator> sortedCategories;
for (auto it = entries.cbegin(); it != entries.cend(); it++) {
sortedCategories.emplace_back(std::move(it));
}
std::sort(sortedCategories.begin(), sortedCategories.end(), [](auto &item0, auto &item1) {
return item0->first.slot < item1->first.slot;
});
const auto &descriptions = ContentRegistry::Settings::getCategoryDescriptions();
for (auto &it : sortedCategories) {
auto &[category, entries] = *it;
if (ImGui::BeginTabItem(LangEntry(category))) {
ImGui::TextUnformatted(LangEntry(category));
const std::string &categoryDesc = descriptions.count(category) ? descriptions.at(category) : category.name;
ImGui::TextUnformatted(LangEntry(categoryDesc));
ImGui::Separator();
for (auto &[name, callback] : entries) {
if (callback(LangEntry(name), ContentRegistry::Settings::getSettingsData()[category][name]))
if (callback(LangEntry(name), ContentRegistry::Settings::getSettingsData()[category.name][name]))
EventManager::post<EventSettingsChanged>();
}
@@ -51,4 +67,4 @@ namespace hex::plugin::builtin {
this->getWindowOpenState() = false;
}
}
}