1991afb87b
* sys: Initial refactoring of the SharedData class * sys/pattern: More refactoring, make every provider have its own patterns * sys: Finished up refactoring. No more SharedData! * sys: Fixed compile on Unix * tests: Fixed unit tests * sys: Moved view and lang files * pattern: Added assignment operator support to for loops * tests: Fixed compile issue
54 lines
2.0 KiB
C++
54 lines
2.0 KiB
C++
#include "content/views/view_settings.hpp"
|
|
|
|
#include <hex/api/content_registry.hpp>
|
|
|
|
#include <nlohmann/json.hpp>
|
|
|
|
namespace hex::plugin::builtin {
|
|
|
|
ViewSettings::ViewSettings() : View("hex.builtin.view.settings.name") {
|
|
EventManager::subscribe<RequestOpenWindow>(this, [this](const std::string &name) {
|
|
if (name == "Settings") {
|
|
ImHexApi::Tasks::doLater([] { ImGui::OpenPopup(View::toWindowName("hex.builtin.view.settings.name").c_str()); });
|
|
this->getWindowOpenState() = true;
|
|
}
|
|
});
|
|
|
|
ContentRegistry::Interface::addMenuItem("hex.builtin.menu.help", 2000, [&, this] {
|
|
if (ImGui::MenuItem("hex.builtin.view.settings.name"_lang)) {
|
|
ImHexApi::Tasks::doLater([] { ImGui::OpenPopup(View::toWindowName("hex.builtin.view.settings.name").c_str()); });
|
|
this->getWindowOpenState() = true;
|
|
}
|
|
});
|
|
}
|
|
|
|
ViewSettings::~ViewSettings() {
|
|
EventManager::unsubscribe<RequestOpenWindow>(this);
|
|
}
|
|
|
|
void ViewSettings::drawContent() {
|
|
|
|
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()) {
|
|
if (ImGui::BeginTabItem(LangEntry(category))) {
|
|
ImGui::TextUnformatted(LangEntry(category));
|
|
ImGui::Separator();
|
|
|
|
for (auto &[name, callback] : entries) {
|
|
if (callback(LangEntry(name), ContentRegistry::Settings::getSettingsData()[category][name]))
|
|
EventManager::post<EventSettingsChanged>();
|
|
}
|
|
|
|
ImGui::EndTabItem();
|
|
}
|
|
}
|
|
|
|
ImGui::EndTabBar();
|
|
}
|
|
ImGui::EndPopup();
|
|
} else
|
|
this->getWindowOpenState() = false;
|
|
}
|
|
|
|
} |