2021-08-29 14:18:45 +02:00
|
|
|
#include <hex/api/content_registry.hpp>
|
|
|
|
#include <hex/api/imhex_api.hpp>
|
|
|
|
|
2021-09-08 15:18:24 +02:00
|
|
|
#include <hex/helpers/lang.hpp>
|
|
|
|
using namespace hex::lang_literals;
|
|
|
|
|
2021-08-29 14:18:45 +02:00
|
|
|
#include <imgui.h>
|
|
|
|
|
|
|
|
#include <nlohmann/json.hpp>
|
2021-01-22 18:01:39 +01:00
|
|
|
|
|
|
|
namespace hex::plugin::builtin {
|
|
|
|
|
|
|
|
void registerSettings() {
|
|
|
|
|
2021-08-22 21:11:01 +02:00
|
|
|
/* General */
|
|
|
|
|
|
|
|
ContentRegistry::Settings::add("hex.builtin.setting.general", "hex.builtin.setting.general.show_tips", 1, [](auto name, nlohmann::json &setting) {
|
2021-09-12 13:59:23 +02:00
|
|
|
static bool enabled = static_cast<int>(setting);
|
2021-08-22 21:11:01 +02:00
|
|
|
|
|
|
|
if (ImGui::Checkbox(name.data(), &enabled)) {
|
|
|
|
setting = static_cast<int>(enabled);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2021-09-30 12:00:11 +02:00
|
|
|
ContentRegistry::Settings::add("hex.builtin.setting.general", "hex.builtin.setting.general.auto_load_patterns", 1, [](auto name, nlohmann::json &setting) {
|
|
|
|
static bool enabled = static_cast<int>(setting);
|
|
|
|
|
|
|
|
if (ImGui::Checkbox(name.data(), &enabled)) {
|
|
|
|
setting = static_cast<int>(enabled);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2021-08-22 21:11:01 +02:00
|
|
|
/* Interface */
|
|
|
|
|
2021-02-13 15:15:32 +01:00
|
|
|
ContentRegistry::Settings::add("hex.builtin.setting.interface", "hex.builtin.setting.interface.color", 0, [](auto name, nlohmann::json &setting) {
|
2021-09-12 13:59:23 +02:00
|
|
|
static int selection = static_cast<int>(setting);
|
2021-02-13 15:15:32 +01:00
|
|
|
|
|
|
|
const char* themes[] = {
|
2021-09-16 22:23:51 +02:00
|
|
|
"hex.builtin.setting.interface.color.system"_lang,
|
2021-02-13 15:15:32 +01:00
|
|
|
"hex.builtin.setting.interface.color.dark"_lang,
|
|
|
|
"hex.builtin.setting.interface.color.light"_lang,
|
|
|
|
"hex.builtin.setting.interface.color.classic"_lang
|
|
|
|
};
|
|
|
|
|
|
|
|
if (ImGui::Combo(name.data(), &selection, themes, IM_ARRAYSIZE(themes))) {
|
2021-02-10 18:17:09 +01:00
|
|
|
setting = selection;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2021-08-21 13:55:21 +02:00
|
|
|
ContentRegistry::Settings::add("hex.builtin.setting.interface", "hex.builtin.setting.interface.scaling", 0, [](auto name, nlohmann::json &setting) {
|
2021-09-12 13:59:23 +02:00
|
|
|
static int selection = static_cast<int>(setting);
|
2021-08-21 13:55:21 +02:00
|
|
|
|
|
|
|
const char* scaling[] = {
|
|
|
|
"hex.builtin.setting.interface.scaling.native"_lang,
|
|
|
|
"hex.builtin.setting.interface.scaling.x0_5"_lang,
|
|
|
|
"hex.builtin.setting.interface.scaling.x1_0"_lang,
|
|
|
|
"hex.builtin.setting.interface.scaling.x1_5"_lang,
|
|
|
|
"hex.builtin.setting.interface.scaling.x2_0"_lang,
|
|
|
|
};
|
|
|
|
|
|
|
|
if (ImGui::Combo(name.data(), &selection, scaling, IM_ARRAYSIZE(scaling))) {
|
|
|
|
setting = selection;
|
2021-08-27 09:57:03 +02:00
|
|
|
|
|
|
|
ImHexApi::Common::restartImHex();
|
|
|
|
|
2021-08-21 13:55:21 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2021-02-13 15:15:32 +01:00
|
|
|
ContentRegistry::Settings::add("hex.builtin.setting.interface", "hex.builtin.setting.interface.language", "en-US", [](auto name, nlohmann::json &setting) {
|
2021-02-10 18:17:09 +01:00
|
|
|
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 = [&]() {
|
2021-09-20 12:44:12 +02:00
|
|
|
std::vector<const char*> result;
|
|
|
|
result.reserve(languages.size());
|
|
|
|
|
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-13 15:15:32 +01:00
|
|
|
if (ImGui::Combo(name.data(), &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-03-06 13:09:20 +01:00
|
|
|
ContentRegistry::Settings::add("hex.builtin.setting.interface", "hex.builtin.setting.interface.fps", 60, [](auto name, nlohmann::json &setting) {
|
2021-09-12 13:59:23 +02:00
|
|
|
static int fps = static_cast<int>(setting);
|
2021-03-06 13:09:20 +01:00
|
|
|
|
2021-10-23 12:59:13 +02:00
|
|
|
auto format = fps > 200 ? "hex.builtin.setting.interface.fps.unlocked"_lang : "%d FPS";
|
|
|
|
|
|
|
|
if (ImGui::SliderInt(name.data(), &fps, 15, 201, format, ImGuiSliderFlags_AlwaysClamp)) {
|
2021-03-06 13:09:20 +01:00
|
|
|
setting = fps;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2021-03-29 23:07:18 +02:00
|
|
|
ContentRegistry::Settings::add("hex.builtin.setting.interface", "hex.builtin.setting.interface.highlight_alpha", 0x80, [](auto name, nlohmann::json &setting) {
|
2021-09-12 13:59:23 +02:00
|
|
|
static int alpha = static_cast<int>(setting);
|
2021-03-29 23:07:18 +02:00
|
|
|
|
|
|
|
if (ImGui::SliderInt(name.data(), &alpha, 0x00, 0xFF)) {
|
|
|
|
setting = alpha;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2021-09-20 23:40:36 +02:00
|
|
|
ContentRegistry::Settings::add("hex.builtin.setting.hex_editor", "hex.builtin.setting.hex_editor.column_count", 16, [](auto name, nlohmann::json &setting) {
|
|
|
|
static int columns = static_cast<int>(setting);
|
|
|
|
|
|
|
|
if (ImGui::SliderInt(name.data(), &columns, 1, 32)) {
|
|
|
|
setting = columns;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
ContentRegistry::Settings::add("hex.builtin.setting.hex_editor", "hex.builtin.setting.hex_editor.hexii", 0, [](auto name, nlohmann::json &setting) {
|
|
|
|
static bool hexii = static_cast<int>(setting);
|
|
|
|
|
|
|
|
if (ImGui::Checkbox(name.data(), &hexii)) {
|
|
|
|
setting = static_cast<int>(hexii);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
ContentRegistry::Settings::add("hex.builtin.setting.hex_editor", "hex.builtin.setting.hex_editor.ascii", 1, [](auto name, nlohmann::json &setting) {
|
|
|
|
static bool ascii = static_cast<int>(setting);
|
|
|
|
|
|
|
|
if (ImGui::Checkbox(name.data(), &ascii)) {
|
|
|
|
setting = static_cast<int>(ascii);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
ContentRegistry::Settings::add("hex.builtin.setting.hex_editor", "hex.builtin.setting.hex_editor.advanced_decoding", 0, [](auto name, nlohmann::json &setting) {
|
|
|
|
static bool advancedDecoding = static_cast<int>(setting);
|
|
|
|
|
|
|
|
if (ImGui::Checkbox(name.data(), &advancedDecoding)) {
|
|
|
|
setting = static_cast<int>(advancedDecoding);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
ContentRegistry::Settings::add("hex.builtin.setting.hex_editor", "hex.builtin.setting.hex_editor.grey_zeros", 1, [](auto name, nlohmann::json &setting) {
|
|
|
|
static bool greyZeros = static_cast<int>(setting);
|
|
|
|
|
|
|
|
if (ImGui::Checkbox(name.data(), &greyZeros)) {
|
|
|
|
setting = static_cast<int>(greyZeros);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
ContentRegistry::Settings::add("hex.builtin.setting.hex_editor", "hex.builtin.setting.hex_editor.uppercase_hex", 1, [](auto name, nlohmann::json &setting) {
|
|
|
|
static bool upperCaseHex = static_cast<int>(setting);
|
|
|
|
|
|
|
|
if (ImGui::Checkbox(name.data(), &upperCaseHex)) {
|
|
|
|
setting = static_cast<int>(upperCaseHex);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
ContentRegistry::Settings::add("hex.builtin.setting.hex_editor", "hex.builtin.setting.hex_editor.extra_info", 1, [](auto name, nlohmann::json &setting) {
|
|
|
|
static bool extraInfos = static_cast<int>(setting);
|
|
|
|
|
|
|
|
if (ImGui::Checkbox(name.data(), &extraInfos)) {
|
|
|
|
setting = static_cast<int>(extraInfos);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2021-01-22 18:01:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|