From fbde2942de8b15f02b248fec6022d59b9e915638 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Thu, 14 Aug 2025 21:22:03 +0200 Subject: [PATCH] build: Refactor ContentRegistry into multiple separate files --- cmake/sdk/template/source/example_plugin.cpp | 2 +- .../include/hex/api/content_registry.hpp | 1542 ----------------- .../content_registry/background_services.hpp | 22 + .../api/content_registry/command_palette.hpp | 82 + .../communication_interface.hpp | 25 + .../api/content_registry/data_formatter.hpp | 72 + .../api/content_registry/data_information.hpp | 81 + .../api/content_registry/data_inspector.hpp | 80 + .../api/content_registry/data_processor.hpp | 64 + .../hex/api/content_registry/diffing.hpp | 68 + .../api/content_registry/disassemblers.hpp | 64 + .../hex/api/content_registry/experiments.hpp | 36 + .../content_registry/file_type_handler.hpp | 37 + .../hex/api/content_registry/hashes.hpp | 101 ++ .../hex/api/content_registry/hex_editor.hpp | 91 + .../hex/api/content_registry/interface.hpp | 0 .../api/content_registry/pattern_language.hpp | 155 ++ .../hex/api/content_registry/provider.hpp | 54 + .../hex/api/content_registry/reports.hpp | 34 + .../hex/api/content_registry/settings.hpp | 345 ++++ .../hex/api/content_registry/tools.hpp | 37 + .../api/content_registry/user_interface.hpp | 287 +++ .../hex/api/content_registry/views.hpp | 63 + .../include/hex/api/theme_manager.hpp | 2 +- lib/libimhex/source/api/content_registry.cpp | 44 +- lib/libimhex/source/api/layout_manager.cpp | 3 +- .../source/api/localization_manager.cpp | 1 - lib/libimhex/source/api/shortcut_manager.cpp | 6 +- main/gui/source/init/run/common.cpp | 2 +- main/gui/source/init/tasks.cpp | 2 +- main/gui/source/window/platform/linux.cpp | 1 - main/gui/source/window/platform/windows.cpp | 2 +- main/gui/source/window/window.cpp | 2 +- .../export_formatters/export_formatter.hpp | 2 +- .../content/providers/null_provider.hpp | 2 + .../content/views/view_command_palette.hpp | 4 +- .../content/views/view_data_inspector.hpp | 3 +- .../include/content/views/view_find.hpp | 3 +- .../content/views/view_highlight_rules.hpp | 1 - .../content/views/view_information.hpp | 2 +- .../content/views/view_pattern_data.hpp | 1 + .../include/content/views/view_settings.hpp | 2 +- .../include/content/views/view_tools.hpp | 2 +- .../source/content/background_services.cpp | 5 +- .../source/content/command_line_interface.cpp | 3 +- .../content/command_palette_commands.cpp | 52 +- .../content/communication_interface.cpp | 2 +- .../source/content/data_formatters.cpp | 2 +- .../content/data_information_sections.cpp | 3 +- .../builtin/source/content/data_inspector.cpp | 2 +- .../data_processor_nodes/basic_nodes.cpp | 16 +- .../data_processor_nodes/control_nodes.cpp | 18 +- .../data_processor_nodes/decode_nodes.cpp | 8 +- .../data_processor_nodes/logic_nodes.cpp | 18 +- .../data_processor_nodes/math_nodes.cpp | 22 +- .../data_processor_nodes/other_nodes.cpp | 45 +- .../data_processor_nodes/visual_nodes.cpp | 12 +- .../source/content/data_visualizers.cpp | 2 +- plugins/builtin/source/content/events.cpp | 5 +- .../builtin/source/content/file_handlers.cpp | 8 +- plugins/builtin/source/content/init_tasks.cpp | 5 +- .../source/content/main_menu_items.cpp | 99 +- .../source/content/minimap_visualizers.cpp | 5 +- .../source/content/out_of_box_experience.cpp | 2 +- .../source/content/pl_builtin_functions.cpp | 2 +- .../source/content/pl_builtin_types.cpp | 2 +- plugins/builtin/source/content/pl_pragmas.cpp | 2 +- .../builtin/source/content/pl_visualizers.cpp | 2 +- .../hex_editor/popup_hex_editor_find.cpp | 1 + plugins/builtin/source/content/project.cpp | 1 - plugins/builtin/source/content/providers.cpp | 2 +- .../content/providers/file_provider.cpp | 2 +- plugins/builtin/source/content/recent.cpp | 5 +- .../source/content/report_generators.cpp | 2 +- .../source/content/settings_entries.cpp | 37 +- .../source/content/tools/ieee_decoder.cpp | 2 +- .../source/content/tools/wiki_explainer.cpp | 2 +- .../builtin/source/content/tools_entries.cpp | 2 +- plugins/builtin/source/content/ui_items.cpp | 35 +- .../view_fullscreen_save_editor.cpp | 2 +- .../source/content/views/view_about.cpp | 17 +- .../content/views/view_achievements.cpp | 5 +- .../source/content/views/view_bookmarks.cpp | 14 +- .../content/views/view_command_palette.cpp | 14 +- .../content/views/view_data_inspector.cpp | 1 + .../content/views/view_data_processor.cpp | 20 +- .../source/content/views/view_hex_editor.cpp | 81 +- .../content/views/view_highlight_rules.cpp | 13 +- .../source/content/views/view_information.cpp | 5 +- .../source/content/views/view_logs.cpp | 4 +- .../content/views/view_pattern_data.cpp | 2 +- .../content/views/view_pattern_editor.cpp | 62 +- .../content/views/view_provider_settings.cpp | 4 +- .../source/content/views/view_settings.cpp | 6 +- .../source/content/views/view_store.cpp | 5 +- .../content/views/view_theme_manager.cpp | 4 +- .../source/content/views/view_tools.cpp | 2 +- .../source/content/views/view_tutorials.cpp | 4 +- .../builtin/source/content/welcome_screen.cpp | 15 +- .../source/content/window_decoration.cpp | 34 +- plugins/builtin/source/content/workspaces.cpp | 2 +- plugins/builtin/source/plugin_builtin.cpp | 1 - .../source/content/pl_functions.cpp | 2 +- .../decompress/source/plugin_decompress.cpp | 1 - .../include/content/views/view_diff.hpp | 1 + .../source/content/diffing_algorithms.cpp | 2 +- plugins/diffing/source/plugin_diffing.cpp | 2 +- .../content/views/view_disassembler.hpp | 6 +- .../disassemblers/capstone_architectures.cpp | 44 +- .../disassemblers/custom_architectures.cpp | 10 +- .../source/content/pl_builtin_types.cpp | 2 +- .../content/views/view_disassembler.cpp | 9 +- .../source/plugin_disassembler.cpp | 3 +- plugins/fonts/include/font_settings.hpp | 2 +- plugins/fonts/source/font_loader.cpp | 2 +- plugins/fonts/source/font_settings.cpp | 6 +- plugins/fonts/source/library_fonts.cpp | 1 - .../include/content/views/view_hashes.hpp | 2 +- plugins/hashes/source/content/hashes.cpp | 2 +- .../source/content/views/view_hashes.cpp | 4 +- plugins/hashes/source/plugin_hashes.cpp | 2 +- plugins/remote/source/plugin_remote.cpp | 2 +- .../source/plugin_script_loader.cpp | 4 +- .../support/c/source/script_api/v1/mem.cpp | 2 +- .../support/c/source/script_api/v1/ui.cpp | 5 +- plugins/ui/include/ui/hex_editor.hpp | 2 +- plugins/ui/include/ui/pattern_drawer.hpp | 2 - plugins/ui/include/ui/visualizer_drawer.hpp | 2 +- plugins/ui/source/library_ui.cpp | 1 - plugins/ui/source/ui/hex_editor.cpp | 2 +- plugins/ui/source/ui/pattern_drawer.cpp | 2 +- plugins/ui/source/ui/visualizer_drawer.cpp | 2 + .../source/content/pl_inline_visualizers.cpp | 7 +- .../source/content/pl_visualizers.cpp | 2 +- .../visualizers/source/plugin_visualizers.cpp | 2 +- .../source/content/settings_entries.cpp | 2 +- plugins/windows/source/content/ui_items.cpp | 7 +- plugins/windows/source/plugin_windows.cpp | 3 +- .../content/data_information_sections.cpp | 4 +- .../source/content/views/view_yara.cpp | 7 +- plugins/yara_rules/source/plugin_yara.cpp | 2 +- 141 files changed, 2337 insertions(+), 2007 deletions(-) delete mode 100644 lib/libimhex/include/hex/api/content_registry.hpp delete mode 100644 lib/libimhex/include/hex/api/content_registry/interface.hpp create mode 100644 lib/libimhex/include/hex/api/content_registry/user_interface.hpp diff --git a/cmake/sdk/template/source/example_plugin.cpp b/cmake/sdk/template/source/example_plugin.cpp index c1532b8eb..8fccb5ffe 100644 --- a/cmake/sdk/template/source/example_plugin.cpp +++ b/cmake/sdk/template/source/example_plugin.cpp @@ -1,7 +1,7 @@ #include // Browse through the headers in lib/libimhex/include/hex/api/ to see what you can do with the API. -// Most important ones are and +// Most important ones are the things under imhex_api and content_registry // This is the main entry point of your plugin. The code in the body of this construct will be executed // when ImHex starts up and loads the plugin. diff --git a/lib/libimhex/include/hex/api/content_registry.hpp b/lib/libimhex/include/hex/api/content_registry.hpp deleted file mode 100644 index 8d7f09664..000000000 --- a/lib/libimhex/include/hex/api/content_registry.hpp +++ /dev/null @@ -1,1542 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#if !defined(HEX_MODULE_EXPORT) - using ImGuiDataType = int; - using ImGuiInputTextFlags = int; - struct ImColor; - enum ImGuiCustomCol : int; - typedef int ImGuiColorEditFlags; -#endif - -EXPORT_MODULE namespace hex { - - #if !defined(HEX_MODULE_EXPORT) - class View; - class Task; - - namespace dp { - class Node; - } - namespace prv { - class Provider; - } - #endif - - /* - The Content Registry is the heart of all features in ImHex that are in some way extendable by Plugins. - It allows you to add/register new content that will be picked up and used by the ImHex core or by other - plugins when needed. - */ - namespace ContentRegistry { - /* Settings Registry. Allows adding of new entries into the ImHex preferences window. */ - namespace Settings { - - namespace Widgets { - - class Widget { - public: - virtual ~Widget() = default; - - virtual bool draw(const std::string &name) = 0; - - virtual void load(const nlohmann::json &data) = 0; - virtual nlohmann::json store() = 0; - - class Interface { - public: - friend class Widget; - - Interface& requiresRestart() { - m_requiresRestart = true; - - return *this; - } - - Interface& setEnabledCallback(std::function callback) { - m_enabledCallback = std::move(callback); - - return *this; - } - - Interface& setChangedCallback(std::function callback) { - m_changedCallback = std::move(callback); - - return *this; - } - - Interface& setTooltip(const std::string &tooltip) { - m_tooltip = tooltip; - - return *this; - } - - [[nodiscard]] - Widget& getWidget() const { - return *m_widget; - } - - private: - explicit Interface(Widget *widget) : m_widget(widget) {} - Widget *m_widget; - - bool m_requiresRestart = false; - std::function m_enabledCallback; - std::function m_changedCallback; - std::optional m_tooltip; - }; - - [[nodiscard]] - bool doesRequireRestart() const { - return m_interface.m_requiresRestart; - } - - [[nodiscard]] - bool isEnabled() const { - return !m_interface.m_enabledCallback || m_interface.m_enabledCallback(); - } - - [[nodiscard]] - const std::optional& getTooltip() const { - return m_interface.m_tooltip; - } - - void onChanged() { - if (m_interface.m_changedCallback) - m_interface.m_changedCallback(*this); - } - - [[nodiscard]] - Interface& getInterface() { - return m_interface; - } - - private: - Interface m_interface = Interface(this); - }; - - class Checkbox : public Widget { - public: - explicit Checkbox(bool defaultValue) : m_value(defaultValue) { } - - bool draw(const std::string &name) override; - - void load(const nlohmann::json &data) override; - nlohmann::json store() override; - - [[nodiscard]] bool isChecked() const { return m_value; } - - protected: - bool m_value; - }; - - class SliderInteger : public Widget { - public: - SliderInteger(i32 defaultValue, i32 min, i32 max) : m_value(defaultValue), m_min(min), m_max(max) { } - bool draw(const std::string &name) override; - - void load(const nlohmann::json &data) override; - nlohmann::json store() override; - - [[nodiscard]] i32 getValue() const { return m_value; } - - protected: - int m_value; - i32 m_min, m_max; - }; - - class SliderFloat : public Widget { - public: - SliderFloat(float defaultValue, float min, float max) : m_value(defaultValue), m_min(min), m_max(max) { } - bool draw(const std::string &name) override; - - void load(const nlohmann::json &data) override; - nlohmann::json store() override; - - [[nodiscard]] float getValue() const { return m_value; } - - protected: - float m_value; - float m_min, m_max; - }; - - class SliderDataSize : public Widget { - public: - SliderDataSize(u64 defaultValue, u64 min, u64 max, u64 stepSize) : m_value(defaultValue), m_min(min), m_max(max), m_stepSize(stepSize) { } - bool draw(const std::string &name) override; - - void load(const nlohmann::json &data) override; - nlohmann::json store() override; - - [[nodiscard]] i32 getValue() const { return m_value; } - - protected: - u64 m_value; - u64 m_min, m_max; - u64 m_stepSize; - }; - - class ColorPicker : public Widget { - public: - explicit ColorPicker(ImColor defaultColor, ImGuiColorEditFlags flags = 0); - - bool draw(const std::string &name) override; - - void load(const nlohmann::json &data) override; - nlohmann::json store() override; - - [[nodiscard]] ImColor getColor() const; - - protected: - std::array m_value = {}, m_defaultValue = {}; - ImGuiColorEditFlags m_flags; - }; - - class DropDown : public Widget { - public: - explicit DropDown(const std::vector &items, const std::vector &settingsValues, const nlohmann::json &defaultItem) : m_items(items.begin(), items.end()), m_settingsValues(settingsValues), m_defaultItem(defaultItem) { } - explicit DropDown(const std::vector &items, const std::vector &settingsValues, const nlohmann::json &defaultItem) : m_items(items), m_settingsValues(settingsValues), m_defaultItem(defaultItem) { } - - bool draw(const std::string &name) override; - - void load(const nlohmann::json &data) override; - nlohmann::json store() override; - - [[nodiscard]] - const nlohmann::json& getValue() const; - - protected: - std::vector m_items; - std::vector m_settingsValues; - nlohmann::json m_defaultItem; - - int m_value = -1; - }; - - class TextBox : public Widget { - public: - explicit TextBox(std::string defaultValue) : m_value(std::move(defaultValue)) { } - - bool draw(const std::string &name) override; - - void load(const nlohmann::json &data) override; - nlohmann::json store() override; - - [[nodiscard]] - const std::string& getValue() const { return m_value; } - - protected: - std::string m_value; - }; - - class FilePicker : public Widget { - public: - bool draw(const std::string &name) override; - - void load(const nlohmann::json &data) override; - nlohmann::json store() override; - - [[nodiscard]] const std::fs::path& getPath() const { - return m_path; - } - - protected: - std::fs::path m_path; - }; - - class Label : public Widget { - public: - bool draw(const std::string &name) override; - - void load(const nlohmann::json &) override {} - nlohmann::json store() override { return {}; } - }; - - } - - namespace impl { - - struct Entry { - UnlocalizedString unlocalizedName; - std::unique_ptr widget; - }; - - struct SubCategory { - UnlocalizedString unlocalizedName; - std::vector entries; - }; - - struct Category { - UnlocalizedString unlocalizedName; - UnlocalizedString unlocalizedDescription; - std::vector subCategories; - }; - - void load(); - void store(); - void clear(); - - const std::vector& getSettings(); - nlohmann::json& getSetting(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedName, const nlohmann::json &defaultValue); - const nlohmann::json& getSettingsData(); - - Widgets::Widget* add(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedSubCategory, const UnlocalizedString &unlocalizedName, std::unique_ptr &&widget); - - void printSettingReadError(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedName, const nlohmann::json::exception &e); - - void runOnChangeHandlers(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedName, const nlohmann::json &value); - } - - template T> - Widgets::Widget::Interface& add(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedSubCategory, const UnlocalizedString &unlocalizedName, auto && ... args) { - return impl::add( - unlocalizedCategory, - unlocalizedSubCategory, - unlocalizedName, - std::make_unique(std::forward(args)...) - )->getInterface(); - } - - void setCategoryDescription(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedDescription); - - class SettingsValue { - public: - SettingsValue(nlohmann::json value) : m_value(std::move(value)) {} - - template - T get(std::common_type_t defaultValue) const { - try { - auto result = m_value; - if (result.is_number() && std::same_as) - result = m_value.get() != 0; - if (m_value.is_null()) - result = defaultValue; - - return result.get(); - } catch (const nlohmann::json::exception &) { - return defaultValue; - } - } - private: - nlohmann::json m_value; - }; - - template - [[nodiscard]] T read(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedName, const std::common_type_t &defaultValue) { - auto setting = impl::getSetting(unlocalizedCategory, unlocalizedName, defaultValue); - - try { - if (setting.is_number() && std::same_as) - setting = setting.template get() != 0; - if (setting.is_null()) - setting = defaultValue; - - return setting.template get(); - } catch (const nlohmann::json::exception &e) { - impl::printSettingReadError(unlocalizedCategory, unlocalizedName, e); - - return defaultValue; - } - } - - template - void write(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedName, const std::common_type_t &value) { - impl::getSetting(unlocalizedCategory, unlocalizedName, value) = value; - impl::runOnChangeHandlers(unlocalizedCategory, unlocalizedName, value); - - impl::store(); - } - - using OnChangeCallback = std::function; - u64 onChange(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedName, const OnChangeCallback &callback); - - using OnSaveCallback = std::function; - u64 onSave(const OnSaveCallback &callback); - - } - - /* Command Palette Command Registry. Allows adding of new commands to the command palette */ - namespace CommandPaletteCommands { - - enum class Type : u32 { - SymbolCommand, - KeywordCommand - }; - - namespace impl { - - struct QueryResult { - std::string name; - std::function callback; - }; - - using DisplayCallback = std::function; - using ExecuteCallback = std::function(std::string)>; - using QueryCallback = std::function(std::string)>; - - struct Entry { - Type type; - std::string command; - UnlocalizedString unlocalizedDescription; - DisplayCallback displayCallback; - ExecuteCallback executeCallback; - }; - - struct Handler { - Type type; - std::string command; - QueryCallback queryCallback; - DisplayCallback displayCallback; - }; - - const std::vector& getEntries(); - const std::vector& getHandlers(); - - } - - /** - * @brief Adds a new command to the command palette - * @param type The type of the command - * @param command The command to add - * @param unlocalizedDescription The description of the command - * @param displayCallback The callback that will be called when the command is displayed in the command palette - * @param executeCallback The callback that will be called when the command is executed - */ - void add( - Type type, - const std::string &command, - const UnlocalizedString &unlocalizedDescription, - const impl::DisplayCallback &displayCallback, - const impl::ExecuteCallback &executeCallback = [](auto) { return std::nullopt; }); - - /** - * @brief Adds a new command handler to the command palette - * @param type The type of the command - * @param command The command to add - * @param queryCallback The callback that will be called when the command palette wants to load the name and callback items - * @param displayCallback The callback that will be called when the command is displayed in the command palette - */ - void addHandler( - Type type, - const std::string &command, - const impl::QueryCallback &queryCallback, - const impl::DisplayCallback &displayCallback); - } - - /* Pattern Language Function Registry. Allows adding of new functions that may be used inside the pattern language */ - namespace PatternLanguage { - - namespace impl { - - using VisualizerFunctionCallback = std::function)>; - - struct FunctionDefinition { - pl::api::Namespace ns; - std::string name; - - pl::api::FunctionParameterCount parameterCount; - pl::api::FunctionCallback callback; - - bool dangerous; - }; - - struct TypeDefinition { - pl::api::Namespace ns; - std::string name; - - pl::api::FunctionParameterCount parameterCount; - pl::api::TypeCallback callback; - }; - - struct Visualizer { - pl::api::FunctionParameterCount parameterCount; - VisualizerFunctionCallback callback; - }; - - const std::map& getVisualizers(); - const std::map& getInlineVisualizers(); - const std::map& getPragmas(); - const std::vector& getFunctions(); - const std::vector& getTypes(); - - } - - /** - * @brief Provides access to the current provider's pattern language runtime - * @return Runtime - */ - pl::PatternLanguage& getRuntime(); - - /** - * @brief Provides access to the current provider's pattern language runtime's lock - * @return Lock - */ - std::mutex& getRuntimeLock(); - - /** - * @brief Configures the pattern language runtime using ImHex's default settings - * @param runtime The pattern language runtime to configure - * @param provider The provider to use for data access - */ - void configureRuntime(pl::PatternLanguage &runtime, prv::Provider *provider); - - /** - * @brief Adds a new pragma to the pattern language - * @param name The name of the pragma - * @param handler The handler that will be called when the pragma is encountered - */ - void addPragma(const std::string &name, const pl::api::PragmaHandler &handler); - - /** - * @brief Adds a new function to the pattern language - * @param ns The namespace of the function - * @param name The name of the function - * @param parameterCount The amount of parameters the function takes - * @param func The function callback - */ - void addFunction( - const pl::api::Namespace &ns, - const std::string &name, - pl::api::FunctionParameterCount parameterCount, - const pl::api::FunctionCallback &func - ); - - /** - * @brief Adds a new dangerous function to the pattern language - * @note Dangerous functions are functions that require the user to explicitly allow them to be used - * @param ns The namespace of the function - * @param name The name of the function - * @param parameterCount The amount of parameters the function takes - * @param func The function callback - */ - void addDangerousFunction( - const pl::api::Namespace &ns, - const std::string &name, - pl::api::FunctionParameterCount parameterCount, - const pl::api::FunctionCallback &func - ); - - /** - * @brief Adds a new type to the pattern language - * @param ns The namespace of the type - * @param name The name of the type - * @param parameterCount The amount of non-type template parameters the type takes - * @param func The type callback - */ - void addType( - const pl::api::Namespace &ns, - const std::string &name, - pl::api::FunctionParameterCount parameterCount, - const pl::api::TypeCallback &func - ); - - /** - * @brief Adds a new visualizer to the pattern language - * @note Visualizers are extensions to the [[hex::visualize]] attribute, used to visualize data - * @param name The name of the visualizer - * @param function The function callback - * @param parameterCount The amount of parameters the function takes - */ - void addVisualizer( - const std::string &name, - const impl::VisualizerFunctionCallback &function, - pl::api::FunctionParameterCount parameterCount - ); - - /** - * @brief Adds a new inline visualizer to the pattern language - * @note Inline visualizers are extensions to the [[hex::inline_visualize]] attribute, used to visualize data - * @param name The name of the visualizer - * @param function The function callback - * @param parameterCount The amount of parameters the function takes - */ - void addInlineVisualizer( - const std::string &name, - const impl::VisualizerFunctionCallback &function, - pl::api::FunctionParameterCount parameterCount - ); - - } - - /* View Registry. Allows adding of new windows */ - namespace Views { - - namespace impl { - - void add(std::unique_ptr &&view); - void setFullScreenView(std::unique_ptr &&view); - - const std::map>& getEntries(); - const std::unique_ptr& getFullScreenView(); - - } - - /** - * @brief Adds a new view to ImHex - * @tparam T The custom view class that extends View - * @tparam Args Arguments types - * @param args Arguments passed to the constructor of the view - */ - template T, typename... Args> - void add(Args &&...args) { - return impl::add(std::make_unique(std::forward(args)...)); - } - - /** - * @brief Sets a view as a full-screen view. This will cause the view to take up the entire ImHex window - * @tparam T The custom view class that extends View - * @tparam Args Arguments types - * @param args Arguments passed to the constructor of the view - */ - template T, typename... Args> - void setFullScreenView(Args &&...args) { - return impl::setFullScreenView(std::make_unique(std::forward(args)...)); - } - - /** - * @brief Gets a view by its unlocalized name - * @param unlocalizedName The unlocalized name of the view - * @return The view if it exists, nullptr otherwise - */ - View* getViewByName(const UnlocalizedString &unlocalizedName); - - /** - * @brief Gets the currently focused view - * @return The view that is focused right now. nullptr if none is focused - */ - View* getFocusedView(); - } - - /* Tools Registry. Allows adding new entries to the tools window */ - namespace Tools { - - namespace impl { - - using Callback = std::function; - - struct Entry { - UnlocalizedString unlocalizedName; - const char *icon; - Callback function; - }; - - const std::vector& getEntries(); - - } - - /** - * @brief Adds a new tool to the tools window - * @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 char *icon, const impl::Callback &function); - } - - /* Data Inspector Registry. Allows adding of new types to the data inspector */ - namespace DataInspector { - - enum class NumberDisplayStyle : u8 { - Decimal, - Hexadecimal, - Octal - }; - - namespace impl { - - using DisplayFunction = std::function; - using EditingFunction = std::function(std::string, std::endian)>; - using GeneratorFunction = std::function &, std::endian, NumberDisplayStyle)>; - - struct Entry { - UnlocalizedString unlocalizedName; - size_t requiredSize; - size_t maxSize; - GeneratorFunction generatorFunction; - std::optional editingFunction; - }; - - const std::vector& getEntries(); - - } - - /** - * @brief Adds a new entry to the data inspector - * @param unlocalizedName The unlocalized name of the entry - * @param requiredSize The minimum required number of bytes available for the entry to appear - * @param displayGeneratorFunction The function that will be called to generate the display function - * @param editingFunction The function that will be called to edit the data - */ - void add( - const UnlocalizedString &unlocalizedName, - size_t requiredSize, - impl::GeneratorFunction displayGeneratorFunction, - std::optional editingFunction = std::nullopt - ); - - /** - * @brief Adds a new entry to the data inspector - * @param unlocalizedName The unlocalized name of the entry - * @param requiredSize The minimum required number of bytes available for the entry to appear - * @param maxSize The maximum number of bytes to read from the data - * @param displayGeneratorFunction The function that will be called to generate the display function - * @param editingFunction The function that will be called to edit the data - */ - void add( - const UnlocalizedString &unlocalizedName, - size_t requiredSize, - size_t maxSize, - impl::GeneratorFunction displayGeneratorFunction, - std::optional editingFunction = std::nullopt - ); - - /** - * @brief Allows adding new menu items to data inspector row context menus. Call this function inside the - * draw function of the data inspector row definition. - * @param function Callback that will draw menu items - */ - void drawMenuItems(const std::function &function); - - } - - /* Data Processor Node Registry. Allows adding new processor nodes to be used in the data processor */ - namespace DataProcessorNode { - - namespace impl { - - using CreatorFunction = std::function()>; - - struct Entry { - UnlocalizedString unlocalizedCategory; - UnlocalizedString unlocalizedName; - CreatorFunction creatorFunction; - }; - - void add(const Entry &entry); - - const std::vector& getEntries(); - } - - - /** - * @brief Adds a new node to the data processor - * @tparam T The custom node class that extends dp::Node - * @tparam Args Arguments types - * @param unlocalizedCategory The unlocalized category name of the node - * @param unlocalizedName The unlocalized name of the node - * @param args Arguments passed to the constructor of the node - */ - template T, typename... Args> - void add(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedName, Args &&...args) { - add(impl::Entry { - unlocalizedCategory, - unlocalizedName, - [unlocalizedName, ...args = std::forward(args)]() mutable { - auto node = std::make_unique(std::forward(args)...); - node->setUnlocalizedName(unlocalizedName); - return node; - } - }); - } - - /** - * @brief Adds a separator to the data processor right click menu - */ - void addSeparator(); - - } - - /* Interface Registry. Allows adding new items to various interfaces */ - namespace Interface { - - struct Icon { - Icon(const char *glyph, ImGuiCustomCol color = ImGuiCustomCol(0x00)) : glyph(glyph), color(color) {} - - std::string glyph; - ImGuiCustomCol color; - }; - - namespace impl { - - using DrawCallback = std::function; - using MenuCallback = std::function; - using EnabledCallback = std::function; - using SelectedCallback = std::function; - using ClickCallback = std::function; - using ToggleCallback = std::function; - - struct MainMenuItem { - UnlocalizedString unlocalizedName; - }; - - struct MenuItem { - std::vector unlocalizedNames; - Icon icon; - Shortcut shortcut; - View *view; - MenuCallback callback; - EnabledCallback enabledCallback; - SelectedCallback selectedCallback; - i32 toolbarIndex; - }; - - struct SidebarItem { - std::string icon; - DrawCallback callback; - EnabledCallback enabledCallback; - }; - - struct TitleBarButton { - std::string icon; - ImGuiCustomCol color; - UnlocalizedString unlocalizedTooltip; - ClickCallback callback; - }; - - struct WelcomeScreenQuickSettingsToggle { - std::string onIcon, offIcon; - UnlocalizedString unlocalizedTooltip; - ToggleCallback callback; - mutable bool state; - }; - - constexpr static auto SeparatorValue = "$SEPARATOR$"; - constexpr static auto SubMenuValue = "$SUBMENU$"; - - const std::multimap& getMainMenuItems(); - - const std::multimap& getMenuItems(); - const std::vector& getToolbarMenuItems(); - std::multimap& getMenuItemsMutable(); - - const std::vector& getWelcomeScreenEntries(); - const std::vector& getFooterItems(); - const std::vector& getToolbarItems(); - const std::vector& getSidebarItems(); - const std::vector& getTitlebarButtons(); - const std::vector& getWelcomeScreenQuickSettingsToggles(); - - } - - /** - * @brief Adds a new top-level main menu entry - * @param unlocalizedName The unlocalized name of the entry - * @param priority The priority of the entry. Lower values are displayed first - */ - void registerMainMenuItem(const UnlocalizedString &unlocalizedName, u32 priority); - - /** - * @brief Adds a new main menu entry - * @param unlocalizedMainMenuNames The unlocalized names of the main menu entries - * @param icon The icon to use for the entry - * @param priority The priority of the entry. Lower values are displayed first - * @param shortcut The shortcut to use for the entry - * @param function The function to call when the entry is clicked - * @param enabledCallback The function to call to determine if the entry is enabled - * @param view The view to use for the entry. If nullptr, the shortcut will work globally - */ - void addMenuItem( - const std::vector &unlocalizedMainMenuNames, - const Icon &icon, - u32 priority, - const Shortcut &shortcut, - const impl::MenuCallback &function, - const impl::EnabledCallback& enabledCallback, View *view - ); - - /** - * @brief Adds a new main menu entry - * @param unlocalizedMainMenuNames The unlocalized names of the main menu entries - * @param icon The icon to use for the entry - * @param priority The priority of the entry. Lower values are displayed first - * @param shortcut The shortcut to use for the entry - * @param function The function to call when the entry is clicked - * @param enabledCallback The function to call to determine if the entry is enabled - * @param selectedCallback The function to call to determine if the entry is selected - * @param view The view to use for the entry. If nullptr, the shortcut will work globally - */ - void addMenuItem( - const std::vector &unlocalizedMainMenuNames, - const Icon &icon, - u32 priority, - Shortcut shortcut, - const impl::MenuCallback &function, - const impl::EnabledCallback& enabledCallback = []{ return true; }, - const impl::SelectedCallback &selectedCallback = []{ return false; }, - View *view = nullptr - ); - - /** - * @brief Adds a new main menu entry - * @param unlocalizedMainMenuNames The unlocalized names of the main menu entries - * @param priority The priority of the entry. Lower values are displayed first - * @param shortcut The shortcut to use for the entry - * @param function The function to call when the entry is clicked - * @param enabledCallback The function to call to determine if the entry is enabled - * @param selectedCallback The function to call to determine if the entry is selected - * @param view The view to use for the entry. If nullptr, the shortcut will work globally - */ - void addMenuItem( - const std::vector &unlocalizedMainMenuNames, - u32 priority, - const Shortcut &shortcut, - const impl::MenuCallback &function, - const impl::EnabledCallback& enabledCallback = []{ return true; }, - const impl::SelectedCallback &selectedCallback = []{ return false; }, - View *view = nullptr - ); - - /** - * @brief Adds a new main menu sub-menu entry - * @param unlocalizedMainMenuNames The unlocalized names of the main menu entries - * @param priority The priority of the entry. Lower values are displayed first - * @param function The function to call when the entry is clicked - * @param enabledCallback The function to call to determine if the entry is enabled - * @param view The view to use for the entry. If nullptr, the item will always be visible - */ - void addMenuItemSubMenu( - std::vector unlocalizedMainMenuNames, - u32 priority, - const impl::MenuCallback &function, - const impl::EnabledCallback& enabledCallback = []{ return true; }, - View *view = nullptr - ); - - /** - * @brief Adds a new main menu sub-menu entry - * @param unlocalizedMainMenuNames The unlocalized names of the main menu entries - * @param icon The icon to use for the entry - * @param priority The priority of the entry. Lower values are displayed first - * @param function The function to call when the entry is clicked - * @param enabledCallback The function to call to determine if the entry is enabled - * @param view The view to use for the entry. If nullptr, the item will always be visible - */ - void addMenuItemSubMenu( - std::vector unlocalizedMainMenuNames, - const char *icon, - u32 priority, - const impl::MenuCallback &function, - const impl::EnabledCallback& enabledCallback = []{ return true; }, - View *view = nullptr - ); - - - /** - * @brief Adds a new main menu separator - * @param unlocalizedMainMenuNames The unlocalized names of the main menu entries - * @param priority The priority of the entry. Lower values are displayed first - * @param view The view to use for the entry. If nullptr, the item will always be visible - */ - void addMenuItemSeparator(std::vector unlocalizedMainMenuNames, u32 priority, View *view = nullptr); - - - /** - * @brief Adds a new welcome screen entry - * @param function The function to call to draw the entry - */ - void addWelcomeScreenEntry(const impl::DrawCallback &function); - - /** - * @brief Adds a new footer item - * @param function The function to call to draw the item - */ - void addFooterItem(const impl::DrawCallback &function); - - /** - * @brief Adds a new toolbar item - * @param function The function to call to draw the item - */ - void addToolbarItem(const impl::DrawCallback &function); - - /** - * @brief Adds a menu item to the toolbar - * @param unlocalizedName Unlocalized name of the menu item - * @param color Color of the toolbar icon - */ - void addMenuItemToToolbar(const UnlocalizedString &unlocalizedName, ImGuiCustomCol color); - - /** - * @brief Reconstructs the toolbar items list after they have been modified - */ - void updateToolbarItems(); - - /** - * @brief Adds a new sidebar item - * @param icon The icon to use for the item - * @param function The function to call to draw the item - * @param enabledCallback The function - */ - void addSidebarItem( - const std::string &icon, - const impl::DrawCallback &function, - const impl::EnabledCallback &enabledCallback = []{ return true; } - ); - - /** - * @brief Adds a new title bar button - * @param icon The icon to use for the button - * @param color The color of the icon - * @param unlocalizedTooltip The unlocalized tooltip to use for the button - * @param function The function to call when the button is clicked - */ - void addTitleBarButton( - const std::string &icon, - ImGuiCustomCol color, - const UnlocalizedString &unlocalizedTooltip, - const impl::ClickCallback &function - ); - - /** - * @brief Adds a new welcome screen quick settings toggle - * @param icon The icon to use for the button - * @param unlocalizedTooltip The unlocalized tooltip to use for the button - * @param defaultState The default state of the toggle - * @param function The function to call when the button is clicked - */ - void addWelcomeScreenQuickSettingsToggle( - const std::string &icon, - const UnlocalizedString &unlocalizedTooltip, - bool defaultState, - const impl::ToggleCallback &function - ); - - /** - * @brief Adds a new welcome screen quick settings toggle - * @param onIcon The icon to use for the button when it's on - * @param offIcon The icon to use for the button when it's off - * @param unlocalizedTooltip The unlocalized tooltip to use for the button - * @param defaultState The default state of the toggle - * @param function The function to call when the button is clicked - */ - void addWelcomeScreenQuickSettingsToggle( - const std::string &onIcon, - const std::string &offIcon, - const UnlocalizedString &unlocalizedTooltip, - bool defaultState, - const impl::ToggleCallback &function - ); - - } - - /* Provider Registry. Allows adding new data providers to be created from the UI */ - namespace Provider { - - namespace impl { - - void addProviderName(const UnlocalizedString &unlocalizedName, const char *icon); - - using ProviderCreationFunction = std::function()>; - void add(const std::string &typeName, ProviderCreationFunction creationFunction); - - struct Entry { - UnlocalizedString unlocalizedName; - const char *icon; - }; - - const std::vector& getEntries(); - - } - - /** - * @brief Adds a new provider to the list of providers - * @tparam T The provider type that extends hex::prv::Provider - * @param addToList Whether to display the provider in the Other Providers list in the welcome screen and File menu - */ - template T> - void add(bool addToList = true) { - const T provider; - auto typeName = provider.getTypeName(); - - impl::add(typeName, []() -> std::unique_ptr { - return std::make_unique(); - }); - - if (addToList) - impl::addProviderName(typeName, provider.getIcon()); - } - - } - - /* Data Formatter Registry. Allows adding formatters that are used in the Copy-As menu for example */ - namespace DataFormatter { - - namespace impl { - - using Callback = std::function; - struct ExportMenuEntry { - UnlocalizedString unlocalizedName; - Callback callback; - }; - - struct FindOccurrence { - Region region; - enum class DecodeType { ASCII, UTF8, Binary, UTF16, Unsigned, Signed, Float, Double } decodeType; - std::endian endian = std::endian::native; - bool selected; - }; - - using FindExporterCallback = std::function(const std::vector&, std::function)>; - struct FindExporterEntry { - UnlocalizedString unlocalizedName; - std::string fileExtension; - FindExporterCallback callback; - }; - - /** - * @brief Retrieves a list of all registered data formatters used by the 'File -> Export' menu - */ - const std::vector& getExportMenuEntries(); - - /** - * @brief Retrieves a list of all registered data formatters used in the Results section of the 'Find' view - */ - const std::vector& getFindExporterEntries(); - - } - - - /** - * @brief Adds a new data formatter - * @param unlocalizedName The unlocalized name of the formatter - * @param callback The function to call to format the data - */ - void addExportMenuEntry(const UnlocalizedString &unlocalizedName, const impl::Callback &callback); - - /** - * @brief Adds a new data exporter for Find results - * @param unlocalizedName The unlocalized name of the formatter - * @param callback The function to call to format the data - */ - void addFindExportFormatter(const UnlocalizedString &unlocalizedName, const std::string &fileExtension, const impl::FindExporterCallback &callback); - - } - - /* File Handler Registry. Allows adding handlers for opening files specific file types */ - namespace FileHandler { - - namespace impl { - - using Callback = std::function; - struct Entry { - std::vector extensions; - Callback callback; - }; - - const std::vector& getEntries(); - - } - - /** - * @brief Adds a new file handler - * @param extensions The file extensions to handle - * @param callback The function to call to handle the file - */ - void add(const std::vector &extensions, const impl::Callback &callback); - - } - - /* Hex Editor Registry. Allows adding new functionality to the hex editor */ - namespace HexEditor { - - class DataVisualizer { - public: - DataVisualizer(UnlocalizedString unlocalizedName, u16 bytesPerCell, u16 maxCharsPerCell) - : m_unlocalizedName(std::move(unlocalizedName)), - m_bytesPerCell(bytesPerCell), - m_maxCharsPerCell(maxCharsPerCell) { } - - virtual ~DataVisualizer() = default; - - virtual void draw(u64 address, const u8 *data, size_t size, bool upperCase) = 0; - virtual bool drawEditing(u64 address, u8 *data, size_t size, bool upperCase, bool startedEditing) = 0; - - [[nodiscard]] u16 getBytesPerCell() const { return m_bytesPerCell; } - [[nodiscard]] u16 getMaxCharsPerCell() const { return m_maxCharsPerCell; } - - [[nodiscard]] const UnlocalizedString& getUnlocalizedName() const { return m_unlocalizedName; } - - [[nodiscard]] static int DefaultTextInputFlags(); - - protected: - bool drawDefaultScalarEditingTextBox(u64 address, const char *format, ImGuiDataType dataType, u8 *data, ImGuiInputTextFlags flags) const; - bool drawDefaultTextEditingTextBox(u64 address, std::string &data, ImGuiInputTextFlags flags) const; - - private: - UnlocalizedString m_unlocalizedName; - u16 m_bytesPerCell; - u16 m_maxCharsPerCell; - }; - - struct MiniMapVisualizer { - using Callback = std::function, std::vector&)>; - - UnlocalizedString unlocalizedName; - Callback callback; - }; - - namespace impl { - - void addDataVisualizer(std::shared_ptr &&visualizer); - - const std::vector>& getVisualizers(); - const std::vector>& getMiniMapVisualizers(); - - } - - /** - * @brief Adds a new cell data visualizer - * @tparam T The data visualizer type that extends hex::DataVisualizer - * @param args The arguments to pass to the constructor of the data visualizer - */ - template T, typename... Args> - void addDataVisualizer(Args &&...args) { - return impl::addDataVisualizer(std::make_shared(std::forward(args)...)); - } - - /** - * @brief Gets a data visualizer by its unlocalized name - * @param unlocalizedName Unlocalized name of the data visualizer - * @return The data visualizer, or nullptr if it doesn't exist - */ - std::shared_ptr getVisualizerByName(const UnlocalizedString &unlocalizedName); - - /** - * @brief Adds a new minimap visualizer - * @param unlocalizedName Unlocalized name of the minimap visualizer - * @param callback The callback that will be called to get the color of a line - */ - void addMiniMapVisualizer(UnlocalizedString unlocalizedName, MiniMapVisualizer::Callback callback); - - } - - /* Diffing Registry. Allows adding new diffing algorithms */ - namespace Diffing { - - enum class DifferenceType : u8 { - Match = 0, - Insertion = 1, - Deletion = 2, - Mismatch = 3 - }; - - using DiffTree = wolv::container::IntervalTree; - - class Algorithm { - public: - explicit Algorithm(UnlocalizedString unlocalizedName, UnlocalizedString unlocalizedDescription) - : m_unlocalizedName(std::move(unlocalizedName)), - m_unlocalizedDescription(std::move(unlocalizedDescription)) { } - - virtual ~Algorithm() = default; - - virtual std::vector analyze(prv::Provider *providerA, prv::Provider *providerB) const = 0; - virtual void drawSettings() { } - - const UnlocalizedString& getUnlocalizedName() const { return m_unlocalizedName; } - const UnlocalizedString& getUnlocalizedDescription() const { return m_unlocalizedDescription; } - - private: - UnlocalizedString m_unlocalizedName, m_unlocalizedDescription; - }; - - namespace impl { - - const std::vector>& getAlgorithms(); - - void addAlgorithm(std::unique_ptr &&hash); - - } - - /** - * @brief Adds a new hash - * @tparam T The hash type that extends hex::Hash - * @param args The arguments to pass to the constructor of the hash - */ - template - void addAlgorithm(Args && ... args) { - impl::addAlgorithm(std::make_unique(std::forward(args)...)); - } - - } - - /* Hash Registry. Allows adding new hashes to the Hash view */ - namespace Hashes { - - class Hash { - public: - explicit Hash(UnlocalizedString unlocalizedName) : m_unlocalizedName(std::move(unlocalizedName)) {} - virtual ~Hash() = default; - - class Function { - public: - using Callback = std::function(const Region&, prv::Provider *)>; - - Function(Hash *type, std::string name, Callback callback) - : m_type(type), m_name(std::move(name)), m_callback(std::move(callback)) { - - } - - [[nodiscard]] Hash *getType() { return m_type; } - [[nodiscard]] const Hash *getType() const { return m_type; } - [[nodiscard]] const std::string& getName() const { return m_name; } - - const std::vector& get(const Region& region, prv::Provider *provider) { - if (m_cache.empty()) { - m_cache = m_callback(region, provider); - } - - return m_cache; - } - - void reset() { - m_cache.clear(); - } - - private: - Hash *m_type; - std::string m_name; - Callback m_callback; - - std::vector m_cache; - }; - - virtual void draw() { } - [[nodiscard]] virtual Function create(std::string name) = 0; - - [[nodiscard]] virtual nlohmann::json store() const = 0; - virtual void load(const nlohmann::json &json) = 0; - - [[nodiscard]] const UnlocalizedString& getUnlocalizedName() const { - return m_unlocalizedName; - } - - protected: - [[nodiscard]] Function create(const std::string &name, const Function::Callback &callback) { - return { this, name, callback }; - } - - private: - UnlocalizedString m_unlocalizedName; - }; - - namespace impl { - - const std::vector>& getHashes(); - - void add(std::unique_ptr &&hash); - - } - - - /** - * @brief Adds a new hash - * @tparam T The hash type that extends hex::Hash - * @param args The arguments to pass to the constructor of the hash - */ - template - void add(Args && ... args) { - impl::add(std::make_unique(std::forward(args)...)); - } - - } - - /* Background Service Registry. Allows adding new background services */ - namespace BackgroundServices { - - namespace impl { - using Callback = std::function; - - void stopServices(); - } - - void registerService(const UnlocalizedString &unlocalizedString, const impl::Callback &callback); - } - - /* Network Communication Interface Registry. Allows adding new communication interface endpoints */ - namespace CommunicationInterface { - - namespace impl { - using NetworkCallback = std::function; - - const std::map& getNetworkEndpoints(); - } - - void registerNetworkEndpoint(const std::string &endpoint, const impl::NetworkCallback &callback); - - } - - /* Experiments Registry. Allows adding new experiments */ - namespace Experiments { - - namespace impl { - - struct Experiment { - UnlocalizedString unlocalizedName, unlocalizedDescription; - bool enabled; - }; - - const std::map& getExperiments(); - } - - void addExperiment( - const std::string &experimentName, - const UnlocalizedString &unlocalizedName, - const UnlocalizedString &unlocalizedDescription = "" - ); - - void enableExperiement(const std::string &experimentName, bool enabled); - - [[nodiscard]] bool isExperimentEnabled(const std::string &experimentName); - } - - /* Reports Registry. Allows adding new sections to exported reports */ - namespace Reports { - - namespace impl { - - using Callback = std::function; - - struct ReportGenerator { - Callback callback; - }; - - const std::vector& getGenerators(); - - } - - void addReportProvider(impl::Callback callback); - - } - - /* Data Information Registry. Allows adding new analyzers to the data information view */ - namespace DataInformation { - - class InformationSection { - public: - InformationSection(const UnlocalizedString &unlocalizedName, const UnlocalizedString &unlocalizedDescription = "", bool hasSettings = false) - : m_unlocalizedName(unlocalizedName), m_unlocalizedDescription(unlocalizedDescription), - m_hasSettings(hasSettings) { } - virtual ~InformationSection() = default; - - [[nodiscard]] const UnlocalizedString& getUnlocalizedName() const { return m_unlocalizedName; } - [[nodiscard]] const UnlocalizedString& getUnlocalizedDescription() const { return m_unlocalizedDescription; } - - virtual void process(Task &task, prv::Provider *provider, Region region) = 0; - virtual void reset() = 0; - - virtual void drawSettings() { } - virtual void drawContent() = 0; - - [[nodiscard]] bool isValid() const { return m_valid; } - void markValid(bool valid = true) { m_valid = valid; } - - [[nodiscard]] bool isEnabled() const { return m_enabled; } - void setEnabled(bool enabled) { m_enabled = enabled; } - - [[nodiscard]] bool isAnalyzing() const { return m_analyzing; } - void setAnalyzing(bool analyzing) { m_analyzing = analyzing; } - - virtual void load(const nlohmann::json &data) { - m_enabled = data.value("enabled", true); - } - [[nodiscard]] virtual nlohmann::json store() { - nlohmann::json data; - data["enabled"] = m_enabled.load(); - - return data; - } - - [[nodiscard]] bool hasSettings() const { return m_hasSettings; } - - private: - UnlocalizedString m_unlocalizedName, m_unlocalizedDescription; - bool m_hasSettings; - - std::atomic m_analyzing = false; - std::atomic m_valid = false; - std::atomic m_enabled = true; - }; - - namespace impl { - - using CreateCallback = std::function()>; - - const std::vector& getInformationSectionConstructors(); - void addInformationSectionCreator(const CreateCallback &callback); - - } - - template - void addInformationSection(auto && ...args) { - impl::addInformationSectionCreator([args...] { - return std::make_unique(std::forward(args)...); - }); - } - - } - - /* Disassembler Registry. Allows adding new disassembler architectures */ - namespace Disassembler { - - struct Instruction { - u64 address; - u64 offset; - size_t size; - std::string bytes; - std::string mnemonic; - std::string operators; - }; - - class Architecture { - public: - explicit Architecture(std::string name) : m_name(std::move(name)) {} - virtual ~Architecture() = default; - - virtual bool start() = 0; - virtual void end() = 0; - - virtual std::optional disassemble(u64 imageBaseAddress, u64 instructionLoadAddress, u64 instructionDataAddress, std::span code) = 0; - virtual void drawSettings() = 0; - - [[nodiscard]] const std::string& getName() const { return m_name; } - - private: - std::string m_name; - }; - - namespace impl { - - using CreatorFunction = std::function()>; - - void addArchitectureCreator(CreatorFunction function); - - const std::map& getArchitectures(); - - } - - template T> - void add(auto && ...args) { - impl::addArchitectureCreator([...args = std::move(args)] { - return std::make_unique(args...); - }); - } - - } - - } - -} diff --git a/lib/libimhex/include/hex/api/content_registry/background_services.hpp b/lib/libimhex/include/hex/api/content_registry/background_services.hpp index e69de29bb..425eccc0b 100644 --- a/lib/libimhex/include/hex/api/content_registry/background_services.hpp +++ b/lib/libimhex/include/hex/api/content_registry/background_services.hpp @@ -0,0 +1,22 @@ +#pragma once + +#include + +#include +#include + +EXPORT_MODULE namespace hex { + + /* Background Service Registry. Allows adding new background services */ + namespace ContentRegistry::BackgroundServices { + + namespace impl { + using Callback = std::function; + + void stopServices(); + } + + void registerService(const UnlocalizedString &unlocalizedString, const impl::Callback &callback); + } + +} \ No newline at end of file diff --git a/lib/libimhex/include/hex/api/content_registry/command_palette.hpp b/lib/libimhex/include/hex/api/content_registry/command_palette.hpp index e69de29bb..2d322f3ad 100644 --- a/lib/libimhex/include/hex/api/content_registry/command_palette.hpp +++ b/lib/libimhex/include/hex/api/content_registry/command_palette.hpp @@ -0,0 +1,82 @@ +#pragma once + +#include + +#include + +#include +#include +#include +#include + +EXPORT_MODULE namespace hex { + + /* Command Palette Command Registry. Allows adding of new commands to the command palette */ + namespace ContentRegistry::CommandPalette { + + enum class Type : u32 { + SymbolCommand, + KeywordCommand + }; + + namespace impl { + + struct QueryResult { + std::string name; + std::function callback; + }; + + using DisplayCallback = std::function; + using ExecuteCallback = std::function(std::string)>; + using QueryCallback = std::function(std::string)>; + + struct Entry { + Type type; + std::string command; + UnlocalizedString unlocalizedDescription; + DisplayCallback displayCallback; + ExecuteCallback executeCallback; + }; + + struct Handler { + Type type; + std::string command; + QueryCallback queryCallback; + DisplayCallback displayCallback; + }; + + const std::vector& getEntries(); + const std::vector& getHandlers(); + + } + + /** + * @brief Adds a new command to the command palette + * @param type The type of the command + * @param command The command to add + * @param unlocalizedDescription The description of the command + * @param displayCallback The callback that will be called when the command is displayed in the command palette + * @param executeCallback The callback that will be called when the command is executed + */ + void add( + Type type, + const std::string &command, + const UnlocalizedString &unlocalizedDescription, + const impl::DisplayCallback &displayCallback, + const impl::ExecuteCallback &executeCallback = [](auto) { return std::nullopt; }); + + /** + * @brief Adds a new command handler to the command palette + * @param type The type of the command + * @param command The command to add + * @param queryCallback The callback that will be called when the command palette wants to load the name and callback items + * @param displayCallback The callback that will be called when the command is displayed in the command palette + */ + void addHandler( + Type type, + const std::string &command, + const impl::QueryCallback &queryCallback, + const impl::DisplayCallback &displayCallback); + } + +} \ No newline at end of file diff --git a/lib/libimhex/include/hex/api/content_registry/communication_interface.hpp b/lib/libimhex/include/hex/api/content_registry/communication_interface.hpp index e69de29bb..5ab9eb421 100644 --- a/lib/libimhex/include/hex/api/content_registry/communication_interface.hpp +++ b/lib/libimhex/include/hex/api/content_registry/communication_interface.hpp @@ -0,0 +1,25 @@ +#pragma once + +#include + +#include + +#include +#include + +EXPORT_MODULE namespace hex { + + /* Network Communication Interface Registry. Allows adding new communication interface endpoints */ + namespace ContentRegistry::CommunicationInterface { + + namespace impl { + using NetworkCallback = std::function; + + const std::map& getNetworkEndpoints(); + } + + void registerNetworkEndpoint(const std::string &endpoint, const impl::NetworkCallback &callback); + + } + +} \ No newline at end of file diff --git a/lib/libimhex/include/hex/api/content_registry/data_formatter.hpp b/lib/libimhex/include/hex/api/content_registry/data_formatter.hpp index e69de29bb..b3bd2a0fa 100644 --- a/lib/libimhex/include/hex/api/content_registry/data_formatter.hpp +++ b/lib/libimhex/include/hex/api/content_registry/data_formatter.hpp @@ -0,0 +1,72 @@ +#pragma once + +#include + +#include + +#include +#include +#include + +EXPORT_MODULE namespace hex { + + #if !defined(HEX_MODULE_EXPORT) + namespace prv { class Provider; } + #endif + + /* Data Formatter Registry. Allows adding formatters that are used in the Copy-As menu for example */ + namespace ContentRegistry::DataFormatter { + + namespace impl { + + using Callback = std::function; + struct ExportMenuEntry { + UnlocalizedString unlocalizedName; + Callback callback; + }; + + struct FindOccurrence { + Region region; + enum class DecodeType { ASCII, UTF8, Binary, UTF16, Unsigned, Signed, Float, Double } decodeType; + std::endian endian = std::endian::native; + bool selected; + }; + + using FindExporterCallback = std::function(const std::vector&, std::function)>; + struct FindExporterEntry { + UnlocalizedString unlocalizedName; + std::string fileExtension; + FindExporterCallback callback; + }; + + /** + * @brief Retrieves a list of all registered data formatters used by the 'File -> Export' menu + */ + const std::vector& getExportMenuEntries(); + + /** + * @brief Retrieves a list of all registered data formatters used in the Results section of the 'Find' view + */ + const std::vector& getFindExporterEntries(); + + } + + + /** + * @brief Adds a new data formatter + * @param unlocalizedName The unlocalized name of the formatter + * @param callback The function to call to format the data + */ + void addExportMenuEntry(const UnlocalizedString &unlocalizedName, const impl::Callback &callback); + + /** + * @brief Adds a new data exporter for Find results + * @param unlocalizedName The unlocalized name of the formatter + * @param fileExtension The file extension to use for the exported file + * @param callback The function to call to format the data + */ + void addFindExportFormatter(const UnlocalizedString &unlocalizedName, const std::string &fileExtension, const impl::FindExporterCallback &callback); + + } + +} \ No newline at end of file diff --git a/lib/libimhex/include/hex/api/content_registry/data_information.hpp b/lib/libimhex/include/hex/api/content_registry/data_information.hpp index e69de29bb..e468c0c63 100644 --- a/lib/libimhex/include/hex/api/content_registry/data_information.hpp +++ b/lib/libimhex/include/hex/api/content_registry/data_information.hpp @@ -0,0 +1,81 @@ +#pragma once + +#include + +#include +#include + +#include + +#include +#include +#include +#include + +EXPORT_MODULE namespace hex { + + #if !defined(HEX_MODULE_EXPORT) + namespace prv { class Provider; } + #endif + + /* Data Information Registry. Allows adding new analyzers to the data information view */ + namespace ContentRegistry::DataInformation { + + class InformationSection { + public: + InformationSection(const UnlocalizedString &unlocalizedName, const UnlocalizedString &unlocalizedDescription = "", bool hasSettings = false) + : m_unlocalizedName(unlocalizedName), m_unlocalizedDescription(unlocalizedDescription), + m_hasSettings(hasSettings) { } + virtual ~InformationSection() = default; + + [[nodiscard]] const UnlocalizedString& getUnlocalizedName() const { return m_unlocalizedName; } + [[nodiscard]] const UnlocalizedString& getUnlocalizedDescription() const { return m_unlocalizedDescription; } + + virtual void process(Task &task, prv::Provider *provider, Region region) = 0; + virtual void reset() = 0; + + virtual void drawSettings() { } + virtual void drawContent() = 0; + + [[nodiscard]] bool isValid() const { return m_valid; } + void markValid(bool valid = true) { m_valid = valid; } + + [[nodiscard]] bool isEnabled() const { return m_enabled; } + void setEnabled(bool enabled) { m_enabled = enabled; } + + [[nodiscard]] bool isAnalyzing() const { return m_analyzing; } + void setAnalyzing(bool analyzing) { m_analyzing = analyzing; } + + virtual void load(const nlohmann::json &data); + [[nodiscard]] virtual nlohmann::json store(); + + [[nodiscard]] bool hasSettings() const { return m_hasSettings; } + + private: + UnlocalizedString m_unlocalizedName, m_unlocalizedDescription; + bool m_hasSettings; + + std::atomic m_analyzing = false; + std::atomic m_valid = false; + std::atomic m_enabled = true; + }; + + namespace impl { + + using CreateCallback = std::function()>; + + const std::vector& getInformationSectionConstructors(); + void addInformationSectionCreator(const CreateCallback &callback); + + } + + template + void addInformationSection(auto && ...args) { + impl::addInformationSectionCreator([args...] { + return std::make_unique(std::forward(args)...); + }); + } + + } + +} \ No newline at end of file diff --git a/lib/libimhex/include/hex/api/content_registry/data_inspector.hpp b/lib/libimhex/include/hex/api/content_registry/data_inspector.hpp index e69de29bb..2e3cabce5 100644 --- a/lib/libimhex/include/hex/api/content_registry/data_inspector.hpp +++ b/lib/libimhex/include/hex/api/content_registry/data_inspector.hpp @@ -0,0 +1,80 @@ +#pragma once + +#include + +#include + +#include +#include +#include +#include + +EXPORT_MODULE namespace hex { + + /* Data Inspector Registry. Allows adding of new types to the data inspector */ + namespace ContentRegistry::DataInspector { + + enum class NumberDisplayStyle : u8 { + Decimal, + Hexadecimal, + Octal + }; + + namespace impl { + + using DisplayFunction = std::function; + using EditingFunction = std::function(std::string, std::endian)>; + using GeneratorFunction = std::function &, std::endian, NumberDisplayStyle)>; + + struct Entry { + UnlocalizedString unlocalizedName; + size_t requiredSize; + size_t maxSize; + GeneratorFunction generatorFunction; + std::optional editingFunction; + }; + + const std::vector& getEntries(); + + } + + /** + * @brief Adds a new entry to the data inspector + * @param unlocalizedName The unlocalized name of the entry + * @param requiredSize The minimum required number of bytes available for the entry to appear + * @param displayGeneratorFunction The function that will be called to generate the display function + * @param editingFunction The function that will be called to edit the data + */ + void add( + const UnlocalizedString &unlocalizedName, + size_t requiredSize, + impl::GeneratorFunction displayGeneratorFunction, + std::optional editingFunction = std::nullopt + ); + + /** + * @brief Adds a new entry to the data inspector + * @param unlocalizedName The unlocalized name of the entry + * @param requiredSize The minimum required number of bytes available for the entry to appear + * @param maxSize The maximum number of bytes to read from the data + * @param displayGeneratorFunction The function that will be called to generate the display function + * @param editingFunction The function that will be called to edit the data + */ + void add( + const UnlocalizedString &unlocalizedName, + size_t requiredSize, + size_t maxSize, + impl::GeneratorFunction displayGeneratorFunction, + std::optional editingFunction = std::nullopt + ); + + /** + * @brief Allows adding new menu items to data inspector row context menus. Call this function inside the + * draw function of the data inspector row definition. + * @param function Callback that will draw menu items + */ + void drawMenuItems(const std::function &function); + + } + +} \ No newline at end of file diff --git a/lib/libimhex/include/hex/api/content_registry/data_processor.hpp b/lib/libimhex/include/hex/api/content_registry/data_processor.hpp index e69de29bb..dca50b759 100644 --- a/lib/libimhex/include/hex/api/content_registry/data_processor.hpp +++ b/lib/libimhex/include/hex/api/content_registry/data_processor.hpp @@ -0,0 +1,64 @@ +#pragma once + +#include + +#include + +#include +#include +#include + +EXPORT_MODULE namespace hex { + + #if !defined(HEX_MODULE_EXPORT) + namespace dp { class Node; } + #endif + + /* Data Processor Node Registry. Allows adding new processor nodes to be used in the data processor */ + namespace ContentRegistry::DataProcessor { + + namespace impl { + + using CreatorFunction = std::function()>; + + struct Entry { + UnlocalizedString unlocalizedCategory; + UnlocalizedString unlocalizedName; + CreatorFunction creatorFunction; + }; + + void add(const Entry &entry); + + const std::vector& getEntries(); + } + + + /** + * @brief Adds a new node to the data processor + * @tparam T The custom node class that extends dp::Node + * @tparam Args Arguments types + * @param unlocalizedCategory The unlocalized category name of the node + * @param unlocalizedName The unlocalized name of the node + * @param args Arguments passed to the constructor of the node + */ + template T, typename... Args> + void add(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedName, Args &&...args) { + add(impl::Entry { + unlocalizedCategory, + unlocalizedName, + [unlocalizedName, ...args = std::forward(args)]() mutable { + auto node = std::make_unique(std::forward(args)...); + node->setUnlocalizedName(unlocalizedName); + return node; + } + }); + } + + /** + * @brief Adds a separator to the data processor right click menu + */ + void addSeparator(); + + } + +} \ No newline at end of file diff --git a/lib/libimhex/include/hex/api/content_registry/diffing.hpp b/lib/libimhex/include/hex/api/content_registry/diffing.hpp index e69de29bb..ed0c37b5a 100644 --- a/lib/libimhex/include/hex/api/content_registry/diffing.hpp +++ b/lib/libimhex/include/hex/api/content_registry/diffing.hpp @@ -0,0 +1,68 @@ +#pragma once + +#include + +#include +#include + +#include +#include + + +EXPORT_MODULE namespace hex { + + #if !defined(HEX_MODULE_EXPORT) + namespace prv { class Provider; } + #endif + + /* Diffing Registry. Allows adding new diffing algorithms */ + namespace ContentRegistry::Diffing { + + enum class DifferenceType : u8 { + Match = 0, + Insertion = 1, + Deletion = 2, + Mismatch = 3 + }; + + using DiffTree = wolv::container::IntervalTree; + + class Algorithm { + public: + explicit Algorithm(UnlocalizedString unlocalizedName, UnlocalizedString unlocalizedDescription) + : m_unlocalizedName(std::move(unlocalizedName)), + m_unlocalizedDescription(std::move(unlocalizedDescription)) { } + + virtual ~Algorithm() = default; + + virtual std::vector analyze(prv::Provider *providerA, prv::Provider *providerB) const = 0; + virtual void drawSettings() { } + + const UnlocalizedString& getUnlocalizedName() const { return m_unlocalizedName; } + const UnlocalizedString& getUnlocalizedDescription() const { return m_unlocalizedDescription; } + + private: + UnlocalizedString m_unlocalizedName, m_unlocalizedDescription; + }; + + namespace impl { + + const std::vector>& getAlgorithms(); + + void addAlgorithm(std::unique_ptr &&hash); + + } + + /** + * @brief Adds a new hash + * @tparam T The hash type that extends hex::Hash + * @param args The arguments to pass to the constructor of the hash + */ + template + void addAlgorithm(Args && ... args) { + impl::addAlgorithm(std::make_unique(std::forward(args)...)); + } + + } + +} \ No newline at end of file diff --git a/lib/libimhex/include/hex/api/content_registry/disassemblers.hpp b/lib/libimhex/include/hex/api/content_registry/disassemblers.hpp index e69de29bb..8315a03cc 100644 --- a/lib/libimhex/include/hex/api/content_registry/disassemblers.hpp +++ b/lib/libimhex/include/hex/api/content_registry/disassemblers.hpp @@ -0,0 +1,64 @@ +#pragma once + +#include + +#include + +#include +#include +#include +#include +#include +#include + +EXPORT_MODULE namespace hex { + + /* Disassembler Registry. Allows adding new disassembler architectures */ + namespace ContentRegistry::Disassemblers { + + struct Instruction { + u64 address; + u64 offset; + size_t size; + std::string bytes; + std::string mnemonic; + std::string operators; + }; + + class Architecture { + public: + explicit Architecture(std::string name) : m_name(std::move(name)) {} + virtual ~Architecture() = default; + + virtual bool start() = 0; + virtual void end() = 0; + + virtual std::optional disassemble(u64 imageBaseAddress, u64 instructionLoadAddress, u64 instructionDataAddress, std::span code) = 0; + virtual void drawSettings() = 0; + + [[nodiscard]] const std::string& getName() const { return m_name; } + + private: + std::string m_name; + }; + + namespace impl { + + using CreatorFunction = std::function()>; + + void addArchitectureCreator(CreatorFunction function); + + const std::map& getArchitectures(); + + } + + template T> + void add(auto && ...args) { + impl::addArchitectureCreator([...args = std::move(args)] { + return std::make_unique(args...); + }); + } + + } + +} \ No newline at end of file diff --git a/lib/libimhex/include/hex/api/content_registry/experiments.hpp b/lib/libimhex/include/hex/api/content_registry/experiments.hpp index e69de29bb..3a52102c8 100644 --- a/lib/libimhex/include/hex/api/content_registry/experiments.hpp +++ b/lib/libimhex/include/hex/api/content_registry/experiments.hpp @@ -0,0 +1,36 @@ +#pragma once + +#include + +#include + +#include +#include + +EXPORT_MODULE namespace hex { + + /* Experiments Registry. Allows adding new experiments */ + namespace ContentRegistry::Experiments { + + namespace impl { + + struct Experiment { + UnlocalizedString unlocalizedName, unlocalizedDescription; + bool enabled; + }; + + const std::map& getExperiments(); + } + + void addExperiment( + const std::string &experimentName, + const UnlocalizedString &unlocalizedName, + const UnlocalizedString &unlocalizedDescription = "" + ); + + void enableExperiement(const std::string &experimentName, bool enabled); + + [[nodiscard]] bool isExperimentEnabled(const std::string &experimentName); + } + +} \ No newline at end of file diff --git a/lib/libimhex/include/hex/api/content_registry/file_type_handler.hpp b/lib/libimhex/include/hex/api/content_registry/file_type_handler.hpp index e69de29bb..8281032f1 100644 --- a/lib/libimhex/include/hex/api/content_registry/file_type_handler.hpp +++ b/lib/libimhex/include/hex/api/content_registry/file_type_handler.hpp @@ -0,0 +1,37 @@ +#pragma once + +#include + +#include + +#include +#include +#include + +EXPORT_MODULE namespace hex { + + /* File Handler Registry. Allows adding handlers for opening files specific file types */ + namespace ContentRegistry::FileTypeHandler { + + namespace impl { + + using Callback = std::function; + struct Entry { + std::vector extensions; + Callback callback; + }; + + const std::vector& getEntries(); + + } + + /** + * @brief Adds a new file handler + * @param extensions The file extensions to handle + * @param callback The function to call to handle the file + */ + void add(const std::vector &extensions, const impl::Callback &callback); + + } + +} \ No newline at end of file diff --git a/lib/libimhex/include/hex/api/content_registry/hashes.hpp b/lib/libimhex/include/hex/api/content_registry/hashes.hpp index e69de29bb..0e5d2107a 100644 --- a/lib/libimhex/include/hex/api/content_registry/hashes.hpp +++ b/lib/libimhex/include/hex/api/content_registry/hashes.hpp @@ -0,0 +1,101 @@ +#pragma once + +#include + +#include + +#include +#include +#include +#include + +#include + +EXPORT_MODULE namespace hex { + + #if !defined(HEX_MODULE_EXPORT) + namespace prv { class Provider; } + #endif + + /* Hash Registry. Allows adding new hashes to the Hash view */ + namespace ContentRegistry::Hashes { + + class Hash { + public: + explicit Hash(UnlocalizedString unlocalizedName) : m_unlocalizedName(std::move(unlocalizedName)) {} + virtual ~Hash() = default; + + class Function { + public: + using Callback = std::function(const Region&, prv::Provider *)>; + + Function(Hash *type, std::string name, Callback callback) + : m_type(type), m_name(std::move(name)), m_callback(std::move(callback)) { + + } + + [[nodiscard]] Hash *getType() { return m_type; } + [[nodiscard]] const Hash *getType() const { return m_type; } + [[nodiscard]] const std::string& getName() const { return m_name; } + + const std::vector& get(const Region& region, prv::Provider *provider) { + if (m_cache.empty()) { + m_cache = m_callback(region, provider); + } + + return m_cache; + } + + void reset() { + m_cache.clear(); + } + + private: + Hash *m_type; + std::string m_name; + Callback m_callback; + + std::vector m_cache; + }; + + virtual void draw() { } + [[nodiscard]] virtual Function create(std::string name) = 0; + + [[nodiscard]] virtual nlohmann::json store() const = 0; + virtual void load(const nlohmann::json &json) = 0; + + [[nodiscard]] const UnlocalizedString& getUnlocalizedName() const { + return m_unlocalizedName; + } + + protected: + [[nodiscard]] Function create(const std::string &name, const Function::Callback &callback) { + return { this, name, callback }; + } + + private: + UnlocalizedString m_unlocalizedName; + }; + + namespace impl { + + const std::vector>& getHashes(); + + void add(std::unique_ptr &&hash); + + } + + + /** + * @brief Adds a new hash + * @tparam T The hash type that extends hex::Hash + * @param args The arguments to pass to the constructor of the hash + */ + template + void add(Args && ... args) { + impl::add(std::make_unique(std::forward(args)...)); + } + + } + +} \ No newline at end of file diff --git a/lib/libimhex/include/hex/api/content_registry/hex_editor.hpp b/lib/libimhex/include/hex/api/content_registry/hex_editor.hpp index e69de29bb..c8a3c1ed6 100644 --- a/lib/libimhex/include/hex/api/content_registry/hex_editor.hpp +++ b/lib/libimhex/include/hex/api/content_registry/hex_editor.hpp @@ -0,0 +1,91 @@ +#pragma once + +#include + +#include + +#include + +#include +#include +#include +#include +#include + +EXPORT_MODULE namespace hex { + + /* Hex Editor Registry. Allows adding new functionality to the hex editor */ + namespace ContentRegistry::HexEditor { + + class DataVisualizer { + public: + DataVisualizer(UnlocalizedString unlocalizedName, u16 bytesPerCell, u16 maxCharsPerCell) + : m_unlocalizedName(std::move(unlocalizedName)), + m_bytesPerCell(bytesPerCell), + m_maxCharsPerCell(maxCharsPerCell) { } + + virtual ~DataVisualizer() = default; + + virtual void draw(u64 address, const u8 *data, size_t size, bool upperCase) = 0; + virtual bool drawEditing(u64 address, u8 *data, size_t size, bool upperCase, bool startedEditing) = 0; + + [[nodiscard]] u16 getBytesPerCell() const { return m_bytesPerCell; } + [[nodiscard]] u16 getMaxCharsPerCell() const { return m_maxCharsPerCell; } + + [[nodiscard]] const UnlocalizedString& getUnlocalizedName() const { return m_unlocalizedName; } + + [[nodiscard]] static int DefaultTextInputFlags(); + + protected: + bool drawDefaultScalarEditingTextBox(u64 address, const char *format, ImGuiDataType dataType, u8 *data, ImGuiInputTextFlags flags) const; + bool drawDefaultTextEditingTextBox(u64 address, std::string &data, ImGuiInputTextFlags flags) const; + + private: + UnlocalizedString m_unlocalizedName; + u16 m_bytesPerCell; + u16 m_maxCharsPerCell; + }; + + struct MiniMapVisualizer { + using Callback = std::function, std::vector&)>; + + UnlocalizedString unlocalizedName; + Callback callback; + }; + + namespace impl { + + void addDataVisualizer(std::shared_ptr &&visualizer); + + const std::vector>& getVisualizers(); + const std::vector>& getMiniMapVisualizers(); + + } + + /** + * @brief Adds a new cell data visualizer + * @tparam T The data visualizer type that extends hex::DataVisualizer + * @param args The arguments to pass to the constructor of the data visualizer + */ + template T, typename... Args> + void addDataVisualizer(Args &&...args) { + return impl::addDataVisualizer(std::make_shared(std::forward(args)...)); + } + + /** + * @brief Gets a data visualizer by its unlocalized name + * @param unlocalizedName Unlocalized name of the data visualizer + * @return The data visualizer, or nullptr if it doesn't exist + */ + std::shared_ptr getVisualizerByName(const UnlocalizedString &unlocalizedName); + + /** + * @brief Adds a new minimap visualizer + * @param unlocalizedName Unlocalized name of the minimap visualizer + * @param callback The callback that will be called to get the color of a line + */ + void addMiniMapVisualizer(UnlocalizedString unlocalizedName, MiniMapVisualizer::Callback callback); + + } + +} \ No newline at end of file diff --git a/lib/libimhex/include/hex/api/content_registry/interface.hpp b/lib/libimhex/include/hex/api/content_registry/interface.hpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/libimhex/include/hex/api/content_registry/pattern_language.hpp b/lib/libimhex/include/hex/api/content_registry/pattern_language.hpp index e69de29bb..b36cc9b77 100644 --- a/lib/libimhex/include/hex/api/content_registry/pattern_language.hpp +++ b/lib/libimhex/include/hex/api/content_registry/pattern_language.hpp @@ -0,0 +1,155 @@ +#pragma once + +#include + +#include + +#include +#include +#include +#include +#include +#include + +EXPORT_MODULE namespace hex { + + #if !defined(HEX_MODULE_EXPORT) + namespace prv { class Provider; } + #endif + + /* Pattern Language Function Registry. Allows adding of new functions that may be used inside the pattern language */ + namespace ContentRegistry::PatternLanguage { + + namespace impl { + + using VisualizerFunctionCallback = std::function)>; + + struct FunctionDefinition { + pl::api::Namespace ns; + std::string name; + + pl::api::FunctionParameterCount parameterCount; + pl::api::FunctionCallback callback; + + bool dangerous; + }; + + struct TypeDefinition { + pl::api::Namespace ns; + std::string name; + + pl::api::FunctionParameterCount parameterCount; + pl::api::TypeCallback callback; + }; + + struct Visualizer { + pl::api::FunctionParameterCount parameterCount; + VisualizerFunctionCallback callback; + }; + + const std::map& getVisualizers(); + const std::map& getInlineVisualizers(); + const std::map& getPragmas(); + const std::vector& getFunctions(); + const std::vector& getTypes(); + + } + + /** + * @brief Provides access to the current provider's pattern language runtime + * @return Runtime + */ + pl::PatternLanguage& getRuntime(); + + /** + * @brief Provides access to the current provider's pattern language runtime's lock + * @return Lock + */ + std::mutex& getRuntimeLock(); + + /** + * @brief Configures the pattern language runtime using ImHex's default settings + * @param runtime The pattern language runtime to configure + * @param provider The provider to use for data access + */ + void configureRuntime(pl::PatternLanguage &runtime, prv::Provider *provider); + + /** + * @brief Adds a new pragma to the pattern language + * @param name The name of the pragma + * @param handler The handler that will be called when the pragma is encountered + */ + void addPragma(const std::string &name, const pl::api::PragmaHandler &handler); + + /** + * @brief Adds a new function to the pattern language + * @param ns The namespace of the function + * @param name The name of the function + * @param parameterCount The amount of parameters the function takes + * @param func The function callback + */ + void addFunction( + const pl::api::Namespace &ns, + const std::string &name, + pl::api::FunctionParameterCount parameterCount, + const pl::api::FunctionCallback &func + ); + + /** + * @brief Adds a new dangerous function to the pattern language + * @note Dangerous functions are functions that require the user to explicitly allow them to be used + * @param ns The namespace of the function + * @param name The name of the function + * @param parameterCount The amount of parameters the function takes + * @param func The function callback + */ + void addDangerousFunction( + const pl::api::Namespace &ns, + const std::string &name, + pl::api::FunctionParameterCount parameterCount, + const pl::api::FunctionCallback &func + ); + + /** + * @brief Adds a new type to the pattern language + * @param ns The namespace of the type + * @param name The name of the type + * @param parameterCount The amount of non-type template parameters the type takes + * @param func The type callback + */ + void addType( + const pl::api::Namespace &ns, + const std::string &name, + pl::api::FunctionParameterCount parameterCount, + const pl::api::TypeCallback &func + ); + + /** + * @brief Adds a new visualizer to the pattern language + * @note Visualizers are extensions to the [[hex::visualize]] attribute, used to visualize data + * @param name The name of the visualizer + * @param function The function callback + * @param parameterCount The amount of parameters the function takes + */ + void addVisualizer( + const std::string &name, + const impl::VisualizerFunctionCallback &function, + pl::api::FunctionParameterCount parameterCount + ); + + /** + * @brief Adds a new inline visualizer to the pattern language + * @note Inline visualizers are extensions to the [[hex::inline_visualize]] attribute, used to visualize data + * @param name The name of the visualizer + * @param function The function callback + * @param parameterCount The amount of parameters the function takes + */ + void addInlineVisualizer( + const std::string &name, + const impl::VisualizerFunctionCallback &function, + pl::api::FunctionParameterCount parameterCount + ); + + } + +} \ No newline at end of file diff --git a/lib/libimhex/include/hex/api/content_registry/provider.hpp b/lib/libimhex/include/hex/api/content_registry/provider.hpp index e69de29bb..e3b25f94f 100644 --- a/lib/libimhex/include/hex/api/content_registry/provider.hpp +++ b/lib/libimhex/include/hex/api/content_registry/provider.hpp @@ -0,0 +1,54 @@ +#pragma once + +#include + +#include +#include + +#include +#include +#include +#include + +EXPORT_MODULE namespace hex { + + /* Provider Registry. Allows adding new data providers to be created from the UI */ + namespace ContentRegistry::Provider { + + namespace impl { + + void addProviderName(const UnlocalizedString &unlocalizedName, const char *icon); + + using ProviderCreationFunction = std::function()>; + void add(const std::string &typeName, ProviderCreationFunction creationFunction); + + struct Entry { + UnlocalizedString unlocalizedName; + const char *icon; + }; + + const std::vector& getEntries(); + + } + + /** + * @brief Adds a new provider to the list of providers + * @tparam T The provider type that extends hex::prv::Provider + * @param addToList Whether to display the provider in the Other Providers list in the welcome screen and File menu + */ + template T> + void add(bool addToList = true) { + const T provider; + auto typeName = provider.getTypeName(); + + impl::add(typeName, []() -> std::unique_ptr { + return std::make_unique(); + }); + + if (addToList) + impl::addProviderName(typeName, provider.getIcon()); + } + + } + +} \ No newline at end of file diff --git a/lib/libimhex/include/hex/api/content_registry/reports.hpp b/lib/libimhex/include/hex/api/content_registry/reports.hpp index e69de29bb..02bb39e94 100644 --- a/lib/libimhex/include/hex/api/content_registry/reports.hpp +++ b/lib/libimhex/include/hex/api/content_registry/reports.hpp @@ -0,0 +1,34 @@ +#pragma once + +#include + +#include +#include +#include + +EXPORT_MODULE namespace hex { + + #if !defined(HEX_MODULE_EXPORT) + namespace prv { class Provider; } + #endif + + /* Reports Registry. Allows adding new sections to exported reports */ + namespace ContentRegistry::Reports { + + namespace impl { + + using Callback = std::function; + + struct ReportGenerator { + Callback callback; + }; + + const std::vector& getGenerators(); + + } + + void addReportProvider(impl::Callback callback); + + } + +} \ No newline at end of file diff --git a/lib/libimhex/include/hex/api/content_registry/settings.hpp b/lib/libimhex/include/hex/api/content_registry/settings.hpp index e69de29bb..c16719252 100644 --- a/lib/libimhex/include/hex/api/content_registry/settings.hpp +++ b/lib/libimhex/include/hex/api/content_registry/settings.hpp @@ -0,0 +1,345 @@ +#pragma once + +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +EXPORT_MODULE namespace hex { + + /* Settings Registry. Allows adding of new entries into the ImHex preferences window. */ + namespace ContentRegistry::Settings { + + namespace Widgets { + + class Widget { + public: + virtual ~Widget() = default; + + virtual bool draw(const std::string &name) = 0; + + virtual void load(const nlohmann::json &data) = 0; + virtual nlohmann::json store() = 0; + + class Interface { + public: + friend class Widget; + + Interface& requiresRestart() { + m_requiresRestart = true; + + return *this; + } + + Interface& setEnabledCallback(std::function callback) { + m_enabledCallback = std::move(callback); + + return *this; + } + + Interface& setChangedCallback(std::function callback) { + m_changedCallback = std::move(callback); + + return *this; + } + + Interface& setTooltip(const std::string &tooltip) { + m_tooltip = tooltip; + + return *this; + } + + [[nodiscard]] + Widget& getWidget() const { + return *m_widget; + } + + private: + explicit Interface(Widget *widget) : m_widget(widget) {} + Widget *m_widget; + + bool m_requiresRestart = false; + std::function m_enabledCallback; + std::function m_changedCallback; + std::optional m_tooltip; + }; + + [[nodiscard]] + bool doesRequireRestart() const { + return m_interface.m_requiresRestart; + } + + [[nodiscard]] + bool isEnabled() const { + return !m_interface.m_enabledCallback || m_interface.m_enabledCallback(); + } + + [[nodiscard]] + const std::optional& getTooltip() const { + return m_interface.m_tooltip; + } + + void onChanged() { + if (m_interface.m_changedCallback) + m_interface.m_changedCallback(*this); + } + + [[nodiscard]] + Interface& getInterface() { + return m_interface; + } + + private: + Interface m_interface = Interface(this); + }; + + class Checkbox : public Widget { + public: + explicit Checkbox(bool defaultValue) : m_value(defaultValue) { } + + bool draw(const std::string &name) override; + + void load(const nlohmann::json &data) override; + nlohmann::json store() override; + + [[nodiscard]] bool isChecked() const { return m_value; } + + protected: + bool m_value; + }; + + class SliderInteger : public Widget { + public: + SliderInteger(i32 defaultValue, i32 min, i32 max) : m_value(defaultValue), m_min(min), m_max(max) { } + bool draw(const std::string &name) override; + + void load(const nlohmann::json &data) override; + nlohmann::json store() override; + + [[nodiscard]] i32 getValue() const { return m_value; } + + protected: + int m_value; + i32 m_min, m_max; + }; + + class SliderFloat : public Widget { + public: + SliderFloat(float defaultValue, float min, float max) : m_value(defaultValue), m_min(min), m_max(max) { } + bool draw(const std::string &name) override; + + void load(const nlohmann::json &data) override; + nlohmann::json store() override; + + [[nodiscard]] float getValue() const { return m_value; } + + protected: + float m_value; + float m_min, m_max; + }; + + class SliderDataSize : public Widget { + public: + SliderDataSize(u64 defaultValue, u64 min, u64 max, u64 stepSize) : m_value(defaultValue), m_min(min), m_max(max), m_stepSize(stepSize) { } + bool draw(const std::string &name) override; + + void load(const nlohmann::json &data) override; + nlohmann::json store() override; + + [[nodiscard]] i32 getValue() const { return m_value; } + + protected: + u64 m_value; + u64 m_min, m_max; + u64 m_stepSize; + }; + + class ColorPicker : public Widget { + public: + explicit ColorPicker(ImColor defaultColor, ImGuiColorEditFlags flags = 0); + + bool draw(const std::string &name) override; + + void load(const nlohmann::json &data) override; + nlohmann::json store() override; + + [[nodiscard]] ImColor getColor() const; + + protected: + std::array m_value = {}, m_defaultValue = {}; + ImGuiColorEditFlags m_flags; + }; + + class DropDown : public Widget { + public: + explicit DropDown(const std::vector &items, const std::vector &settingsValues, const nlohmann::json &defaultItem) : m_items(items.begin(), items.end()), m_settingsValues(settingsValues), m_defaultItem(defaultItem) { } + explicit DropDown(const std::vector &items, const std::vector &settingsValues, const nlohmann::json &defaultItem) : m_items(items), m_settingsValues(settingsValues), m_defaultItem(defaultItem) { } + + bool draw(const std::string &name) override; + + void load(const nlohmann::json &data) override; + nlohmann::json store() override; + + [[nodiscard]] + const nlohmann::json& getValue() const; + + protected: + std::vector m_items; + std::vector m_settingsValues; + nlohmann::json m_defaultItem; + + int m_value = -1; + }; + + class TextBox : public Widget { + public: + explicit TextBox(std::string defaultValue) : m_value(std::move(defaultValue)) { } + + bool draw(const std::string &name) override; + + void load(const nlohmann::json &data) override; + nlohmann::json store() override; + + [[nodiscard]] + const std::string& getValue() const { return m_value; } + + protected: + std::string m_value; + }; + + class FilePicker : public Widget { + public: + bool draw(const std::string &name) override; + + void load(const nlohmann::json &data) override; + nlohmann::json store() override; + + [[nodiscard]] const std::fs::path& getPath() const { + return m_path; + } + + protected: + std::fs::path m_path; + }; + + class Label : public Widget { + public: + bool draw(const std::string &name) override; + + void load(const nlohmann::json &) override {} + nlohmann::json store() override { return {}; } + }; + + } + + namespace impl { + + struct Entry { + UnlocalizedString unlocalizedName; + std::unique_ptr widget; + }; + + struct SubCategory { + UnlocalizedString unlocalizedName; + std::vector entries; + }; + + struct Category { + UnlocalizedString unlocalizedName; + UnlocalizedString unlocalizedDescription; + std::vector subCategories; + }; + + void load(); + void store(); + void clear(); + + const std::vector& getSettings(); + nlohmann::json& getSetting(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedName, const nlohmann::json &defaultValue); + const nlohmann::json& getSettingsData(); + + Widgets::Widget* add(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedSubCategory, const UnlocalizedString &unlocalizedName, std::unique_ptr &&widget); + + void printSettingReadError(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedName, const nlohmann::json::exception &e); + + void runOnChangeHandlers(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedName, const nlohmann::json &value); + } + + template T> + Widgets::Widget::Interface& add(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedSubCategory, const UnlocalizedString &unlocalizedName, auto && ... args) { + return impl::add( + unlocalizedCategory, + unlocalizedSubCategory, + unlocalizedName, + std::make_unique(std::forward(args)...) + )->getInterface(); + } + + void setCategoryDescription(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedDescription); + + class SettingsValue { + public: + SettingsValue(nlohmann::json value) : m_value(std::move(value)) {} + + template + T get(std::common_type_t defaultValue) const { + try { + auto result = m_value; + if (result.is_number() && std::same_as) + result = m_value.get() != 0; + if (m_value.is_null()) + result = defaultValue; + + return result.get(); + } catch (const nlohmann::json::exception &) { + return defaultValue; + } + } + private: + nlohmann::json m_value; + }; + + template + [[nodiscard]] T read(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedName, const std::common_type_t &defaultValue) { + auto setting = impl::getSetting(unlocalizedCategory, unlocalizedName, defaultValue); + + try { + if (setting.is_number() && std::same_as) + setting = setting.template get() != 0; + if (setting.is_null()) + setting = defaultValue; + + return setting.template get(); + } catch (const nlohmann::json::exception &e) { + impl::printSettingReadError(unlocalizedCategory, unlocalizedName, e); + + return defaultValue; + } + } + + template + void write(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedName, const std::common_type_t &value) { + impl::getSetting(unlocalizedCategory, unlocalizedName, value) = value; + impl::runOnChangeHandlers(unlocalizedCategory, unlocalizedName, value); + + impl::store(); + } + + using OnChangeCallback = std::function; + u64 onChange(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedName, const OnChangeCallback &callback); + + using OnSaveCallback = std::function; + u64 onSave(const OnSaveCallback &callback); + + } + +} \ No newline at end of file diff --git a/lib/libimhex/include/hex/api/content_registry/tools.hpp b/lib/libimhex/include/hex/api/content_registry/tools.hpp index e69de29bb..a4d22f2f2 100644 --- a/lib/libimhex/include/hex/api/content_registry/tools.hpp +++ b/lib/libimhex/include/hex/api/content_registry/tools.hpp @@ -0,0 +1,37 @@ +#pragma once + +#include + +#include + +#include +#include + +EXPORT_MODULE namespace hex { + + /* Tools Registry. Allows adding new entries to the tools window */ + namespace ContentRegistry::Tools { + + namespace impl { + + using Callback = std::function; + + struct Entry { + UnlocalizedString unlocalizedName; + const char *icon; + Callback function; + }; + + const std::vector& getEntries(); + + } + + /** + * @brief Adds a new tool to the tools window + * @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 char *icon, const impl::Callback &function); + } + +} \ No newline at end of file diff --git a/lib/libimhex/include/hex/api/content_registry/user_interface.hpp b/lib/libimhex/include/hex/api/content_registry/user_interface.hpp new file mode 100644 index 000000000..70ef6dcd0 --- /dev/null +++ b/lib/libimhex/include/hex/api/content_registry/user_interface.hpp @@ -0,0 +1,287 @@ +#pragma once + +#include + +#include +#include + +#include +#include +#include +#include + +EXPORT_MODULE namespace hex { + + /* User Interface Registry. Allows adding new items to various interfaces */ + namespace ContentRegistry::UserInterface { + + struct Icon { + Icon(const char *glyph, ImGuiCustomCol color = ImGuiCustomCol(0x00)) : glyph(glyph), color(color) {} + + std::string glyph; + ImGuiCustomCol color; + }; + + namespace impl { + + using DrawCallback = std::function; + using MenuCallback = std::function; + using EnabledCallback = std::function; + using SelectedCallback = std::function; + using ClickCallback = std::function; + using ToggleCallback = std::function; + + struct MainMenuItem { + UnlocalizedString unlocalizedName; + }; + + struct MenuItem { + std::vector unlocalizedNames; + Icon icon; + Shortcut shortcut; + View *view; + MenuCallback callback; + EnabledCallback enabledCallback; + SelectedCallback selectedCallback; + i32 toolbarIndex; + }; + + struct SidebarItem { + std::string icon; + DrawCallback callback; + EnabledCallback enabledCallback; + }; + + struct TitleBarButton { + std::string icon; + ImGuiCustomCol color; + UnlocalizedString unlocalizedTooltip; + ClickCallback callback; + }; + + struct WelcomeScreenQuickSettingsToggle { + std::string onIcon, offIcon; + UnlocalizedString unlocalizedTooltip; + ToggleCallback callback; + mutable bool state; + }; + + constexpr static auto SeparatorValue = "$SEPARATOR$"; + constexpr static auto SubMenuValue = "$SUBMENU$"; + + const std::multimap& getMainMenuItems(); + + const std::multimap& getMenuItems(); + const std::vector& getToolbarMenuItems(); + std::multimap& getMenuItemsMutable(); + + const std::vector& getWelcomeScreenEntries(); + const std::vector& getFooterItems(); + const std::vector& getToolbarItems(); + const std::vector& getSidebarItems(); + const std::vector& getTitlebarButtons(); + const std::vector& getWelcomeScreenQuickSettingsToggles(); + + } + + /** + * @brief Adds a new top-level main menu entry + * @param unlocalizedName The unlocalized name of the entry + * @param priority The priority of the entry. Lower values are displayed first + */ + void registerMainMenuItem(const UnlocalizedString &unlocalizedName, u32 priority); + + /** + * @brief Adds a new main menu entry + * @param unlocalizedMainMenuNames The unlocalized names of the main menu entries + * @param icon The icon to use for the entry + * @param priority The priority of the entry. Lower values are displayed first + * @param shortcut The shortcut to use for the entry + * @param function The function to call when the entry is clicked + * @param enabledCallback The function to call to determine if the entry is enabled + * @param view The view to use for the entry. If nullptr, the shortcut will work globally + */ + void addMenuItem( + const std::vector &unlocalizedMainMenuNames, + const Icon &icon, + u32 priority, + const Shortcut &shortcut, + const impl::MenuCallback &function, + const impl::EnabledCallback& enabledCallback, View *view + ); + + /** + * @brief Adds a new main menu entry + * @param unlocalizedMainMenuNames The unlocalized names of the main menu entries + * @param icon The icon to use for the entry + * @param priority The priority of the entry. Lower values are displayed first + * @param shortcut The shortcut to use for the entry + * @param function The function to call when the entry is clicked + * @param enabledCallback The function to call to determine if the entry is enabled + * @param selectedCallback The function to call to determine if the entry is selected + * @param view The view to use for the entry. If nullptr, the shortcut will work globally + */ + void addMenuItem( + const std::vector &unlocalizedMainMenuNames, + const Icon &icon, + u32 priority, + Shortcut shortcut, + const impl::MenuCallback &function, + const impl::EnabledCallback& enabledCallback = []{ return true; }, + const impl::SelectedCallback &selectedCallback = []{ return false; }, + View *view = nullptr + ); + + /** + * @brief Adds a new main menu entry + * @param unlocalizedMainMenuNames The unlocalized names of the main menu entries + * @param priority The priority of the entry. Lower values are displayed first + * @param shortcut The shortcut to use for the entry + * @param function The function to call when the entry is clicked + * @param enabledCallback The function to call to determine if the entry is enabled + * @param selectedCallback The function to call to determine if the entry is selected + * @param view The view to use for the entry. If nullptr, the shortcut will work globally + */ + void addMenuItem( + const std::vector &unlocalizedMainMenuNames, + u32 priority, + const Shortcut &shortcut, + const impl::MenuCallback &function, + const impl::EnabledCallback& enabledCallback = []{ return true; }, + const impl::SelectedCallback &selectedCallback = []{ return false; }, + View *view = nullptr + ); + + /** + * @brief Adds a new main menu sub-menu entry + * @param unlocalizedMainMenuNames The unlocalized names of the main menu entries + * @param priority The priority of the entry. Lower values are displayed first + * @param function The function to call when the entry is clicked + * @param enabledCallback The function to call to determine if the entry is enabled + * @param view The view to use for the entry. If nullptr, the item will always be visible + */ + void addMenuItemSubMenu( + std::vector unlocalizedMainMenuNames, + u32 priority, + const impl::MenuCallback &function, + const impl::EnabledCallback& enabledCallback = []{ return true; }, + View *view = nullptr + ); + + /** + * @brief Adds a new main menu sub-menu entry + * @param unlocalizedMainMenuNames The unlocalized names of the main menu entries + * @param icon The icon to use for the entry + * @param priority The priority of the entry. Lower values are displayed first + * @param function The function to call when the entry is clicked + * @param enabledCallback The function to call to determine if the entry is enabled + * @param view The view to use for the entry. If nullptr, the item will always be visible + */ + void addMenuItemSubMenu( + std::vector unlocalizedMainMenuNames, + const char *icon, + u32 priority, + const impl::MenuCallback &function, + const impl::EnabledCallback& enabledCallback = []{ return true; }, + View *view = nullptr + ); + + + /** + * @brief Adds a new main menu separator + * @param unlocalizedMainMenuNames The unlocalized names of the main menu entries + * @param priority The priority of the entry. Lower values are displayed first + * @param view The view to use for the entry. If nullptr, the item will always be visible + */ + void addMenuItemSeparator(std::vector unlocalizedMainMenuNames, u32 priority, View *view = nullptr); + + + /** + * @brief Adds a new welcome screen entry + * @param function The function to call to draw the entry + */ + void addWelcomeScreenEntry(const impl::DrawCallback &function); + + /** + * @brief Adds a new footer item + * @param function The function to call to draw the item + */ + void addFooterItem(const impl::DrawCallback &function); + + /** + * @brief Adds a new toolbar item + * @param function The function to call to draw the item + */ + void addToolbarItem(const impl::DrawCallback &function); + + /** + * @brief Adds a menu item to the toolbar + * @param unlocalizedName Unlocalized name of the menu item + * @param color Color of the toolbar icon + */ + void addMenuItemToToolbar(const UnlocalizedString &unlocalizedName, ImGuiCustomCol color); + + /** + * @brief Reconstructs the toolbar items list after they have been modified + */ + void updateToolbarItems(); + + /** + * @brief Adds a new sidebar item + * @param icon The icon to use for the item + * @param function The function to call to draw the item + * @param enabledCallback The function + */ + void addSidebarItem( + const std::string &icon, + const impl::DrawCallback &function, + const impl::EnabledCallback &enabledCallback = []{ return true; } + ); + + /** + * @brief Adds a new title bar button + * @param icon The icon to use for the button + * @param color The color of the icon + * @param unlocalizedTooltip The unlocalized tooltip to use for the button + * @param function The function to call when the button is clicked + */ + void addTitleBarButton( + const std::string &icon, + ImGuiCustomCol color, + const UnlocalizedString &unlocalizedTooltip, + const impl::ClickCallback &function + ); + + /** + * @brief Adds a new welcome screen quick settings toggle + * @param icon The icon to use for the button + * @param unlocalizedTooltip The unlocalized tooltip to use for the button + * @param defaultState The default state of the toggle + * @param function The function to call when the button is clicked + */ + void addWelcomeScreenQuickSettingsToggle( + const std::string &icon, + const UnlocalizedString &unlocalizedTooltip, + bool defaultState, + const impl::ToggleCallback &function + ); + + /** + * @brief Adds a new welcome screen quick settings toggle + * @param onIcon The icon to use for the button when it's on + * @param offIcon The icon to use for the button when it's off + * @param unlocalizedTooltip The unlocalized tooltip to use for the button + * @param defaultState The default state of the toggle + * @param function The function to call when the button is clicked + */ + void addWelcomeScreenQuickSettingsToggle( + const std::string &onIcon, + const std::string &offIcon, + const UnlocalizedString &unlocalizedTooltip, + bool defaultState, + const impl::ToggleCallback &function + ); + + } + +} \ No newline at end of file diff --git a/lib/libimhex/include/hex/api/content_registry/views.hpp b/lib/libimhex/include/hex/api/content_registry/views.hpp index e69de29bb..0eb3d6c8f 100644 --- a/lib/libimhex/include/hex/api/content_registry/views.hpp +++ b/lib/libimhex/include/hex/api/content_registry/views.hpp @@ -0,0 +1,63 @@ +#pragma once + +#include + +#include +#include + +#include +#include +#include + +EXPORT_MODULE namespace hex { + + /* View Registry. Allows adding of new windows */ + namespace ContentRegistry::Views { + + namespace impl { + + void add(std::unique_ptr &&view); + void setFullScreenView(std::unique_ptr &&view); + + const std::map>& getEntries(); + const std::unique_ptr& getFullScreenView(); + + } + + /** + * @brief Adds a new view to ImHex + * @tparam T The custom view class that extends View + * @tparam Args Arguments types + * @param args Arguments passed to the constructor of the view + */ + template T, typename... Args> + void add(Args &&...args) { + return impl::add(std::make_unique(std::forward(args)...)); + } + + /** + * @brief Sets a view as a full-screen view. This will cause the view to take up the entire ImHex window + * @tparam T The custom view class that extends View + * @tparam Args Arguments types + * @param args Arguments passed to the constructor of the view + */ + template T, typename... Args> + void setFullScreenView(Args &&...args) { + return impl::setFullScreenView(std::make_unique(std::forward(args)...)); + } + + /** + * @brief Gets a view by its unlocalized name + * @param unlocalizedName The unlocalized name of the view + * @return The view if it exists, nullptr otherwise + */ + View* getViewByName(const UnlocalizedString &unlocalizedName); + + /** + * @brief Gets the currently focused view + * @return The view that is focused right now. nullptr if none is focused + */ + View* getFocusedView(); + } + +} \ No newline at end of file diff --git a/lib/libimhex/include/hex/api/theme_manager.hpp b/lib/libimhex/include/hex/api/theme_manager.hpp index d5aeb3542..237cb6eb9 100644 --- a/lib/libimhex/include/hex/api/theme_manager.hpp +++ b/lib/libimhex/include/hex/api/theme_manager.hpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include EXPORT_MODULE namespace hex { diff --git a/lib/libimhex/source/api/content_registry.cpp b/lib/libimhex/source/api/content_registry.cpp index 0aa6d60af..957b8f175 100644 --- a/lib/libimhex/source/api/content_registry.cpp +++ b/lib/libimhex/source/api/content_registry.cpp @@ -1,4 +1,24 @@ -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include #include @@ -579,7 +599,7 @@ namespace hex { } - namespace ContentRegistry::CommandPaletteCommands { + namespace ContentRegistry::CommandPalette { namespace impl { @@ -851,7 +871,7 @@ namespace hex { } - namespace ContentRegistry::DataProcessorNode { + namespace ContentRegistry::DataProcessor { namespace impl { @@ -874,7 +894,7 @@ namespace hex { } - namespace ContentRegistry::Interface { + namespace ContentRegistry::UserInterface { namespace impl { @@ -1026,7 +1046,7 @@ namespace hex { }; void updateToolbarItems() { - std::set menuItems; + std::set menuItems; for (auto &[priority, menuItem] : impl::getMenuItemsMutable()) { if (menuItem.toolbarIndex != -1) { @@ -1124,7 +1144,7 @@ namespace hex { } - namespace ContentRegistry::FileHandler { + namespace ContentRegistry::FileTypeHandler { namespace impl { @@ -1429,6 +1449,16 @@ namespace hex { namespace ContentRegistry::DataInformation { + void InformationSection::load(const nlohmann::json &data) { + m_enabled = data.value("enabled", true); + } + [[nodiscard]] nlohmann::json InformationSection::store() { + nlohmann::json data; + data["enabled"] = m_enabled.load(); + + return data; + } + namespace impl { static AutoReset> s_informationSectionConstructors; @@ -1444,7 +1474,7 @@ namespace hex { } - namespace ContentRegistry::Disassembler { + namespace ContentRegistry::Disassemblers { namespace impl { diff --git a/lib/libimhex/source/api/layout_manager.cpp b/lib/libimhex/source/api/layout_manager.cpp index f4fee2f45..e23a3676f 100644 --- a/lib/libimhex/source/api/layout_manager.cpp +++ b/lib/libimhex/source/api/layout_manager.cpp @@ -1,8 +1,7 @@ #include -#include +#include #include -#include #include #include #include diff --git a/lib/libimhex/source/api/localization_manager.cpp b/lib/libimhex/source/api/localization_manager.cpp index b499ac054..0eea641e9 100644 --- a/lib/libimhex/source/api/localization_manager.cpp +++ b/lib/libimhex/source/api/localization_manager.cpp @@ -1,4 +1,3 @@ -#include #include #include diff --git a/lib/libimhex/source/api/shortcut_manager.cpp b/lib/libimhex/source/api/shortcut_manager.cpp index 8d3f941c6..e0c3c9c61 100644 --- a/lib/libimhex/source/api/shortcut_manager.cpp +++ b/lib/libimhex/source/api/shortcut_manager.cpp @@ -1,11 +1,13 @@ #include #include -#include +#include #include #include #include +#include + namespace hex { namespace { @@ -443,7 +445,7 @@ namespace hex { } if (result) { - for (auto &[priority, menuItem] : ContentRegistry::Interface::impl::getMenuItemsMutable()) { + for (auto &[priority, menuItem] : ContentRegistry::UserInterface::impl::getMenuItemsMutable()) { if (menuItem.view == view && menuItem.shortcut == oldShortcut) { menuItem.shortcut = newShortcut; break; diff --git a/main/gui/source/init/run/common.cpp b/main/gui/source/init/run/common.cpp index e64da3291..6364ef67f 100644 --- a/main/gui/source/init/run/common.cpp +++ b/main/gui/source/init/run/common.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include diff --git a/main/gui/source/init/tasks.cpp b/main/gui/source/init/tasks.cpp index aefb5b2b0..3e3e86806 100644 --- a/main/gui/source/init/tasks.cpp +++ b/main/gui/source/init/tasks.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include diff --git a/main/gui/source/window/platform/linux.cpp b/main/gui/source/window/platform/linux.cpp index 902463e67..766cffe67 100644 --- a/main/gui/source/window/platform/linux.cpp +++ b/main/gui/source/window/platform/linux.cpp @@ -3,7 +3,6 @@ #if defined(OS_LINUX) #include - #include #include #include #include diff --git a/main/gui/source/window/platform/windows.cpp b/main/gui/source/window/platform/windows.cpp index db1c9f66e..e8267fae3 100644 --- a/main/gui/source/window/platform/windows.cpp +++ b/main/gui/source/window/platform/windows.cpp @@ -5,7 +5,7 @@ #include "messaging.hpp" #include - #include + #include #include #include diff --git a/main/gui/source/window/window.cpp b/main/gui/source/window/window.cpp index 4e001f30c..2a5a88ed4 100644 --- a/main/gui/source/window/window.cpp +++ b/main/gui/source/window/window.cpp @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include #include diff --git a/plugins/builtin/include/content/export_formatters/export_formatter.hpp b/plugins/builtin/include/content/export_formatters/export_formatter.hpp index 5a5bcebf8..e3456e301 100644 --- a/plugins/builtin/include/content/export_formatters/export_formatter.hpp +++ b/plugins/builtin/include/content/export_formatters/export_formatter.hpp @@ -5,7 +5,7 @@ #include #include -#include +#include namespace hex::plugin::builtin::export_fmt { diff --git a/plugins/builtin/include/content/providers/null_provider.hpp b/plugins/builtin/include/content/providers/null_provider.hpp index f2cca2019..693774499 100644 --- a/plugins/builtin/include/content/providers/null_provider.hpp +++ b/plugins/builtin/include/content/providers/null_provider.hpp @@ -4,6 +4,8 @@ #include #include +#include + namespace hex::plugin::builtin { class NullProvider : public hex::prv::Provider { diff --git a/plugins/builtin/include/content/views/view_command_palette.hpp b/plugins/builtin/include/content/views/view_command_palette.hpp index 7aea4e025..48cbc9966 100644 --- a/plugins/builtin/include/content/views/view_command_palette.hpp +++ b/plugins/builtin/include/content/views/view_command_palette.hpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include namespace hex::plugin::builtin { @@ -38,7 +38,7 @@ namespace hex::plugin::builtin { struct CommandResult { std::string displayResult; std::string matchedCommand; - ContentRegistry::CommandPaletteCommands::impl::ExecuteCallback executeCallback; + ContentRegistry::CommandPalette::impl::ExecuteCallback executeCallback; }; bool m_commandPaletteOpen = false; diff --git a/plugins/builtin/include/content/views/view_data_inspector.hpp b/plugins/builtin/include/content/views/view_data_inspector.hpp index b5f01d243..0a74031fc 100644 --- a/plugins/builtin/include/content/views/view_data_inspector.hpp +++ b/plugins/builtin/include/content/views/view_data_inspector.hpp @@ -3,7 +3,8 @@ #include #include -#include +#include +#include #include #include diff --git a/plugins/builtin/include/content/views/view_find.hpp b/plugins/builtin/include/content/views/view_find.hpp index 8335e9f9c..ea5fcfff6 100644 --- a/plugins/builtin/include/content/views/view_find.hpp +++ b/plugins/builtin/include/content/views/view_find.hpp @@ -11,7 +11,8 @@ #include -#include +#include +#include namespace hex::plugin::builtin { diff --git a/plugins/builtin/include/content/views/view_highlight_rules.hpp b/plugins/builtin/include/content/views/view_highlight_rules.hpp index 56e99823b..627e191f3 100644 --- a/plugins/builtin/include/content/views/view_highlight_rules.hpp +++ b/plugins/builtin/include/content/views/view_highlight_rules.hpp @@ -1,6 +1,5 @@ #pragma once -#include #include #include diff --git a/plugins/builtin/include/content/views/view_information.hpp b/plugins/builtin/include/content/views/view_information.hpp index a48425878..a1ce189ff 100644 --- a/plugins/builtin/include/content/views/view_information.hpp +++ b/plugins/builtin/include/content/views/view_information.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include #include diff --git a/plugins/builtin/include/content/views/view_pattern_data.hpp b/plugins/builtin/include/content/views/view_pattern_data.hpp index bf0339307..fbaa9df2f 100644 --- a/plugins/builtin/include/content/views/view_pattern_data.hpp +++ b/plugins/builtin/include/content/views/view_pattern_data.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include diff --git a/plugins/builtin/include/content/views/view_settings.hpp b/plugins/builtin/include/content/views/view_settings.hpp index b49dcac01..8ce07a34e 100644 --- a/plugins/builtin/include/content/views/view_settings.hpp +++ b/plugins/builtin/include/content/views/view_settings.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include namespace hex::plugin::builtin { diff --git a/plugins/builtin/include/content/views/view_tools.hpp b/plugins/builtin/include/content/views/view_tools.hpp index 80cc392b2..763d470b2 100644 --- a/plugins/builtin/include/content/views/view_tools.hpp +++ b/plugins/builtin/include/content/views/view_tools.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include diff --git a/plugins/builtin/source/content/background_services.cpp b/plugins/builtin/source/content/background_services.cpp index 6e6ebe5b7..5fce59f51 100644 --- a/plugins/builtin/source/content/background_services.cpp +++ b/plugins/builtin/source/content/background_services.cpp @@ -1,6 +1,7 @@ #include -#include -#include +#include +#include +#include #include #include #include diff --git a/plugins/builtin/source/content/command_line_interface.cpp b/plugins/builtin/source/content/command_line_interface.cpp index 2426776d5..44351c014 100644 --- a/plugins/builtin/source/content/command_line_interface.cpp +++ b/plugins/builtin/source/content/command_line_interface.cpp @@ -1,8 +1,9 @@ #include -#include #include #include +#include +#include #include #include #include diff --git a/plugins/builtin/source/content/command_palette_commands.cpp b/plugins/builtin/source/content/command_palette_commands.cpp index 6d0644585..0f8668836 100644 --- a/plugins/builtin/source/content/command_palette_commands.cpp +++ b/plugins/builtin/source/content/command_palette_commands.cpp @@ -1,7 +1,9 @@ -#include #include - #include +#include +#include +#include +#include #include @@ -250,8 +252,8 @@ namespace hex::plugin::builtin { void registerCommandPaletteCommands() { - ContentRegistry::CommandPaletteCommands::add( - ContentRegistry::CommandPaletteCommands::Type::SymbolCommand, + ContentRegistry::CommandPalette::add( + ContentRegistry::CommandPalette::Type::SymbolCommand, "=", "hex.builtin.command.calc.desc", [](auto input) { @@ -279,8 +281,8 @@ namespace hex::plugin::builtin { } }); - ContentRegistry::CommandPaletteCommands::add( - ContentRegistry::CommandPaletteCommands::Type::SymbolCommand, + ContentRegistry::CommandPalette::add( + ContentRegistry::CommandPalette::Type::SymbolCommand, "@", "hex.builtin.command.goto.desc", [](auto input) { @@ -307,8 +309,8 @@ namespace hex::plugin::builtin { return std::nullopt; }); - ContentRegistry::CommandPaletteCommands::add( - ContentRegistry::CommandPaletteCommands::Type::KeywordCommand, + ContentRegistry::CommandPalette::add( + ContentRegistry::CommandPalette::Type::KeywordCommand, "/web", "hex.builtin.command.web.desc", [](auto input) { @@ -319,8 +321,8 @@ namespace hex::plugin::builtin { return std::nullopt; }); - ContentRegistry::CommandPaletteCommands::add( - ContentRegistry::CommandPaletteCommands::Type::SymbolCommand, + ContentRegistry::CommandPalette::add( + ContentRegistry::CommandPalette::Type::SymbolCommand, "$", "hex.builtin.command.cmd.desc", [](auto input) { @@ -349,13 +351,13 @@ namespace hex::plugin::builtin { return std::nullopt; }); - ContentRegistry::CommandPaletteCommands::addHandler( - ContentRegistry::CommandPaletteCommands::Type::SymbolCommand, + ContentRegistry::CommandPalette::addHandler( + ContentRegistry::CommandPalette::Type::SymbolCommand, ">", [](const auto &input) { - std::vector result; + std::vector result; - for (const auto &[priority, entry] : ContentRegistry::Interface::impl::getMenuItems()) { + for (const auto &[priority, entry] : ContentRegistry::UserInterface::impl::getMenuItems()) { if (!entry.enabledCallback()) continue; @@ -367,8 +369,8 @@ namespace hex::plugin::builtin { std::vector names; std::transform(entry.unlocalizedNames.begin(), entry.unlocalizedNames.end(), std::back_inserter(names), [](auto &name) { return Lang(name); }); - if (auto combined = wolv::util::combineStrings(names, " -> "); hex::containsIgnoreCase(combined, input) && !combined.contains(ContentRegistry::Interface::impl::SeparatorValue) && !combined.contains(ContentRegistry::Interface::impl::SubMenuValue)) { - result.emplace_back(ContentRegistry::CommandPaletteCommands::impl::QueryResult { + if (auto combined = wolv::util::combineStrings(names, " -> "); hex::containsIgnoreCase(combined, input) && !combined.contains(ContentRegistry::UserInterface::impl::SeparatorValue) && !combined.contains(ContentRegistry::UserInterface::impl::SubMenuValue)) { + result.emplace_back(ContentRegistry::CommandPalette::impl::QueryResult { std::move(combined), [&entry](const auto&) { entry.callback(); } }); @@ -381,11 +383,11 @@ namespace hex::plugin::builtin { return fmt::format("Menu Item: {}", input.data()); }); - ContentRegistry::CommandPaletteCommands::addHandler( - ContentRegistry::CommandPaletteCommands::Type::SymbolCommand, + ContentRegistry::CommandPalette::addHandler( + ContentRegistry::CommandPalette::Type::SymbolCommand, ".", [](const auto &input) { - std::vector result; + std::vector result; u32 index = 0; for (const auto &provider : ImHexApi::Provider::getProviders()) { @@ -395,7 +397,7 @@ namespace hex::plugin::builtin { if (!hex::containsIgnoreCase(name, input)) continue; - result.emplace_back(ContentRegistry::CommandPaletteCommands::impl::QueryResult { + result.emplace_back(ContentRegistry::CommandPalette::impl::QueryResult { provider->getName(), [index](const auto&) { ImHexApi::Provider::setCurrentProvider(index); } }); @@ -407,17 +409,17 @@ namespace hex::plugin::builtin { return fmt::format("Data Source: {}", input.data()); }); - ContentRegistry::CommandPaletteCommands::add( - ContentRegistry::CommandPaletteCommands::Type::SymbolCommand, + ContentRegistry::CommandPalette::add( + ContentRegistry::CommandPalette::Type::SymbolCommand, "%", "hex.builtin.command.convert.desc", handleConversionCommand); - ContentRegistry::CommandPaletteCommands::addHandler( - ContentRegistry::CommandPaletteCommands::Type::SymbolCommand, + ContentRegistry::CommandPalette::addHandler( + ContentRegistry::CommandPalette::Type::SymbolCommand, "+", [](const auto &input) { - std::vector result; + std::vector result; for (const auto &[unlocalizedName, view] : ContentRegistry::Views::impl::getEntries()) { if (!view->shouldProcess()) diff --git a/plugins/builtin/source/content/communication_interface.cpp b/plugins/builtin/source/content/communication_interface.cpp index e765fb0e0..b6bb259fc 100644 --- a/plugins/builtin/source/content/communication_interface.cpp +++ b/plugins/builtin/source/content/communication_interface.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include diff --git a/plugins/builtin/source/content/data_formatters.cpp b/plugins/builtin/source/content/data_formatters.cpp index 21ead5754..5ddfd6cd4 100644 --- a/plugins/builtin/source/content/data_formatters.cpp +++ b/plugins/builtin/source/content/data_formatters.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/plugins/builtin/source/content/data_information_sections.cpp b/plugins/builtin/source/content/data_information_sections.cpp index 0a6fa08da..946d4bc31 100644 --- a/plugins/builtin/source/content/data_information_sections.cpp +++ b/plugins/builtin/source/content/data_information_sections.cpp @@ -1,4 +1,5 @@ -#include +#include +#include #include #include diff --git a/plugins/builtin/source/content/data_inspector.cpp b/plugins/builtin/source/content/data_inspector.cpp index e158bcecd..94eed486a 100644 --- a/plugins/builtin/source/content/data_inspector.cpp +++ b/plugins/builtin/source/content/data_inspector.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include diff --git a/plugins/builtin/source/content/data_processor_nodes/basic_nodes.cpp b/plugins/builtin/source/content/data_processor_nodes/basic_nodes.cpp index 2a5f793b5..c8118a020 100644 --- a/plugins/builtin/source/content/data_processor_nodes/basic_nodes.cpp +++ b/plugins/builtin/source/content/data_processor_nodes/basic_nodes.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include @@ -263,13 +263,13 @@ namespace hex::plugin::builtin { }; void registerBasicDataProcessorNodes() { - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.constants", "hex.builtin.nodes.constants.int"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.constants", "hex.builtin.nodes.constants.float"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.constants", "hex.builtin.nodes.constants.nullptr"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.constants", "hex.builtin.nodes.constants.buffer"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.constants", "hex.builtin.nodes.constants.string"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.constants", "hex.builtin.nodes.constants.rgba8"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.constants", "hex.builtin.nodes.constants.comment"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.constants", "hex.builtin.nodes.constants.int"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.constants", "hex.builtin.nodes.constants.float"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.constants", "hex.builtin.nodes.constants.nullptr"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.constants", "hex.builtin.nodes.constants.buffer"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.constants", "hex.builtin.nodes.constants.string"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.constants", "hex.builtin.nodes.constants.rgba8"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.constants", "hex.builtin.nodes.constants.comment"); } } diff --git a/plugins/builtin/source/content/data_processor_nodes/control_nodes.cpp b/plugins/builtin/source/content/data_processor_nodes/control_nodes.cpp index 1f71bef58..7f62ba2e2 100644 --- a/plugins/builtin/source/content/data_processor_nodes/control_nodes.cpp +++ b/plugins/builtin/source/content/data_processor_nodes/control_nodes.cpp @@ -1,4 +1,4 @@ -#include +#include #include namespace hex::plugin::builtin { @@ -148,14 +148,14 @@ namespace hex::plugin::builtin { }; void registerControlDataProcessorNodes() { - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.control_flow", "hex.builtin.nodes.control_flow.if"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.control_flow", "hex.builtin.nodes.control_flow.equals"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.control_flow", "hex.builtin.nodes.control_flow.not"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.control_flow", "hex.builtin.nodes.control_flow.gt"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.control_flow", "hex.builtin.nodes.control_flow.lt"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.control_flow", "hex.builtin.nodes.control_flow.and"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.control_flow", "hex.builtin.nodes.control_flow.or"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.control_flow", "hex.builtin.nodes.control_flow.loop"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.control_flow", "hex.builtin.nodes.control_flow.if"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.control_flow", "hex.builtin.nodes.control_flow.equals"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.control_flow", "hex.builtin.nodes.control_flow.not"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.control_flow", "hex.builtin.nodes.control_flow.gt"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.control_flow", "hex.builtin.nodes.control_flow.lt"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.control_flow", "hex.builtin.nodes.control_flow.and"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.control_flow", "hex.builtin.nodes.control_flow.or"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.control_flow", "hex.builtin.nodes.control_flow.loop"); } } diff --git a/plugins/builtin/source/content/data_processor_nodes/decode_nodes.cpp b/plugins/builtin/source/content/data_processor_nodes/decode_nodes.cpp index 7a099dc28..cf31d12b5 100644 --- a/plugins/builtin/source/content/data_processor_nodes/decode_nodes.cpp +++ b/plugins/builtin/source/content/data_processor_nodes/decode_nodes.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include @@ -145,9 +145,9 @@ namespace hex::plugin::builtin { }; void registerDecodeDataProcessorNodes() { - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.decoding", "hex.builtin.nodes.decoding.base64"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.decoding", "hex.builtin.nodes.decoding.hex"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.crypto", "hex.builtin.nodes.crypto.aes"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.decoding", "hex.builtin.nodes.decoding.base64"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.decoding", "hex.builtin.nodes.decoding.hex"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.crypto", "hex.builtin.nodes.crypto.aes"); } } diff --git a/plugins/builtin/source/content/data_processor_nodes/logic_nodes.cpp b/plugins/builtin/source/content/data_processor_nodes/logic_nodes.cpp index e966cb7b9..bd9637e01 100644 --- a/plugins/builtin/source/content/data_processor_nodes/logic_nodes.cpp +++ b/plugins/builtin/source/content/data_processor_nodes/logic_nodes.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -166,14 +166,14 @@ namespace hex::plugin::builtin { }; void registerLogicDataProcessorNodes() { - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.add"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.and"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.or"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.xor"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.not"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.shift_left"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.shift_right"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.swap"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.add"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.and"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.or"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.xor"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.not"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.shift_left"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.shift_right"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.swap"); } } \ No newline at end of file diff --git a/plugins/builtin/source/content/data_processor_nodes/math_nodes.cpp b/plugins/builtin/source/content/data_processor_nodes/math_nodes.cpp index 36337716d..948d9f0b8 100644 --- a/plugins/builtin/source/content/data_processor_nodes/math_nodes.cpp +++ b/plugins/builtin/source/content/data_processor_nodes/math_nodes.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -152,16 +152,16 @@ namespace hex::plugin::builtin { }; void registerMathDataProcessorNodes() { - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.add"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.sub"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.mul"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.div"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.mod"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.average"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.median"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.ceil"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.floor"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.round"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.add"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.sub"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.mul"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.div"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.mod"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.average"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.median"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.ceil"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.floor"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.round"); } } \ No newline at end of file diff --git a/plugins/builtin/source/content/data_processor_nodes/other_nodes.cpp b/plugins/builtin/source/content/data_processor_nodes/other_nodes.cpp index 30799b9c4..22a7c83a5 100644 --- a/plugins/builtin/source/content/data_processor_nodes/other_nodes.cpp +++ b/plugins/builtin/source/content/data_processor_nodes/other_nodes.cpp @@ -1,5 +1,6 @@ #include -#include +#include +#include #include #include @@ -12,6 +13,8 @@ #include #include +#include + namespace hex::plugin::builtin { class NodeReadData : public dp::Node { @@ -461,30 +464,30 @@ namespace hex::plugin::builtin { }; void registerOtherDataProcessorNodes() { - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.data_access", "hex.builtin.nodes.data_access.read"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.data_access", "hex.builtin.nodes.data_access.write"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.data_access", "hex.builtin.nodes.data_access.size"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.data_access", "hex.builtin.nodes.data_access.selection"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.data_access", "hex.builtin.nodes.data_access.read"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.data_access", "hex.builtin.nodes.data_access.write"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.data_access", "hex.builtin.nodes.data_access.size"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.data_access", "hex.builtin.nodes.data_access.selection"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.casting", "hex.builtin.nodes.casting.int_to_buffer"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.casting", "hex.builtin.nodes.casting.buffer_to_int"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.casting", "hex.builtin.nodes.casting.float_to_buffer"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.casting", "hex.builtin.nodes.casting.buffer_to_float"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.casting", "hex.builtin.nodes.casting.int_to_buffer"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.casting", "hex.builtin.nodes.casting.buffer_to_int"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.casting", "hex.builtin.nodes.casting.float_to_buffer"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.casting", "hex.builtin.nodes.casting.buffer_to_float"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.buffer", "hex.builtin.nodes.buffer.combine"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.buffer", "hex.builtin.nodes.buffer.slice"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.buffer", "hex.builtin.nodes.buffer.repeat"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.buffer", "hex.builtin.nodes.buffer.patch"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.buffer", "hex.builtin.nodes.buffer.size"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.buffer", "hex.builtin.nodes.buffer.byte_swap"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.buffer", "hex.builtin.nodes.buffer.combine"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.buffer", "hex.builtin.nodes.buffer.slice"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.buffer", "hex.builtin.nodes.buffer.repeat"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.buffer", "hex.builtin.nodes.buffer.patch"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.buffer", "hex.builtin.nodes.buffer.size"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.buffer", "hex.builtin.nodes.buffer.byte_swap"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.visualizer", "hex.builtin.nodes.visualizer.digram"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.visualizer", "hex.builtin.nodes.visualizer.layered_dist"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.visualizer", "hex.builtin.nodes.visualizer.image"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.visualizer", "hex.builtin.nodes.visualizer.image_rgba"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.visualizer", "hex.builtin.nodes.visualizer.byte_distribution"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.visualizer", "hex.builtin.nodes.visualizer.digram"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.visualizer", "hex.builtin.nodes.visualizer.layered_dist"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.visualizer", "hex.builtin.nodes.visualizer.image"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.visualizer", "hex.builtin.nodes.visualizer.image_rgba"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.visualizer", "hex.builtin.nodes.visualizer.byte_distribution"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.pattern_language", "hex.builtin.nodes.pattern_language.out_var"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.pattern_language", "hex.builtin.nodes.pattern_language.out_var"); } } diff --git a/plugins/builtin/source/content/data_processor_nodes/visual_nodes.cpp b/plugins/builtin/source/content/data_processor_nodes/visual_nodes.cpp index 6f597eb1e..c6bc1aa01 100644 --- a/plugins/builtin/source/content/data_processor_nodes/visual_nodes.cpp +++ b/plugins/builtin/source/content/data_processor_nodes/visual_nodes.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include @@ -184,11 +184,11 @@ namespace hex::plugin::builtin { }; void registerVisualDataProcessorNodes() { - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.display", "hex.builtin.nodes.display.int"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.display", "hex.builtin.nodes.display.float"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.display", "hex.builtin.nodes.display.buffer"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.display", "hex.builtin.nodes.display.string"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.display", "hex.builtin.nodes.display.bits"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.display", "hex.builtin.nodes.display.int"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.display", "hex.builtin.nodes.display.float"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.display", "hex.builtin.nodes.display.buffer"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.display", "hex.builtin.nodes.display.string"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.display", "hex.builtin.nodes.display.bits"); } } diff --git a/plugins/builtin/source/content/data_visualizers.cpp b/plugins/builtin/source/content/data_visualizers.cpp index 8d60dc76e..efc48a9fe 100644 --- a/plugins/builtin/source/content/data_visualizers.cpp +++ b/plugins/builtin/source/content/data_visualizers.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/plugins/builtin/source/content/events.cpp b/plugins/builtin/source/content/events.cpp index 6f59be5fc..fe45a9638 100644 --- a/plugins/builtin/source/content/events.cpp +++ b/plugins/builtin/source/content/events.cpp @@ -7,7 +7,8 @@ #include #include -#include +#include +#include #include #include #include @@ -262,7 +263,7 @@ namespace hex::plugin::builtin { EventFileDropped::subscribe([](const std::fs::path &path) { // Check if a custom file handler can handle the file bool handled = false; - for (const auto &[extensions, handler] : ContentRegistry::FileHandler::impl::getEntries()) { + for (const auto &[extensions, handler] : ContentRegistry::FileTypeHandler::impl::getEntries()) { for (const auto &extension : extensions) { if (path.extension() == extension) { // Pass the file to the handler and check if it was successful diff --git a/plugins/builtin/source/content/file_handlers.cpp b/plugins/builtin/source/content/file_handlers.cpp index 0d74d1eaa..b071bd5a3 100644 --- a/plugins/builtin/source/content/file_handlers.cpp +++ b/plugins/builtin/source/content/file_handlers.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -9,11 +9,11 @@ namespace hex::plugin::builtin { void registerFileHandlers() { - ContentRegistry::FileHandler::add({ ".hexproj" }, [](const std::fs::path &path) { + ContentRegistry::FileTypeHandler::add({ ".hexproj" }, [](const std::fs::path &path) { return ProjectFile::load(path); }); - ContentRegistry::FileHandler::add({ ".hexlyt" }, [](const std::fs::path &path) { + ContentRegistry::FileTypeHandler::add({ ".hexlyt" }, [](const std::fs::path &path) { for (const auto &folder : paths::Layouts.write()) { if (wolv::io::fs::copyFile(path, folder / path.filename())) return true; @@ -22,7 +22,7 @@ namespace hex::plugin::builtin { return false; }); - ContentRegistry::FileHandler::add({ ".mgc" }, [](const auto &path) { + ContentRegistry::FileTypeHandler::add({ ".mgc" }, [](const auto &path) { for (const auto &destPath : paths::Magic.write()) { if (wolv::io::fs::copyFile(path, destPath / path.filename(), std::fs::copy_options::overwrite_existing)) { ui::ToastInfo::open("hex.builtin.view.information.magic_db_added"_lang); diff --git a/plugins/builtin/source/content/init_tasks.cpp b/plugins/builtin/source/content/init_tasks.cpp index a507d52a6..6487747a8 100644 --- a/plugins/builtin/source/content/init_tasks.cpp +++ b/plugins/builtin/source/content/init_tasks.cpp @@ -1,5 +1,6 @@ #include -#include +#include +#include #include #include @@ -37,7 +38,7 @@ namespace hex::plugin::builtin { return; TaskManager::doLater([updateString] { - ContentRegistry::Interface::addTitleBarButton(ICON_VS_ARROW_DOWN, ImGuiCustomCol_ToolbarGreen, "hex.builtin.welcome.update.title", [] { + ContentRegistry::UserInterface::addTitleBarButton(ICON_VS_ARROW_DOWN, ImGuiCustomCol_ToolbarGreen, "hex.builtin.welcome.update.title", [] { ImHexApi::System::updateImHex(ImHexApi::System::isNightlyBuild() ? ImHexApi::System::UpdateType::Nightly : ImHexApi::System::UpdateType::Stable); }); diff --git a/plugins/builtin/source/content/main_menu_items.cpp b/plugins/builtin/source/content/main_menu_items.cpp index 065320c81..2274b3630 100644 --- a/plugins/builtin/source/content/main_menu_items.cpp +++ b/plugins/builtin/source/content/main_menu_items.cpp @@ -1,5 +1,10 @@ #include -#include +#include +#include +#include +#include +#include +#include #include #include @@ -367,10 +372,10 @@ namespace hex::plugin::builtin { static void createFileMenu() { - ContentRegistry::Interface::registerMainMenuItem("hex.builtin.menu.file", 1000); + ContentRegistry::UserInterface::registerMainMenuItem("hex.builtin.menu.file", 1000); /* Create File */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.create_file" }, ICON_VS_FILE, 1050, CTRLCMD + Keys::N + AllowWhileTyping, [] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.create_file" }, ICON_VS_FILE, 1050, CTRLCMD + Keys::N + AllowWhileTyping, [] { auto newProvider = hex::ImHexApi::Provider::createProvider("hex.builtin.provider.mem_file", true); if (newProvider != nullptr && !newProvider->open()) hex::ImHexApi::Provider::remove(newProvider); @@ -379,12 +384,12 @@ namespace hex::plugin::builtin { }, noRunningTasks); /* Open File */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.open_file" }, ICON_VS_FOLDER_OPENED, 1100, CTRLCMD + Keys::O + AllowWhileTyping, [] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.open_file" }, ICON_VS_FOLDER_OPENED, 1100, CTRLCMD + Keys::O + AllowWhileTyping, [] { RequestOpenWindow::post("Open File"); }, noRunningTasks, ContentRegistry::Views::getViewByName("hex.builtin.view.hex_editor.name")); /* Open Other */ - ContentRegistry::Interface::addMenuItemSubMenu({ "hex.builtin.menu.file", "hex.builtin.menu.file.open_other"}, ICON_VS_TELESCOPE, 1150, [] { + ContentRegistry::UserInterface::addMenuItemSubMenu({ "hex.builtin.menu.file", "hex.builtin.menu.file.open_other"}, ICON_VS_TELESCOPE, 1150, [] { for (const auto &[unlocalizedProviderName, icon] : ContentRegistry::Provider::impl::getEntries()) { if (menu::menuItemEx(Lang(unlocalizedProviderName), icon)) ImHexApi::Provider::createProvider(unlocalizedProviderName); @@ -392,7 +397,7 @@ namespace hex::plugin::builtin { }, noRunningTasks); /* Reload Provider */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.reload_provider"}, ICON_VS_REFRESH, 1250, CTRLCMD + Keys::R + AllowWhileTyping, [] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.reload_provider"}, ICON_VS_REFRESH, 1250, CTRLCMD + Keys::R + AllowWhileTyping, [] { auto provider = ImHexApi::Provider::get(); provider->close(); @@ -404,41 +409,41 @@ namespace hex::plugin::builtin { /* Project open / save */ - ContentRegistry::Interface::addMenuItemSubMenu({ "hex.builtin.menu.file", "hex.builtin.menu.file.project" }, ICON_VS_NOTEBOOK, 1400, []{}, noRunningTasks); + ContentRegistry::UserInterface::addMenuItemSubMenu({ "hex.builtin.menu.file", "hex.builtin.menu.file.project" }, ICON_VS_NOTEBOOK, 1400, []{}, noRunningTasks); - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.project", "hex.builtin.menu.file.project.open" }, ICON_VS_ROOT_FOLDER_OPENED, 1410, + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.project", "hex.builtin.menu.file.project.open" }, ICON_VS_ROOT_FOLDER_OPENED, 1410, CTRL + ALT + Keys::O + AllowWhileTyping, openProject, noRunningTasks); - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.project", "hex.builtin.menu.file.project.save" }, ICON_VS_SAVE, 1450, + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.project", "hex.builtin.menu.file.project.save" }, ICON_VS_SAVE, 1450, CTRL + ALT + Keys::S + AllowWhileTyping, saveProject, [&] { return noRunningTaskAndValidProvider() && ProjectFile::hasPath(); }); - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.project", "hex.builtin.menu.file.project.save_as" }, ICON_VS_SAVE_AS, 1500, + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.project", "hex.builtin.menu.file.project.save_as" }, ICON_VS_SAVE_AS, 1500, ALT + SHIFT + Keys::S + AllowWhileTyping, saveProjectAs, noRunningTaskAndValidProvider); - ContentRegistry::Interface::addMenuItemSeparator({ "hex.builtin.menu.file" }, 2000); + ContentRegistry::UserInterface::addMenuItemSeparator({ "hex.builtin.menu.file" }, 2000); /* Import */ { - ContentRegistry::Interface::addMenuItemSubMenu({ "hex.builtin.menu.file", "hex.builtin.menu.file.import" }, ICON_VS_SIGN_IN, 5140, []{}, noRunningTaskAndValidProvider); + ContentRegistry::UserInterface::addMenuItemSubMenu({ "hex.builtin.menu.file", "hex.builtin.menu.file.import" }, ICON_VS_SIGN_IN, 5140, []{}, noRunningTaskAndValidProvider); /* IPS */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.import", "hex.builtin.menu.file.import.ips"}, ICON_VS_GIT_PULL_REQUEST_NEW_CHANGES, 5150, + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.import", "hex.builtin.menu.file.import.ips"}, ICON_VS_GIT_PULL_REQUEST_NEW_CHANGES, 5150, Shortcut::None, importIPSPatch, noRunningTaskAndWritableProvider); /* IPS32 */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.import", "hex.builtin.menu.file.import.ips32"}, ICON_VS_GIT_PULL_REQUEST_NEW_CHANGES, 5200, + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.import", "hex.builtin.menu.file.import.ips32"}, ICON_VS_GIT_PULL_REQUEST_NEW_CHANGES, 5200, Shortcut::None, importIPS32Patch, noRunningTaskAndWritableProvider); /* Modified File */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.import", "hex.builtin.menu.file.import.modified_file" }, ICON_VS_FILES, 5300, + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.import", "hex.builtin.menu.file.import.modified_file" }, ICON_VS_FILES, 5300, Shortcut::None, importModifiedFile, noRunningTaskAndWritableProvider); @@ -447,68 +452,68 @@ namespace hex::plugin::builtin { /* Export */ /* Only make them accessible if the current provider is dumpable */ { - ContentRegistry::Interface::addMenuItemSubMenu({ "hex.builtin.menu.file", "hex.builtin.menu.file.export" }, ICON_VS_SIGN_OUT, 6000, []{}, isProviderDumpable); + ContentRegistry::UserInterface::addMenuItemSubMenu({ "hex.builtin.menu.file", "hex.builtin.menu.file.export" }, ICON_VS_SIGN_OUT, 6000, []{}, isProviderDumpable); /* Selection to File */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.export", "hex.builtin.menu.file.export.selection_to_file" }, ICON_VS_FILE_BINARY, 6010, + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.export", "hex.builtin.menu.file.export.selection_to_file" }, ICON_VS_FILE_BINARY, 6010, Shortcut::None, exportSelectionToFile, ImHexApi::HexEditor::isSelectionValid); /* Base 64 */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.export", "hex.builtin.menu.file.export.base64" }, ICON_VS_NOTE, 6020, + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.export", "hex.builtin.menu.file.export.base64" }, ICON_VS_NOTE, 6020, Shortcut::None, exportBase64, isProviderDumpable); /* Language */ - ContentRegistry::Interface::addMenuItemSubMenu({ "hex.builtin.menu.file", "hex.builtin.menu.file.export", "hex.builtin.menu.file.export.as_language" }, ICON_VS_CODE, 6030, + ContentRegistry::UserInterface::addMenuItemSubMenu({ "hex.builtin.menu.file", "hex.builtin.menu.file.export", "hex.builtin.menu.file.export.as_language" }, ICON_VS_CODE, 6030, drawExportLanguageMenu, isProviderDumpable); /* Report */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.export", "hex.builtin.menu.file.export.report" }, ICON_VS_MARKDOWN, 6040, + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.export", "hex.builtin.menu.file.export.report" }, ICON_VS_MARKDOWN, 6040, Shortcut::None, exportReport, ImHexApi::Provider::isValid); - ContentRegistry::Interface::addMenuItemSeparator({ "hex.builtin.menu.file", "hex.builtin.menu.file.export" }, 6050); + ContentRegistry::UserInterface::addMenuItemSeparator({ "hex.builtin.menu.file", "hex.builtin.menu.file.export" }, 6050); /* IPS */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.export", "hex.builtin.menu.file.export.ips" }, ICON_VS_GIT_PULL_REQUEST_NEW_CHANGES, 6100, + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.export", "hex.builtin.menu.file.export.ips" }, ICON_VS_GIT_PULL_REQUEST_NEW_CHANGES, 6100, Shortcut::None, exportIPSPatch, isProviderDumpable); /* IPS32 */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.export", "hex.builtin.menu.file.export.ips32" }, ICON_VS_GIT_PULL_REQUEST_NEW_CHANGES, 6150, + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.export", "hex.builtin.menu.file.export.ips32" }, ICON_VS_GIT_PULL_REQUEST_NEW_CHANGES, 6150, Shortcut::None, exportIPS32Patch, isProviderDumpable); } - ContentRegistry::Interface::addMenuItemSeparator({ "hex.builtin.menu.file" }, 10000); + ContentRegistry::UserInterface::addMenuItemSeparator({ "hex.builtin.menu.file" }, 10000); /* Close Provider */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.close"}, ICON_VS_CHROME_CLOSE, 10050, CTRLCMD + Keys::W + AllowWhileTyping, [] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.close"}, ICON_VS_CHROME_CLOSE, 10050, CTRLCMD + Keys::W + AllowWhileTyping, [] { ImHexApi::Provider::remove(ImHexApi::Provider::get()); }, noRunningTaskAndValidProvider); /* Quit ImHex */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.quit"}, ICON_VS_CLOSE_ALL, 10100, ALT + Keys::F4 + AllowWhileTyping, [] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.quit"}, ICON_VS_CLOSE_ALL, 10100, ALT + Keys::F4 + AllowWhileTyping, [] { ImHexApi::System::closeImHex(); }); } static void createEditMenu() { - ContentRegistry::Interface::registerMainMenuItem("hex.builtin.menu.edit", 2000); + ContentRegistry::UserInterface::registerMainMenuItem("hex.builtin.menu.edit", 2000); } static void createViewMenu() { - ContentRegistry::Interface::registerMainMenuItem("hex.builtin.menu.view", 3000); + ContentRegistry::UserInterface::registerMainMenuItem("hex.builtin.menu.view", 3000); #if !defined(OS_WEB) - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.view", "hex.builtin.menu.view.always_on_top" }, ICON_VS_PINNED, 1000, Keys::F10 + AllowWhileTyping, [] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.view", "hex.builtin.menu.view.always_on_top" }, ICON_VS_PINNED, 1000, Keys::F10 + AllowWhileTyping, [] { static bool state = false; state = !state; @@ -517,7 +522,7 @@ namespace hex::plugin::builtin { #endif #if !defined(OS_MACOS) && !defined(OS_WEB) - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.view", "hex.builtin.menu.view.fullscreen" }, ICON_VS_SCREEN_FULL, 2000, Keys::F11 + AllowWhileTyping, [] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.view", "hex.builtin.menu.view.fullscreen" }, ICON_VS_SCREEN_FULL, 2000, Keys::F11 + AllowWhileTyping, [] { static bool state = false; static ImVec2 position, size; @@ -542,10 +547,10 @@ namespace hex::plugin::builtin { #endif #if !defined(OS_WEB) - ContentRegistry::Interface::addMenuItemSeparator({ "hex.builtin.menu.view" }, 3000); + ContentRegistry::UserInterface::addMenuItemSeparator({ "hex.builtin.menu.view" }, 3000); #endif - ContentRegistry::Interface::addMenuItemSubMenu({ "hex.builtin.menu.view" }, 4000, [] { + ContentRegistry::UserInterface::addMenuItemSubMenu({ "hex.builtin.menu.view" }, 4000, [] { for (auto &[name, view] : ContentRegistry::Views::impl::getEntries()) { if (view->hasViewMenuItemEntry()) { auto &state = view->getWindowOpenState(); @@ -561,15 +566,15 @@ namespace hex::plugin::builtin { static void createLayoutMenu() { LayoutManager::reload(); - ContentRegistry::Interface::addMenuItemSubMenu({ "hex.builtin.menu.workspace", "hex.builtin.menu.workspace.layout" }, ICON_VS_LAYOUT, 1050, []{}, ImHexApi::Provider::isValid); + ContentRegistry::UserInterface::addMenuItemSubMenu({ "hex.builtin.menu.workspace", "hex.builtin.menu.workspace.layout" }, ICON_VS_LAYOUT, 1050, []{}, ImHexApi::Provider::isValid); - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.workspace", "hex.builtin.menu.workspace.layout", "hex.builtin.menu.workspace.layout.save" }, 1100, Shortcut::None, [] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.workspace", "hex.builtin.menu.workspace.layout", "hex.builtin.menu.workspace.layout.save" }, 1100, Shortcut::None, [] { ui::PopupTextInput::open("hex.builtin.popup.save_layout.title", "hex.builtin.popup.save_layout.desc", [](const std::string &name) { LayoutManager::save(name); }); }, ImHexApi::Provider::isValid); - ContentRegistry::Interface::addMenuItemSubMenu({ "hex.builtin.menu.workspace", "hex.builtin.menu.workspace.layout" }, ICON_VS_LAYOUT, 1150, [] { + ContentRegistry::UserInterface::addMenuItemSubMenu({ "hex.builtin.menu.workspace", "hex.builtin.menu.workspace.layout" }, ICON_VS_LAYOUT, 1150, [] { bool locked = LayoutManager::isLayoutLocked(); if (menu::menuItemEx("hex.builtin.menu.workspace.layout.lock"_lang, ICON_VS_LOCK, Shortcut::None, locked, ImHexApi::Provider::isValid())) { LayoutManager::lockLayout(!locked); @@ -577,9 +582,9 @@ namespace hex::plugin::builtin { } }); - ContentRegistry::Interface::addMenuItemSeparator({ "hex.builtin.menu.workspace", "hex.builtin.menu.workspace.layout" }, 1200); + ContentRegistry::UserInterface::addMenuItemSeparator({ "hex.builtin.menu.workspace", "hex.builtin.menu.workspace.layout" }, 1200); - ContentRegistry::Interface::addMenuItemSubMenu({ "hex.builtin.menu.workspace", "hex.builtin.menu.workspace.layout" }, 2000, [] { + ContentRegistry::UserInterface::addMenuItemSubMenu({ "hex.builtin.menu.workspace", "hex.builtin.menu.workspace.layout" }, 2000, [] { for (const auto &path : romfs::list("layouts")) { if (menu::menuItem(wolv::util::capitalizeString(path.stem().string()).c_str(), Shortcut::None, false, ImHexApi::Provider::isValid())) { LayoutManager::loadFromString(std::string(romfs::get(path).string())); @@ -601,19 +606,19 @@ namespace hex::plugin::builtin { } static void createWorkspaceMenu() { - ContentRegistry::Interface::registerMainMenuItem("hex.builtin.menu.workspace", 4000); + ContentRegistry::UserInterface::registerMainMenuItem("hex.builtin.menu.workspace", 4000); createLayoutMenu(); - ContentRegistry::Interface::addMenuItemSeparator({ "hex.builtin.menu.workspace" }, 3000); + ContentRegistry::UserInterface::addMenuItemSeparator({ "hex.builtin.menu.workspace" }, 3000); - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.workspace", "hex.builtin.menu.workspace.create" }, ICON_VS_ADD, 3100, Shortcut::None, [] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.workspace", "hex.builtin.menu.workspace.create" }, ICON_VS_ADD, 3100, Shortcut::None, [] { ui::PopupTextInput::open("hex.builtin.popup.create_workspace.title", "hex.builtin.popup.create_workspace.desc", [](const std::string &name) { WorkspaceManager::createWorkspace(name); }); }, ImHexApi::Provider::isValid); - ContentRegistry::Interface::addMenuItemSubMenu({ "hex.builtin.menu.workspace" }, 3200, [] { + ContentRegistry::UserInterface::addMenuItemSubMenu({ "hex.builtin.menu.workspace" }, 3200, [] { const auto &workspaces = WorkspaceManager::getWorkspaces(); bool shiftPressed = ImGui::GetIO().KeyShift; @@ -634,11 +639,11 @@ namespace hex::plugin::builtin { } static void createExtrasMenu() { - ContentRegistry::Interface::registerMainMenuItem("hex.builtin.menu.extras", 5000); + ContentRegistry::UserInterface::registerMainMenuItem("hex.builtin.menu.extras", 5000); - ContentRegistry::Interface::addMenuItemSeparator({ "hex.builtin.menu.extras" }, 2600); + ContentRegistry::UserInterface::addMenuItemSeparator({ "hex.builtin.menu.extras" }, 2600); - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.extras", "hex.builtin.menu.extras.check_for_update" }, ICON_VS_SYNC, 2700, Shortcut::None, [] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.extras", "hex.builtin.menu.extras.check_for_update" }, ICON_VS_SYNC, 2700, Shortcut::None, [] { TaskManager::createBackgroundTask("Checking for updates", [] { auto versionString = ImHexApi::System::checkForUpdate(); if (!versionString.has_value()) { @@ -653,18 +658,18 @@ namespace hex::plugin::builtin { }); if (ImHexApi::System::isNightlyBuild()) { - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.extras", "hex.builtin.menu.extras.switch_to_stable" }, ICON_VS_ROCKET, 2750, Shortcut::None, [] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.extras", "hex.builtin.menu.extras.switch_to_stable" }, ICON_VS_ROCKET, 2750, Shortcut::None, [] { ImHexApi::System::updateImHex(ImHexApi::System::UpdateType::Stable); }); } else { - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.extras", "hex.builtin.menu.extras.switch_to_nightly" }, ICON_VS_ROCKET, 2750, Shortcut::None, [] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.extras", "hex.builtin.menu.extras.switch_to_nightly" }, ICON_VS_ROCKET, 2750, Shortcut::None, [] { ImHexApi::System::updateImHex(ImHexApi::System::UpdateType::Nightly); }); } } static void createHelpMenu() { - ContentRegistry::Interface::registerMainMenuItem("hex.builtin.menu.help", 6000); + ContentRegistry::UserInterface::registerMainMenuItem("hex.builtin.menu.help", 6000); } diff --git a/plugins/builtin/source/content/minimap_visualizers.cpp b/plugins/builtin/source/content/minimap_visualizers.cpp index de435b52b..416970040 100644 --- a/plugins/builtin/source/content/minimap_visualizers.cpp +++ b/plugins/builtin/source/content/minimap_visualizers.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -9,9 +9,6 @@ #include #include -#include - - namespace hex::plugin::builtin { namespace { diff --git a/plugins/builtin/source/content/out_of_box_experience.cpp b/plugins/builtin/source/content/out_of_box_experience.cpp index 612ae7dcd..3aa5ed403 100644 --- a/plugins/builtin/source/content/out_of_box_experience.cpp +++ b/plugins/builtin/source/content/out_of_box_experience.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include diff --git a/plugins/builtin/source/content/pl_builtin_functions.cpp b/plugins/builtin/source/content/pl_builtin_functions.cpp index 31fd4ecc8..dd0c06b88 100644 --- a/plugins/builtin/source/content/pl_builtin_functions.cpp +++ b/plugins/builtin/source/content/pl_builtin_functions.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include diff --git a/plugins/builtin/source/content/pl_builtin_types.cpp b/plugins/builtin/source/content/pl_builtin_types.cpp index 790663a54..421bbc00e 100644 --- a/plugins/builtin/source/content/pl_builtin_types.cpp +++ b/plugins/builtin/source/content/pl_builtin_types.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/plugins/builtin/source/content/pl_pragmas.cpp b/plugins/builtin/source/content/pl_pragmas.cpp index 8ff9066b1..c6e8f6235 100644 --- a/plugins/builtin/source/content/pl_pragmas.cpp +++ b/plugins/builtin/source/content/pl_pragmas.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include diff --git a/plugins/builtin/source/content/pl_visualizers.cpp b/plugins/builtin/source/content/pl_visualizers.cpp index a6f3978c2..ddf2eded1 100644 --- a/plugins/builtin/source/content/pl_visualizers.cpp +++ b/plugins/builtin/source/content/pl_visualizers.cpp @@ -1,4 +1,4 @@ -#include +#include #include diff --git a/plugins/builtin/source/content/popups/hex_editor/popup_hex_editor_find.cpp b/plugins/builtin/source/content/popups/hex_editor/popup_hex_editor_find.cpp index ce16d8a27..e34831101 100644 --- a/plugins/builtin/source/content/popups/hex_editor/popup_hex_editor_find.cpp +++ b/plugins/builtin/source/content/popups/hex_editor/popup_hex_editor_find.cpp @@ -2,6 +2,7 @@ #include "content/views/view_hex_editor.hpp" +#include #include #include #include diff --git a/plugins/builtin/source/content/project.cpp b/plugins/builtin/source/content/project.cpp index 669133a38..472836514 100644 --- a/plugins/builtin/source/content/project.cpp +++ b/plugins/builtin/source/content/project.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include diff --git a/plugins/builtin/source/content/providers.cpp b/plugins/builtin/source/content/providers.cpp index d704bb352..347159f9e 100644 --- a/plugins/builtin/source/content/providers.cpp +++ b/plugins/builtin/source/content/providers.cpp @@ -1,4 +1,4 @@ -#include +#include #include "content/providers/gdb_provider.hpp" #include "content/providers/file_provider.hpp" diff --git a/plugins/builtin/source/content/providers/file_provider.cpp b/plugins/builtin/source/content/providers/file_provider.cpp index 1e782d0ad..b5f4fe1ca 100644 --- a/plugins/builtin/source/content/providers/file_provider.cpp +++ b/plugins/builtin/source/content/providers/file_provider.cpp @@ -1,7 +1,7 @@ #include "content/providers/file_provider.hpp" #include "content/providers/memory_file_provider.hpp" -#include +#include #include #include #include diff --git a/plugins/builtin/source/content/recent.cpp b/plugins/builtin/source/content/recent.cpp index 3f5a60eb4..d0d2e37b7 100644 --- a/plugins/builtin/source/content/recent.cpp +++ b/plugins/builtin/source/content/recent.cpp @@ -3,7 +3,8 @@ #include #include -#include +#include +#include #include #include #include @@ -359,7 +360,7 @@ namespace hex::plugin::builtin::recent { return; #endif - ContentRegistry::Interface::addMenuItemSubMenu({ "hex.builtin.menu.file" }, 1200, [] { + ContentRegistry::UserInterface::addMenuItemSubMenu({ "hex.builtin.menu.file" }, 1200, [] { if (menu::beginMenuEx("hex.builtin.menu.file.open_recent"_lang, ICON_VS_ARCHIVE, !recent::s_recentEntriesUpdating && !s_recentEntries.empty())) { // Copy to avoid changing list while iteration auto recentEntries = s_recentEntries; diff --git a/plugins/builtin/source/content/report_generators.cpp b/plugins/builtin/source/content/report_generators.cpp index 983c77809..f0f1aa9d3 100644 --- a/plugins/builtin/source/content/report_generators.cpp +++ b/plugins/builtin/source/content/report_generators.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/plugins/builtin/source/content/settings_entries.cpp b/plugins/builtin/source/content/settings_entries.cpp index a1f2e66b8..dab50b11f 100644 --- a/plugins/builtin/source/content/settings_entries.cpp +++ b/plugins/builtin/source/content/settings_entries.cpp @@ -1,5 +1,8 @@ #include -#include +#include +#include +#include +#include #include #include #include @@ -412,7 +415,7 @@ namespace hex::plugin::builtin { bool draw(const std::string &) override { bool changed = false; - const auto currIndex = std::ranges::count_if(ContentRegistry::Interface::impl::getMenuItems(), [](const auto &entry) { + const auto currIndex = std::ranges::count_if(ContentRegistry::UserInterface::impl::getMenuItems(), [](const auto &entry) { return entry.second.toolbarIndex != -1; }); @@ -429,7 +432,7 @@ namespace hex::plugin::builtin { ImGui::TableNextColumn(); // Loop over all available menu items - for (auto &[priority, menuItem] : ContentRegistry::Interface::impl::getMenuItems()) { + for (auto &[priority, menuItem] : ContentRegistry::UserInterface::impl::getMenuItems()) { ImGui::PushID(&menuItem); ON_SCOPE_EXIT { ImGui::PopID(); }; @@ -441,9 +444,9 @@ namespace hex::plugin::builtin { const auto &unlocalizedName = menuItem.unlocalizedNames.back(); if (menuItem.unlocalizedNames.size() > 2) continue; - if (unlocalizedName.get() == ContentRegistry::Interface::impl::SeparatorValue) + if (unlocalizedName.get() == ContentRegistry::UserInterface::impl::SeparatorValue) continue; - if (unlocalizedName.get() == ContentRegistry::Interface::impl::SubMenuValue) + if (unlocalizedName.get() == ContentRegistry::UserInterface::impl::SubMenuValue) continue; if (menuItem.toolbarIndex != -1) continue; @@ -478,7 +481,7 @@ namespace hex::plugin::builtin { // Handle dropping menu items from the toolbar box if (ImGui::BeginDragDropTarget()) { if (auto payload = ImGui::AcceptDragDropPayload("TOOLBAR_ITEM_PAYLOAD"); payload != nullptr) { - auto &menuItem = *static_cast(payload->Data); + auto &menuItem = *static_cast(payload->Data); menuItem->toolbarIndex = -1; changed = true; @@ -497,8 +500,8 @@ namespace hex::plugin::builtin { ImGui::TableNextRow(); // Find all menu items that are in the toolbar and sort them by their toolbar index - std::vector toolbarItems; - for (auto &[priority, menuItem] : ContentRegistry::Interface::impl::getMenuItemsMutable()) { + std::vector toolbarItems; + for (auto &[priority, menuItem] : ContentRegistry::UserInterface::impl::getMenuItemsMutable()) { if (menuItem.toolbarIndex == -1) continue; @@ -520,7 +523,7 @@ namespace hex::plugin::builtin { const auto &unlocalizedName = menuItem->unlocalizedNames.back(); if (menuItem->unlocalizedNames.size() > 2) continue; - if (unlocalizedName.get() == ContentRegistry::Interface::impl::SubMenuValue) + if (unlocalizedName.get() == ContentRegistry::UserInterface::impl::SubMenuValue) continue; if (menuItem->toolbarIndex == -1) continue; @@ -542,10 +545,10 @@ namespace hex::plugin::builtin { // Handle dropping toolbar items onto each other to reorder them if (ImGui::BeginDragDropTarget()) { if (auto payload = ImGui::AcceptDragDropPayload("TOOLBAR_ITEM_PAYLOAD"); payload != nullptr) { - auto &otherMenuItem = *static_cast(payload->Data); + auto &otherMenuItem = *static_cast(payload->Data); // Get all toolbar items sorted by toolbarIndex - std::vector newToolbarItems = toolbarItems; + std::vector newToolbarItems = toolbarItems; // Remove otherMenuItem from its current position auto it = std::ranges::find(newToolbarItems, otherMenuItem); @@ -636,7 +639,7 @@ namespace hex::plugin::builtin { // Handle dropping menu items onto the toolbar box if (ImGui::BeginDragDropTarget()) { if (auto payload = ImGui::AcceptDragDropPayload("MENU_ITEM_PAYLOAD"); payload != nullptr) { - auto &menuItem = *static_cast(payload->Data); + auto &menuItem = *static_cast(payload->Data); menuItem->toolbarIndex = currIndex; changed = true; @@ -649,7 +652,7 @@ namespace hex::plugin::builtin { } if (changed) { - ContentRegistry::Interface::updateToolbarItems(); + ContentRegistry::UserInterface::updateToolbarItems(); } return changed; @@ -658,7 +661,7 @@ namespace hex::plugin::builtin { nlohmann::json store() override { std::map> items; - for (const auto &[priority, menuItem] : ContentRegistry::Interface::impl::getMenuItems()) { + for (const auto &[priority, menuItem] : ContentRegistry::UserInterface::impl::getMenuItems()) { if (menuItem.toolbarIndex != -1) items.emplace(menuItem.toolbarIndex, std::make_pair(menuItem.unlocalizedNames.back().get(), menuItem.icon.color)); } @@ -673,14 +676,14 @@ namespace hex::plugin::builtin { if (data.is_array() && data.empty()) return; - for (auto &[priority, menuItem] : ContentRegistry::Interface::impl::getMenuItemsMutable()) + for (auto &[priority, menuItem] : ContentRegistry::UserInterface::impl::getMenuItemsMutable()) menuItem.toolbarIndex = -1; auto toolbarItems = data.get>>(); if (toolbarItems.empty()) return; - for (auto &[priority, menuItem] : ContentRegistry::Interface::impl::getMenuItemsMutable()) { + for (auto &[priority, menuItem] : ContentRegistry::UserInterface::impl::getMenuItemsMutable()) { for (const auto &[index, value] : toolbarItems) { const auto &[name, color] = value; if (menuItem.unlocalizedNames.back().get() == name) { @@ -691,7 +694,7 @@ namespace hex::plugin::builtin { } } - ContentRegistry::Interface::updateToolbarItems(); + ContentRegistry::UserInterface::updateToolbarItems(); } }; diff --git a/plugins/builtin/source/content/tools/ieee_decoder.cpp b/plugins/builtin/source/content/tools/ieee_decoder.cpp index d325ddf5e..52c9b6620 100644 --- a/plugins/builtin/source/content/tools/ieee_decoder.cpp +++ b/plugins/builtin/source/content/tools/ieee_decoder.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include diff --git a/plugins/builtin/source/content/tools/wiki_explainer.cpp b/plugins/builtin/source/content/tools/wiki_explainer.cpp index 3eeb5dd0c..113c6447d 100644 --- a/plugins/builtin/source/content/tools/wiki_explainer.cpp +++ b/plugins/builtin/source/content/tools/wiki_explainer.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/plugins/builtin/source/content/tools_entries.cpp b/plugins/builtin/source/content/tools_entries.cpp index 24e42882d..d6580937c 100644 --- a/plugins/builtin/source/content/tools_entries.cpp +++ b/plugins/builtin/source/content/tools_entries.cpp @@ -1,4 +1,4 @@ -#include +#include #include diff --git a/plugins/builtin/source/content/ui_items.cpp b/plugins/builtin/source/content/ui_items.cpp index d5cc68058..e78cd003c 100644 --- a/plugins/builtin/source/content/ui_items.cpp +++ b/plugins/builtin/source/content/ui_items.cpp @@ -1,4 +1,5 @@ -#include +#include +#include #include #include #include @@ -29,7 +30,7 @@ namespace hex::plugin::builtin { void addTitleBarButtons() { if (dbg::debugModeEnabled()) { - ContentRegistry::Interface::addTitleBarButton(ICON_VS_DEBUG, ImGuiCustomCol_ToolbarGray, "hex.builtin.title_bar_button.debug_build", []{ + ContentRegistry::UserInterface::addTitleBarButton(ICON_VS_DEBUG, ImGuiCustomCol_ToolbarGray, "hex.builtin.title_bar_button.debug_build", []{ if (ImGui::GetIO().KeyShift) { RequestOpenPopup::post("DebugMenu"); } else { @@ -38,7 +39,7 @@ namespace hex::plugin::builtin { }); } - ContentRegistry::Interface::addTitleBarButton(ICON_VS_SMILEY, ImGuiCustomCol_ToolbarGray, "hex.builtin.title_bar_button.feedback", []{ + ContentRegistry::UserInterface::addTitleBarButton(ICON_VS_SMILEY, ImGuiCustomCol_ToolbarGray, "hex.builtin.title_bar_button.feedback", []{ hex::openWebpage("https://github.com/WerWolv/ImHex/discussions/categories/feedback"); }); @@ -223,7 +224,7 @@ namespace hex::plugin::builtin { void addFooterItems() { if (hex::isProcessElevated()) { - ContentRegistry::Interface::addFooterItem([] { + ContentRegistry::UserInterface::addFooterItem([] { ImGui::PushStyleColor(ImGuiCol_Text, ImGuiExt::GetCustomColorU32(ImGuiCustomCol_Highlight)); ImGui::TextUnformatted(ICON_VS_SHIELD); ImGui::PopStyleColor(); @@ -231,7 +232,7 @@ namespace hex::plugin::builtin { } if (dbg::debugModeEnabled()) { - ContentRegistry::Interface::addFooterItem([] { + ContentRegistry::UserInterface::addFooterItem([] { static float framerate = 0; if (ImGuiExt::HasSecondPassed()) { framerate = 1.0F / ImGui::GetIO().DeltaTime; @@ -273,7 +274,7 @@ namespace hex::plugin::builtin { }); } - ContentRegistry::Interface::addFooterItem([] { + ContentRegistry::UserInterface::addFooterItem([] { static bool shouldResetProgress = false; auto taskCount = TaskManager::getRunningTaskCount(); @@ -452,11 +453,11 @@ namespace hex::plugin::builtin { }); // Toolbar items - ContentRegistry::Interface::addToolbarItem([] { + ContentRegistry::UserInterface::addToolbarItem([] { - for (const auto &menuItem : ContentRegistry::Interface::impl::getToolbarMenuItems()) { + for (const auto &menuItem : ContentRegistry::UserInterface::impl::getToolbarMenuItems()) { const auto &unlocalizedItemName = menuItem->unlocalizedNames.back(); - if (unlocalizedItemName.get() == ContentRegistry::Interface::impl::SeparatorValue) { + if (unlocalizedItemName.get() == ContentRegistry::UserInterface::impl::SeparatorValue) { ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical); continue; } @@ -472,7 +473,7 @@ namespace hex::plugin::builtin { }); // Provider switcher - ContentRegistry::Interface::addToolbarItem([] { + ContentRegistry::UserInterface::addToolbarItem([] { const bool providerValid = ImHexApi::Provider::get() != nullptr; const bool tasksRunning = TaskManager::getRunningTaskCount() > 0; @@ -549,13 +550,13 @@ namespace hex::plugin::builtin { }); EventImHexStartupFinished::subscribe([] { - ContentRegistry::Interface::addMenuItemToToolbar("hex.builtin.view.hex_editor.menu.edit.undo", ImGuiCustomCol_ToolbarBlue); - ContentRegistry::Interface::addMenuItemToToolbar("hex.builtin.view.hex_editor.menu.edit.redo", ImGuiCustomCol_ToolbarBlue); - ContentRegistry::Interface::addMenuItemToToolbar("hex.builtin.menu.file.create_file", ImGuiCustomCol_ToolbarGray); - ContentRegistry::Interface::addMenuItemToToolbar("hex.builtin.menu.file.open_file", ImGuiCustomCol_ToolbarBrown); - ContentRegistry::Interface::addMenuItemToToolbar("hex.builtin.view.hex_editor.menu.file.save", ImGuiCustomCol_ToolbarBlue); - ContentRegistry::Interface::addMenuItemToToolbar("hex.builtin.view.hex_editor.menu.file.save_as", ImGuiCustomCol_ToolbarBlue); - ContentRegistry::Interface::addMenuItemToToolbar("hex.builtin.menu.edit.bookmark.create", ImGuiCustomCol_ToolbarGreen); + ContentRegistry::UserInterface::addMenuItemToToolbar("hex.builtin.view.hex_editor.menu.edit.undo", ImGuiCustomCol_ToolbarBlue); + ContentRegistry::UserInterface::addMenuItemToToolbar("hex.builtin.view.hex_editor.menu.edit.redo", ImGuiCustomCol_ToolbarBlue); + ContentRegistry::UserInterface::addMenuItemToToolbar("hex.builtin.menu.file.create_file", ImGuiCustomCol_ToolbarGray); + ContentRegistry::UserInterface::addMenuItemToToolbar("hex.builtin.menu.file.open_file", ImGuiCustomCol_ToolbarBrown); + ContentRegistry::UserInterface::addMenuItemToToolbar("hex.builtin.view.hex_editor.menu.file.save", ImGuiCustomCol_ToolbarBlue); + ContentRegistry::UserInterface::addMenuItemToToolbar("hex.builtin.view.hex_editor.menu.file.save_as", ImGuiCustomCol_ToolbarBlue); + ContentRegistry::UserInterface::addMenuItemToToolbar("hex.builtin.menu.edit.bookmark.create", ImGuiCustomCol_ToolbarGreen); }); } diff --git a/plugins/builtin/source/content/views/fullscreen/view_fullscreen_save_editor.cpp b/plugins/builtin/source/content/views/fullscreen/view_fullscreen_save_editor.cpp index 204f8edc6..4167813d5 100644 --- a/plugins/builtin/source/content/views/fullscreen/view_fullscreen_save_editor.cpp +++ b/plugins/builtin/source/content/views/fullscreen/view_fullscreen_save_editor.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include #include diff --git a/plugins/builtin/source/content/views/view_about.cpp b/plugins/builtin/source/content/views/view_about.cpp index 9aa796f16..3d2aec9e0 100644 --- a/plugins/builtin/source/content/views/view_about.cpp +++ b/plugins/builtin/source/content/views/view_about.cpp @@ -2,7 +2,7 @@ #include "hex/ui/popup.hpp" #include -#include +#include #include #include @@ -11,16 +11,15 @@ #include #include #include - -#include +#include #include #include #include +#include #include -#include namespace hex::plugin::builtin { @@ -80,13 +79,13 @@ namespace hex::plugin::builtin { ViewAbout::ViewAbout() : View::Modal("hex.builtin.view.help.about.name", ICON_VS_HEART) { // Add "About" menu item to the help menu - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.help", "hex.builtin.view.help.about.name" }, ICON_VS_INFO, 1000, Shortcut::None, [this] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.help", "hex.builtin.view.help.about.name" }, ICON_VS_INFO, 1000, Shortcut::None, [this] { this->getWindowOpenState() = true; }); - ContentRegistry::Interface::addMenuItemSeparator({ "hex.builtin.menu.help" }, 2000); + ContentRegistry::UserInterface::addMenuItemSeparator({ "hex.builtin.menu.help" }, 2000); - ContentRegistry::Interface::addMenuItemSubMenu({ "hex.builtin.menu.help" }, 3000, [] { + ContentRegistry::UserInterface::addMenuItemSubMenu({ "hex.builtin.menu.help" }, 3000, [] { if (menu::isNativeMenuBarUsed()) return; @@ -100,11 +99,11 @@ namespace hex::plugin::builtin { ImGui::PopStyleVar(); }); - ContentRegistry::Interface::addMenuItemSeparator({ "hex.builtin.menu.help" }, 4000); + ContentRegistry::UserInterface::addMenuItemSeparator({ "hex.builtin.menu.help" }, 4000); // Add documentation link to the help menu - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.help", "hex.builtin.view.help.documentation" }, ICON_VS_BOOK, 5000, Shortcut::None, [] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.help", "hex.builtin.view.help.documentation" }, ICON_VS_BOOK, 5000, Shortcut::None, [] { hex::openWebpage("https://docs.werwolv.net/imhex"); AchievementManager::unlockAchievement("hex.builtin.achievement.starting_out", "hex.builtin.achievement.starting_out.docs.name"); }); diff --git a/plugins/builtin/source/content/views/view_achievements.cpp b/plugins/builtin/source/content/views/view_achievements.cpp index 4cc36e022..fc04eedd8 100644 --- a/plugins/builtin/source/content/views/view_achievements.cpp +++ b/plugins/builtin/source/content/views/view_achievements.cpp @@ -1,6 +1,7 @@ #include "content/views/view_achievements.hpp" -#include +#include +#include #include #include #include @@ -14,7 +15,7 @@ namespace hex::plugin::builtin { ViewAchievements::ViewAchievements() : View::Floating("hex.builtin.view.achievements.name", ICON_VS_SPARKLE) { // Add achievements menu item to Extas menu - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.extras", "hex.builtin.view.achievements.name" }, ICON_VS_SPARKLE, 2600, Shortcut::None, [&, this] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.extras", "hex.builtin.view.achievements.name" }, ICON_VS_SPARKLE, 2600, Shortcut::None, [&, this] { this->getWindowOpenState() = true; }); diff --git a/plugins/builtin/source/content/views/view_bookmarks.cpp b/plugins/builtin/source/content/views/view_bookmarks.cpp index 047ccbeae..73805a6a2 100644 --- a/plugins/builtin/source/content/views/view_bookmarks.cpp +++ b/plugins/builtin/source/content/views/view_bookmarks.cpp @@ -1,6 +1,8 @@ #include "content/views/view_bookmarks.hpp" -#include +#include +#include +#include #include #include #include @@ -600,7 +602,7 @@ namespace hex::plugin::builtin { void ViewBookmarks::registerMenuItems() { /* Create bookmark */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.menu.edit.bookmark.create" }, ICON_VS_BOOKMARK, 1900, CTRLCMD + Keys::B, [&] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.menu.edit.bookmark.create" }, ICON_VS_BOOKMARK, 1900, CTRLCMD + Keys::B, [&] { if (!ImHexApi::HexEditor::isSelectionValid()) return; @@ -610,10 +612,10 @@ namespace hex::plugin::builtin { ContentRegistry::Views::getViewByName("hex.builtin.view.hex_editor.name")); - ContentRegistry::Interface::addMenuItemSeparator({ "hex.builtin.menu.file", "hex.builtin.menu.file.import" }, 5400); + ContentRegistry::UserInterface::addMenuItemSeparator({ "hex.builtin.menu.file", "hex.builtin.menu.file.import" }, 5400); /* Import bookmarks */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.import", "hex.builtin.menu.file.import.bookmark" }, ICON_VS_BOOKMARK, 5500, Shortcut::None, [this]{ + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.import", "hex.builtin.menu.file.import.bookmark" }, ICON_VS_BOOKMARK, 5500, Shortcut::None, [this]{ fs::openFileBrowser(fs::DialogMode::Open, { { "Bookmarks File", "hexbm"} }, [&, this](const std::fs::path &path) { try { this->importBookmarks(ImHexApi::Provider::get(), nlohmann::json::parse(wolv::io::File(path, wolv::io::File::Mode::Read).readString())); @@ -621,11 +623,11 @@ namespace hex::plugin::builtin { }); }, ImHexApi::Provider::isValid); - ContentRegistry::Interface::addMenuItemSeparator({ "hex.builtin.menu.file", "hex.builtin.menu.file.export" }, 6200); + ContentRegistry::UserInterface::addMenuItemSeparator({ "hex.builtin.menu.file", "hex.builtin.menu.file.export" }, 6200); /* Export bookmarks */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.export", "hex.builtin.menu.file.export.bookmark" }, ICON_VS_BOOKMARK, 6250, Shortcut::None, [this]{ + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.export", "hex.builtin.menu.file.export.bookmark" }, ICON_VS_BOOKMARK, 6250, Shortcut::None, [this]{ fs::openFileBrowser(fs::DialogMode::Save, { { "Bookmarks File", "hexbm"} }, [&, this](const std::fs::path &path) { nlohmann::json json; this->exportBookmarks(ImHexApi::Provider::get(), json); diff --git a/plugins/builtin/source/content/views/view_command_palette.cpp b/plugins/builtin/source/content/views/view_command_palette.cpp index 6aae2e851..7f89cb3d7 100644 --- a/plugins/builtin/source/content/views/view_command_palette.cpp +++ b/plugins/builtin/source/content/views/view_command_palette.cpp @@ -1,6 +1,6 @@ #include "content/views/view_command_palette.hpp" -#include +#include #include #include #include @@ -177,7 +177,7 @@ namespace hex::plugin::builtin { std::vector results; // Loop over every registered command and check if the input matches it - for (const auto &[type, command, unlocalizedDescription, displayCallback, executeCallback] : ContentRegistry::CommandPaletteCommands::impl::getEntries()) { + for (const auto &[type, command, unlocalizedDescription, displayCallback, executeCallback] : ContentRegistry::CommandPalette::impl::getEntries()) { auto AutoComplete = [this, currCommand = command](auto) { this->focusInputTextBox(); @@ -187,7 +187,7 @@ namespace hex::plugin::builtin { return std::nullopt; }; - if (type == ContentRegistry::CommandPaletteCommands::Type::SymbolCommand) { + if (type == ContentRegistry::CommandPalette::Type::SymbolCommand) { // Handle symbol commands // These commands are used by entering a single symbol and then any input @@ -199,7 +199,7 @@ namespace hex::plugin::builtin { results.push_back({ displayCallback(matchedCommand), matchedCommand, executeCallback }); } } - } else if (type == ContentRegistry::CommandPaletteCommands::Type::KeywordCommand) { + } else if (type == ContentRegistry::CommandPalette::Type::KeywordCommand) { // Handle keyword commands // These commands are used by entering a keyword followed by a space and then any input @@ -215,7 +215,7 @@ namespace hex::plugin::builtin { } // WHen a command has been identified, show the query results for that command - for (const auto &handler : ContentRegistry::CommandPaletteCommands::impl::getHandlers()) { + for (const auto &handler : ContentRegistry::CommandPalette::impl::getHandlers()) { const auto &[type, command, queryCallback, displayCallback] = handler; auto processedInput = input; @@ -223,11 +223,11 @@ namespace hex::plugin::builtin { processedInput = wolv::util::trim(processedInput.substr(command.length())); for (const auto &[description, callback] : queryCallback(processedInput)) { - if (type == ContentRegistry::CommandPaletteCommands::Type::SymbolCommand) { + if (type == ContentRegistry::CommandPalette::Type::SymbolCommand) { if (auto [match, value] = MatchCommand(input, command); match != MatchType::NoMatch) { results.push_back({ fmt::format("{} ({})", command, description), "", [callback](auto ... args){ callback(args...); return std::nullopt; } }); } - } else if (type == ContentRegistry::CommandPaletteCommands::Type::KeywordCommand) { + } else if (type == ContentRegistry::CommandPalette::Type::KeywordCommand) { if (auto [match, value] = MatchCommand(input, command + " "); match != MatchType::NoMatch) { results.push_back({ fmt::format("{} ({})", command, description), "", [callback](auto ... args){ callback(args...); return std::nullopt; } }); } diff --git a/plugins/builtin/source/content/views/view_data_inspector.cpp b/plugins/builtin/source/content/views/view_data_inspector.cpp index 09bdccc33..c3cd1ad07 100644 --- a/plugins/builtin/source/content/views/view_data_inspector.cpp +++ b/plugins/builtin/source/content/views/view_data_inspector.cpp @@ -1,6 +1,7 @@ #include "content/views/view_data_inspector.hpp" #include +#include #include #include #include diff --git a/plugins/builtin/source/content/views/view_data_processor.cpp b/plugins/builtin/source/content/views/view_data_processor.cpp index 1642ceffc..2d5243b9f 100644 --- a/plugins/builtin/source/content/views/view_data_processor.cpp +++ b/plugins/builtin/source/content/views/view_data_processor.cpp @@ -1,7 +1,9 @@ #include "content/views/view_data_processor.hpp" #include -#include +#include +#include +#include #include #include @@ -355,9 +357,9 @@ namespace hex::plugin::builtin { }; ViewDataProcessor::ViewDataProcessor() : View::Window("hex.builtin.view.data_processor.name", ICON_VS_CHIP) { - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.custom", "hex.builtin.nodes.custom.custom", this); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.custom", "hex.builtin.nodes.custom.input"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.custom", "hex.builtin.nodes.custom.output"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.custom", "hex.builtin.nodes.custom.custom", this); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.custom", "hex.builtin.nodes.custom.input"); + ContentRegistry::DataProcessor::add("hex.builtin.nodes.custom", "hex.builtin.nodes.custom.output"); ProjectFile::registerPerProviderHandler({ .basePath = "data_processor.json", @@ -398,7 +400,7 @@ namespace hex::plugin::builtin { }); /* Import Nodes */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.import", "hex.builtin.menu.file.import.data_processor" }, ICON_VS_CHIP, 5600, Shortcut::None, [this]{ + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.import", "hex.builtin.menu.file.import.data_processor" }, ICON_VS_CHIP, 5600, Shortcut::None, [this]{ fs::openFileBrowser(fs::DialogMode::Open, { {"hex.builtin.view.data_processor.name"_lang, "hexnode" } }, [&](const std::fs::path &path) { wolv::io::File file(path, wolv::io::File::Mode::Read); @@ -410,7 +412,7 @@ namespace hex::plugin::builtin { }, ImHexApi::Provider::isValid); /* Export Nodes */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.export", "hex.builtin.menu.file.export.data_processor" }, ICON_VS_CHIP, 8050, Shortcut::None, [this]{ + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.export", "hex.builtin.menu.file.export.data_processor" }, ICON_VS_CHIP, 8050, Shortcut::None, [this]{ fs::openFileBrowser(fs::DialogMode::Save, { {"hex.builtin.view.data_processor.name"_lang, "hexnode" } }, [&, this](const std::fs::path &path) { wolv::io::File file(path, wolv::io::File::Mode::Create); @@ -421,7 +423,7 @@ namespace hex::plugin::builtin { return ImHexApi::Provider::isValid() && !m_workspaceStack->empty() && !m_workspaceStack->back()->nodes.empty(); }); - ContentRegistry::FileHandler::add({ ".hexnode" }, [this](const auto &path) { + ContentRegistry::FileTypeHandler::add({ ".hexnode" }, [this](const auto &path) { wolv::io::File file(path, wolv::io::File::Mode::Read); if (!file.isValid()) return false; @@ -685,7 +687,7 @@ namespace hex::plugin::builtin { } // Draw all nodes that are registered in the content registry - for (const auto &[unlocalizedCategory, unlocalizedName, function] : ContentRegistry::DataProcessorNode::impl::getEntries()) { + for (const auto &[unlocalizedCategory, unlocalizedName, function] : ContentRegistry::DataProcessor::impl::getEntries()) { if (unlocalizedCategory.empty() && unlocalizedName.empty()) { // Draw a separator if the node has no category and no name ImGui::Separator(); @@ -1147,7 +1149,7 @@ namespace hex::plugin::builtin { std::unique_ptr ViewDataProcessor::loadNode(nlohmann::json data) { try { - auto &nodeEntries = ContentRegistry::DataProcessorNode::impl::getEntries(); + auto &nodeEntries = ContentRegistry::DataProcessor::impl::getEntries(); std::unique_ptr newNode; for (auto &entry : nodeEntries) { diff --git a/plugins/builtin/source/content/views/view_hex_editor.cpp b/plugins/builtin/source/content/views/view_hex_editor.cpp index 3aa900333..9d5092962 100644 --- a/plugins/builtin/source/content/views/view_hex_editor.cpp +++ b/plugins/builtin/source/content/views/view_hex_editor.cpp @@ -1,6 +1,9 @@ #include "content/views/view_hex_editor.hpp" -#include +#include +#include +#include +#include #include #include #include @@ -1195,7 +1198,7 @@ namespace hex::plugin::builtin { showSelectionInWindowFooter = !show; }); - ContentRegistry::Interface::addFooterItem([] { + ContentRegistry::UserInterface::addFooterItem([] { if (!showSelectionInWindowFooter) return; if (auto selection = ImHexApi::HexEditor::getSelection(); selection.has_value()) { @@ -1210,23 +1213,23 @@ namespace hex::plugin::builtin { void ViewHexEditor::registerMenuItems() { /* Undo */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.undo" }, ICON_VS_DISCARD, 1000, CTRLCMD + Keys::Z, [] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.undo" }, ICON_VS_DISCARD, 1000, CTRLCMD + Keys::Z, [] { auto provider = ImHexApi::Provider::get(); provider->undo(); }, [&] { return ImHexApi::Provider::isValid() && ImHexApi::Provider::get()->canUndo(); }, this); /* Redo */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.redo" }, ICON_VS_REDO, 1050, CTRLCMD + Keys::Y, [] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.redo" }, ICON_VS_REDO, 1050, CTRLCMD + Keys::Y, [] { auto provider = ImHexApi::Provider::get(); provider->redo(); }, [&] { return ImHexApi::Provider::isValid() && ImHexApi::Provider::get()->canRedo(); }, this); - ContentRegistry::Interface::addMenuItemSeparator({ "hex.builtin.menu.file" }, 1300); + ContentRegistry::UserInterface::addMenuItemSeparator({ "hex.builtin.menu.file" }, 1300); /* Save */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.view.hex_editor.menu.file.save" }, ICON_VS_SAVE, 1350, + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.view.hex_editor.menu.file.save" }, ICON_VS_SAVE, 1350, CTRLCMD + Keys::S, save, [] { @@ -1238,7 +1241,7 @@ namespace hex::plugin::builtin { this); /* Save As */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.view.hex_editor.menu.file.save_as" }, ICON_VS_SAVE_AS, 1375, + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.view.hex_editor.menu.file.save_as" }, ICON_VS_SAVE_AS, 1375, CTRLCMD + SHIFT + Keys::S, saveAs, [] { @@ -1250,7 +1253,7 @@ namespace hex::plugin::builtin { this); /* Load Encoding File */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.import", "hex.builtin.menu.file.import.custom_encoding" }, "あ", 5700, Shortcut::None, + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.import", "hex.builtin.menu.file.import.custom_encoding" }, "あ", 5700, Shortcut::None, [this]{ const auto basePaths = paths::Encodings.read(); std::vector paths; @@ -1278,10 +1281,10 @@ namespace hex::plugin::builtin { ImHexApi::Provider::isValid, this); - ContentRegistry::Interface::addMenuItemSeparator({ "hex.builtin.menu.file" }, 1500, this); + ContentRegistry::UserInterface::addMenuItemSeparator({ "hex.builtin.menu.file" }, 1500, this); /* Search */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.view.hex_editor.menu.file.search" }, ICON_VS_SEARCH, 1550, + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.view.hex_editor.menu.file.search" }, ICON_VS_SEARCH, 1550, CTRLCMD + Keys::F, [this] { this->openPopup(this); @@ -1290,7 +1293,7 @@ namespace hex::plugin::builtin { this); /* Goto */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.view.hex_editor.menu.file.goto" }, ICON_VS_DEBUG_STEP_INTO, 1600, + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.view.hex_editor.menu.file.goto" }, ICON_VS_DEBUG_STEP_INTO, 1600, CTRLCMD + Keys::G, [this] { this->openPopup(); @@ -1299,12 +1302,12 @@ namespace hex::plugin::builtin { this); /* Skip until */ - ContentRegistry::Interface::addMenuItemSubMenu({ "hex.builtin.menu.file", "hex.builtin.view.hex_editor.menu.file.skip_until" }, ICON_VS_DEBUG_STEP_OVER, 1610, + ContentRegistry::UserInterface::addMenuItemSubMenu({ "hex.builtin.menu.file", "hex.builtin.view.hex_editor.menu.file.skip_until" }, ICON_VS_DEBUG_STEP_OVER, 1610, []{}, canSearchForDifferingByte); /* Skip until previous differing byte */ - ContentRegistry::Interface::addMenuItem({ + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.view.hex_editor.menu.file.skip_until", "hex.builtin.view.hex_editor.menu.file.skip_until.previous_differing_byte" @@ -1343,7 +1346,7 @@ namespace hex::plugin::builtin { canSearchForDifferingByte); /* Skip until next differing byte */ - ContentRegistry::Interface::addMenuItem({ + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.view.hex_editor.menu.file.skip_until", "hex.builtin.view.hex_editor.menu.file.skip_until.next_differing_byte" @@ -1382,10 +1385,10 @@ namespace hex::plugin::builtin { canSearchForDifferingByte); - ContentRegistry::Interface::addMenuItemSeparator({ "hex.builtin.menu.edit" }, 1100, this); + ContentRegistry::UserInterface::addMenuItemSeparator({ "hex.builtin.menu.edit" }, 1100, this); /* Copy */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.copy" }, ICON_VS_COPY, 1150, + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.copy" }, ICON_VS_COPY, 1150, CurrentView + CTRLCMD + Keys::C, [] { auto selection = ImHexApi::HexEditor::getSelection(); @@ -1395,10 +1398,10 @@ namespace hex::plugin::builtin { ImHexApi::HexEditor::isSelectionValid, this); - ContentRegistry::Interface::addMenuItemSubMenu({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.copy_as" }, ICON_VS_PREVIEW, 1190, []{}, ImHexApi::HexEditor::isSelectionValid, this); + ContentRegistry::UserInterface::addMenuItemSubMenu({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.copy_as" }, ICON_VS_PREVIEW, 1190, []{}, ImHexApi::HexEditor::isSelectionValid, this); /* Copy As */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.copy_as", "hex.builtin.view.hex_editor.copy.ascii" }, ICON_VS_SYMBOL_KEY, 1200, + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.copy_as", "hex.builtin.view.hex_editor.copy.ascii" }, ICON_VS_SYMBOL_KEY, 1200, CurrentView + CTRLCMD + ALT + Keys::C, [] { auto selection = ImHexApi::HexEditor::getSelection(); @@ -1409,7 +1412,7 @@ namespace hex::plugin::builtin { this); /* Copy address */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.copy_as", "hex.builtin.view.hex_editor.copy.address" }, ICON_VS_LOCATION, 1250, + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.copy_as", "hex.builtin.view.hex_editor.copy.address" }, ICON_VS_LOCATION, 1250, Shortcut::None, [] { auto selection = ImHexApi::HexEditor::getSelection(); @@ -1420,7 +1423,7 @@ namespace hex::plugin::builtin { this); /* Copy custom encoding */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.copy_as", "hex.builtin.view.hex_editor.copy.custom_encoding" }, "あ", 1300, + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.copy_as", "hex.builtin.view.hex_editor.copy.custom_encoding" }, "あ", 1300, SHIFT + ALT + Keys::C, [this] { auto selection = ImHexApi::HexEditor::getSelection(); @@ -1433,10 +1436,10 @@ namespace hex::plugin::builtin { }, this); - ContentRegistry::Interface::addMenuItemSeparator({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.copy_as" }, 1350, this); + ContentRegistry::UserInterface::addMenuItemSeparator({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.copy_as" }, 1350, this); /* Copy as... */ - ContentRegistry::Interface::addMenuItemSubMenu({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.copy_as" }, ICON_VS_FILE_CODE, 1400, []{ + ContentRegistry::UserInterface::addMenuItemSubMenu({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.copy_as" }, ICON_VS_FILE_CODE, 1400, []{ auto selection = ImHexApi::HexEditor::getSelection(); auto provider = ImHexApi::Provider::get(); @@ -1476,7 +1479,7 @@ namespace hex::plugin::builtin { }, this); /* Paste */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.paste" }, ICON_VS_OUTPUT, 1450, CurrentView + CTRLCMD + Keys::V, + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.paste" }, ICON_VS_OUTPUT, 1450, CurrentView + CTRLCMD + Keys::V, [this] { processPasteBehaviour(ImHexApi::HexEditor::getSelection().value_or( ImHexApi::HexEditor::ProviderRegion(Region { 0, 0 }, ImHexApi::Provider::get()))); }, @@ -1484,10 +1487,10 @@ namespace hex::plugin::builtin { this); /* Paste... */ - ContentRegistry::Interface::addMenuItemSubMenu({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.paste_as" }, ICON_VS_CLIPPY, 1490, []{}, ImHexApi::HexEditor::isSelectionValid, this); + ContentRegistry::UserInterface::addMenuItemSubMenu({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.paste_as" }, ICON_VS_CLIPPY, 1490, []{}, ImHexApi::HexEditor::isSelectionValid, this); /* Paste... > Paste all */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.paste_as", "hex.builtin.view.hex_editor.menu.edit.paste_all" }, ICON_VS_CLIPPY, 1500, CurrentView + CTRLCMD + SHIFT + Keys::V, + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.paste_as", "hex.builtin.view.hex_editor.menu.edit.paste_all" }, ICON_VS_CLIPPY, 1500, CurrentView + CTRLCMD + SHIFT + Keys::V, [] { pasteBytes(ImHexApi::HexEditor::getSelection().value_or( ImHexApi::HexEditor::ProviderRegion(Region { 0, 0 }, ImHexApi::Provider::get())), false, false); }, @@ -1495,7 +1498,7 @@ namespace hex::plugin::builtin { this); /* Paste... > Paste all as string */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.paste_as", "hex.builtin.view.hex_editor.menu.edit.paste_all_string" }, ICON_VS_SYMBOL_KEY, 1510, + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.paste_as", "hex.builtin.view.hex_editor.menu.edit.paste_all_string" }, ICON_VS_SYMBOL_KEY, 1510, Shortcut::None, [] { pasteBytes(ImHexApi::HexEditor::getSelection().value_or( ImHexApi::HexEditor::ProviderRegion(Region { 0, 0 }, ImHexApi::Provider::get())), false, true); @@ -1504,7 +1507,7 @@ namespace hex::plugin::builtin { this); /* Select */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.select" }, ICON_VS_LIST_SELECTION, 1525, + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.select" }, ICON_VS_LIST_SELECTION, 1525, CTRLCMD + SHIFT + Keys::A, [this] { auto selection = ImHexApi::HexEditor::getSelection().value_or(ImHexApi::HexEditor::ProviderRegion{ { 0, 1 }, nullptr }); @@ -1514,7 +1517,7 @@ namespace hex::plugin::builtin { this); /* Select All */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.select_all" }, ICON_VS_LIST_FLAT, 1550, CurrentView + CTRLCMD + Keys::A, + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.select_all" }, ICON_VS_LIST_FLAT, 1550, CurrentView + CTRLCMD + Keys::A, [] { auto provider = ImHexApi::Provider::get(); ImHexApi::HexEditor::setSelection(provider->getBaseAddress(), provider->getActualSize()); @@ -1523,10 +1526,10 @@ namespace hex::plugin::builtin { this); - ContentRegistry::Interface::addMenuItemSeparator({ "hex.builtin.menu.edit" }, 1600, this); + ContentRegistry::UserInterface::addMenuItemSeparator({ "hex.builtin.menu.edit" }, 1600, this); /* Set Base Address */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.set_base" }, ICON_VS_LOCATION, 1650, Shortcut::None, + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.set_base" }, ICON_VS_LOCATION, 1650, Shortcut::None, [this] { auto provider = ImHexApi::Provider::get(); this->openPopup(provider->getBaseAddress()); @@ -1535,7 +1538,7 @@ namespace hex::plugin::builtin { this); /* Resize */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.resize" }, ICON_VS_ARROW_BOTH, 1700, Shortcut::None, + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.resize" }, ICON_VS_ARROW_BOTH, 1700, Shortcut::None, [this] { auto provider = ImHexApi::Provider::get(); this->openPopup(provider->getActualSize()); @@ -1544,7 +1547,7 @@ namespace hex::plugin::builtin { this); /* Insert */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.insert" }, ICON_VS_INSERT, 1750, Shortcut::None, + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.insert" }, ICON_VS_INSERT, 1750, Shortcut::None, [this] { auto selection = ImHexApi::HexEditor::getSelection(); @@ -1554,7 +1557,7 @@ namespace hex::plugin::builtin { this); /* Remove */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.remove" }, ICON_VS_CLEAR_ALL, 1800, Shortcut::None, + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.remove" }, ICON_VS_CLEAR_ALL, 1800, Shortcut::None, [this] { auto selection = ImHexApi::HexEditor::getSelection(); @@ -1564,7 +1567,7 @@ namespace hex::plugin::builtin { this); /* Fill */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.fill" }, ICON_VS_PAINTCAN, 1810, Shortcut::None, + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.fill" }, ICON_VS_PAINTCAN, 1810, Shortcut::None, [this] { auto selection = ImHexApi::HexEditor::getSelection(); @@ -1574,7 +1577,7 @@ namespace hex::plugin::builtin { this); /* Toggle Overwrite/Insert mode */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.insert_mode" }, ICON_VS_EDIT, 1820, Shortcut::None, + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.insert_mode" }, ICON_VS_EDIT, 1820, Shortcut::None, [this] { if (m_hexEditor.getMode() == ui::HexEditor::Mode::Insert) m_hexEditor.setMode(ui::HexEditor::Mode::Overwrite); @@ -1593,7 +1596,7 @@ namespace hex::plugin::builtin { this); /* Jump to */ - ContentRegistry::Interface::addMenuItemSubMenu({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.jump_to" }, ICON_VS_DEBUG_STEP_OUT, 1850, + ContentRegistry::UserInterface::addMenuItemSubMenu({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.jump_to" }, ICON_VS_DEBUG_STEP_OUT, 1850, [] { auto provider = ImHexApi::Provider::get(); if (provider == nullptr) @@ -1639,7 +1642,7 @@ namespace hex::plugin::builtin { this); /* Set Page Size */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.set_page_size" }, ICON_VS_BROWSER, 1860, Shortcut::None, + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.set_page_size" }, ICON_VS_BROWSER, 1860, Shortcut::None, [this] { auto provider = ImHexApi::Provider::get(); this->openPopup(provider->getPageSize()); @@ -1647,10 +1650,10 @@ namespace hex::plugin::builtin { [] { return ImHexApi::Provider::isValid() && ImHexApi::Provider::get()->isReadable(); }, this); - ContentRegistry::Interface::addMenuItemSeparator({ "hex.builtin.menu.edit" }, 1900, this); + ContentRegistry::UserInterface::addMenuItemSeparator({ "hex.builtin.menu.edit" }, 1900, this); /* Open in new provider */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.open_in_new_provider" }, ICON_VS_GO_TO_FILE, 1950, Shortcut::None, + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.hex_editor.menu.edit.open_in_new_provider" }, ICON_VS_GO_TO_FILE, 1950, Shortcut::None, [] { auto selection = ImHexApi::HexEditor::getSelection(); diff --git a/plugins/builtin/source/content/views/view_highlight_rules.cpp b/plugins/builtin/source/content/views/view_highlight_rules.cpp index fed815fdc..12301e97c 100644 --- a/plugins/builtin/source/content/views/view_highlight_rules.cpp +++ b/plugins/builtin/source/content/views/view_highlight_rules.cpp @@ -1,15 +1,16 @@ #include "content/views/view_highlight_rules.hpp" -#include +#include +#include #include #include #include -#include - -#include - #include +#include +#include +#include + namespace hex::plugin::builtin { @@ -115,7 +116,7 @@ namespace hex::plugin::builtin { ViewHighlightRules::ViewHighlightRules() : View::Floating("hex.builtin.view.highlight_rules.name", ICON_VS_TAG) { - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.highlight_rules.menu.edit.rules" }, ICON_VS_TAG, 1950, Shortcut::None, [&, this] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.highlight_rules.menu.edit.rules" }, ICON_VS_TAG, 1950, Shortcut::None, [&, this] { this->getWindowOpenState() = true; }, ImHexApi::Provider::isValid, ContentRegistry::Views::getViewByName("hex.builtin.view.hex_editor.name")); diff --git a/plugins/builtin/source/content/views/view_information.cpp b/plugins/builtin/source/content/views/view_information.cpp index 4ec15d5c5..efa5fc746 100644 --- a/plugins/builtin/source/content/views/view_information.cpp +++ b/plugins/builtin/source/content/views/view_information.cpp @@ -1,15 +1,16 @@ #include "content/views/view_information.hpp" -#include +#include #include #include #include - #include #include +#include + namespace hex::plugin::builtin { using namespace hex::literals; diff --git a/plugins/builtin/source/content/views/view_logs.cpp b/plugins/builtin/source/content/views/view_logs.cpp index 92dbfdb9e..4f04ccfbf 100644 --- a/plugins/builtin/source/content/views/view_logs.cpp +++ b/plugins/builtin/source/content/views/view_logs.cpp @@ -1,6 +1,6 @@ #include "content/views/view_logs.hpp" -#include +#include #include #include @@ -8,7 +8,7 @@ namespace hex::plugin::builtin { ViewLogs::ViewLogs() : View::Floating("hex.builtin.view.logs.name", ICON_VS_DEBUG_LINE_BY_LINE) { - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.extras", "hex.builtin.view.logs.name" }, ICON_VS_BRACKET_ERROR, 2500, Shortcut::None, [&, this] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.extras", "hex.builtin.view.logs.name" }, ICON_VS_BRACKET_ERROR, 2500, Shortcut::None, [&, this] { this->getWindowOpenState() = true; }); } diff --git a/plugins/builtin/source/content/views/view_pattern_data.cpp b/plugins/builtin/source/content/views/view_pattern_data.cpp index 69c1edac0..f3a60a862 100644 --- a/plugins/builtin/source/content/views/view_pattern_data.cpp +++ b/plugins/builtin/source/content/views/view_pattern_data.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include #include #include diff --git a/plugins/builtin/source/content/views/view_pattern_editor.cpp b/plugins/builtin/source/content/views/view_pattern_editor.cpp index 5bf38ae69..96eb71789 100644 --- a/plugins/builtin/source/content/views/view_pattern_editor.cpp +++ b/plugins/builtin/source/content/views/view_pattern_editor.cpp @@ -1,7 +1,11 @@ #include "content/views/view_pattern_editor.hpp" #include -#include +#include +#include +#include +#include +#include #include #include @@ -1994,13 +1998,13 @@ namespace hex::plugin::builtin { /* Open File */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.view.pattern_editor.menu.file.open_pattern" }, ICON_VS_FOLDER_OPENED, 1100, AllowWhileTyping + CTRLCMD + Keys::O, [this] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.view.pattern_editor.menu.file.open_pattern" }, ICON_VS_FOLDER_OPENED, 1100, AllowWhileTyping + CTRLCMD + Keys::O, [this] { m_openPatternFile(true); }, [] { return ImHexApi::Provider::isValid(); }, this); /* Save */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.view.pattern_editor.menu.file.save_pattern" }, ICON_VS_SAVE, 1350, AllowWhileTyping + CTRLCMD + Keys::S, [this] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.view.pattern_editor.menu.file.save_pattern" }, ICON_VS_SAVE, 1350, AllowWhileTyping + CTRLCMD + Keys::S, [this] { m_savePatternFile(true); },[this] { auto provider = ImHexApi::Provider::get(); @@ -2011,24 +2015,24 @@ namespace hex::plugin::builtin { this); /* Save As */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.view.pattern_editor.menu.file.save_pattern_as" }, ICON_VS_SAVE_AS, 1375, AllowWhileTyping + CTRLCMD + SHIFT + Keys::S, [this] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.view.pattern_editor.menu.file.save_pattern_as" }, ICON_VS_SAVE_AS, 1375, AllowWhileTyping + CTRLCMD + SHIFT + Keys::S, [this] { m_savePatternAsFile(true); },[] { return ImHexApi::Provider::isValid(); }, this); - ContentRegistry::Interface::addMenuItemSeparator({ "hex.builtin.menu.file" }, 1500, this); + ContentRegistry::UserInterface::addMenuItemSeparator({ "hex.builtin.menu.file" }, 1500, this); /* Find */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.view.pattern_editor.menu.find" }, ICON_VS_SEARCH, 1510, AllowWhileTyping + CTRLCMD + Keys::F, [this] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.view.pattern_editor.menu.find" }, ICON_VS_SEARCH, 1510, AllowWhileTyping + CTRLCMD + Keys::F, [this] { m_replaceMode = false; m_openFindReplacePopUp = true; }, [] { return true; }, this); /* Find Next */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.view.pattern_editor.menu.find_next" }, 1520, AllowWhileTyping + Keys::F3, [this] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.view.pattern_editor.menu.find_next" }, 1520, AllowWhileTyping + Keys::F3, [this] { if (auto editor = getEditorFromFocusedWindow(); editor != nullptr) { ui::TextEditor::FindReplaceHandler *findReplaceHandler = editor->getFindReplaceHandler(); findReplaceHandler->findMatch(editor, true); @@ -2046,7 +2050,7 @@ namespace hex::plugin::builtin { this); /* Find Previous */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.view.pattern_editor.menu.find_previous" }, 1530, AllowWhileTyping + SHIFT + Keys::F3, [this] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.view.pattern_editor.menu.find_previous" }, 1530, AllowWhileTyping + SHIFT + Keys::F3, [this] { if (auto editor = getEditorFromFocusedWindow(); editor != nullptr) { ui::TextEditor::FindReplaceHandler *findReplaceHandler = editor->getFindReplaceHandler(); findReplaceHandler->findMatch(editor, false); @@ -2064,74 +2068,74 @@ namespace hex::plugin::builtin { this); /* Replace */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.view.pattern_editor.menu.replace" }, ICON_VS_REPLACE, 1540, AllowWhileTyping + CTRLCMD + Keys::H, [this] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.view.pattern_editor.menu.replace" }, ICON_VS_REPLACE, 1540, AllowWhileTyping + CTRLCMD + Keys::H, [this] { m_replaceMode = true; m_openFindReplacePopUp = true; }, [this] { return m_focusedSubWindowName.contains(textEditorView); }, this); /* Replace Next */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.view.pattern_editor.menu.replace_next" }, 1550, Shortcut::None, [this] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.view.pattern_editor.menu.replace_next" }, 1550, Shortcut::None, [this] { m_textEditor->getFindReplaceHandler()->replace(&*m_textEditor, true); }, [this] { return ImHexApi::Provider::isValid() && !m_textEditor->getFindReplaceHandler()->getReplaceWord().empty() && m_focusedSubWindowName.contains(textEditorView); }, []{ return false; }, this); /* Replace Previous */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.view.pattern_editor.menu.replace_previous" }, 1560, Shortcut::None, [this] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.view.pattern_editor.menu.replace_previous" }, 1560, Shortcut::None, [this] { m_textEditor->getFindReplaceHandler()->replace(&*m_textEditor, false); }, [this] { return ImHexApi::Provider::isValid() && !m_textEditor->getFindReplaceHandler()->getReplaceWord().empty() && m_focusedSubWindowName.contains(textEditorView); }, []{ return false; }, this); /* Replace All */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.view.pattern_editor.menu.replace_all" }, ICON_VS_REPLACE_ALL, 1570, Shortcut::None, [this] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.view.pattern_editor.menu.replace_all" }, ICON_VS_REPLACE_ALL, 1570, Shortcut::None, [this] { m_textEditor->getFindReplaceHandler()->replaceAll(&*m_textEditor); }, [this] { return ImHexApi::Provider::isValid() && !m_textEditor->getFindReplaceHandler()->getReplaceWord().empty() && m_focusedSubWindowName.contains(textEditorView); }, this); /* Goto Line */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.view.pattern_editor.menu.goto_line" }, ICON_VS_DEBUG_STEP_INTO, 1600, AllowWhileTyping + CTRLCMD + Keys::G, [this] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.view.pattern_editor.menu.goto_line" }, ICON_VS_DEBUG_STEP_INTO, 1600, AllowWhileTyping + CTRLCMD + Keys::G, [this] { m_openGotoLinePopUp = true; }, [] { return true; }, this); /* Import Pattern */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.import", "hex.builtin.menu.file.import.pattern" }, ICON_VS_FILE_CODE, 5600, Shortcut::None, [this] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.import", "hex.builtin.menu.file.import.pattern" }, ICON_VS_FILE_CODE, 5600, Shortcut::None, [this] { m_openPatternFile(false); }, ImHexApi::Provider::isValid); /* Export Pattern */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.export", "hex.builtin.menu.file.export.pattern" }, ICON_VS_FILE_CODE, 7050, Shortcut::None, [this] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.export", "hex.builtin.menu.file.export.pattern" }, ICON_VS_FILE_CODE, 7050, Shortcut::None, [this] { m_savePatternFile(false); }, [this] { return ImHexApi::Provider::isValid() && !wolv::util::trim(m_textEditor->getText()).empty(); }); /* Undo */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.pattern_editor.menu.edit.undo" }, ICON_VS_DISCARD, 1250, AllowWhileTyping + CTRLCMD + Keys::Z, [this] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.pattern_editor.menu.edit.undo" }, ICON_VS_DISCARD, 1250, AllowWhileTyping + CTRLCMD + Keys::Z, [this] { m_textEditor->undo(); }, [this] { return ImHexApi::Provider::isValid() && m_textEditor->canUndo() && m_focusedSubWindowName.contains(textEditorView); }, this); /* Redo */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.pattern_editor.menu.edit.redo" }, ICON_VS_REDO, 1275, AllowWhileTyping + CTRLCMD + Keys::Y, [this] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.pattern_editor.menu.edit.redo" }, ICON_VS_REDO, 1275, AllowWhileTyping + CTRLCMD + Keys::Y, [this] { m_textEditor->redo(); }, [this] { return ImHexApi::Provider::isValid() && m_textEditor->canRedo() && m_focusedSubWindowName.contains(textEditorView); }, this); - ContentRegistry::Interface::addMenuItemSeparator({ "hex.builtin.menu.edit" }, 1280, this); + ContentRegistry::UserInterface::addMenuItemSeparator({ "hex.builtin.menu.edit" }, 1280, this); /* Cut */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.pattern_editor.menu.edit.cut" }, ICON_VS_COMBINE, 1300, AllowWhileTyping + CTRLCMD + Keys::X, [this] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.pattern_editor.menu.edit.cut" }, ICON_VS_COMBINE, 1300, AllowWhileTyping + CTRLCMD + Keys::X, [this] { m_textEditor->cut(); }, [this] { return ImHexApi::Provider::isValid() && m_textEditor->hasSelection() && m_focusedSubWindowName.contains(textEditorView); }, this); /* Copy */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.pattern_editor.menu.edit.copy" }, ICON_VS_COPY, 1400, AllowWhileTyping + CTRLCMD + Keys::C, [this] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.pattern_editor.menu.edit.copy" }, ICON_VS_COPY, 1400, AllowWhileTyping + CTRLCMD + Keys::C, [this] { if (auto editor = getEditorFromFocusedWindow(); editor != nullptr) { editor->copy(); } else { @@ -2146,23 +2150,23 @@ namespace hex::plugin::builtin { this); /* Paste */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.pattern_editor.menu.edit.paste" }, ICON_VS_OUTPUT, 1500, AllowWhileTyping + CTRLCMD + Keys::V, [this] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.pattern_editor.menu.edit.paste" }, ICON_VS_OUTPUT, 1500, AllowWhileTyping + CTRLCMD + Keys::V, [this] { m_textEditor->paste(); }, [this] { return m_focusedSubWindowName.contains(textEditorView); }, this); /* Select All */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.pattern_editor.menu.edit.select_all" }, ICON_VS_LIST_FLAT, 1650, AllowWhileTyping + CTRLCMD + Keys::A, [this] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.pattern_editor.menu.edit.select_all" }, ICON_VS_LIST_FLAT, 1650, AllowWhileTyping + CTRLCMD + Keys::A, [this] { if (auto editor = getEditorFromFocusedWindow(); editor != nullptr) editor->selectAll(); }, [] { return ImHexApi::Provider::isValid(); }, this); - ContentRegistry::Interface::addMenuItemSeparator({ "hex.builtin.menu.edit" }, 1700, this); + ContentRegistry::UserInterface::addMenuItemSeparator({ "hex.builtin.menu.edit" }, 1700, this); /* Add Breakpoint */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.pattern_editor.menu.edit.add_breakpoint"}, ICON_VS_DEBUG_BREAKPOINT_DATA, 1750, Keys::F8 + AllowWhileTyping, [this] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.view.pattern_editor.menu.edit.add_breakpoint"}, ICON_VS_DEBUG_BREAKPOINT_DATA, 1750, Keys::F8 + AllowWhileTyping, [this] { const auto line = m_textEditor.get(ImHexApi::Provider::get()).getCursorPosition().m_line + 1; const auto &runtime = ContentRegistry::PatternLanguage::getRuntime(); @@ -2181,7 +2185,7 @@ namespace hex::plugin::builtin { this); /* Trigger Evaluation */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.edit","hex.builtin.view.pattern_editor.menu.edit.run_pattern" }, ICON_VS_PLAY, 1800, Keys::F5 + AllowWhileTyping, [this] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.edit","hex.builtin.view.pattern_editor.menu.edit.run_pattern" }, ICON_VS_PLAY, 1800, Keys::F5 + AllowWhileTyping, [this] { auto &runtime = ContentRegistry::PatternLanguage::getRuntime(); if (runtime.isRunning()) { m_breakpointHit = false; @@ -2192,7 +2196,7 @@ namespace hex::plugin::builtin { this); /* Continue debugger */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.edit","hex.builtin.view.pattern_editor.menu.edit.continue_debugger"}, ICON_VS_DEBUG_CONTINUE, 1850, SHIFT + Keys::F9 + AllowWhileTyping, [this] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.edit","hex.builtin.view.pattern_editor.menu.edit.continue_debugger"}, ICON_VS_DEBUG_CONTINUE, 1850, SHIFT + Keys::F9 + AllowWhileTyping, [this] { const auto &runtime = ContentRegistry::PatternLanguage::getRuntime(); if (runtime.isRunning()) m_breakpointHit = false; @@ -2200,7 +2204,7 @@ namespace hex::plugin::builtin { this); /* Step debugger */ - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.edit","hex.builtin.view.pattern_editor.menu.edit.step_debugger" },ICON_VS_DEBUG_STEP_INTO, 1900, SHIFT + Keys::F7 + AllowWhileTyping, [this] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.edit","hex.builtin.view.pattern_editor.menu.edit.step_debugger" },ICON_VS_DEBUG_STEP_INTO, 1900, SHIFT + Keys::F7 + AllowWhileTyping, [this] { const auto &runtime = ContentRegistry::PatternLanguage::getRuntime(); if (runtime.isRunning()) { runtime.getInternals().evaluator->pauseNextLine(); @@ -2217,7 +2221,7 @@ namespace hex::plugin::builtin { }}; /* Place pattern... */ - ContentRegistry::Interface::addMenuItemSubMenu({ "hex.builtin.menu.edit", "hex.builtin.view.pattern_editor.menu.edit.place_pattern" }, ICON_VS_LIBRARY, 3000, + ContentRegistry::UserInterface::addMenuItemSubMenu({ "hex.builtin.menu.edit", "hex.builtin.view.pattern_editor.menu.edit.place_pattern" }, ICON_VS_LIBRARY, 3000, [&, this] { if (menu::beginMenu("hex.builtin.view.pattern_editor.menu.edit.place_pattern.builtin"_lang)) { if (menu::beginMenu("hex.builtin.view.pattern_editor.menu.edit.place_pattern.builtin.single"_lang)) { @@ -2267,7 +2271,7 @@ namespace hex::plugin::builtin { } void ViewPatternEditor::registerHandlers() { - ContentRegistry::FileHandler::add({ ".hexpat", ".pat" }, [](const std::fs::path &path) -> bool { + ContentRegistry::FileTypeHandler::add({ ".hexpat", ".pat" }, [](const std::fs::path &path) -> bool { wolv::io::File file(path, wolv::io::File::Mode::Read); if (file.isValid()) { diff --git a/plugins/builtin/source/content/views/view_provider_settings.cpp b/plugins/builtin/source/content/views/view_provider_settings.cpp index dfc9a3e3d..ffce839e3 100644 --- a/plugins/builtin/source/content/views/view_provider_settings.cpp +++ b/plugins/builtin/source/content/views/view_provider_settings.cpp @@ -1,7 +1,7 @@ #include "content/views/view_provider_settings.hpp" #include -#include +#include #include #include #include @@ -16,7 +16,7 @@ namespace hex::plugin::builtin { this->getWindowOpenState() = true; }); - ContentRegistry::Interface::addSidebarItem(ICON_VS_SERVER_PROCESS, [] { + ContentRegistry::UserInterface::addSidebarItem(ICON_VS_SERVER_PROCESS, [] { auto provider = hex::ImHexApi::Provider::get(); if (auto *sidebarInterfaceProvider = dynamic_cast(provider); sidebarInterfaceProvider != nullptr) diff --git a/plugins/builtin/source/content/views/view_settings.cpp b/plugins/builtin/source/content/views/view_settings.cpp index d8928d4a0..cf6c347c7 100644 --- a/plugins/builtin/source/content/views/view_settings.cpp +++ b/plugins/builtin/source/content/views/view_settings.cpp @@ -1,7 +1,7 @@ #include "content/views/view_settings.hpp" #include -#include +#include #include #include @@ -23,8 +23,8 @@ namespace hex::plugin::builtin { }); // Add the settings menu item to the Extras menu - ContentRegistry::Interface::addMenuItemSeparator({ "hex.builtin.menu.extras" }, 3000); - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.extras", "hex.builtin.view.settings.name" }, ICON_VS_SETTINGS_GEAR, 4000, CTRLCMD + Keys::Comma, [&, this] { + ContentRegistry::UserInterface::addMenuItemSeparator({ "hex.builtin.menu.extras" }, 3000); + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.extras", "hex.builtin.view.settings.name" }, ICON_VS_SETTINGS_GEAR, 4000, CTRLCMD + Keys::Comma, [&, this] { this->getWindowOpenState() = true; }); diff --git a/plugins/builtin/source/content/views/view_store.cpp b/plugins/builtin/source/content/views/view_store.cpp index b371db203..12dabbd4e 100644 --- a/plugins/builtin/source/content/views/view_store.cpp +++ b/plugins/builtin/source/content/views/view_store.cpp @@ -3,7 +3,8 @@ #include #include -#include +#include +#include #include #include @@ -30,7 +31,7 @@ namespace hex::plugin::builtin { using namespace std::literals::chrono_literals; ViewStore::ViewStore() : View::Floating("hex.builtin.view.store.name", ICON_VS_EXTENSIONS) { - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.extras", "hex.builtin.view.store.name" }, ICON_VS_EXTENSIONS, 1000, Shortcut::None, [&, this] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.extras", "hex.builtin.view.store.name" }, ICON_VS_EXTENSIONS, 1000, Shortcut::None, [&, this] { if (m_requestStatus == RequestStatus::NotAttempted) this->refresh(); diff --git a/plugins/builtin/source/content/views/view_theme_manager.cpp b/plugins/builtin/source/content/views/view_theme_manager.cpp index 0e4edf0c5..f481899a3 100644 --- a/plugins/builtin/source/content/views/view_theme_manager.cpp +++ b/plugins/builtin/source/content/views/view_theme_manager.cpp @@ -1,6 +1,6 @@ #include "content/views/view_theme_manager.hpp" -#include +#include #include #include @@ -10,7 +10,7 @@ namespace hex::plugin::builtin { ViewThemeManager::ViewThemeManager() : View::Floating("hex.builtin.view.theme_manager.name", ICON_VS_SYMBOL_COLOR) { - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.extras", "hex.builtin.view.theme_manager.name" }, ICON_VS_SYMBOL_COLOR, 2000, Shortcut::None, [&, this] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.extras", "hex.builtin.view.theme_manager.name" }, ICON_VS_SYMBOL_COLOR, 2000, Shortcut::None, [&, this] { this->getWindowOpenState() = true; }); } diff --git a/plugins/builtin/source/content/views/view_tools.cpp b/plugins/builtin/source/content/views/view_tools.cpp index 7a304fe2b..1917fb999 100644 --- a/plugins/builtin/source/content/views/view_tools.cpp +++ b/plugins/builtin/source/content/views/view_tools.cpp @@ -1,7 +1,7 @@ #include "content/views/view_tools.hpp" #include -#include +#include #include #include diff --git a/plugins/builtin/source/content/views/view_tutorials.cpp b/plugins/builtin/source/content/views/view_tutorials.cpp index 31fb58cbf..d45c9629c 100644 --- a/plugins/builtin/source/content/views/view_tutorials.cpp +++ b/plugins/builtin/source/content/views/view_tutorials.cpp @@ -1,6 +1,6 @@ #include "content/views/view_tutorials.hpp" -#include +#include #include #include #include @@ -12,7 +12,7 @@ namespace hex::plugin::builtin { ViewTutorials::ViewTutorials() : View::Floating("hex.builtin.view.tutorials.name", ICON_VS_BOOK) { - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.help", "hex.builtin.view.tutorials.name" }, ICON_VS_COMPASS, 4000, Shortcut::None, [&, this] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.help", "hex.builtin.view.tutorials.name" }, ICON_VS_COMPASS, 4000, Shortcut::None, [&, this] { this->getWindowOpenState() = true; }); diff --git a/plugins/builtin/source/content/welcome_screen.cpp b/plugins/builtin/source/content/welcome_screen.cpp index 7532d069a..4600da33b 100644 --- a/plugins/builtin/source/content/welcome_screen.cpp +++ b/plugins/builtin/source/content/welcome_screen.cpp @@ -1,7 +1,10 @@ #include #include -#include +#include +#include +#include +#include #include #include #include @@ -430,7 +433,7 @@ namespace hex::plugin::builtin { } ImGuiExt::EndSubWindow(); - auto extraWelcomeScreenEntries = ContentRegistry::Interface::impl::getWelcomeScreenEntries(); + auto extraWelcomeScreenEntries = ContentRegistry::UserInterface::impl::getWelcomeScreenEntries(); if (!extraWelcomeScreenEntries.empty()) { ImGui::TableNextRow(ImGuiTableRowFlags_None, ImGui::GetTextLineHeightWithSpacing() * 5); ImGui::TableNextColumn(); @@ -514,7 +517,7 @@ namespace hex::plugin::builtin { static bool hovered = false; ImGui::PushStyleVar(ImGuiStyleVar_Alpha, hovered ? 1.0F : 0.3F); { - const auto &quickSettings = ContentRegistry::Interface::impl::getWelcomeScreenQuickSettingsToggles(); + const auto &quickSettings = ContentRegistry::UserInterface::impl::getWelcomeScreenQuickSettingsToggles(); if (!quickSettings.empty()) { const auto padding = ImGui::GetStyle().FramePadding.y; const ImVec2 windowSize = { 150_scaled, 2 * ImGui::GetTextLineHeightWithSpacing() + padding + std::ceil(quickSettings.size() / 5.0F) * (ImGui::GetTextLineHeightWithSpacing() + padding) }; @@ -646,16 +649,16 @@ namespace hex::plugin::builtin { }); - ContentRegistry::Interface::addWelcomeScreenQuickSettingsToggle(ICON_VS_COMPASS_ACTIVE, ICON_VS_COMPASS, "hex.builtin.welcome.quick_settings.simplified", false, [](bool state) { + ContentRegistry::UserInterface::addWelcomeScreenQuickSettingsToggle(ICON_VS_COMPASS_ACTIVE, ICON_VS_COMPASS, "hex.builtin.welcome.quick_settings.simplified", false, [](bool state) { s_simplifiedWelcomeScreen = state; WorkspaceManager::switchWorkspace(s_simplifiedWelcomeScreen ? "Minimal" : "Default"); }); EventImHexStartupFinished::subscribe([]() { - for (const auto &quickSetting : ContentRegistry::Interface::impl::getWelcomeScreenQuickSettingsToggles()) { + for (const auto &quickSetting : ContentRegistry::UserInterface::impl::getWelcomeScreenQuickSettingsToggles()) { auto &setting = quickSetting.unlocalizedTooltip; ContentRegistry::Settings::onChange("hex.builtin.settings.quick_settings", setting, [setting](const ContentRegistry::Settings::SettingsValue &value) { - for (auto &[onIcon, offIcon, unlocalizedTooltip, toggleCallback, state] : ContentRegistry::Interface::impl::getWelcomeScreenQuickSettingsToggles()) { + for (auto &[onIcon, offIcon, unlocalizedTooltip, toggleCallback, state] : ContentRegistry::UserInterface::impl::getWelcomeScreenQuickSettingsToggles()) { if (unlocalizedTooltip == setting) { state = value.get(state); toggleCallback(state); diff --git a/plugins/builtin/source/content/window_decoration.cpp b/plugins/builtin/source/content/window_decoration.cpp index fb87e7021..d143c630d 100644 --- a/plugins/builtin/source/content/window_decoration.cpp +++ b/plugins/builtin/source/content/window_decoration.cpp @@ -1,4 +1,6 @@ -#include +#include +#include +#include #include #include #include @@ -49,15 +51,15 @@ namespace hex::plugin::builtin { ImGui::GetWindowDrawList()->AddShadowCircle(pos, diameter / 2, ImGui::GetColorU32(ImGuiCol_ButtonActive, 0.8F), diameter / 4, ImVec2()); } - void createNestedMenu(std::span menuItems, const char *icon, const Shortcut &shortcut, View *view, const ContentRegistry::Interface::impl::MenuCallback &callback, const ContentRegistry::Interface::impl::EnabledCallback &enabledCallback, const ContentRegistry::Interface::impl::SelectedCallback &selectedCallback) { + void createNestedMenu(std::span menuItems, const char *icon, const Shortcut &shortcut, View *view, const ContentRegistry::UserInterface::impl::MenuCallback &callback, const ContentRegistry::UserInterface::impl::EnabledCallback &enabledCallback, const ContentRegistry::UserInterface::impl::SelectedCallback &selectedCallback) { const auto &name = menuItems.front(); - if (name.get() == ContentRegistry::Interface::impl::SeparatorValue) { + if (name.get() == ContentRegistry::UserInterface::impl::SeparatorValue) { menu::menuSeparator(); return; } - if (name.get() == ContentRegistry::Interface::impl::SubMenuValue) { + if (name.get() == ContentRegistry::UserInterface::impl::SubMenuValue) { if (enabledCallback()) { callback(); } @@ -74,9 +76,9 @@ namespace hex::plugin::builtin { } } } else { - bool isSubmenu = (menuItems.begin() + 1)->get() == ContentRegistry::Interface::impl::SubMenuValue; + bool isSubmenu = (menuItems.begin() + 1)->get() == ContentRegistry::UserInterface::impl::SubMenuValue; - if (menu::beginMenuEx(Lang(name), std::next(menuItems.begin())->get() == ContentRegistry::Interface::impl::SubMenuValue ? icon : nullptr, isSubmenu ? enabledCallback() : true)) { + if (menu::beginMenuEx(Lang(name), std::next(menuItems.begin())->get() == ContentRegistry::UserInterface::impl::SubMenuValue ? icon : nullptr, isSubmenu ? enabledCallback() : true)) { createNestedMenu({ std::next(menuItems.begin()), menuItems.end() }, icon, shortcut, view, callback, enabledCallback, selectedCallback); menu::endMenu(); } @@ -89,7 +91,7 @@ namespace hex::plugin::builtin { ImGui::Separator(); ImGui::SetCursorPosX(8); - for (const auto &callback : ContentRegistry::Interface::impl::getFooterItems()) { + for (const auto &callback : ContentRegistry::UserInterface::impl::getFooterItems()) { const auto y = ImGui::GetCursorPosY(); const auto prevIdx = drawList->_VtxCurrentIdx; callback(); @@ -110,7 +112,7 @@ namespace hex::plugin::builtin { u32 index = 0; u32 drawIndex = 1; ImGui::PushID("SideBarWindows"); - for (const auto &[icon, callback, enabledCallback] : ContentRegistry::Interface::impl::getSidebarItems()) { + for (const auto &[icon, callback, enabledCallback] : ContentRegistry::UserInterface::impl::getSidebarItems()) { ImGui::SetCursorPosY(sidebarPos.y + sidebarWidth * drawIndex); ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetColorU32(ImGuiCol_MenuBarBg)); @@ -234,7 +236,7 @@ namespace hex::plugin::builtin { #endif } - const auto &titleBarButtons = ContentRegistry::Interface::impl::getTitlebarButtons(); + const auto &titleBarButtons = ContentRegistry::UserInterface::impl::getTitlebarButtons(); // Draw custom title bar buttons if (!titleBarButtons.empty()) { @@ -308,7 +310,7 @@ namespace hex::plugin::builtin { } } - bool isMenuItemVisible(const ContentRegistry::Interface::impl::MenuItem &menuItem) { + bool isMenuItemVisible(const ContentRegistry::UserInterface::impl::MenuItem &menuItem) { const auto lastFocusedView = View::getLastFocusedView(); if (lastFocusedView == nullptr && menuItem.view != nullptr) { return false; @@ -325,7 +327,7 @@ namespace hex::plugin::builtin { std::set getVisibleMainMenus() { std::set result; - for (auto &[priority, menuItem] : ContentRegistry::Interface::impl::getMenuItems()) { + for (auto &[priority, menuItem] : ContentRegistry::UserInterface::impl::getMenuItems()) { if (isMenuItemVisible(menuItem)) { result.emplace(menuItem.unlocalizedNames.front()); } @@ -335,7 +337,7 @@ namespace hex::plugin::builtin { } void populateMenu(const UnlocalizedString &menuName) { - for (auto &[priority, menuItem] : ContentRegistry::Interface::impl::getMenuItems()) { + for (auto &[priority, menuItem] : ContentRegistry::UserInterface::impl::getMenuItems()) { if (!menuName.empty()) { if (menuItem.unlocalizedNames[0] != menuName) continue; @@ -383,7 +385,7 @@ namespace hex::plugin::builtin { } void drawMenu() { - const auto &menuItems = ContentRegistry::Interface::impl::getMainMenuItems(); + const auto &menuItems = ContentRegistry::UserInterface::impl::getMainMenuItems(); const auto visibleMainMenus = getVisibleMainMenus(); if (menu::isNativeMenuBarUsed()) { @@ -561,7 +563,7 @@ namespace hex::plugin::builtin { ImGui::BeginDisabled(ContentRegistry::Views::impl::getFullScreenView() != nullptr); { - for (const auto &callback : ContentRegistry::Interface::impl::getToolbarItems()) { + for (const auto &callback : ContentRegistry::UserInterface::impl::getToolbarItems()) { callback(); ImGui::SameLine(); } @@ -582,7 +584,7 @@ namespace hex::plugin::builtin { } bool anySidebarItemsAvailable() { - if (const auto &items = ContentRegistry::Interface::impl::getSidebarItems(); items.empty()) { + if (const auto &items = ContentRegistry::UserInterface::impl::getSidebarItems(); items.empty()) { return false; } else { return std::any_of(items.begin(), items.end(), [](const auto &item) { @@ -670,7 +672,7 @@ namespace hex::plugin::builtin { ImGui::PopStyleVar(2); // Draw main menu popups - for (auto &[priority, menuItem] : ContentRegistry::Interface::impl::getMainMenuItems()) { + for (auto &[priority, menuItem] : ContentRegistry::UserInterface::impl::getMainMenuItems()) { const auto &unlocalizedNames = menuItem.unlocalizedName; if (ImGui::BeginPopup(unlocalizedNames.get().c_str())) { populateMenu(unlocalizedNames); diff --git a/plugins/builtin/source/content/workspaces.cpp b/plugins/builtin/source/content/workspaces.cpp index 57cf1eb05..ac4510111 100644 --- a/plugins/builtin/source/content/workspaces.cpp +++ b/plugins/builtin/source/content/workspaces.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/plugins/builtin/source/plugin_builtin.cpp b/plugins/builtin/source/plugin_builtin.cpp index b18b9f7e1..e0d51b29b 100644 --- a/plugins/builtin/source/plugin_builtin.cpp +++ b/plugins/builtin/source/plugin_builtin.cpp @@ -1,6 +1,5 @@ #include -#include #include #include #include diff --git a/plugins/decompress/source/content/pl_functions.cpp b/plugins/decompress/source/content/pl_functions.cpp index ef11686ba..a373cc5fb 100644 --- a/plugins/decompress/source/content/pl_functions.cpp +++ b/plugins/decompress/source/content/pl_functions.cpp @@ -1,7 +1,7 @@ #include #include -#include +#include #include #include diff --git a/plugins/decompress/source/plugin_decompress.cpp b/plugins/decompress/source/plugin_decompress.cpp index 521d11a12..396cf4d7e 100644 --- a/plugins/decompress/source/plugin_decompress.cpp +++ b/plugins/decompress/source/plugin_decompress.cpp @@ -1,6 +1,5 @@ #include -#include #include #include diff --git a/plugins/diffing/include/content/views/view_diff.hpp b/plugins/diffing/include/content/views/view_diff.hpp index 9fa9f1f19..43bba97f7 100644 --- a/plugins/diffing/include/content/views/view_diff.hpp +++ b/plugins/diffing/include/content/views/view_diff.hpp @@ -4,6 +4,7 @@ #include #include +#include #include #include diff --git a/plugins/diffing/source/content/diffing_algorithms.cpp b/plugins/diffing/source/content/diffing_algorithms.cpp index c4d0643d8..0c122b6b1 100644 --- a/plugins/diffing/source/content/diffing_algorithms.cpp +++ b/plugins/diffing/source/content/diffing_algorithms.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include #include diff --git a/plugins/diffing/source/plugin_diffing.cpp b/plugins/diffing/source/plugin_diffing.cpp index 577e7b839..73aeee2b7 100644 --- a/plugins/diffing/source/plugin_diffing.cpp +++ b/plugins/diffing/source/plugin_diffing.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include #include diff --git a/plugins/disassembler/include/content/views/view_disassembler.hpp b/plugins/disassembler/include/content/views/view_disassembler.hpp index 783f5a977..ebc611d0e 100644 --- a/plugins/disassembler/include/content/views/view_disassembler.hpp +++ b/plugins/disassembler/include/content/views/view_disassembler.hpp @@ -9,7 +9,7 @@ #include #include -#include +#include namespace hex::plugin::disasm { @@ -28,9 +28,9 @@ namespace hex::plugin::disasm { PerProvider m_range; PerProvider m_regionToDisassemble; - PerProvider> m_currArchitecture; + PerProvider> m_currArchitecture; - PerProvider> m_disassembly; + PerProvider> m_disassembly; void disassemble(); void exportToFile(); diff --git a/plugins/disassembler/source/content/disassemblers/capstone_architectures.cpp b/plugins/disassembler/source/content/disassemblers/capstone_architectures.cpp index 3982636cd..d6b22864c 100644 --- a/plugins/disassembler/source/content/disassemblers/capstone_architectures.cpp +++ b/plugins/disassembler/source/content/disassemblers/capstone_architectures.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -7,7 +7,7 @@ namespace hex::plugin::disasm { - class CapstoneArchitecture : public ContentRegistry::Disassembler::Architecture { + class CapstoneArchitecture : public ContentRegistry::Disassemblers::Architecture { public: explicit CapstoneArchitecture(BuiltinArchitecture architecture, cs_mode mode = cs_mode(0)) : Architecture(CapstoneDisassembler::ArchitectureNames[u32(architecture)]), @@ -51,7 +51,7 @@ namespace hex::plugin::disasm { ImGui::NewLine(); } - std::optional disassemble(u64 imageBaseAddress, u64 instructionLoadAddress, u64 instructionDataAddress, std::span code) override { + std::optional disassemble(u64 imageBaseAddress, u64 instructionLoadAddress, u64 instructionDataAddress, std::span code) override { auto ptr = code.data(); auto size = code.size_bytes(); @@ -59,7 +59,7 @@ namespace hex::plugin::disasm { return std::nullopt; } - ContentRegistry::Disassembler::Instruction disassembly = { }; + ContentRegistry::Disassemblers::Instruction disassembly = { }; disassembly.address = m_instruction->address; disassembly.offset = instructionDataAddress - imageBaseAddress; disassembly.size = m_instruction->size; @@ -440,26 +440,26 @@ namespace hex::plugin::disasm { #endif void registerCapstoneArchitectures() { - ContentRegistry::Disassembler::add(); - ContentRegistry::Disassembler::add(); - ContentRegistry::Disassembler::add(); - ContentRegistry::Disassembler::add(); - ContentRegistry::Disassembler::add(); - ContentRegistry::Disassembler::add(); - ContentRegistry::Disassembler::add(); - ContentRegistry::Disassembler::add(); - ContentRegistry::Disassembler::add(); - ContentRegistry::Disassembler::add(); - ContentRegistry::Disassembler::add(); - ContentRegistry::Disassembler::add(); + ContentRegistry::Disassemblers::add(); + ContentRegistry::Disassemblers::add(); + ContentRegistry::Disassemblers::add(); + ContentRegistry::Disassemblers::add(); + ContentRegistry::Disassemblers::add(); + ContentRegistry::Disassemblers::add(); + ContentRegistry::Disassemblers::add(); + ContentRegistry::Disassemblers::add(); + ContentRegistry::Disassemblers::add(); + ContentRegistry::Disassemblers::add(); + ContentRegistry::Disassemblers::add(); + ContentRegistry::Disassemblers::add(); #if CS_API_MAJOR >= 5 - ContentRegistry::Disassembler::add(); - ContentRegistry::Disassembler::add(); - ContentRegistry::Disassembler::add(); - ContentRegistry::Disassembler::add(); - ContentRegistry::Disassembler::add(); - ContentRegistry::Disassembler::add(); + ContentRegistry::Disassemblers::add(); + ContentRegistry::Disassemblers::add(); + ContentRegistry::Disassemblers::add(); + ContentRegistry::Disassemblers::add(); + ContentRegistry::Disassemblers::add(); + ContentRegistry::Disassemblers::add(); #endif } diff --git a/plugins/disassembler/source/content/disassemblers/custom_architectures.cpp b/plugins/disassembler/source/content/disassemblers/custom_architectures.cpp index 9ce1924e2..223fcdd6b 100644 --- a/plugins/disassembler/source/content/disassemblers/custom_architectures.cpp +++ b/plugins/disassembler/source/content/disassemblers/custom_architectures.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -8,7 +8,7 @@ namespace hex::plugin::disasm { - class CustomArchitecture : public ContentRegistry::Disassembler::Architecture { + class CustomArchitecture : public ContentRegistry::Disassemblers::Architecture { public: CustomArchitecture(std::string name, std::fs::path path) : Architecture(std::move(name)), m_path(std::move(path)) {} @@ -26,7 +26,7 @@ namespace hex::plugin::disasm { } - std::optional disassemble(u64 imageBaseAddress, u64 instructionLoadAddress, u64 instructionDataAddress, std::span code) override { + std::optional disassemble(u64 imageBaseAddress, u64 instructionLoadAddress, u64 instructionDataAddress, std::span code) override { std::ignore = imageBaseAddress; std::ignore = instructionDataAddress; std::ignore = instructionLoadAddress; @@ -39,7 +39,7 @@ namespace hex::plugin::disasm { const auto &instruction = instructions.front(); - ContentRegistry::Disassembler::Instruction disassembly = { }; + ContentRegistry::Disassemblers::Instruction disassembly = { }; disassembly.address = instructionDataAddress; disassembly.offset = instructionDataAddress - imageBaseAddress; disassembly.size = instruction.bytes.size(); @@ -69,7 +69,7 @@ namespace hex::plugin::disasm { try { auto spec = ::disasm::spec::Loader::load(entry.path(), { entry.path().parent_path() }); - ContentRegistry::Disassembler::add(spec.getName(), entry.path()); + ContentRegistry::Disassemblers::add(spec.getName(), entry.path()); } catch (const std::exception &e) { log::error("Failed to load disassembler config '{}': {}", wolv::util::toUTF8String(entry.path()), e.what()); } diff --git a/plugins/disassembler/source/content/pl_builtin_types.cpp b/plugins/disassembler/source/content/pl_builtin_types.cpp index a01c780d0..fa98b07d5 100644 --- a/plugins/disassembler/source/content/pl_builtin_types.cpp +++ b/plugins/disassembler/source/content/pl_builtin_types.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/plugins/disassembler/source/content/views/view_disassembler.cpp b/plugins/disassembler/source/content/views/view_disassembler.cpp index 623d895c7..b65809492 100644 --- a/plugins/disassembler/source/content/views/view_disassembler.cpp +++ b/plugins/disassembler/source/content/views/view_disassembler.cpp @@ -1,5 +1,6 @@ #include -#include +#include +#include #include #include @@ -21,7 +22,7 @@ namespace hex::plugin::disasm { m_disassembly.get(provider).clear(); }); - ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.menu.edit.disassemble_range" }, ICON_VS_DEBUG_LINE_BY_LINE, 3100, CTRLCMD + SHIFT + Keys::D, [this] { + ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.edit", "hex.builtin.menu.edit.disassemble_range" }, ICON_VS_DEBUG_LINE_BY_LINE, 3100, CTRLCMD + SHIFT + Keys::D, [this] { ImGui::SetWindowFocus(this->getName().c_str()); this->getWindowOpenState() = true; @@ -121,7 +122,7 @@ namespace hex::plugin::disasm { } // As disassembly code can be quite long, we prefer writing each disassembled instruction to file - for (const ContentRegistry::Disassembler::Instruction& instruction : m_disassembly.get(provider)) { + for (const ContentRegistry::Disassemblers::Instruction& instruction : m_disassembly.get(provider)) { // We test for a "bugged" case that should never happen - the instruction should always have a mnemonic if (instruction.mnemonic.empty()) continue; @@ -172,7 +173,7 @@ namespace hex::plugin::disasm { ImGuiExt::Header("hex.ui.common.settings"_lang); // Draw architecture selector - const auto &architectures = ContentRegistry::Disassembler::impl::getArchitectures(); + const auto &architectures = ContentRegistry::Disassemblers::impl::getArchitectures(); if (architectures.empty()) { ImGuiExt::TextSpinner("hex.disassembler.view.disassembler.arch"_lang); } else { diff --git a/plugins/disassembler/source/plugin_disassembler.cpp b/plugins/disassembler/source/plugin_disassembler.cpp index 98bc0bf41..79a06d8b3 100644 --- a/plugins/disassembler/source/plugin_disassembler.cpp +++ b/plugins/disassembler/source/plugin_disassembler.cpp @@ -1,6 +1,7 @@ #include -#include +#include +#include #include #include diff --git a/plugins/fonts/include/font_settings.hpp b/plugins/fonts/include/font_settings.hpp index 19949264a..8919412c1 100644 --- a/plugins/fonts/include/font_settings.hpp +++ b/plugins/fonts/include/font_settings.hpp @@ -2,7 +2,7 @@ #include #include -#include +#include namespace hex::fonts { diff --git a/plugins/fonts/source/font_loader.cpp b/plugins/fonts/source/font_loader.cpp index c7f994682..21119d15f 100644 --- a/plugins/fonts/source/font_loader.cpp +++ b/plugins/fonts/source/font_loader.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/plugins/fonts/source/font_settings.cpp b/plugins/fonts/source/font_settings.cpp index 1a7b6b581..0ad60e013 100644 --- a/plugins/fonts/source/font_settings.cpp +++ b/plugins/fonts/source/font_settings.cpp @@ -1,7 +1,6 @@ #include -#include -#include +#include #include #include @@ -10,6 +9,9 @@ #include #include +#include +#include + namespace hex::fonts { constexpr static auto PixelPerfectFontName = "Pixel-Perfect Default Font (Proggy Clean)"; constexpr static auto SmoothFontName = "Smooth Default Font (JetBrains Mono)"; diff --git a/plugins/fonts/source/library_fonts.cpp b/plugins/fonts/source/library_fonts.cpp index 948e78f80..6789cefaa 100644 --- a/plugins/fonts/source/library_fonts.cpp +++ b/plugins/fonts/source/library_fonts.cpp @@ -1,6 +1,5 @@ #include -#include #include #include diff --git a/plugins/hashes/include/content/views/view_hashes.hpp b/plugins/hashes/include/content/views/view_hashes.hpp index 7e6acb425..c3808ac45 100644 --- a/plugins/hashes/include/content/views/view_hashes.hpp +++ b/plugins/hashes/include/content/views/view_hashes.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include diff --git a/plugins/hashes/source/content/hashes.cpp b/plugins/hashes/source/content/hashes.cpp index abebc96e6..7d12d20fd 100644 --- a/plugins/hashes/source/content/hashes.cpp +++ b/plugins/hashes/source/content/hashes.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include diff --git a/plugins/hashes/source/content/views/view_hashes.cpp b/plugins/hashes/source/content/views/view_hashes.cpp index 8ec5f7b2e..2b791e760 100644 --- a/plugins/hashes/source/content/views/view_hashes.cpp +++ b/plugins/hashes/source/content/views/view_hashes.cpp @@ -2,8 +2,9 @@ #include #include -#include #include +#include +#include #include @@ -11,6 +12,7 @@ #include #include +#include #include diff --git a/plugins/hashes/source/plugin_hashes.cpp b/plugins/hashes/source/plugin_hashes.cpp index 3ea063789..c0db215e7 100644 --- a/plugins/hashes/source/plugin_hashes.cpp +++ b/plugins/hashes/source/plugin_hashes.cpp @@ -1,7 +1,7 @@ #include #include -#include +#include #include diff --git a/plugins/remote/source/plugin_remote.cpp b/plugins/remote/source/plugin_remote.cpp index 12631e784..8ae92b8dd 100644 --- a/plugins/remote/source/plugin_remote.cpp +++ b/plugins/remote/source/plugin_remote.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include #include diff --git a/plugins/script_loader/source/plugin_script_loader.cpp b/plugins/script_loader/source/plugin_script_loader.cpp index 1ac65cae3..54c3c70e6 100644 --- a/plugins/script_loader/source/plugin_script_loader.cpp +++ b/plugins/script_loader/source/plugin_script_loader.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include @@ -86,7 +86,7 @@ std::vector loadAllScripts() { void addScriptsMenu() { static std::vector scripts; static TaskHolder runnerTask, updaterTask; - hex::ContentRegistry::Interface::addMenuItemSubMenu({ "hex.builtin.menu.extras" }, 5000, [] { + hex::ContentRegistry::UserInterface::addMenuItemSubMenu({ "hex.builtin.menu.extras" }, 5000, [] { static bool menuJustOpened = true; if (menu::beginMenuEx("hex.script_loader.menu.run_script"_lang, ICON_VS_LIBRARY)) { diff --git a/plugins/script_loader/support/c/source/script_api/v1/mem.cpp b/plugins/script_loader/support/c/source/script_api/v1/mem.cpp index 2e3a54cb3..c76077661 100644 --- a/plugins/script_loader/support/c/source/script_api/v1/mem.cpp +++ b/plugins/script_loader/support/c/source/script_api/v1/mem.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include diff --git a/plugins/script_loader/support/c/source/script_api/v1/ui.cpp b/plugins/script_loader/support/c/source/script_api/v1/ui.cpp index f7cc4e170..4cdcacce9 100644 --- a/plugins/script_loader/support/c/source/script_api/v1/ui.cpp +++ b/plugins/script_loader/support/c/source/script_api/v1/ui.cpp @@ -1,5 +1,6 @@ #include -#include +#include +#include #include #include @@ -182,5 +183,5 @@ SCRIPT_API(void registerView, const char *icon, const char *name, void *drawFunc SCRIPT_API(void addMenuItem, const char *icon, const char *menuName, const char *itemName, void *function) { using MenuFunction = void(*)(); - ContentRegistry::Interface::addMenuItem({ menuName, itemName }, icon, 9999, Shortcut::None, reinterpret_cast(function)); + ContentRegistry::UserInterface::addMenuItem({ menuName, itemName }, icon, 9999, Shortcut::None, reinterpret_cast(function)); } \ No newline at end of file diff --git a/plugins/ui/include/ui/hex_editor.hpp b/plugins/ui/include/ui/hex_editor.hpp index eb35e6824..85db3194b 100644 --- a/plugins/ui/include/ui/hex_editor.hpp +++ b/plugins/ui/include/ui/hex_editor.hpp @@ -1,7 +1,7 @@ #pragma once #include -#include +#include #include #include diff --git a/plugins/ui/include/ui/pattern_drawer.hpp b/plugins/ui/include/ui/pattern_drawer.hpp index 2d6d32a33..103316e9b 100644 --- a/plugins/ui/include/ui/pattern_drawer.hpp +++ b/plugins/ui/include/ui/pattern_drawer.hpp @@ -1,14 +1,12 @@ #pragma once #include -#include #include #include #include #include -#include #include diff --git a/plugins/ui/include/ui/visualizer_drawer.hpp b/plugins/ui/include/ui/visualizer_drawer.hpp index 75b212185..4a9546212 100644 --- a/plugins/ui/include/ui/visualizer_drawer.hpp +++ b/plugins/ui/include/ui/visualizer_drawer.hpp @@ -2,7 +2,7 @@ #include #include -#include "hex/api/content_registry.hpp" +#include namespace hex::ui { diff --git a/plugins/ui/source/library_ui.cpp b/plugins/ui/source/library_ui.cpp index 5c3e649f5..bf66d518a 100644 --- a/plugins/ui/source/library_ui.cpp +++ b/plugins/ui/source/library_ui.cpp @@ -1,6 +1,5 @@ #include -#include #include #include diff --git a/plugins/ui/source/ui/hex_editor.cpp b/plugins/ui/source/ui/hex_editor.cpp index 1784254b4..f2342c9b2 100644 --- a/plugins/ui/source/ui/hex_editor.cpp +++ b/plugins/ui/source/ui/hex_editor.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include #include diff --git a/plugins/ui/source/ui/pattern_drawer.cpp b/plugins/ui/source/ui/pattern_drawer.cpp index ee790773e..90dc17848 100644 --- a/plugins/ui/source/ui/pattern_drawer.cpp +++ b/plugins/ui/source/ui/pattern_drawer.cpp @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include diff --git a/plugins/ui/source/ui/visualizer_drawer.cpp b/plugins/ui/source/ui/visualizer_drawer.cpp index 212f8f6ce..429791e13 100644 --- a/plugins/ui/source/ui/visualizer_drawer.cpp +++ b/plugins/ui/source/ui/visualizer_drawer.cpp @@ -1,5 +1,7 @@ #include +#include + #include "imgui.h" namespace hex::ui { diff --git a/plugins/visualizers/source/content/pl_inline_visualizers.cpp b/plugins/visualizers/source/content/pl_inline_visualizers.cpp index 8780a73e9..ce69a08f7 100644 --- a/plugins/visualizers/source/content/pl_inline_visualizers.cpp +++ b/plugins/visualizers/source/content/pl_inline_visualizers.cpp @@ -1,13 +1,10 @@ -#include +#include #include +#include #include -#include - -#include - namespace hex::plugin::visualizers { namespace { diff --git a/plugins/visualizers/source/content/pl_visualizers.cpp b/plugins/visualizers/source/content/pl_visualizers.cpp index b0d477712..ffa29b1bb 100644 --- a/plugins/visualizers/source/content/pl_visualizers.cpp +++ b/plugins/visualizers/source/content/pl_visualizers.cpp @@ -1,4 +1,4 @@ -#include +#include #include diff --git a/plugins/visualizers/source/plugin_visualizers.cpp b/plugins/visualizers/source/plugin_visualizers.cpp index 87eb07e73..f1ae80fa4 100644 --- a/plugins/visualizers/source/plugin_visualizers.cpp +++ b/plugins/visualizers/source/plugin_visualizers.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include #include diff --git a/plugins/windows/source/content/settings_entries.cpp b/plugins/windows/source/content/settings_entries.cpp index 8f1e0d757..20de8b709 100644 --- a/plugins/windows/source/content/settings_entries.cpp +++ b/plugins/windows/source/content/settings_entries.cpp @@ -1,4 +1,4 @@ -#include +#include #include diff --git a/plugins/windows/source/content/ui_items.cpp b/plugins/windows/source/content/ui_items.cpp index 4a989cba9..597119b9c 100644 --- a/plugins/windows/source/content/ui_items.cpp +++ b/plugins/windows/source/content/ui_items.cpp @@ -1,4 +1,5 @@ -#include +#include +#include #include @@ -19,7 +20,7 @@ namespace hex::plugin::windows { showResourceUsage = value.get(false); }); - ContentRegistry::Interface::addFooterItem([] { + ContentRegistry::UserInterface::addFooterItem([] { if (!showResourceUsage) return; @@ -72,7 +73,7 @@ namespace hex::plugin::windows { ImGuiExt::TextFormatted(ICON_VS_DASHBOARD " {0:2}.{1:02}%", u32(cpuUsage), u32(cpuUsage * 100) % 100); }); - ContentRegistry::Interface::addFooterItem([] { + ContentRegistry::UserInterface::addFooterItem([] { if (!showResourceUsage) return; diff --git a/plugins/windows/source/plugin_windows.cpp b/plugins/windows/source/plugin_windows.cpp index 328841958..b0f71d64d 100644 --- a/plugins/windows/source/plugin_windows.cpp +++ b/plugins/windows/source/plugin_windows.cpp @@ -1,6 +1,7 @@ #include -#include +#include +#include #include #include #include diff --git a/plugins/yara_rules/source/content/data_information_sections.cpp b/plugins/yara_rules/source/content/data_information_sections.cpp index b83c7b50e..5f9f00786 100644 --- a/plugins/yara_rules/source/content/data_information_sections.cpp +++ b/plugins/yara_rules/source/content/data_information_sections.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -9,6 +9,8 @@ #include #include +#include + namespace hex::plugin::yara { class InformationAdvancedFileInformation : public ContentRegistry::DataInformation::InformationSection { diff --git a/plugins/yara_rules/source/content/views/view_yara.cpp b/plugins/yara_rules/source/content/views/view_yara.cpp index dc3d43de8..550ccb6cc 100644 --- a/plugins/yara_rules/source/content/views/view_yara.cpp +++ b/plugins/yara_rules/source/content/views/view_yara.cpp @@ -1,7 +1,7 @@ #include "content/views/view_yara.hpp" #include -#include +#include #include #include @@ -10,10 +10,9 @@ #include #include -#include - #include #include +#include namespace hex::plugin::yara { @@ -22,7 +21,7 @@ namespace hex::plugin::yara { ViewYara::ViewYara() : View::Window("hex.yara_rules.view.yara.name", ICON_VS_BUG) { YaraRule::init(); - ContentRegistry::FileHandler::add({ ".yar", ".yara" }, [](const auto &path) { + ContentRegistry::FileTypeHandler::add({ ".yar", ".yara" }, [](const auto &path) { for (const auto &destPath : paths::Yara.write()) { if (wolv::io::fs::copyFile(path, destPath / path.filename(), std::fs::copy_options::overwrite_existing)) { ui::ToastInfo::open("hex.yara_rules.view.yara.rule_added"_lang); diff --git a/plugins/yara_rules/source/plugin_yara.cpp b/plugins/yara_rules/source/plugin_yara.cpp index 4ef8d1d1c..2261c181f 100644 --- a/plugins/yara_rules/source/plugin_yara.cpp +++ b/plugins/yara_rules/source/plugin_yara.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include #include