impr: Added icons to all tools

This commit is contained in:
WerWolv
2025-08-05 23:32:27 +02:00
parent a27b10f69a
commit 263c5f6830
4 changed files with 27 additions and 25 deletions

View File

@@ -632,6 +632,7 @@ EXPORT_MODULE namespace hex {
struct Entry {
UnlocalizedString unlocalizedName;
const char *icon;
Callback function;
};
@@ -644,7 +645,7 @@ EXPORT_MODULE namespace hex {
* @param unlocalizedName The unlocalized name of the tool
* @param function The function that will be called to draw the tool
*/
void add(const UnlocalizedString &unlocalizedName, const impl::Callback &function);
void add(const UnlocalizedString &unlocalizedName, const char *icon, const impl::Callback &function);
}
/* Data Inspector Registry. Allows adding of new types to the data inspector */

View File

@@ -767,10 +767,10 @@ namespace hex {
}
void add(const UnlocalizedString &unlocalizedName, const impl::Callback &function) {
void add(const UnlocalizedString &unlocalizedName, const char *icon, const impl::Callback &function) {
log::debug("Registered new tool: {}", unlocalizedName.get());
impl::s_tools->emplace_back(impl::Entry { unlocalizedName, function });
impl::s_tools->emplace_back(impl::Entry { unlocalizedName, icon, function });
}
}

View File

@@ -5,6 +5,7 @@
#include <content/tools_entries.hpp>
#include <imgui.h>
#include <fonts/vscode_icons.hpp>
namespace hex::plugin::builtin {
@@ -31,23 +32,23 @@ namespace hex::plugin::builtin {
}
void registerToolEntries() {
ContentRegistry::Tools::add("hex.builtin.tools.demangler", drawDemangler);
ContentRegistry::Tools::add("hex.builtin.tools.ascii_table", drawASCIITable);
ContentRegistry::Tools::add("hex.builtin.tools.regex_replacer", drawRegexReplacer);
ContentRegistry::Tools::add("hex.builtin.tools.color", drawColorPicker);
ContentRegistry::Tools::add("hex.builtin.tools.calc", drawMathEvaluator);
ContentRegistry::Tools::add("hex.builtin.tools.graphing", drawGraphingCalculator);
ContentRegistry::Tools::add("hex.builtin.tools.base_converter", drawBaseConverter);
ContentRegistry::Tools::add("hex.builtin.tools.byte_swapper", drawByteSwapper);
ContentRegistry::Tools::add("hex.builtin.tools.permissions", drawPermissionsCalculator);
//ContentRegistry::Tools::add("hex.builtin.tools.file_uploader", drawFileUploader);
ContentRegistry::Tools::add("hex.builtin.tools.wiki_explain", drawWikiExplainer);
ContentRegistry::Tools::add("hex.builtin.tools.file_tools", drawFileTools);
ContentRegistry::Tools::add("hex.builtin.tools.ieee754", drawIEEE754Decoder);
ContentRegistry::Tools::add("hex.builtin.tools.invariant_multiplication", drawInvariantMultiplicationDecoder);
ContentRegistry::Tools::add("hex.builtin.tools.tcp_client_server", drawTCPClientServer);
ContentRegistry::Tools::add("hex.builtin.tools.euclidean_algorithm", drawEuclidianAlgorithm);
ContentRegistry::Tools::add("hex.builtin.tools.http_requests", drawHTTPRequestMaker);
ContentRegistry::Tools::add("hex.builtin.tools.demangler", ICON_VS_CODE, drawDemangler);
ContentRegistry::Tools::add("hex.builtin.tools.ascii_table", ICON_VS_TABLE, drawASCIITable);
ContentRegistry::Tools::add("hex.builtin.tools.regex_replacer", ICON_VS_REGEX, drawRegexReplacer);
ContentRegistry::Tools::add("hex.builtin.tools.color", ICON_VS_SYMBOL_COLOR, drawColorPicker);
ContentRegistry::Tools::add("hex.builtin.tools.calc", ICON_VS_SYMBOL_OPERATOR, drawMathEvaluator);
ContentRegistry::Tools::add("hex.builtin.tools.graphing", ICON_VS_GRAPH_LINE, drawGraphingCalculator);
ContentRegistry::Tools::add("hex.builtin.tools.base_converter", ICON_VS_SYMBOL_RULER, drawBaseConverter);
ContentRegistry::Tools::add("hex.builtin.tools.byte_swapper", ICON_VS_ARROW_SWAP, drawByteSwapper);
ContentRegistry::Tools::add("hex.builtin.tools.permissions", ICON_VS_ACCOUNT, drawPermissionsCalculator);
// ContentRegistry::Tools::add("hex.builtin.tools.file_uploader", ICON_VS_CLOUD_UPLOAD, drawFileUploader);
ContentRegistry::Tools::add("hex.builtin.tools.wiki_explain", ICON_VS_GLOBE, drawWikiExplainer);
ContentRegistry::Tools::add("hex.builtin.tools.file_tools", ICON_VS_FILES, drawFileTools);
ContentRegistry::Tools::add("hex.builtin.tools.ieee754", ICON_VS_PERCENTAGE, drawIEEE754Decoder);
ContentRegistry::Tools::add("hex.builtin.tools.invariant_multiplication", ICON_VS_UNFOLD, drawInvariantMultiplicationDecoder);
ContentRegistry::Tools::add("hex.builtin.tools.tcp_client_server", ICON_VS_SERVER_ENVIRONMENT, drawTCPClientServer);
ContentRegistry::Tools::add("hex.builtin.tools.euclidean_algorithm", ICON_VS_GROUP_BY_REF_TYPE, drawEuclidianAlgorithm);
ContentRegistry::Tools::add("hex.builtin.tools.http_requests", ICON_VS_SERVER_PROCESS, drawHTTPRequestMaker);
}
}

View File

@@ -20,7 +20,7 @@ namespace hex::plugin::builtin {
});
LayoutManager::registerStoreCallback([this](ImGuiTextBuffer *buffer) {
for (auto &[unlocalizedName, function] : ContentRegistry::Tools::impl::getEntries()) {
for (auto &[unlocalizedName, icon, function] : ContentRegistry::Tools::impl::getEntries()) {
auto detached = m_detachedTools[unlocalizedName];
buffer->appendf("%s=%d\n", unlocalizedName.get().c_str(), detached);
}
@@ -32,13 +32,13 @@ namespace hex::plugin::builtin {
// Draw all tools
for (auto iter = tools.begin(); iter != tools.end(); ++iter) {
auto &[unlocalizedName, function] = *iter;
auto &[unlocalizedName, icon, function] = *iter;
// If the tool has been detached from the main window, don't draw it here anymore
if (m_detachedTools[unlocalizedName]) continue;
// Draw the tool
if (ImGui::CollapsingHeader(Lang(unlocalizedName))) {
if (ImGui::CollapsingHeader(hex::format("{} {}", icon, Lang(unlocalizedName)).c_str())) {
function();
ImGui::NewLine();
} else {
@@ -69,13 +69,13 @@ namespace hex::plugin::builtin {
auto &tools = ContentRegistry::Tools::impl::getEntries();
for (auto iter = tools.begin(); iter != tools.end(); ++iter) {
auto &[unlocalizedName, function] = *iter;
auto &[unlocalizedName, icon, function] = *iter;
// If the tool is still attached to the main window, don't draw it here
if (!m_detachedTools[unlocalizedName]) continue;
// Load the window height that is dependent on the tool content
const auto windowName = View::toWindowName(unlocalizedName);
const auto windowName = hex::format("{} {}", icon, View::toWindowName(unlocalizedName));
const auto height = m_windowHeights[ImGui::FindWindowByName(windowName.c_str())];
if (height > 0)
ImGui::SetNextWindowSizeConstraints(ImVec2(400_scaled, height), ImVec2(FLT_MAX, height));