1
0
mirror of synced 2024-11-16 03:53:22 +01:00
ImHex/plugins/builtin/source/content/views/view_help.cpp

189 lines
7.3 KiB
C++
Raw Normal View History

2021-12-07 22:47:41 +01:00
#include "content/views/view_help.hpp"
#include <hex/helpers/paths.hpp>
2020-11-14 21:16:03 +01:00
#include <hex/helpers/fmt.hpp>
#include <hex/helpers/utils.hpp>
2022-01-22 23:11:28 +01:00
#include <romfs/romfs.hpp>
2021-12-07 22:47:41 +01:00
namespace hex::plugin::builtin {
2020-11-14 21:16:03 +01:00
2021-12-07 22:47:41 +01:00
ViewHelp::ViewHelp() : View("hex.builtin.view.help.about.name") {
2020-11-14 21:16:03 +01:00
}
ViewHelp::~ViewHelp() {
}
static void link(const std::string &label, const std::string &url) {
if (ImGui::BulletHyperlink(label.data()))
hex::openWebpage(url.data());
}
void ViewHelp::drawAboutMainPage() {
ImGui::TextFormatted("ImHex Hex Editor v{} by WerWolv - " ICON_FA_CODE_BRANCH, IMHEX_VERSION);
#if defined(GIT_BRANCH) && defined(GIT_COMMIT_HASH)
ImGui::SameLine();
if (ImGui::Hyperlink(hex::format("{0}@{1}", GIT_BRANCH, GIT_COMMIT_HASH).c_str()))
hex::openWebpage("https://github.com/WerWolv/ImHex/commit/" GIT_COMMIT_HASH);
#endif
ImGui::TextUnformatted("hex.builtin.view.help.about.translator"_lang);
ImGui::TextUnformatted("hex.builtin.view.help.about.source"_lang); ImGui::SameLine();
if (ImGui::Hyperlink("WerWolv/ImHex"))
hex::openWebpage("https://github.com/WerWolv/ImHex");
ImGui::NewLine();
ImGui::TextUnformatted("hex.builtin.view.help.about.donations"_lang);
ImGui::Separator();
2020-11-14 21:16:03 +01:00
constexpr const char* Links[] = { "https://werwolv.net/donate", "https://www.patreon.com/werwolv", "https://github.com/sponsors/WerWolv" };
2022-01-15 14:14:53 +01:00
ImGui::TextFormattedWrapped("{}", static_cast<const char *>("hex.builtin.view.help.about.thanks"_lang));
ImGui::NewLine();
2021-01-23 00:46:50 +01:00
for (auto &link : Links) {
if (ImGui::Hyperlink(link))
hex::openWebpage(link);
}
}
2021-01-23 00:46:50 +01:00
void ViewHelp::drawContributorPage() {
link("Mary for porting ImHex to MacOS", "https://github.com/Thog");
link("Roblabla for adding the MSI Windows installer", "https://github.com/roblabla");
link("jam1garner for adding support for Rust plugins", "https://github.com/jam1garner");
2020-11-14 21:16:03 +01:00
}
2021-01-23 00:46:50 +01:00
void ViewHelp::drawLibraryCreditsPage() {
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0.2F, 0.2F, 0.2F, 0.3F));
2021-01-23 00:46:50 +01:00
link("ImGui by ocornut", "https://github.com/ocornut/imgui");
link("imgui_club by ocornut", "https://github.com/ocornut/imgui_club");
link("imnodes by Nelarius", "https://github.com/Nelarius/imnodes");
link("ImGuiColorTextEdit by BalazsJako", "https://github.com/BalazsJako/ImGuiColorTextEdit");
link("ImPlot by epezent", "https://github.com/epezent/implot");
link("capstone by aquynh", "https://github.com/aquynh/capstone");
link("JSON for Modern C++ by nlohmann", "https://github.com/nlohmann/json");
link("YARA by VirusTotal", "https://github.com/VirusTotal/yara");
link("Native File Dialog Extended by btzy and mlabbe", "https://github.com/btzy/nativefiledialog-extended");
link("Native File Dialog Extended by btzy and mlabbe", "https://github.com/btzy/nativefiledialog-extended");
ImGui::NewLine();
link("GNU libmagic", "http://www.darwinsys.com/file/");
link("GLFW3", "https://github.com/glfw/glfw");
link("LLVM", "https://github.com/llvm/llvm-project");
link("Python 3", "https://github.com/python/cpython");
link("FreeType", "https://gitlab.freedesktop.org/freetype/freetype");
link("Mbed TLS", "https://github.com/ARMmbed/mbedtls");
2021-01-23 00:46:50 +01:00
ImGui::PopStyleColor();
}
2021-01-23 00:46:50 +01:00
void ViewHelp::drawPathsPage() {
if (ImGui::BeginTable("##imhex_paths", 2, ImGuiTableFlags_ScrollY | ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingFixedFit)) {
ImGui::TableSetupScrollFreeze(0, 1);
ImGui::TableSetupColumn("Type");
ImGui::TableSetupColumn("Paths");
constexpr std::array<std::pair<const char*, ImHexPath>, 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))
2022-01-13 14:33:30 +01:00
ImGui::TextUnformatted(path.string().c_str());
2021-01-23 00:46:50 +01:00
}
ImGui::EndTable();
}
}
2022-01-22 23:11:28 +01:00
void ViewHelp::drawLicensePage() {
ImGui::TextFormattedWrapped("{}", romfs::get("LICENSE").string());
}
void ViewHelp::drawAboutPopup() {
ImGui::SetNextWindowSize(scaled(ImVec2(600, 350)), ImGuiCond_Always);
if (ImGui::BeginPopupModal(View::toWindowName("hex.builtin.view.help.about.name").c_str(), &this->m_aboutWindowOpen, ImGuiWindowFlags_NoResize)) {
if (ImGui::IsKeyDown(ImGui::GetKeyIndex(ImGuiKey_Escape)))
ImGui::CloseCurrentPopup();
if (ImGui::BeginTabBar("about_tab_bar")) {
if (ImGui::BeginTabItem("ImHex")) {
ImGui::NewLine();
this->drawAboutMainPage();
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("hex.builtin.view.help.about.contributor"_lang)) {
ImGui::NewLine();
this->drawContributorPage();
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("hex.builtin.view.help.about.libs"_lang)) {
ImGui::NewLine();
this->drawLibraryCreditsPage();
ImGui::EndTabItem();
}
2020-11-14 21:16:03 +01:00
if (ImGui::BeginTabItem("hex.builtin.view.help.about.paths"_lang)) {
ImGui::NewLine();
this->drawPathsPage();
ImGui::EndTabItem();
}
2022-01-22 23:11:28 +01:00
if (ImGui::BeginTabItem("hex.builtin.view.help.about.license"_lang)) {
ImGui::NewLine();
this->drawLicensePage();
ImGui::EndTabItem();
}
ImGui::EndTabBar();
}
ImGui::EndPopup();
2020-11-14 21:16:03 +01:00
}
}
void ViewHelp::drawContent() {
if (!this->m_aboutWindowOpen)
this->getWindowOpenState() = false;
2020-11-17 13:59:16 +01:00
this->drawAboutPopup();
2020-11-14 21:16:03 +01:00
}
void ViewHelp::drawMenu() {
if (ImGui::BeginMenu("hex.builtin.menu.help"_lang)) {
2021-12-07 22:47:41 +01:00
if (ImGui::MenuItem("hex.builtin.view.help.about.name"_lang, "")) {
View::doLater([] { ImGui::OpenPopup(View::toWindowName("hex.builtin.view.help.about.name").c_str()); });
this->m_aboutWindowOpen = true;
this->getWindowOpenState() = true;
}
2021-12-07 22:47:41 +01:00
if (ImGui::MenuItem("hex.builtin.view.help.documentation"_lang, "")) {
hex::openWebpage("https://imhex.werwolv.net/docs");
}
2020-11-14 21:16:03 +01:00
ImGui::EndMenu();
}
}
}