2021-01-11 20:31:40 +01:00
|
|
|
#include "views/view_settings.hpp"
|
|
|
|
|
2021-01-13 17:28:27 +01:00
|
|
|
#include <hex/api/content_registry.hpp>
|
2021-01-11 20:31:40 +01:00
|
|
|
|
|
|
|
namespace hex {
|
|
|
|
|
|
|
|
ViewSettings::ViewSettings() : View("Settings") {
|
|
|
|
this->getWindowOpenState() = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
ViewSettings::~ViewSettings() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void ViewSettings::drawContent() {
|
|
|
|
|
|
|
|
ImGui::SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(FLT_MAX, FLT_MAX));
|
|
|
|
|
|
|
|
if (ImGui::BeginPopupModal("Preferences", &this->m_settingsWindowOpen, ImGuiWindowFlags_AlwaysAutoResize)) {
|
|
|
|
for (auto &[category, entries] : ContentRegistry::Settings::getEntries()) {
|
|
|
|
ImGui::TextUnformatted(category.c_str());
|
|
|
|
ImGui::Separator();
|
|
|
|
for (auto &[name, callback] : entries) {
|
|
|
|
ImGui::TextUnformatted(name.c_str());
|
|
|
|
ImGui::SameLine();
|
|
|
|
if (callback(ContentRegistry::Settings::getSettingsData()[category][name]))
|
2021-01-21 10:53:12 +01:00
|
|
|
View::postEvent(Events::SettingsChanged);
|
2021-01-11 20:31:40 +01:00
|
|
|
ImGui::NewLine();
|
|
|
|
}
|
|
|
|
ImGui::NewLine();
|
|
|
|
}
|
|
|
|
ImGui::EndPopup();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void ViewSettings::drawMenu() {
|
|
|
|
if (ImGui::BeginMenu("Help")) {
|
|
|
|
if (ImGui::MenuItem("Preferences")) {
|
|
|
|
View::doLater([]{ ImGui::OpenPopup("Preferences"); });
|
|
|
|
this->m_settingsWindowOpen = true;
|
|
|
|
}
|
|
|
|
ImGui::EndMenu();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|