2022-07-02 16:22:38 +02:00
|
|
|
#include <hex/api/imhex_api.hpp>
|
2021-08-29 14:18:45 +02:00
|
|
|
#include <hex/api/content_registry.hpp>
|
2022-02-01 18:09:40 +01:00
|
|
|
#include <hex/api/localization.hpp>
|
2022-12-29 19:26:00 +01:00
|
|
|
#include <hex/api/theme_manager.hpp>
|
2021-09-08 15:18:24 +02:00
|
|
|
|
2023-03-23 11:23:07 +01:00
|
|
|
#include <hex/helpers/http_requests.hpp>
|
2022-07-02 16:22:38 +02:00
|
|
|
|
2021-08-29 14:18:45 +02:00
|
|
|
#include <imgui.h>
|
2022-02-18 22:34:54 +01:00
|
|
|
#include <hex/ui/imgui_imhex_extensions.h>
|
|
|
|
#include <fonts/codicons_font.h>
|
2021-08-29 14:18:45 +02:00
|
|
|
|
|
|
|
#include <nlohmann/json.hpp>
|
2021-01-22 18:01:39 +01:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
#include <wolv/utils/string.hpp>
|
2022-07-14 11:38:23 +02:00
|
|
|
|
2021-01-22 18:01:39 +01:00
|
|
|
namespace hex::plugin::builtin {
|
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
namespace {
|
2023-03-14 14:07:18 +01:00
|
|
|
|
2023-06-20 11:55:56 +02:00
|
|
|
/*
|
2023-10-21 23:07:33 +02:00
|
|
|
Values of this setting:
|
2023-06-20 11:55:56 +02:00
|
|
|
0 - do not check for updates on startup
|
|
|
|
1 - check for updates on startup
|
|
|
|
2 - default value - ask the user if he wants to check for updates. This value should only be encountered on the first startup.
|
|
|
|
*/
|
2023-10-21 23:07:33 +02:00
|
|
|
class ServerContactWidget : public ContentRegistry::Settings::Widgets::Widget {
|
|
|
|
public:
|
|
|
|
bool draw(const std::string &name) override {
|
|
|
|
bool enabled = this->m_value == 1;
|
2023-05-15 11:30:24 +02:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
if (ImGui::Checkbox(name.data(), &enabled)) {
|
|
|
|
this->m_value = enabled ? 1 : 0;
|
|
|
|
return true;
|
2022-12-29 19:26:00 +01:00
|
|
|
}
|
2022-07-02 16:22:38 +02:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
return false;
|
2021-02-10 18:17:09 +01:00
|
|
|
}
|
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
void load(const nlohmann::json &data) override {
|
|
|
|
if (data.is_number())
|
|
|
|
this->m_value = data.get<int>();
|
|
|
|
}
|
2021-08-21 13:55:21 +02:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
nlohmann::json store() override {
|
|
|
|
return this->m_value;
|
|
|
|
}
|
2021-08-21 13:55:21 +02:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
private:
|
|
|
|
u32 m_value = 2;
|
|
|
|
};
|
|
|
|
|
|
|
|
class FPSWidget : public ContentRegistry::Settings::Widgets::Widget {
|
|
|
|
public:
|
|
|
|
bool draw(const std::string &name) override {
|
|
|
|
auto format = [this] -> std::string {
|
|
|
|
if (this->m_value > 200)
|
|
|
|
return "hex.builtin.setting.interface.fps.unlocked"_lang;
|
|
|
|
else if (this->m_value < 15)
|
|
|
|
return "hex.builtin.setting.interface.fps.native"_lang;
|
|
|
|
else
|
|
|
|
return "%d FPS";
|
|
|
|
}();
|
|
|
|
|
|
|
|
if (ImGui::SliderInt(name.data(), &this->m_value, 14, 201, format.c_str(), ImGuiSliderFlags_AlwaysClamp)) {
|
2022-02-21 21:46:25 +01:00
|
|
|
return true;
|
|
|
|
}
|
2021-08-21 13:55:21 +02:00
|
|
|
|
2022-02-21 21:46:25 +01:00
|
|
|
return false;
|
2021-02-10 18:17:09 +01:00
|
|
|
}
|
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
void load(const nlohmann::json &data) override {
|
|
|
|
if (data.is_number())
|
|
|
|
this->m_value = data.get<int>();
|
2022-05-22 23:26:46 +02:00
|
|
|
}
|
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
nlohmann::json store() override {
|
|
|
|
return this->m_value;
|
2021-03-06 13:09:20 +01:00
|
|
|
}
|
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
private:
|
|
|
|
int m_value = 60;
|
|
|
|
};
|
2021-03-06 13:09:20 +01:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
class UserFolderWidget : public ContentRegistry::Settings::Widgets::Widget {
|
|
|
|
public:
|
|
|
|
bool draw(const std::string &) override {
|
|
|
|
bool result = false;
|
2022-10-06 21:26:24 +02:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
if (!ImGui::BeginListBox("", ImVec2(-38, -10))) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
for (size_t n = 0; n < this->m_paths.size(); n++) {
|
|
|
|
const bool isSelected = (this->m_itemIndex == n);
|
|
|
|
if (ImGui::Selectable(wolv::util::toUTF8String(this->m_paths[n]).c_str(), isSelected)) {
|
|
|
|
this->m_itemIndex = n;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isSelected) {
|
|
|
|
ImGui::SetItemDefaultFocus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ImGui::EndListBox();
|
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
|
|
|
ImGui::BeginGroup();
|
2022-10-06 21:26:24 +02:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
if (ImGui::IconButton(ICON_VS_NEW_FOLDER, ImGui::GetStyleColorVec4(ImGuiCol_Text), ImVec2(30, 30))) {
|
|
|
|
fs::openFileBrowser(fs::DialogMode::Folder, {}, [&](const std::fs::path &path) {
|
|
|
|
if (std::find(this->m_paths.begin(), this->m_paths.end(), path) == this->m_paths.end()) {
|
|
|
|
this->m_paths.emplace_back(path);
|
|
|
|
ImHexApi::System::setAdditionalFolderPaths(this->m_paths);
|
2022-10-06 21:26:24 +02:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
result = true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
ImGui::InfoTooltip("hex.builtin.setting.folders.add_folder"_lang);
|
2022-05-27 20:42:07 +02:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
if (ImGui::IconButton(ICON_VS_REMOVE_CLOSE, ImGui::GetStyleColorVec4(ImGuiCol_Text), ImVec2(30, 30))) {
|
|
|
|
if (!this->m_paths.empty()) {
|
|
|
|
this->m_paths.erase(std::next(this->m_paths.begin(), this->m_itemIndex));
|
|
|
|
ImHexApi::System::setAdditionalFolderPaths(this->m_paths);
|
2022-05-27 20:42:07 +02:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
result = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ImGui::InfoTooltip("hex.builtin.setting.folders.remove_folder"_lang);
|
2022-05-27 20:42:07 +02:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
ImGui::EndGroup();
|
2021-03-29 23:07:18 +02:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
return result;
|
2021-03-29 23:07:18 +02:00
|
|
|
}
|
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
void load(const nlohmann::json &data) override {
|
|
|
|
if (data.is_array()) {
|
|
|
|
std::vector<std::string> pathStrings = data;
|
2022-09-18 16:22:08 +02:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
for (const auto &pathString : pathStrings) {
|
|
|
|
this->m_paths.emplace_back(pathString);
|
|
|
|
}
|
|
|
|
}
|
2022-09-18 16:22:08 +02:00
|
|
|
}
|
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
nlohmann::json store() override {
|
|
|
|
std::vector<std::string> pathStrings;
|
2022-09-18 16:22:08 +02:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
for (const auto &path : this->m_paths) {
|
|
|
|
pathStrings.push_back(wolv::util::toUTF8String(path));
|
|
|
|
}
|
2022-10-07 11:28:44 +02:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
return pathStrings;
|
2022-10-07 11:28:44 +02:00
|
|
|
}
|
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
private:
|
|
|
|
u32 m_itemIndex = 0;
|
|
|
|
std::vector<std::fs::path> m_paths;
|
|
|
|
};
|
|
|
|
|
|
|
|
class ScalingWidget : public ContentRegistry::Settings::Widgets::Widget {
|
|
|
|
public:
|
|
|
|
bool draw(const std::string &name) override {
|
|
|
|
auto format = [this] -> std::string {
|
|
|
|
if (this->m_value == 0)
|
|
|
|
return "hex.builtin.setting.interface.scaling.native"_lang;
|
|
|
|
else
|
|
|
|
return "x%.1f";
|
|
|
|
}();
|
|
|
|
|
|
|
|
if (ImGui::SliderFloat(name.data(), &this->m_value, 0, 10, format.c_str(), ImGuiSliderFlags_AlwaysClamp)) {
|
|
|
|
return true;
|
|
|
|
}
|
2022-10-07 11:28:44 +02:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
return false;
|
2022-10-07 11:28:44 +02:00
|
|
|
}
|
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
void load(const nlohmann::json &data) override {
|
|
|
|
if (data.is_number())
|
|
|
|
this->m_value = data.get<float>();
|
|
|
|
}
|
2023-07-31 11:17:37 +02:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
nlohmann::json store() override {
|
|
|
|
return this->m_value;
|
2023-07-31 11:17:37 +02:00
|
|
|
}
|
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
private:
|
|
|
|
float m_value = 0;
|
|
|
|
};
|
2023-07-31 11:17:37 +02:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
}
|
2022-02-21 21:46:25 +01:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
void registerSettings() {
|
2022-05-27 20:42:07 +02:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
/* General */
|
2022-02-21 21:46:25 +01:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
namespace Widgets = ContentRegistry::Settings::Widgets;
|
2022-02-21 21:46:25 +01:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.general", "", "hex.builtin.setting.general.show_tips", true);
|
|
|
|
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.general", "", "hex.builtin.setting.general.save_recent_providers", true);
|
|
|
|
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.general", "hex.builtin.setting.general.patterns", "hex.builtin.setting.general.auto_load_patterns", true);
|
|
|
|
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.general", "hex.builtin.setting.general.patterns", "hex.builtin.setting.general.sync_pattern_source", false);
|
|
|
|
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.general", "hex.builtin.setting.general.network", "hex.builtin.setting.general.network_interface", false);
|
|
|
|
ContentRegistry::Settings::add<ServerContactWidget>("hex.builtin.setting.general", "hex.builtin.setting.general.network", "hex.builtin.setting.general.server_contact");
|
|
|
|
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.general", "hex.builtin.setting.general.network", "hex.builtin.setting.general.upload_crash_logs", true);
|
2022-02-21 21:46:25 +01:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
/* Interface */
|
2022-02-21 21:46:25 +01:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
auto themeNames = ThemeManager::getThemeNames();
|
|
|
|
std::vector<nlohmann::json> themeJsons = { };
|
|
|
|
for (const auto &themeName : themeNames)
|
|
|
|
themeJsons.emplace_back(themeName);
|
2022-02-21 21:46:25 +01:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
themeNames.emplace(themeNames.begin(), ThemeManager::NativeTheme);
|
|
|
|
themeJsons.emplace(themeJsons.begin(), ThemeManager::NativeTheme);
|
2022-02-21 21:46:25 +01:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
ContentRegistry::Settings::add<Widgets::DropDown>("hex.builtin.setting.interface", "", "hex.builtin.setting.interface.color",
|
|
|
|
themeNames,
|
2023-10-22 17:31:53 +02:00
|
|
|
themeJsons,
|
|
|
|
"Dark").setChangedCallback([](auto &widget) {
|
2023-10-21 23:07:33 +02:00
|
|
|
auto dropDown = static_cast<Widgets::DropDown *>(&widget);
|
2022-02-21 21:46:25 +01:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
if (dropDown->getValue() == ThemeManager::NativeTheme)
|
|
|
|
ImHexApi::System::enableSystemThemeDetection(true);
|
|
|
|
else {
|
|
|
|
ImHexApi::System::enableSystemThemeDetection(false);
|
|
|
|
ThemeManager::changeTheme(dropDown->getValue());
|
|
|
|
}
|
|
|
|
});
|
2022-02-21 21:46:25 +01:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
ContentRegistry::Settings::add<ScalingWidget>("hex.builtin.setting.interface", "", "hex.builtin.setting.interface.scaling").requiresRestart();
|
2022-02-21 21:46:25 +01:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
std::vector<std::string> languageNames;
|
|
|
|
std::vector<nlohmann::json> languageCodes;
|
2022-02-21 21:46:25 +01:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
for (auto &[languageCode, languageName] : LangEntry::getSupportedLanguages()) {
|
|
|
|
languageNames.emplace_back(languageName);
|
|
|
|
languageCodes.emplace_back(languageCode);
|
|
|
|
}
|
2022-02-21 21:46:25 +01:00
|
|
|
|
2023-10-22 17:51:00 +02:00
|
|
|
ContentRegistry::Settings::add<Widgets::DropDown>("hex.builtin.setting.interface", "", "hex.builtin.setting.interface.language", languageNames, languageCodes, "en-US");
|
2022-02-21 21:46:25 +01:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
ContentRegistry::Settings::add<Widgets::TextBox>("hex.builtin.setting.interface", "", "hex.builtin.setting.interface.wiki_explain_language", "en");
|
|
|
|
ContentRegistry::Settings::add<FPSWidget>("hex.builtin.setting.interface", "", "hex.builtin.setting.interface.fps");
|
2022-05-27 20:42:07 +02:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
#if defined (OS_LINUX)
|
|
|
|
constexpr static auto MultiWindowSupportEnabledDefault = 0;
|
|
|
|
#else
|
|
|
|
constexpr static auto MultiWindowSupportEnabledDefault = 1;
|
|
|
|
#endif
|
2022-02-18 22:34:54 +01:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.interface", "", "hex.builtin.setting.interface.multi_windows", MultiWindowSupportEnabledDefault).requiresRestart();
|
|
|
|
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.interface", "", "hex.builtin.setting.interface.restore_window_pos", false);
|
2022-02-18 22:34:54 +01:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
ContentRegistry::Settings::add<Widgets::ColorPicker>("hex.builtin.setting.hex_editor", "", "hex.builtin.setting.hex_editor.highlight_color", ImColor(0x80, 0x80, 0xC0, 0x60));
|
|
|
|
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.hex_editor", "", "hex.builtin.setting.hex_editor.sync_scrolling", false);
|
|
|
|
ContentRegistry::Settings::add<Widgets::SliderInteger>("hex.builtin.setting.hex_editor", "", "hex.builtin.setting.hex_editor.byte_padding", 0, 0, 50);
|
|
|
|
ContentRegistry::Settings::add<Widgets::SliderInteger>("hex.builtin.setting.hex_editor", "", "hex.builtin.setting.hex_editor.char_padding", 0, 0, 50);
|
2022-03-27 00:01:28 +01:00
|
|
|
|
2022-07-02 17:53:13 +02:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
/* Fonts */
|
2022-07-02 17:53:13 +02:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.font", "hex.builtin.setting.font.glyphs", "hex.builtin.setting.font.load_all_unicode_chars", false);
|
|
|
|
auto fontPathSetting = ContentRegistry::Settings::add<Widgets::FilePicker>("hex.builtin.setting.font", "hex.builtin.setting.font.custom_font", "hex.builtin.setting.font.font_path").requiresRestart();
|
|
|
|
ContentRegistry::Settings::add<Widgets::SliderInteger>("hex.builtin.setting.font", "hex.builtin.setting.font.custom_font", "hex.builtin.setting.font.font_size", 13, 0, 100)
|
|
|
|
.requiresRestart()
|
|
|
|
.setEnabledCallback([fontPathSetting]{
|
|
|
|
auto &filePicker = static_cast<Widgets::FilePicker &>(fontPathSetting.getWidget());
|
2022-07-14 11:38:23 +02:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
return !filePicker.getPath().empty();
|
2022-02-18 22:34:54 +01:00
|
|
|
});
|
|
|
|
|
2022-07-02 17:53:13 +02:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
/* Folders */
|
2022-02-18 22:34:54 +01:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
ContentRegistry::Settings::setCategoryDescription("hex.builtin.setting.folders", "hex.builtin.setting.folders.description");
|
|
|
|
ContentRegistry::Settings::add<UserFolderWidget>("hex.builtin.setting.folders", "", "hex.builtin.setting.folders.description");
|
2022-07-01 14:05:32 +02:00
|
|
|
|
|
|
|
/* Proxy */
|
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
HttpRequest::setProxy(ContentRegistry::Settings::read("hex.builtin.setting.proxy", "hex.builtin.setting.proxy.url", "").get<std::string>());
|
2022-07-01 14:05:32 +02:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
ContentRegistry::Settings::setCategoryDescription("hex.builtin.setting.proxy", "hex.builtin.setting.proxy.description");
|
2022-07-01 14:05:32 +02:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
auto proxyEnabledSetting = ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.proxy", "", "hex.builtin.setting.proxy.enable", false).setChangedCallback([](Widgets::Widget &widget) {
|
|
|
|
auto checkBox = static_cast<Widgets::Checkbox *>(&widget);
|
2022-07-01 14:05:32 +02:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
if (checkBox->isChecked()) {
|
|
|
|
HttpRequest::setProxy(ContentRegistry::Settings::read("hex.builtin.setting.proxy", "hex.builtin.setting.proxy.url", "").get<std::string>());
|
|
|
|
} else {
|
|
|
|
HttpRequest::setProxy("");
|
|
|
|
}
|
|
|
|
});
|
2022-07-01 14:05:32 +02:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
ContentRegistry::Settings::add<Widgets::TextBox>("hex.builtin.setting.proxy", "", "hex.builtin.setting.proxy.url", "")
|
|
|
|
.setEnabledCallback([proxyEnabledSetting] {
|
|
|
|
auto &checkBox = static_cast<Widgets::Checkbox &>(proxyEnabledSetting.getWidget());
|
2022-07-01 14:05:32 +02:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
return checkBox.isChecked();
|
|
|
|
})
|
|
|
|
.setChangedCallback([](Widgets::Widget &widget) {
|
|
|
|
auto textBox = static_cast<Widgets::TextBox *>(&widget);
|
2022-07-01 14:05:32 +02:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
HttpRequest::setProxy(textBox->getValue());
|
|
|
|
});
|
2023-11-10 20:47:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
/* Experiments */
|
|
|
|
ContentRegistry::Settings::setCategoryDescription("hex.builtin.setting.experiments", "hex.builtin.setting.experiments.description");
|
|
|
|
EventManager::subscribe<EventImHexStartupFinished>([]{
|
|
|
|
for (const auto &[name, experiment] : ContentRegistry::Experiments::impl::getExperiments()) {
|
|
|
|
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.experiments", "", experiment.unlocalizedName, false)
|
|
|
|
.setTooltip(LangEntry(experiment.unlocalizedDescription))
|
|
|
|
.setChangedCallback([name](Widgets::Widget &widget) {
|
|
|
|
auto checkBox = static_cast<Widgets::Checkbox *>(&widget);
|
|
|
|
|
|
|
|
ContentRegistry::Experiments::enableExperiement(name, checkBox->isChecked());
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2021-01-22 18:01:39 +01:00
|
|
|
}
|
|
|
|
|
2022-07-02 16:22:38 +02:00
|
|
|
static void loadThemeSettings() {
|
2023-10-21 23:07:33 +02:00
|
|
|
auto theme = ContentRegistry::Settings::read("hex.builtin.setting.interface", "hex.builtin.setting.interface.color", ThemeManager::NativeTheme).get<std::string>();
|
2022-07-02 16:22:38 +02:00
|
|
|
|
2023-03-23 20:35:16 +01:00
|
|
|
if (theme == ThemeManager::NativeTheme)
|
2022-12-29 19:26:00 +01:00
|
|
|
ImHexApi::System::enableSystemThemeDetection(true);
|
|
|
|
else {
|
|
|
|
ImHexApi::System::enableSystemThemeDetection(false);
|
2023-03-23 20:35:16 +01:00
|
|
|
ThemeManager::changeTheme(theme);
|
2022-12-29 19:26:00 +01:00
|
|
|
}
|
2022-07-02 16:22:38 +02:00
|
|
|
}
|
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
static void loadFolderSettings() {
|
|
|
|
auto folderPathStrings = ContentRegistry::Settings::read("hex.builtin.setting.folders", "hex.builtin.setting.folders", std::vector<std::string> { });
|
|
|
|
|
|
|
|
std::vector<std::fs::path> paths;
|
|
|
|
for (const auto &pathString : folderPathStrings) {
|
|
|
|
paths.emplace_back(pathString);
|
|
|
|
}
|
2023-03-21 15:33:43 +01:00
|
|
|
|
2023-10-21 23:07:33 +02:00
|
|
|
ImHexApi::System::setAdditionalFolderPaths(paths);
|
2022-07-14 11:38:23 +02:00
|
|
|
}
|
|
|
|
|
2022-07-02 16:22:38 +02:00
|
|
|
void loadSettings() {
|
|
|
|
loadThemeSettings();
|
2023-10-21 23:07:33 +02:00
|
|
|
loadFolderSettings();
|
2022-07-02 16:22:38 +02:00
|
|
|
}
|
|
|
|
|
2022-02-18 22:34:54 +01:00
|
|
|
}
|