diff --git a/include/views/view_hexeditor.hpp b/include/views/view_hexeditor.hpp index d2bec1668..38eb1c153 100644 --- a/include/views/view_hexeditor.hpp +++ b/include/views/view_hexeditor.hpp @@ -55,6 +55,7 @@ namespace hex { std::string m_loaderScriptFilePath; hex::EncodingFile m_currEncodingFile; + u8 m_highlightAlpha = 0x80; void drawSearchPopup(); void drawGotoPopup(); diff --git a/plugins/builtin/source/content/settings_entries.cpp b/plugins/builtin/source/content/settings_entries.cpp index 85626690b..9ccb14a84 100644 --- a/plugins/builtin/source/content/settings_entries.cpp +++ b/plugins/builtin/source/content/settings_entries.cpp @@ -72,6 +72,17 @@ namespace hex::plugin::builtin { return false; }); + ContentRegistry::Settings::add("hex.builtin.setting.interface", "hex.builtin.setting.interface.highlight_alpha", 0x80, [](auto name, nlohmann::json &setting) { + static int alpha = setting.is_number() ? static_cast(setting) : 0x80; + + if (ImGui::SliderInt(name.data(), &alpha, 0x00, 0xFF)) { + setting = alpha; + return true; + } + + return false; + }); + } } \ No newline at end of file diff --git a/plugins/builtin/source/lang/de_DE.cpp b/plugins/builtin/source/lang/de_DE.cpp index d553a6ffa..7f9762124 100644 --- a/plugins/builtin/source/lang/de_DE.cpp +++ b/plugins/builtin/source/lang/de_DE.cpp @@ -512,6 +512,7 @@ namespace hex::plugin::builtin { { "hex.builtin.setting.interface.color.classic", "Klassisch" }, { "hex.builtin.setting.interface.language", "Sprache" }, { "hex.builtin.setting.interface.fps", "FPS Limite" }, + { "hex.builtin.setting.interface.highlight_alpha", "Markierungssichtbarkeit" }, { "hex.builtin.provider.file.path", "Dateipfad" }, { "hex.builtin.provider.file.size", "Größe" }, diff --git a/plugins/builtin/source/lang/en_US.cpp b/plugins/builtin/source/lang/en_US.cpp index 5264c64fb..61a1e3575 100644 --- a/plugins/builtin/source/lang/en_US.cpp +++ b/plugins/builtin/source/lang/en_US.cpp @@ -512,6 +512,7 @@ namespace hex::plugin::builtin { { "hex.builtin.setting.interface.color.classic", "Classic" }, { "hex.builtin.setting.interface.language", "Language" }, { "hex.builtin.setting.interface.fps", "FPS Limit" }, + { "hex.builtin.setting.interface.highlight_alpha", "Highlighting opacity" }, { "hex.builtin.provider.file.path", "File path" }, { "hex.builtin.provider.file.size", "Size" }, diff --git a/plugins/builtin/source/lang/it_IT.cpp b/plugins/builtin/source/lang/it_IT.cpp index 7abb9aa5e..0e895df15 100644 --- a/plugins/builtin/source/lang/it_IT.cpp +++ b/plugins/builtin/source/lang/it_IT.cpp @@ -512,6 +512,7 @@ namespace hex::plugin::builtin { { "hex.builtin.setting.interface.color.classic", "Classico" }, { "hex.builtin.setting.interface.language", "Lingua" }, { "hex.builtin.setting.interface.fps", "Limite FPS" }, + // { "hex.builtin.setting.interface.highlight_alpha", "" }, { "hex.builtin.provider.file.path", "Percorso del File" }, { "hex.builtin.provider.file.size", "Dimensione" }, diff --git a/source/views/view_hexeditor.cpp b/source/views/view_hexeditor.cpp index b8e44ea9c..ab9903052 100644 --- a/source/views/view_hexeditor.cpp +++ b/source/views/view_hexeditor.cpp @@ -52,19 +52,21 @@ namespace hex { off += SharedData::currentProvider->getBaseAddress(); + u32 alpha = static_cast(_this->m_highlightAlpha) << 24; + for (const auto &[region, name, comment, color, locked] : ImHexApi::Bookmarks::getEntries()) { if (off >= region.address && off < (region.address + region.size)) - currColor = (color & 0x00FFFFFF) | 0x80000000; + currColor = (color & 0x00FFFFFF) | alpha; if ((off - 1) >= region.address && (off - 1) < (region.address + region.size)) - prevColor = (color & 0x00FFFFFF) | 0x80000000; + prevColor = (color & 0x00FFFFFF) | alpha; } if (_this->m_highlightedBytes.contains(off)) { - auto color = (_this->m_highlightedBytes[off] & 0x00FFFFFF) | 0x80000000; + auto color = (_this->m_highlightedBytes[off] & 0x00FFFFFF) | alpha; currColor = currColor.has_value() ? ImAlphaBlendColors(color, currColor.value()) : color; } if (_this->m_highlightedBytes.contains(off - 1)) { - auto color = (_this->m_highlightedBytes[off - 1] & 0x00FFFFFF) | 0x80000000; + auto color = (_this->m_highlightedBytes[off - 1] & 0x00FFFFFF) | alpha; prevColor = prevColor.has_value() ? ImAlphaBlendColors(color, prevColor.value()) : color; } @@ -73,7 +75,7 @@ namespace hex { } if (currColor.has_value() && (currColor.value() & 0x00FFFFFF) != 0x00) { - _this->m_memoryEditor.HighlightColor = (currColor.value() & 0x00FFFFFF) | 0x40000000; + _this->m_memoryEditor.HighlightColor = (currColor.value() & 0x00FFFFFF) | alpha; return true; } @@ -177,6 +179,12 @@ namespace hex { EventManager::subscribe(this, [](std::string path) { EventManager::post(std::filesystem::path(path).filename().string()); }); + + EventManager::subscribe(this, [this] { + auto alpha = ContentRegistry::Settings::getSetting("hex.builtin.setting.interface", "hex.builtin.setting.interface.highlight_alpha"); + + this->m_highlightAlpha = alpha; + }); } ViewHexEditor::~ViewHexEditor() { @@ -186,6 +194,8 @@ namespace hex { EventManager::unsubscribe(this); EventManager::unsubscribe(this); EventManager::unsubscribe(this); + EventManager::unsubscribe(this); + EventManager::unsubscribe(this); } void ViewHexEditor::drawContent() {