From 21525a7261aa8f496e5f81d1585eb06d995076ae Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sun, 23 May 2021 23:35:04 +0200 Subject: [PATCH] ui: Added ImHex directories table to about page --- plugins/builtin/source/lang/de_DE.cpp | 1 + plugins/builtin/source/lang/en_US.cpp | 1 + plugins/builtin/source/lang/it_IT.cpp | 1 + source/views/view_help.cpp | 38 +++++++++++++++++++++++++-- 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/plugins/builtin/source/lang/de_DE.cpp b/plugins/builtin/source/lang/de_DE.cpp index 1ff1e10ff..9e5dde76e 100644 --- a/plugins/builtin/source/lang/de_DE.cpp +++ b/plugins/builtin/source/lang/de_DE.cpp @@ -134,6 +134,7 @@ namespace hex::plugin::builtin { { "hex.view.help.about.donations", "Spenden" }, { "hex.view.help.about.thanks", "Wenn dir meine Arbeit gefällt, bitte ziehe eine Spende in Betracht, um das Projekt am Laufen zu halten. Vielen Dank <3" }, { "hex.view.help.about.libs", "Benutzte Libraries" }, + { "hex.view.help.about.paths", "ImHex Ordner" }, { "hex.view.help.pattern_cheat_sheet", "Pattern Language Cheat Sheet"}, { "hex.view.help.calc_cheat_sheet", "Rechner Cheat Sheet" }, diff --git a/plugins/builtin/source/lang/en_US.cpp b/plugins/builtin/source/lang/en_US.cpp index 3cf67198c..5e1f6742a 100644 --- a/plugins/builtin/source/lang/en_US.cpp +++ b/plugins/builtin/source/lang/en_US.cpp @@ -134,6 +134,7 @@ namespace hex::plugin::builtin { { "hex.view.help.about.donations", "Donations" }, { "hex.view.help.about.thanks", "If you like my work, please consider donating to keep the project going. Thanks a lot <3" }, { "hex.view.help.about.libs", "Libraries used" }, + { "hex.view.help.about.paths", "ImHex Directories" }, { "hex.view.help.pattern_cheat_sheet", "Pattern Language Cheat Sheet"}, { "hex.view.help.calc_cheat_sheet", "Calculator Cheat Sheet" }, diff --git a/plugins/builtin/source/lang/it_IT.cpp b/plugins/builtin/source/lang/it_IT.cpp index 3d8c40bff..bf1047b80 100644 --- a/plugins/builtin/source/lang/it_IT.cpp +++ b/plugins/builtin/source/lang/it_IT.cpp @@ -134,6 +134,7 @@ namespace hex::plugin::builtin { { "hex.view.help.about.donations", "Donazioni" }, { "hex.view.help.about.thanks", "Se ti piace il mio lavoro, per favore considera di fare una donazione. Grazie mille <3" }, { "hex.view.help.about.libs", "Librerie usate" }, + { "hex.view.help.about.paths", "ImHex cartelle" }, { "hex.view.help.pattern_cheat_sheet", "Pattern Language Cheat Sheet"}, { "hex.view.help.calc_cheat_sheet", "Calcolatrice Cheat Sheet" }, diff --git a/source/views/view_help.cpp b/source/views/view_help.cpp index 566ab121f..ee979e2d3 100644 --- a/source/views/view_help.cpp +++ b/source/views/view_help.cpp @@ -64,7 +64,7 @@ namespace hex { hex::openWebpage(url.data()); }; - ImGui::Text("hex.view.help.about.libs"_lang); + ImGui::TextUnformatted("hex.view.help.about.libs"_lang); ImGui::Separator(); ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0.2F, 0.2F, 0.2F, 0.3F)); Link("ImGui by ocornut", "https://github.com/ocornut/imgui"); @@ -89,6 +89,40 @@ namespace hex { if (ImGui::IsKeyDown(ImGui::GetKeyIndex(ImGuiKey_Escape))) ImGui::CloseCurrentPopup(); + ImGui::NewLine(); + ImGui::TextUnformatted("hex.view.help.about.paths"_lang); + ImGui::Separator(); + + if (ImGui::BeginTable("##imhex_paths", 2, ImGuiTableFlags_ScrollY | ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg)) { + ImGui::TableSetupScrollFreeze(0, 1); + ImGui::TableSetupColumn("Type"); + ImGui::TableSetupColumn("Paths"); + + constexpr std::array, 8> PathTypes = {{ + { "Resources", ImHexPath::Resources }, + { "Config", ImHexPath::Config }, + { "Magic", ImHexPath::Magic }, + { "Patterns", ImHexPath::Patterns }, + { "Patterns Includes", ImHexPath::PatternsInclude }, + { "Plugins", ImHexPath::Plugins }, + { "Python Scripts", ImHexPath::Python }, + { "Yara Patterns", ImHexPath::Yara } + }}; + + ImGui::TableHeadersRow(); + for (const auto &[name, type] : PathTypes) { + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::TextUnformatted(name); + + ImGui::TableNextColumn(); + for (auto &path : hex::getPath(type)) + ImGui::TextUnformatted(path.c_str()); + } + + ImGui::EndTable(); + } + ImGui::EndPopup(); } } @@ -322,7 +356,7 @@ namespace hex { void ViewHelp::drawMenu() { if (ImGui::BeginMenu("hex.menu.help"_lang)) { if (ImGui::MenuItem("hex.view.help.about.name"_lang, "")) { - View::doLater([] { ImGui::OpenPopup(View::toWindowName("hex.view.about.name").c_str()); }); + View::doLater([] { ImGui::OpenPopup(View::toWindowName("hex.view.help.about.name").c_str()); }); this->m_aboutWindowOpen = true; this->getWindowOpenState() = true; }