mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 13:37:42 -05:00
sys: Removed all references to hex.builtin from main application
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
#include <hex/api/event.hpp>
|
||||
#include <hex/api/content_registry.hpp>
|
||||
|
||||
#include <hex/ui/view.hpp>
|
||||
#include <hex/helpers/project_file_handler.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/helpers/file.hpp>
|
||||
#include <hex/helpers/logger.hpp>
|
||||
|
||||
#include <imgui.h>
|
||||
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
#include <hex/api/imhex_api.hpp>
|
||||
#include <hex/api/content_registry.hpp>
|
||||
#include <hex/api/imhex_api.hpp>
|
||||
|
||||
#include <hex/api/localization.hpp>
|
||||
|
||||
#include <hex/helpers/net.hpp>
|
||||
#include <hex/helpers/utils.hpp>
|
||||
#include <hex/helpers/logger.hpp>
|
||||
|
||||
#include <imgui.h>
|
||||
#include <hex/ui/imgui_imhex_extensions.h>
|
||||
#include <fonts/codicons_font.h>
|
||||
#include <hex/helpers/net.hpp>
|
||||
#include <hex/helpers/utils.hpp>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
@@ -53,6 +55,11 @@ namespace hex::plugin::builtin {
|
||||
|
||||
if (ImGui::Combo(name.data(), &selection, themes, IM_ARRAYSIZE(themes))) {
|
||||
setting = selection;
|
||||
|
||||
ImHexApi::System::enableSystemThemeDetection(selection == 0);
|
||||
if (selection != 0)
|
||||
ImHexApi::System::setTheme(static_cast<ImHexApi::System::Theme>(selection));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -392,4 +399,71 @@ namespace hex::plugin::builtin {
|
||||
false);
|
||||
}
|
||||
|
||||
|
||||
static void loadInterfaceScalingSetting() {
|
||||
float interfaceScaling = 1.0F;
|
||||
switch (ContentRegistry::Settings::read("hex.builtin.setting.interface", "hex.builtin.setting.interface.scaling", 0)) {
|
||||
default:
|
||||
case 0:
|
||||
// Native scaling
|
||||
break;
|
||||
case 1:
|
||||
interfaceScaling = 0.5F;
|
||||
break;
|
||||
case 2:
|
||||
interfaceScaling = 1.0F;
|
||||
break;
|
||||
case 3:
|
||||
interfaceScaling = 1.5F;
|
||||
break;
|
||||
case 4:
|
||||
interfaceScaling = 2.0F;
|
||||
break;
|
||||
}
|
||||
|
||||
ImHexApi::System::impl::setGlobalScale(interfaceScaling);
|
||||
}
|
||||
|
||||
static void loadFontSettings() {
|
||||
std::fs::path fontFile = ContentRegistry::Settings::read("hex.builtin.setting.font", "hex.builtin.setting.font.font_path", "");
|
||||
if (!fs::exists(fontFile))
|
||||
fontFile.clear();
|
||||
|
||||
// If no custom font has been specified, search for a file called "font.ttf" in one of the resource folders
|
||||
if (fontFile.empty()) {
|
||||
for (const auto &dir : fs::getDefaultPaths(fs::ImHexPath::Resources)) {
|
||||
auto path = dir / "font.ttf";
|
||||
if (fs::exists(path)) {
|
||||
log::info("Loading custom front from {}", path.string());
|
||||
|
||||
fontFile = path;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If a custom font has been loaded now, also load the font size
|
||||
float fontSize = 13.0F * ImHexApi::System::getGlobalScale();
|
||||
if (!fontFile.empty()) {
|
||||
ImHexApi::System::impl::setCustomFontPath(fontFile);
|
||||
|
||||
fontSize = ContentRegistry::Settings::read("hex.builtin.setting.font", "hex.builtin.setting.font.font_size", 13) * ImHexApi::System::getGlobalScale();
|
||||
}
|
||||
|
||||
ImHexApi::System::impl::setFontSize(fontSize);
|
||||
}
|
||||
|
||||
static void loadThemeSettings() {
|
||||
auto theme = ContentRegistry::Settings::read("hex.builtin.setting.interface", "hex.builtin.setting.interface.color", static_cast<i64>(ImHexApi::System::Theme::Dark));
|
||||
|
||||
ImHexApi::System::enableSystemThemeDetection(theme == 0);
|
||||
ImHexApi::System::setTheme(static_cast<ImHexApi::System::Theme>(theme));
|
||||
}
|
||||
|
||||
void loadSettings() {
|
||||
loadInterfaceScalingSetting();
|
||||
loadFontSettings();
|
||||
loadThemeSettings();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,19 +1,15 @@
|
||||
#include <hex/api/content_registry.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
|
||||
#include <hex/ui/view.hpp>
|
||||
#include <hex/helpers/utils.hpp>
|
||||
#include <hex/helpers/fmt.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
|
||||
#include <hex/providers/provider.hpp>
|
||||
|
||||
#include <codicons_font.h>
|
||||
#include <imgui.h>
|
||||
#include <imgui_internal.h>
|
||||
#include <hex/ui/imgui_imhex_extensions.h>
|
||||
|
||||
#include <atomic>
|
||||
|
||||
namespace hex::plugin::builtin {
|
||||
|
||||
static void drawGlobalPopups() {
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace hex::plugin::builtin {
|
||||
void registerPatternLanguagePragmas();
|
||||
void registerCommandPaletteCommands();
|
||||
void registerSettings();
|
||||
void loadSettings();
|
||||
void registerDataProcessorNodes();
|
||||
void registerHashes();
|
||||
void registerProviders();
|
||||
@@ -51,6 +52,7 @@ IMHEX_PLUGIN_SETUP("Built-in", "WerWolv", "Default ImHex functionality") {
|
||||
registerPatternLanguagePragmas();
|
||||
registerCommandPaletteCommands();
|
||||
registerSettings();
|
||||
loadSettings();
|
||||
registerDataProcessorNodes();
|
||||
registerHashes();
|
||||
registerProviders();
|
||||
|
||||
Reference in New Issue
Block a user