mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 05:27:41 -05:00
impr: Various code cleanup
This commit is contained in:
@@ -15,6 +15,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
ViewAbout::ViewAbout() : View("hex.builtin.view.help.about.name") {
|
||||
|
||||
// Add "About" menu item to the help menu
|
||||
ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.help", "hex.builtin.view.help.about.name" }, 1000, Shortcut::None, [this] {
|
||||
TaskManager::doLater([] { ImGui::OpenPopup(View::toWindowName("hex.builtin.view.help.about.name").c_str()); });
|
||||
this->m_aboutWindowOpen = true;
|
||||
@@ -23,6 +24,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
ContentRegistry::Interface::addMenuItemSeparator({ "hex.builtin.menu.help" }, 2000);
|
||||
|
||||
// Add documentation links to the help menu
|
||||
ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.help", "hex.builtin.view.help.documentation" }, 3000, Shortcut::None, [] {
|
||||
hex::openWebpage("https://docs.werwolv.net/imhex");
|
||||
AchievementManager::unlockAchievement("hex.builtin.achievement.starting_out", "hex.builtin.achievement.starting_out.docs.name");
|
||||
@@ -31,18 +33,23 @@ namespace hex::plugin::builtin {
|
||||
ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.help", "hex.builtin.menu.help.ask_for_help" }, 4000, CTRLCMD + SHIFT + Keys::D, [] {
|
||||
PopupDocsQuestion::open();
|
||||
});
|
||||
|
||||
this->m_logoTexture = ImGui::Texture(romfs::get("assets/common/logo.png").span());
|
||||
}
|
||||
|
||||
static void link(const std::string &name, const std::string &author, const std::string &url) {
|
||||
// Draw the hyperlink and open the URL if clicked
|
||||
if (ImGui::BulletHyperlink(name.c_str()))
|
||||
hex::openWebpage(url);
|
||||
|
||||
// Show the URL as a tooltip
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::TextFormatted("{}", url);
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
|
||||
// Show the author if there is one
|
||||
if (!author.empty()) {
|
||||
ImGui::SameLine(0, 0);
|
||||
ImGui::TextFormatted("by {}", author);
|
||||
@@ -50,28 +57,33 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
|
||||
void ViewAbout::drawAboutMainPage() {
|
||||
// Draw main about table
|
||||
if (ImGui::BeginTable("about_table", 2, ImGuiTableFlags_SizingFixedFit)) {
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
if (!this->m_logoTexture.isValid()) {
|
||||
auto logo = romfs::get("assets/common/logo.png");
|
||||
this->m_logoTexture = ImGui::Texture(reinterpret_cast<const ImU8 *>(logo.data()), logo.size());
|
||||
}
|
||||
|
||||
// Draw the ImHex icon
|
||||
ImGui::Image(this->m_logoTexture, scaled({ 64, 64 }));
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
// Draw basic information about ImHex and its version
|
||||
ImGui::TextFormatted("ImHex Hex Editor v{} by WerWolv - " ICON_FA_CODE_BRANCH, ImHexApi::System::getImHexVersion());
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
// Draw clickable link to the current commit
|
||||
if (ImGui::Hyperlink(hex::format("{0}@{1}", ImHexApi::System::getCommitBranch(), ImHexApi::System::getCommitHash()).c_str()))
|
||||
hex::openWebpage("https://github.com/WerWolv/ImHex/commit/" + ImHexApi::System::getCommitHash(true));
|
||||
|
||||
// Draw the author of the current translation
|
||||
ImGui::TextUnformatted("hex.builtin.view.help.about.translator"_lang);
|
||||
|
||||
// Draw information about the open-source nature of ImHex
|
||||
ImGui::TextUnformatted("hex.builtin.view.help.about.source"_lang);
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
//Draw clickable link to the GitHub repository
|
||||
if (ImGui::Hyperlink("WerWolv/ImHex"))
|
||||
hex::openWebpage("https://github.com/WerWolv/ImHex");
|
||||
|
||||
@@ -80,6 +92,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
ImGui::NewLine();
|
||||
|
||||
// Draw donation links
|
||||
ImGui::TextUnformatted("hex.builtin.view.help.about.donations"_lang);
|
||||
ImGui::Separator();
|
||||
|
||||
@@ -99,6 +112,13 @@ namespace hex::plugin::builtin {
|
||||
ImGui::TextFormattedWrapped("These amazing people have contributed to ImHex in the past. If you'd like to become part of them, please submit a PR to the GitHub Repository!");
|
||||
ImGui::NewLine();
|
||||
|
||||
// Draw main ImHex contributors
|
||||
link("iTrooz for a huge amount of help maintaining ImHex and the CI", "", "https://github.com/iTrooz");
|
||||
link("jumanji144 for a ton of help with the Pattern Language, API and usage stats", "", "https://github.com/Nowilltolife");
|
||||
|
||||
ImGui::NewLine();
|
||||
|
||||
// Draw additional contributors
|
||||
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");
|
||||
@@ -111,6 +131,7 @@ namespace hex::plugin::builtin {
|
||||
void ViewAbout::drawLibraryCreditsPage() {
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0.2F, 0.2F, 0.2F, 0.3F));
|
||||
|
||||
// Draw ImGui dependencies
|
||||
link("ImGui", "ocornut", "https://github.com/ocornut/imgui/");
|
||||
link("imgui_club", "ocornut", "https://github.com/ocornut/imgui_club/");
|
||||
link("imnodes", "Nelarius", "https://github.com/Nelarius/imnodes/");
|
||||
@@ -119,6 +140,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
ImGui::NewLine();
|
||||
|
||||
// Draw dependencies maintained by individual people
|
||||
link("capstone", "aquynh", "https://github.com/aquynh/capstone/");
|
||||
link("JSON for Modern C++", "nlohmann", "https://github.com/nlohmann/json/");
|
||||
link("YARA", "VirusTotal", "https://github.com/VirusTotal/yara/");
|
||||
@@ -127,12 +149,13 @@ namespace hex::plugin::builtin {
|
||||
link("microtar", "rxi", "https://github.com/rxi/microtar/");
|
||||
link("xdgpp", "danyspin97", "https://sr.ht/~danyspin97/xdgpp/");
|
||||
link("FreeType", "David Turner", "https://gitlab.freedesktop.org/freetype/freetype/");
|
||||
link("Mbed TLS", "ARM", "https://github.com/ARMmbed/mbedtls/");
|
||||
link("mbedTLS", "ARM", "https://github.com/ARMmbed/mbedtls/");
|
||||
link("libcurl", "Daniel Stenberg", "https://curl.se/");
|
||||
link("libfmt", "vitaut", "https://fmt.dev/");
|
||||
|
||||
ImGui::NewLine();
|
||||
|
||||
// Draw dependencies maintained by groups
|
||||
link("GNU libmagic", "", "https://www.darwinsys.com/file/");
|
||||
link("GLFW3", "", "https://github.com/glfw/glfw/");
|
||||
link("LLVM", "", "https://github.com/llvm/llvm-project/");
|
||||
@@ -148,7 +171,8 @@ namespace hex::plugin::builtin {
|
||||
ImGui::TableSetupColumn("Type");
|
||||
ImGui::TableSetupColumn("Paths");
|
||||
|
||||
constexpr static std::array<std::pair<const char *, fs::ImHexPath>, u32(fs::ImHexPath::END)-1> PathTypes = {
|
||||
// Specify the types of paths to display
|
||||
constexpr static std::array<std::pair<const char *, fs::ImHexPath>, size_t(fs::ImHexPath::END) - 1U> PathTypes = {
|
||||
{
|
||||
{ "Patterns", fs::ImHexPath::Patterns },
|
||||
{ "Patterns Includes", fs::ImHexPath::PatternsInclude },
|
||||
@@ -169,6 +193,7 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
};
|
||||
|
||||
// Draw the table
|
||||
ImGui::TableHeadersRow();
|
||||
for (const auto &[name, type] : PathTypes) {
|
||||
ImGui::TableNextRow();
|
||||
@@ -177,6 +202,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
for (auto &path : fs::getDefaultPaths(type, true)){
|
||||
// Draw hyperlink to paths that exist or red text if they don't
|
||||
if (wolv::io::fs::isDirectory(path)){
|
||||
if (ImGui::Hyperlink(wolv::util::toUTF8String(path).c_str())) {
|
||||
fs::openFolderExternal(path);
|
||||
@@ -198,11 +224,13 @@ namespace hex::plugin::builtin {
|
||||
void ViewAbout::drawAboutPopup() {
|
||||
if (ImGui::BeginPopupModal(View::toWindowName("hex.builtin.view.help.about.name").c_str(), &this->m_aboutWindowOpen)) {
|
||||
|
||||
// Allow window to be closed by pressing ESC
|
||||
if (ImGui::IsKeyDown(ImGui::GetKeyIndex(ImGuiKey_Escape)))
|
||||
ImGui::CloseCurrentPopup();
|
||||
|
||||
if (ImGui::BeginTabBar("about_tab_bar")) {
|
||||
|
||||
// Draw main ImHex tab
|
||||
if (ImGui::BeginTabItem("ImHex")) {
|
||||
if (ImGui::BeginChild(1)) {
|
||||
this->drawAboutMainPage();
|
||||
@@ -211,6 +239,7 @@ namespace hex::plugin::builtin {
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
// Draw contributors tab
|
||||
if (ImGui::BeginTabItem("hex.builtin.view.help.about.contributor"_lang)) {
|
||||
ImGui::NewLine();
|
||||
if (ImGui::BeginChild(1)) {
|
||||
@@ -220,6 +249,7 @@ namespace hex::plugin::builtin {
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
// Draw libraries tab
|
||||
if (ImGui::BeginTabItem("hex.builtin.view.help.about.libs"_lang)) {
|
||||
ImGui::NewLine();
|
||||
if (ImGui::BeginChild(1)) {
|
||||
@@ -229,6 +259,7 @@ namespace hex::plugin::builtin {
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
// Draw paths tab
|
||||
if (ImGui::BeginTabItem("hex.builtin.view.help.about.paths"_lang)) {
|
||||
ImGui::NewLine();
|
||||
if (ImGui::BeginChild(1)) {
|
||||
@@ -238,6 +269,7 @@ namespace hex::plugin::builtin {
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
// Draw license tab
|
||||
if (ImGui::BeginTabItem("hex.builtin.view.help.about.license"_lang)) {
|
||||
ImGui::NewLine();
|
||||
if (ImGui::BeginChild(1)) {
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#include "content/views/view_achievements.hpp"
|
||||
|
||||
#include <hex/api/content_registry.hpp>
|
||||
|
||||
#include <wolv/utils/guards.hpp>
|
||||
#include <hex/api/task.hpp>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user