diff --git a/external/ImGui/include/imgui_memory_editor.h b/external/ImGui/include/imgui_memory_editor.h index eb3b2fe76..9c456044a 100644 --- a/external/ImGui/include/imgui_memory_editor.h +++ b/external/ImGui/include/imgui_memory_editor.h @@ -92,6 +92,7 @@ struct MemoryEditor bool OptShowAdvancedDecoding; // = true // display advanced decoding data on the right side. bool OptGreyOutZeroes; // = true // display null/zero bytes using the TextDisabled color. bool OptUpperCaseHex; // = true // display hexadecimal values as "FF" instead of "ff". + bool OptShowExtraInfo; // = true // display extra information about size of data and current selection int OptMidColsCount; // = 8 // set to 0 to disable extra spacing between every mid-cols. int OptAddrDigitsCount; // = 0 // number of addr digits to display (default calculated based on maximum displayed addr). ImU32 HighlightColor; // // background color of highlighted bytes. @@ -311,9 +312,8 @@ struct MemoryEditor size_t data_preview_addr_next = (size_t)-1; if (ImGui::IsWindowFocused()) { - if (DataEditingAddr != (size_t)-1) - { - // Move cursor but only apply on next frame so scrolling with be synchronized (because currently we can't change the scrolling while the window is being rendered) + // Move cursor but only apply on next frame so scrolling with be synchronized (because currently we can't change the scrolling while the window is being rendered) + if (DataEditingAddr != (size_t)-1) { if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_UpArrow)) && DataEditingAddr >= (size_t)Cols) { data_editing_addr_next = DataEditingAddr - Cols; DataEditingTakeFocus = true; } else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_DownArrow)) && DataEditingAddr < mem_size - Cols) { data_editing_addr_next = DataEditingAddr + Cols; DataEditingTakeFocus = true; } else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_LeftArrow)) && DataEditingAddr > 0) { data_editing_addr_next = DataEditingAddr - 1; DataEditingTakeFocus = true; } @@ -323,7 +323,6 @@ struct MemoryEditor else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Home)) && DataEditingAddr > 0) { data_editing_addr_next = 0; DataEditingTakeFocus = true; } else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_End)) && DataEditingAddr < mem_size - 1) { data_editing_addr_next = mem_size - 1; DataEditingTakeFocus = true; } } else if (DataPreviewAddr != -1) { - // Move cursor but only apply on next frame so scrolling with be synchronized (because currently we can't change the scrolling while the window is being rendered) if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_UpArrow)) && DataPreviewAddr >= (size_t)Cols) { DataPreviewAddr = data_preview_addr_next = DataPreviewAddr - Cols; if (!ImGui::GetIO().KeyShift) DataPreviewAddrEnd = DataPreviewAddr; } else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_DownArrow)) && DataPreviewAddr < mem_size - Cols) { DataPreviewAddr = data_preview_addr_next = DataPreviewAddr + Cols; if (!ImGui::GetIO().KeyShift) DataPreviewAddrEnd = DataPreviewAddr; } else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_LeftArrow)) && DataPreviewAddr > 0) { DataPreviewAddr = data_preview_addr_next = DataPreviewAddr - 1; if (!ImGui::GetIO().KeyShift) DataPreviewAddrEnd = DataPreviewAddr; } @@ -333,6 +332,11 @@ struct MemoryEditor else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Home)) && DataPreviewAddr > 0) { DataPreviewAddr = data_preview_addr_next = 0; if (!ImGui::GetIO().KeyShift) DataPreviewAddrEnd = DataPreviewAddr; } else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_End)) && DataPreviewAddr < mem_size - 1) { DataPreviewAddr = data_preview_addr_next = mem_size - 1; if (!ImGui::GetIO().KeyShift) DataPreviewAddrEnd = DataPreviewAddr; } } + } else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Escape))) { + DataPreviewAddr = data_preview_addr_next = DataPreviewAddrEnd = (size_t)-1; + HighlightMin = HighlightMax = (size_t)-1; + + hex::EventManager::post(hex::Region{ (size_t)-1, 0 }); } if (data_preview_addr_next != (size_t)-1 && (data_preview_addr_next / Cols) != (data_preview_addr_backup / Cols)) @@ -688,35 +692,19 @@ struct MemoryEditor const char* format_range = OptUpperCaseHex ? "Range %0*" _PRISizeT "X..%0*" _PRISizeT "X" : "Range %0*" _PRISizeT "x..%0*" _PRISizeT "x"; const char* format_selection = OptUpperCaseHex ? "Selection %0*" _PRISizeT "X..%0*" _PRISizeT "X (%ld %s)" : "Range %0*" _PRISizeT "x..%0*" _PRISizeT "x (%ld %s)"; - // Options menu - if (ImGui::Button("Options")) - ImGui::OpenPopup("options"); + if (this->OptShowExtraInfo) { + ImGui::Text(format_range, s.AddrDigitsCount, base_display_addr, s.AddrDigitsCount, base_display_addr + mem_size - 1); + if (DataPreviewAddr != (size_t)-1 && DataPreviewAddrEnd != (size_t)-1) { + ImGui::SameLine(); + ImGui::Spacing(); + ImGui::SameLine(); - if (ImGui::BeginPopup("options")) { - ImGui::PushItemWidth(ImGui::CalcTextSize("00 cols").x * 1.1f); - if (ImGui::DragInt("##cols", &Cols, 0.2f, 4, 32, "%d cols")) { ContentsWidthChanged = true; if (Cols < 1) Cols = 1; } - ImGui::PopItemWidth(); - ImGui::Checkbox("Show HexII", &OptShowHexII); - if (ImGui::Checkbox("Show Ascii", &OptShowAscii)) { ContentsWidthChanged = true; } - if (ImGui::Checkbox("Show Advanced Decoding", &OptShowAdvancedDecoding)) { ContentsWidthChanged = true; } - ImGui::Checkbox("Grey out zeroes", &OptGreyOutZeroes); - ImGui::Checkbox("Uppercase Hex", &OptUpperCaseHex); + auto selectionStart = std::min(DataPreviewAddr, DataPreviewAddrEnd); + auto selectionEnd = std::max(DataPreviewAddr, DataPreviewAddrEnd); - ImGui::EndPopup(); - } - - ImGui::SameLine(); - ImGui::Text(format_range, s.AddrDigitsCount, base_display_addr, s.AddrDigitsCount, base_display_addr + mem_size - 1); - if (DataPreviewAddr != (size_t)-1 && DataPreviewAddrEnd != (size_t)-1) { - ImGui::SameLine(); - ImGui::Spacing(); - ImGui::SameLine(); - - auto selectionStart = std::min(DataPreviewAddr, DataPreviewAddrEnd); - auto selectionEnd = std::max(DataPreviewAddr, DataPreviewAddrEnd); - - size_t regionSize = (selectionEnd - selectionStart) + 1; - ImGui::Text(format_selection, s.AddrDigitsCount, base_display_addr + selectionStart, s.AddrDigitsCount, base_display_addr + selectionEnd, regionSize, regionSize == 1 ? "byte" : "bytes"); + size_t regionSize = (selectionEnd - selectionStart) + 1; + ImGui::Text(format_selection, s.AddrDigitsCount, base_display_addr + selectionStart, s.AddrDigitsCount, base_display_addr + selectionEnd, regionSize, regionSize == 1 ? "byte" : "bytes"); + } } if (GotoAddr != (size_t)-1) diff --git a/plugins/builtin/source/content/data_inspector.cpp b/plugins/builtin/source/content/data_inspector.cpp index d03d353aa..b232b63ae 100644 --- a/plugins/builtin/source/content/data_inspector.cpp +++ b/plugins/builtin/source/content/data_inspector.cpp @@ -131,7 +131,7 @@ namespace hex::plugin::builtin { return [value] { ImGui::TextUnformatted(value.c_str()); return value; }; }); - ContentRegistry::DataInspector::add("hex.builtin.inspector.string", 0, [](auto buffer, auto endian, auto style) { + ContentRegistry::DataInspector::add("hex.builtin.inspector.string", 1, [](auto buffer, auto endian, auto style) { Region currSelection = { 0 }; EventManager::post(currSelection); @@ -143,7 +143,7 @@ namespace hex::plugin::builtin { stringBuffer += "..."; for (auto &c : stringBuffer) - if (c < 0x20 || c == '\n' || c == '\r') + if (c < 0x20) c = ' '; diff --git a/plugins/builtin/source/content/settings_entries.cpp b/plugins/builtin/source/content/settings_entries.cpp index 9a2eefbaf..477c1cf1e 100644 --- a/plugins/builtin/source/content/settings_entries.cpp +++ b/plugins/builtin/source/content/settings_entries.cpp @@ -131,6 +131,83 @@ namespace hex::plugin::builtin { return false; }); + 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(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(setting); + + if (ImGui::Checkbox(name.data(), &hexii)) { + setting = static_cast(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(setting); + + if (ImGui::Checkbox(name.data(), &ascii)) { + setting = static_cast(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(setting); + + if (ImGui::Checkbox(name.data(), &advancedDecoding)) { + setting = static_cast(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(setting); + + if (ImGui::Checkbox(name.data(), &greyZeros)) { + setting = static_cast(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(setting); + + if (ImGui::Checkbox(name.data(), &upperCaseHex)) { + setting = static_cast(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(setting); + + if (ImGui::Checkbox(name.data(), &extraInfos)) { + setting = static_cast(extraInfos); + 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 fd91c69c3..f604ccef4 100644 --- a/plugins/builtin/source/lang/de_DE.cpp +++ b/plugins/builtin/source/lang/de_DE.cpp @@ -96,6 +96,7 @@ namespace hex::plugin::builtin { { "hex.view.data_inspector.name", "Dateninspektor" }, { "hex.view.data_inspector.table.name", "Name" }, { "hex.view.data_inspector.table.value", "Wert" }, + { "hex.view.data_inspector.no_data", "Keine bytes angewählt"}, { "hex.view.data_processor.name", "Datenprozessor" }, { "hex.view.data_processor.menu.remove_selection", "Auswahl entfernen" }, @@ -596,6 +597,14 @@ namespace hex::plugin::builtin { { "hex.builtin.setting.interface.language", "Sprache" }, { "hex.builtin.setting.interface.fps", "FPS Limite" }, { "hex.builtin.setting.interface.highlight_alpha", "Markierungssichtbarkeit" }, + { "hex.builtin.setting.hex_editor", "Hex Editor" }, + { "hex.builtin.setting.hex_editor.column_count", "Anzahl Byte Spalten" }, + { "hex.builtin.setting.hex_editor.hexii", "HexII anstatt Bytes anzeigen" }, + { "hex.builtin.setting.hex_editor.ascii", "ASCII Spalte anzeigen" }, + { "hex.builtin.setting.hex_editor.advanced_decoding", "Erweiterte Dekodierungsspalte anzeigen" }, + { "hex.builtin.setting.hex_editor.grey_zeros", "Nullen ausgrauen" }, + { "hex.builtin.setting.hex_editor.uppercase_hex", "Hex Zeichen als Grossbuchstaben" }, + { "hex.builtin.setting.hex_editor.extra_info", "Extra informationen anzeigen" }, { "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 095bacf1d..1b940727a 100644 --- a/plugins/builtin/source/lang/en_US.cpp +++ b/plugins/builtin/source/lang/en_US.cpp @@ -96,6 +96,7 @@ namespace hex::plugin::builtin { { "hex.view.data_inspector.name", "Data Inspector" }, { "hex.view.data_inspector.table.name", "Name" }, { "hex.view.data_inspector.table.value", "Value" }, + { "hex.view.data_inspector.no_data", "No bytes selected"}, { "hex.view.data_processor.name", "Data Processor" }, { "hex.view.data_processor.menu.remove_selection", "Remove Selected" }, @@ -597,6 +598,14 @@ namespace hex::plugin::builtin { { "hex.builtin.setting.interface.language", "Language" }, { "hex.builtin.setting.interface.fps", "FPS Limit" }, { "hex.builtin.setting.interface.highlight_alpha", "Highlighting opacity" }, + { "hex.builtin.setting.hex_editor", "Hex Editor" }, + { "hex.builtin.setting.hex_editor.column_count", "Byte column count" }, + { "hex.builtin.setting.hex_editor.hexii", "Display HexII instead of Bytes" }, + { "hex.builtin.setting.hex_editor.ascii", "Display ASCII column" }, + { "hex.builtin.setting.hex_editor.advanced_decoding", "Display advanced decoding column" }, + { "hex.builtin.setting.hex_editor.grey_zeros", "Grey out zeros" }, + { "hex.builtin.setting.hex_editor.uppercase_hex", "Upper case Hex characters" }, + { "hex.builtin.setting.hex_editor.extra_info", "Display extra information" }, { "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 b21a425c4..a546a6a0d 100644 --- a/plugins/builtin/source/lang/it_IT.cpp +++ b/plugins/builtin/source/lang/it_IT.cpp @@ -95,6 +95,8 @@ namespace hex::plugin::builtin { { "hex.view.data_inspector.name", "Ispezione Dati" }, { "hex.view.data_inspector.table.name", "Nome" }, { "hex.view.data_inspector.table.value", "Valore" }, + //{ "hex.view.data_inspector.no_data", "No bytes selected"}, + { "hex.view.data_processor.name", "Processa Dati" }, { "hex.view.data_processor.menu.remove_selection", "Rimuovi i selezionati" }, @@ -593,8 +595,16 @@ namespace hex::plugin::builtin { { "hex.builtin.setting.interface.scaling.x1_0", "x1.0" }, { "hex.builtin.setting.interface.scaling.x1_5", "x1.5" }, { "hex.builtin.setting.interface.scaling.x2_0", "x2.0" }, - { "hex.builtin.setting.interface.fps", "Limite FPS" }, - { "hex.builtin.setting.interface.highlight_alpha", "Evidenziazione dell'opacità" }, + { "hex.builtin.setting.interface.fps", "Limite FPS" }, + { "hex.builtin.setting.interface.highlight_alpha", "Evidenziazione dell'opacità" }, + //{ "hex.builtin.setting.hex_editor", "Hex Editor" }, + //{ "hex.builtin.setting.hex_editor.column_count", "Byte column count" }, + //{ "hex.builtin.setting.hex_editor.hexii", "Display HexII instead of Bytes" }, + //{ "hex.builtin.setting.hex_editor.ascii", "Display ASCII column" }, + //{ "hex.builtin.setting.hex_editor.advanced_decoding", "Display advanced decoding column" }, + //{ "hex.builtin.setting.hex_editor.grey_zeros", "Grey out zeros" }, + //{ "hex.builtin.setting.hex_editor.uppercase_hex", "Upper case Hex characters" }, + //{ "hex.builtin.setting.hex_editor.extra_info", "Display extra information" }, { "hex.builtin.provider.file.path", "Percorso del File" }, { "hex.builtin.provider.file.size", "Dimensione" }, diff --git a/plugins/builtin/source/lang/zh_CN.cpp b/plugins/builtin/source/lang/zh_CN.cpp index 6ab4b06fa..3c5b3e1e1 100644 --- a/plugins/builtin/source/lang/zh_CN.cpp +++ b/plugins/builtin/source/lang/zh_CN.cpp @@ -96,6 +96,7 @@ namespace hex::plugin::builtin { { "hex.view.data_inspector.name", "数据分析器" }, { "hex.view.data_inspector.table.name", "名称" }, { "hex.view.data_inspector.table.value", "值" }, + //{ "hex.view.data_inspector.no_data", "No bytes selected"}, { "hex.view.data_processor.name", "数据处理器" }, { "hex.view.data_processor.menu.remove_selection", "移除已选" }, @@ -598,6 +599,14 @@ namespace hex::plugin::builtin { { "hex.builtin.setting.interface.language", "语言" }, { "hex.builtin.setting.interface.fps", "FPS限制" }, { "hex.builtin.setting.interface.highlight_alpha", "高亮不透明度" }, + //{ "hex.builtin.setting.hex_editor", "Hex Editor" }, + //{ "hex.builtin.setting.hex_editor.column_count", "Byte column count" }, + //{ "hex.builtin.setting.hex_editor.hexii", "Display HexII instead of Bytes" }, + //{ "hex.builtin.setting.hex_editor.ascii", "Display ASCII column" }, + //{ "hex.builtin.setting.hex_editor.advanced_decoding", "Display advanced decoding column" }, + //{ "hex.builtin.setting.hex_editor.grey_zeros", "Grey out zeros" }, + //{ "hex.builtin.setting.hex_editor.uppercase_hex", "Upper case Hex characters" }, + //{ "hex.builtin.setting.hex_editor.extra_info", "Display extra information" }, { "hex.builtin.provider.file.path", "路径" }, { "hex.builtin.provider.file.size", "大小" }, diff --git a/plugins/libimhex/include/hex/views/view.hpp b/plugins/libimhex/include/hex/views/view.hpp index 1c2e88a0b..b5582910c 100644 --- a/plugins/libimhex/include/hex/views/view.hpp +++ b/plugins/libimhex/include/hex/views/view.hpp @@ -3,6 +3,8 @@ #include #include +#define IMGUI_DEFINE_MATH_OPERATORS +#include #include #include diff --git a/source/providers/file_provider.cpp b/source/providers/file_provider.cpp index 93f63083f..647e00a98 100644 --- a/source/providers/file_provider.cpp +++ b/source/providers/file_provider.cpp @@ -45,7 +45,7 @@ namespace hex::prv { void FileProvider::read(u64 offset, void *buffer, size_t size, bool overlays) { - if (((offset - this->getBaseAddress()) + size) > this->getSize() || buffer == nullptr || size == 0) + if ((offset - this->getBaseAddress()) > (this->getSize() - size) || buffer == nullptr || size == 0) return; std::memcpy(buffer, reinterpret_cast(this->m_mappedFile) + PageSize * this->m_currPage + offset - this->getBaseAddress(), size); diff --git a/source/views/view_data_inspector.cpp b/source/views/view_data_inspector.cpp index c13301ba2..cebc08454 100644 --- a/source/views/view_data_inspector.cpp +++ b/source/views/view_data_inspector.cpp @@ -14,19 +14,13 @@ namespace hex { EventManager::subscribe(this, [this](Region region) { auto provider = SharedData::currentProvider; - if (provider == nullptr) { + if (provider == nullptr || region.address == (size_t)-1) { this->m_validBytes = 0; - return; + } else { + this->m_validBytes = u64(provider->getSize() - region.address); + this->m_startAddress = region.address; } - if (region.address == (size_t)-1) { - this->m_validBytes = 0; - return; - } - - this->m_validBytes = u64(provider->getSize() - region.address); - this->m_startAddress = region.address; - this->m_shouldInvalidate = true; }); } @@ -56,7 +50,7 @@ namespace hex { if (ImGui::Begin(View::toWindowName("hex.view.data_inspector.name").c_str(), &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) { auto provider = SharedData::currentProvider; - if (provider != nullptr && provider->isReadable()) { + if (provider != nullptr && provider->isReadable() && this->m_validBytes > 0) { if (ImGui::BeginTable("##datainspector", 2, ImGuiTableFlags_ScrollY | ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_RowBg, ImVec2(0, ImGui::GetTextLineHeightWithSpacing() * (this->m_cachedData.size() + 1)))) { @@ -112,6 +106,13 @@ namespace hex { this->m_numberDisplayStyle = NumberDisplayStyle::Octal; this->m_shouldInvalidate = true; } + } else { + std::string text = "hex.view.data_inspector.no_data"_lang; + auto textSize = ImGui::CalcTextSize(text.c_str()); + auto availableSpace = ImGui::GetContentRegionAvail(); + + ImGui::SetCursorPos((availableSpace - textSize) / 2.0F); + ImGui::TextUnformatted(text.c_str()); } } ImGui::End(); diff --git a/source/views/view_disassembler.cpp b/source/views/view_disassembler.cpp index f5364736b..42699334e 100644 --- a/source/views/view_disassembler.cpp +++ b/source/views/view_disassembler.cpp @@ -19,8 +19,12 @@ namespace hex { EventManager::subscribe(this, [this](Region region) { if (this->m_shouldMatchSelection) { - this->m_codeRegion[0] = region.address; - this->m_codeRegion[1] = region.address + region.size; + if (region.address == size_t(-1)) { + this->m_codeRegion[0] = this->m_codeRegion[1] = 0; + } else { + this->m_codeRegion[0] = region.address; + this->m_codeRegion[1] = region.address + region.size; + } } }); } diff --git a/source/views/view_hashes.cpp b/source/views/view_hashes.cpp index 3a030e596..576028f91 100644 --- a/source/views/view_hashes.cpp +++ b/source/views/view_hashes.cpp @@ -15,8 +15,12 @@ namespace hex { EventManager::subscribe(this, [this](Region region) { if (this->m_shouldMatchSelection) { - this->m_hashRegion[0] = region.address; - this->m_hashRegion[1] = region.address + region.size; + if (region.address == size_t(-1)) { + this->m_hashRegion[0] = this->m_hashRegion[1] = 0; + } else { + this->m_hashRegion[0] = region.address; + this->m_hashRegion[1] = region.address + region.size; + } this->m_shouldInvalidate = true; } }); diff --git a/source/views/view_hexeditor.cpp b/source/views/view_hexeditor.cpp index 00dcc901b..86272246e 100644 --- a/source/views/view_hexeditor.cpp +++ b/source/views/view_hexeditor.cpp @@ -204,10 +204,53 @@ namespace hex { }); EventManager::subscribe(this, [this] { - auto alpha = ContentRegistry::Settings::getSetting("hex.builtin.setting.interface", "hex.builtin.setting.interface.highlight_alpha"); + { + auto alpha = ContentRegistry::Settings::getSetting("hex.builtin.setting.interface", "hex.builtin.setting.interface.highlight_alpha"); - if (alpha.is_number()) this->m_highlightAlpha = alpha; + } + + { + auto columnCount = ContentRegistry::Settings::getSetting("hex.builtin.setting.hex_editor", "hex.builtin.setting.hex_editor.column_count"); + + this->m_memoryEditor.Cols = static_cast(columnCount); + } + + { + auto hexii = ContentRegistry::Settings::getSetting("hex.builtin.setting.hex_editor", "hex.builtin.setting.hex_editor.hexii"); + + this->m_memoryEditor.OptShowHexII = static_cast(hexii); + } + + { + auto ascii = ContentRegistry::Settings::getSetting("hex.builtin.setting.hex_editor", "hex.builtin.setting.hex_editor.ascii"); + + this->m_memoryEditor.OptShowAscii = static_cast(ascii); + } + + { + auto advancedDecoding = ContentRegistry::Settings::getSetting("hex.builtin.setting.hex_editor", "hex.builtin.setting.hex_editor.advanced_decoding"); + + this->m_memoryEditor.OptShowAdvancedDecoding = static_cast(advancedDecoding); + } + + { + auto greyOutZeros = ContentRegistry::Settings::getSetting("hex.builtin.setting.hex_editor", "hex.builtin.setting.hex_editor.grey_zeros"); + + this->m_memoryEditor.OptGreyOutZeroes = static_cast(greyOutZeros); + } + + { + auto upperCaseHex = ContentRegistry::Settings::getSetting("hex.builtin.setting.hex_editor", "hex.builtin.setting.hex_editor.uppercase_hex"); + + this->m_memoryEditor.OptUpperCaseHex = static_cast(upperCaseHex); + } + + { + auto showExtraInfo = ContentRegistry::Settings::getSetting("hex.builtin.setting.hex_editor", "hex.builtin.setting.hex_editor.extra_info"); + + this->m_memoryEditor.OptShowExtraInfo = static_cast(showExtraInfo); + } }); EventManager::subscribe(this, [this](auto ®ion) { @@ -246,25 +289,26 @@ namespace hex { ImGui::EndPopup(); } - ImGui::SameLine(); - ImGui::Spacing(); - ImGui::SameLine(); - ImGui::TextUnformatted(hex::format("hex.view.hexeditor.page"_lang, provider->getCurrentPage() + 1, provider->getPageCount()).c_str()); - ImGui::SameLine(); + if (provider->getPageCount() > 1) { + ImGui::TextUnformatted(hex::format("hex.view.hexeditor.page"_lang, provider->getCurrentPage() + 1, provider->getPageCount()).c_str()); - if (ImGui::ArrowButton("prevPage", ImGuiDir_Left)) { - provider->setCurrentPage(provider->getCurrentPage() - 1); + ImGui::SameLine(); - EventManager::post(Region { std::min(this->m_memoryEditor.DataPreviewAddr, this->m_memoryEditor.DataPreviewAddrEnd), 1 }); + if (ImGui::ArrowButton("prevPage", ImGuiDir_Left)) { + provider->setCurrentPage(provider->getCurrentPage() - 1); + + EventManager::post(Region { std::min(this->m_memoryEditor.DataPreviewAddr, this->m_memoryEditor.DataPreviewAddrEnd), 1 }); + } + + ImGui::SameLine(); + + if (ImGui::ArrowButton("nextPage", ImGuiDir_Right)) { + provider->setCurrentPage(provider->getCurrentPage() + 1); + + EventManager::post(Region { std::min(this->m_memoryEditor.DataPreviewAddr, this->m_memoryEditor.DataPreviewAddrEnd), 1 }); + } } - ImGui::SameLine(); - - if (ImGui::ArrowButton("nextPage", ImGuiDir_Right)) { - provider->setCurrentPage(provider->getCurrentPage() + 1); - - EventManager::post(Region { std::min(this->m_memoryEditor.DataPreviewAddr, this->m_memoryEditor.DataPreviewAddrEnd), 1 }); - } } ImGui::End(); diff --git a/source/views/view_settings.cpp b/source/views/view_settings.cpp index e72770874..4a546239e 100644 --- a/source/views/view_settings.cpp +++ b/source/views/view_settings.cpp @@ -24,14 +24,22 @@ namespace hex { ImGui::SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(FLT_MAX, FLT_MAX)); if (ImGui::BeginPopupModal(View::toWindowName("hex.view.settings.name").c_str(), &this->getWindowOpenState(), ImGuiWindowFlags_AlwaysAutoResize)) { - for (auto &[category, entries] : ContentRegistry::Settings::getEntries()) { - ImGui::TextUnformatted(LangEntry(category)); - ImGui::Separator(); - for (auto &[name, callback] : entries) { - if (callback(LangEntry(name), ContentRegistry::Settings::getSettingsData()[category][name])) - EventManager::post(); + if (ImGui::BeginTabBar("settings")) { + for (auto &[category, entries] : ContentRegistry::Settings::getEntries()) { + if (ImGui::BeginTabItem(LangEntry(category))) { + ImGui::TextUnformatted(LangEntry(category)); + ImGui::Separator(); + + for (auto &[name, callback] : entries) { + if (callback(LangEntry(name), ContentRegistry::Settings::getSettingsData()[category][name])) + EventManager::post(); + } + + ImGui::EndTabItem(); + } } - ImGui::NewLine(); + + ImGui::EndTabBar(); } ImGui::EndPopup(); } else