build: Refactor ContentRegistry into multiple separate files

This commit is contained in:
WerWolv 2025-08-14 21:22:03 +02:00
parent d920718b44
commit fbde2942de
141 changed files with 2337 additions and 2007 deletions

View File

@ -1,7 +1,7 @@
#include <hex/plugin.hpp> #include <hex/plugin.hpp>
// Browse through the headers in lib/libimhex/include/hex/api/ to see what you can do with the API. // Browse through the headers in lib/libimhex/include/hex/api/ to see what you can do with the API.
// Most important ones are <hex/api/imhex_api.hpp> and <hex/api/content_registry.hpp> // 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 // 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. // when ImHex starts up and loads the plugin.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,22 @@
#pragma once
#include <hex.hpp>
#include <functional>
#include <hex/api/localization_manager.hpp>
EXPORT_MODULE namespace hex {
/* Background Service Registry. Allows adding new background services */
namespace ContentRegistry::BackgroundServices {
namespace impl {
using Callback = std::function<void()>;
void stopServices();
}
void registerService(const UnlocalizedString &unlocalizedString, const impl::Callback &callback);
}
}

View File

@ -0,0 +1,82 @@
#pragma once
#include <hex.hpp>
#include <hex/api/localization_manager.hpp>
#include <string>
#include <functional>
#include <optional>
#include <vector>
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<void(std::string)> callback;
};
using DisplayCallback = std::function<std::string(std::string)>;
using ExecuteCallback = std::function<std::optional<std::string>(std::string)>;
using QueryCallback = std::function<std::vector<QueryResult>(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<Entry>& getEntries();
const std::vector<Handler>& 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);
}
}

View File

@ -0,0 +1,25 @@
#pragma once
#include <hex.hpp>
#include <nlohmann/json_fwd.hpp>
#include <map>
#include <string>
EXPORT_MODULE namespace hex {
/* Network Communication Interface Registry. Allows adding new communication interface endpoints */
namespace ContentRegistry::CommunicationInterface {
namespace impl {
using NetworkCallback = std::function<nlohmann::json(const nlohmann::json &)>;
const std::map<std::string, NetworkCallback>& getNetworkEndpoints();
}
void registerNetworkEndpoint(const std::string &endpoint, const impl::NetworkCallback &callback);
}
}

View File

@ -0,0 +1,72 @@
#pragma once
#include <hex.hpp>
#include <hex/api/localization_manager.hpp>
#include <string>
#include <functional>
#include <vector>
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<std::string(prv::Provider *provider, u64 address, size_t size, bool preview)>;
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<std::vector<u8>(const std::vector<FindOccurrence>&, std::function<std::string(FindOccurrence)>)>;
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<ExportMenuEntry>& getExportMenuEntries();
/**
* @brief Retrieves a list of all registered data formatters used in the Results section of the 'Find' view
*/
const std::vector<FindExporterEntry>& 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);
}
}

View File

@ -0,0 +1,81 @@
#pragma once
#include <hex.hpp>
#include <hex/api/task_manager.hpp>
#include <hex/api/localization_manager.hpp>
#include <nlohmann/json_fwd.hpp>
#include <atomic>
#include <functional>
#include <memory>
#include <vector>
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<bool> m_analyzing = false;
std::atomic<bool> m_valid = false;
std::atomic<bool> m_enabled = true;
};
namespace impl {
using CreateCallback = std::function<std::unique_ptr<InformationSection>()>;
const std::vector<CreateCallback>& getInformationSectionConstructors();
void addInformationSectionCreator(const CreateCallback &callback);
}
template<typename T>
void addInformationSection(auto && ...args) {
impl::addInformationSectionCreator([args...] {
return std::make_unique<T>(std::forward<decltype(args)>(args)...);
});
}
}
}

View File

@ -0,0 +1,80 @@
#pragma once
#include <hex.hpp>
#include <hex/api/localization_manager.hpp>
#include <functional>
#include <optional>
#include <string>
#include <vector>
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<std::string()>;
using EditingFunction = std::function<std::vector<u8>(std::string, std::endian)>;
using GeneratorFunction = std::function<DisplayFunction(const std::vector<u8> &, std::endian, NumberDisplayStyle)>;
struct Entry {
UnlocalizedString unlocalizedName;
size_t requiredSize;
size_t maxSize;
GeneratorFunction generatorFunction;
std::optional<EditingFunction> editingFunction;
};
const std::vector<Entry>& 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<impl::EditingFunction> 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<impl::EditingFunction> 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<void()> &function);
}
}

View File

@ -0,0 +1,64 @@
#pragma once
#include <hex.hpp>
#include <hex/api/localization_manager.hpp>
#include <functional>
#include <memory>
#include <vector>
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<std::unique_ptr<dp::Node>()>;
struct Entry {
UnlocalizedString unlocalizedCategory;
UnlocalizedString unlocalizedName;
CreatorFunction creatorFunction;
};
void add(const Entry &entry);
const std::vector<Entry>& 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<std::derived_from<dp::Node> T, typename... Args>
void add(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedName, Args &&...args) {
add(impl::Entry {
unlocalizedCategory,
unlocalizedName,
[unlocalizedName, ...args = std::forward<Args>(args)]() mutable {
auto node = std::make_unique<T>(std::forward<Args>(args)...);
node->setUnlocalizedName(unlocalizedName);
return node;
}
});
}
/**
* @brief Adds a separator to the data processor right click menu
*/
void addSeparator();
}
}

View File

@ -0,0 +1,68 @@
#pragma once
#include <hex.hpp>
#include <hex/api/localization_manager.hpp>
#include <wolv/container/interval_tree.hpp>
#include <vector>
#include <memory>
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<DifferenceType>;
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<DiffTree> 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<std::unique_ptr<Algorithm>>& getAlgorithms();
void addAlgorithm(std::unique_ptr<Algorithm> &&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<typename T, typename ... Args>
void addAlgorithm(Args && ... args) {
impl::addAlgorithm(std::make_unique<T>(std::forward<Args>(args)...));
}
}
}

View File

@ -0,0 +1,64 @@
#pragma once
#include <hex.hpp>
#include <hex/api/localization_manager.hpp>
#include <string>
#include <map>
#include <memory>
#include <functional>
#include <optional>
#include <span>
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<Instruction> disassemble(u64 imageBaseAddress, u64 instructionLoadAddress, u64 instructionDataAddress, std::span<const u8> 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<std::unique_ptr<Architecture>()>;
void addArchitectureCreator(CreatorFunction function);
const std::map<std::string, CreatorFunction>& getArchitectures();
}
template<std::derived_from<Architecture> T>
void add(auto && ...args) {
impl::addArchitectureCreator([...args = std::move(args)] {
return std::make_unique<T>(args...);
});
}
}
}

View File

@ -0,0 +1,36 @@
#pragma once
#include <hex.hpp>
#include <hex/api/localization_manager.hpp>
#include <map>
#include <string>
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<std::string, Experiment>& 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);
}
}

View File

@ -0,0 +1,37 @@
#pragma once
#include <hex.hpp>
#include <hex/helpers/fs.hpp>
#include <vector>
#include <string>
#include <functional>
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<bool(std::fs::path)>;
struct Entry {
std::vector<std::string> extensions;
Callback callback;
};
const std::vector<Entry>& 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<std::string> &extensions, const impl::Callback &callback);
}
}

View File

@ -0,0 +1,101 @@
#pragma once
#include <hex.hpp>
#include <hex/api/localization_manager.hpp>
#include <vector>
#include <string>
#include <memory>
#include <functional>
#include <nlohmann/json_fwd.hpp>
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<std::vector<u8>(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<u8>& 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<u8> 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<std::unique_ptr<Hash>>& getHashes();
void add(std::unique_ptr<Hash> &&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<typename T, typename ... Args>
void add(Args && ... args) {
impl::add(std::make_unique<T>(std::forward<Args>(args)...));
}
}
}

View File

@ -0,0 +1,91 @@
#pragma once
#include <hex.hpp>
#include <imgui.h>
#include <hex/api/localization_manager.hpp>
#include <functional>
#include <memory>
#include <string>
#include <vector>
#include <span>
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<void(u64, std::span<const u8>, std::vector<ImColor>&)>;
UnlocalizedString unlocalizedName;
Callback callback;
};
namespace impl {
void addDataVisualizer(std::shared_ptr<DataVisualizer> &&visualizer);
const std::vector<std::shared_ptr<DataVisualizer>>& getVisualizers();
const std::vector<std::shared_ptr<MiniMapVisualizer>>& 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<std::derived_from<DataVisualizer> T, typename... Args>
void addDataVisualizer(Args &&...args) {
return impl::addDataVisualizer(std::make_shared<T>(std::forward<Args>(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<DataVisualizer> 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);
}
}

View File

@ -0,0 +1,155 @@
#pragma once
#include <hex.hpp>
#include <pl/pattern_language.hpp>
#include <functional>
#include <span>
#include <string>
#include <map>
#include <vector>
#include <mutex>
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<void(pl::ptrn::Pattern&, bool, std::span<const pl::core::Token::Literal>)>;
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<std::string, Visualizer>& getVisualizers();
const std::map<std::string, Visualizer>& getInlineVisualizers();
const std::map<std::string, pl::api::PragmaHandler>& getPragmas();
const std::vector<FunctionDefinition>& getFunctions();
const std::vector<TypeDefinition>& 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 File

@ -0,0 +1,54 @@
#pragma once
#include <hex.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/providers/provider.hpp>
#include <functional>
#include <memory>
#include <string>
#include <vector>
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<std::unique_ptr<prv::Provider>()>;
void add(const std::string &typeName, ProviderCreationFunction creationFunction);
struct Entry {
UnlocalizedString unlocalizedName;
const char *icon;
};
const std::vector<Entry>& 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<std::derived_from<prv::Provider> T>
void add(bool addToList = true) {
const T provider;
auto typeName = provider.getTypeName();
impl::add(typeName, []() -> std::unique_ptr<prv::Provider> {
return std::make_unique<T>();
});
if (addToList)
impl::addProviderName(typeName, provider.getIcon());
}
}
}

View File

@ -0,0 +1,34 @@
#pragma once
#include <hex.hpp>
#include <functional>
#include <string>
#include <vector>
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<std::string(prv::Provider*)>;
struct ReportGenerator {
Callback callback;
};
const std::vector<ReportGenerator>& getGenerators();
}
void addReportProvider(impl::Callback callback);
}
}

View File

@ -0,0 +1,345 @@
#pragma once
#include <hex.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/helpers/fs.hpp>
#include <string>
#include <vector>
#include <memory>
#include <functional>
#include <optional>
#include <nlohmann/json.hpp>
#include <imgui.h>
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<bool()> callback) {
m_enabledCallback = std::move(callback);
return *this;
}
Interface& setChangedCallback(std::function<void(Widget&)> 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<bool()> m_enabledCallback;
std::function<void(Widget&)> m_changedCallback;
std::optional<UnlocalizedString> 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<UnlocalizedString>& 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<float, 4> m_value = {}, m_defaultValue = {};
ImGuiColorEditFlags m_flags;
};
class DropDown : public Widget {
public:
explicit DropDown(const std::vector<std::string> &items, const std::vector<nlohmann::json> &settingsValues, const nlohmann::json &defaultItem) : m_items(items.begin(), items.end()), m_settingsValues(settingsValues), m_defaultItem(defaultItem) { }
explicit DropDown(const std::vector<UnlocalizedString> &items, const std::vector<nlohmann::json> &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<UnlocalizedString> m_items;
std::vector<nlohmann::json> 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<Widgets::Widget> widget;
};
struct SubCategory {
UnlocalizedString unlocalizedName;
std::vector<Entry> entries;
};
struct Category {
UnlocalizedString unlocalizedName;
UnlocalizedString unlocalizedDescription;
std::vector<SubCategory> subCategories;
};
void load();
void store();
void clear();
const std::vector<Category>& 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<Widgets::Widget> &&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<std::derived_from<Widgets::Widget> 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<T>(std::forward<decltype(args)>(args)...)
)->getInterface();
}
void setCategoryDescription(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedDescription);
class SettingsValue {
public:
SettingsValue(nlohmann::json value) : m_value(std::move(value)) {}
template<typename T>
T get(std::common_type_t<T> defaultValue) const {
try {
auto result = m_value;
if (result.is_number() && std::same_as<T, bool>)
result = m_value.get<int>() != 0;
if (m_value.is_null())
result = defaultValue;
return result.get<T>();
} catch (const nlohmann::json::exception &) {
return defaultValue;
}
}
private:
nlohmann::json m_value;
};
template<typename T>
[[nodiscard]] T read(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedName, const std::common_type_t<T> &defaultValue) {
auto setting = impl::getSetting(unlocalizedCategory, unlocalizedName, defaultValue);
try {
if (setting.is_number() && std::same_as<T, bool>)
setting = setting.template get<int>() != 0;
if (setting.is_null())
setting = defaultValue;
return setting.template get<T>();
} catch (const nlohmann::json::exception &e) {
impl::printSettingReadError(unlocalizedCategory, unlocalizedName, e);
return defaultValue;
}
}
template<typename T>
void write(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedName, const std::common_type_t<T> &value) {
impl::getSetting(unlocalizedCategory, unlocalizedName, value) = value;
impl::runOnChangeHandlers(unlocalizedCategory, unlocalizedName, value);
impl::store();
}
using OnChangeCallback = std::function<void(const SettingsValue &)>;
u64 onChange(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedName, const OnChangeCallback &callback);
using OnSaveCallback = std::function<void()>;
u64 onSave(const OnSaveCallback &callback);
}
}

View File

@ -0,0 +1,37 @@
#pragma once
#include <hex.hpp>
#include <hex/api/localization_manager.hpp>
#include <functional>
#include <vector>
EXPORT_MODULE namespace hex {
/* Tools Registry. Allows adding new entries to the tools window */
namespace ContentRegistry::Tools {
namespace impl {
using Callback = std::function<void()>;
struct Entry {
UnlocalizedString unlocalizedName;
const char *icon;
Callback function;
};
const std::vector<Entry>& 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);
}
}

View File

@ -0,0 +1,287 @@
#pragma once
#include <hex.hpp>
#include <hex/api/shortcut_manager.hpp>
#include <hex/ui/imgui_imhex_extensions.h>
#include <string>
#include <vector>
#include <map>
#include <functional>
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<void()>;
using MenuCallback = std::function<void()>;
using EnabledCallback = std::function<bool()>;
using SelectedCallback = std::function<bool()>;
using ClickCallback = std::function<void()>;
using ToggleCallback = std::function<void(bool)>;
struct MainMenuItem {
UnlocalizedString unlocalizedName;
};
struct MenuItem {
std::vector<UnlocalizedString> 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<u32, MainMenuItem>& getMainMenuItems();
const std::multimap<u32, MenuItem>& getMenuItems();
const std::vector<MenuItem*>& getToolbarMenuItems();
std::multimap<u32, MenuItem>& getMenuItemsMutable();
const std::vector<DrawCallback>& getWelcomeScreenEntries();
const std::vector<DrawCallback>& getFooterItems();
const std::vector<DrawCallback>& getToolbarItems();
const std::vector<SidebarItem>& getSidebarItems();
const std::vector<TitleBarButton>& getTitlebarButtons();
const std::vector<WelcomeScreenQuickSettingsToggle>& 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<UnlocalizedString> &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<UnlocalizedString> &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<UnlocalizedString> &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<UnlocalizedString> 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<UnlocalizedString> 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<UnlocalizedString> 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
);
}
}

View File

@ -0,0 +1,63 @@
#pragma once
#include <hex.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/ui/view.hpp>
#include <map>
#include <memory>
#include <functional>
EXPORT_MODULE namespace hex {
/* View Registry. Allows adding of new windows */
namespace ContentRegistry::Views {
namespace impl {
void add(std::unique_ptr<View> &&view);
void setFullScreenView(std::unique_ptr<View> &&view);
const std::map<UnlocalizedString, std::unique_ptr<View>>& getEntries();
const std::unique_ptr<View>& 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<std::derived_from<View> T, typename... Args>
void add(Args &&...args) {
return impl::add(std::make_unique<T>(std::forward<Args>(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<std::derived_from<View> T, typename... Args>
void setFullScreenView(Args &&...args) {
return impl::setFullScreenView(std::make_unique<T>(std::forward<Args>(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();
}
}

View File

@ -6,7 +6,7 @@
#include <string> #include <string>
#include <variant> #include <variant>
#include <nlohmann/json_fwd.hpp> #include <nlohmann/json.hpp>
#include <imgui.h> #include <imgui.h>
EXPORT_MODULE namespace hex { EXPORT_MODULE namespace hex {

View File

@ -1,4 +1,24 @@
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/background_services.hpp>
#include <hex/api/content_registry/command_palette.hpp>
#include <hex/api/content_registry/communication_interface.hpp>
#include <hex/api/content_registry/data_formatter.hpp>
#include <hex/api/content_registry/data_information.hpp>
#include <hex/api/content_registry/data_inspector.hpp>
#include <hex/api/content_registry/data_processor.hpp>
#include <hex/api/content_registry/diffing.hpp>
#include <hex/api/content_registry/disassemblers.hpp>
#include <hex/api/content_registry/experiments.hpp>
#include <hex/api/content_registry/file_type_handler.hpp>
#include <hex/api/content_registry/hashes.hpp>
#include <hex/api/content_registry/hex_editor.hpp>
#include <hex/api/content_registry/user_interface.hpp>
#include <hex/api/content_registry/pattern_language.hpp>
#include <hex/api/content_registry/provider.hpp>
#include <hex/api/content_registry/reports.hpp>
#include <hex/api/content_registry/settings.hpp>
#include <hex/api/content_registry/tools.hpp>
#include <hex/api/content_registry/views.hpp>
#include <hex/api/shortcut_manager.hpp> #include <hex/api/shortcut_manager.hpp>
#include <hex/api/events/requests_provider.hpp> #include <hex/api/events/requests_provider.hpp>
@ -579,7 +599,7 @@ namespace hex {
} }
namespace ContentRegistry::CommandPaletteCommands { namespace ContentRegistry::CommandPalette {
namespace impl { namespace impl {
@ -851,7 +871,7 @@ namespace hex {
} }
namespace ContentRegistry::DataProcessorNode { namespace ContentRegistry::DataProcessor {
namespace impl { namespace impl {
@ -874,7 +894,7 @@ namespace hex {
} }
namespace ContentRegistry::Interface { namespace ContentRegistry::UserInterface {
namespace impl { namespace impl {
@ -1026,7 +1046,7 @@ namespace hex {
}; };
void updateToolbarItems() { void updateToolbarItems() {
std::set<ContentRegistry::Interface::impl::MenuItem*, MenuItemSorter> menuItems; std::set<impl::MenuItem*, MenuItemSorter> menuItems;
for (auto &[priority, menuItem] : impl::getMenuItemsMutable()) { for (auto &[priority, menuItem] : impl::getMenuItemsMutable()) {
if (menuItem.toolbarIndex != -1) { if (menuItem.toolbarIndex != -1) {
@ -1124,7 +1144,7 @@ namespace hex {
} }
namespace ContentRegistry::FileHandler { namespace ContentRegistry::FileTypeHandler {
namespace impl { namespace impl {
@ -1429,6 +1449,16 @@ namespace hex {
namespace ContentRegistry::DataInformation { namespace ContentRegistry::DataInformation {
void InformationSection::load(const nlohmann::json &data) {
m_enabled = data.value<bool>("enabled", true);
}
[[nodiscard]] nlohmann::json InformationSection::store() {
nlohmann::json data;
data["enabled"] = m_enabled.load();
return data;
}
namespace impl { namespace impl {
static AutoReset<std::vector<CreateCallback>> s_informationSectionConstructors; static AutoReset<std::vector<CreateCallback>> s_informationSectionConstructors;
@ -1444,7 +1474,7 @@ namespace hex {
} }
namespace ContentRegistry::Disassembler { namespace ContentRegistry::Disassemblers {
namespace impl { namespace impl {

View File

@ -1,8 +1,7 @@
#include <hex/api/layout_manager.hpp> #include <hex/api/layout_manager.hpp>
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/views.hpp>
#include <hex/ui/view.hpp> #include <hex/ui/view.hpp>
#include <hex/helpers/fs.hpp>
#include <hex/helpers/logger.hpp> #include <hex/helpers/logger.hpp>
#include <hex/helpers/auto_reset.hpp> #include <hex/helpers/auto_reset.hpp>
#include <hex/helpers/default_paths.hpp> #include <hex/helpers/default_paths.hpp>

View File

@ -1,4 +1,3 @@
#include <hex/api/content_registry.hpp>
#include <hex/api/localization_manager.hpp> #include <hex/api/localization_manager.hpp>
#include <hex/helpers/auto_reset.hpp> #include <hex/helpers/auto_reset.hpp>

View File

@ -1,11 +1,13 @@
#include <hex/api/shortcut_manager.hpp> #include <hex/api/shortcut_manager.hpp>
#include <imgui.h> #include <imgui.h>
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/user_interface.hpp>
#include <hex/api/task_manager.hpp> #include <hex/api/task_manager.hpp>
#include <hex/helpers/auto_reset.hpp> #include <hex/helpers/auto_reset.hpp>
#include <hex/ui/view.hpp> #include <hex/ui/view.hpp>
#include <imgui_internal.h>
namespace hex { namespace hex {
namespace { namespace {
@ -443,7 +445,7 @@ namespace hex {
} }
if (result) { 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) { if (menuItem.view == view && menuItem.shortcut == oldShortcut) {
menuItem.shortcut = newShortcut; menuItem.shortcut = newShortcut;
break; break;

View File

@ -1,7 +1,7 @@
#include <hex/api/events/requests_interaction.hpp> #include <hex/api/events/requests_interaction.hpp>
#include <hex/api/task_manager.hpp> #include <hex/api/task_manager.hpp>
#include <hex/api/imhex_api/system.hpp> #include <hex/api/imhex_api/system.hpp>
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/settings.hpp>
#include <hex/api/tutorial_manager.hpp> #include <hex/api/tutorial_manager.hpp>
#include <hex/api/shortcut_manager.hpp> #include <hex/api/shortcut_manager.hpp>

View File

@ -9,7 +9,7 @@
#include <hex/helpers/logger.hpp> #include <hex/helpers/logger.hpp>
#include <hex/helpers/default_paths.hpp> #include <hex/helpers/default_paths.hpp>
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/settings.hpp>
#include <hex/api/plugin_manager.hpp> #include <hex/api/plugin_manager.hpp>
#include <hex/api/achievement_manager.hpp> #include <hex/api/achievement_manager.hpp>

View File

@ -3,7 +3,6 @@
#if defined(OS_LINUX) #if defined(OS_LINUX)
#include <hex/api/imhex_api/system.hpp> #include <hex/api/imhex_api/system.hpp>
#include <hex/api/content_registry.hpp>
#include <hex/api/events/events_gui.hpp> #include <hex/api/events/events_gui.hpp>
#include <hex/api/events/events_interaction.hpp> #include <hex/api/events/events_interaction.hpp>
#include <hex/api/events/requests_gui.hpp> #include <hex/api/events/requests_gui.hpp>

View File

@ -5,7 +5,7 @@
#include "messaging.hpp" #include "messaging.hpp"
#include <hex/api/imhex_api/system.hpp> #include <hex/api/imhex_api/system.hpp>
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/settings.hpp>
#include <hex/api/theme_manager.hpp> #include <hex/api/theme_manager.hpp>
#include <hex/helpers/utils.hpp> #include <hex/helpers/utils.hpp>

View File

@ -3,7 +3,7 @@
#include <hex.hpp> #include <hex.hpp>
#include <hex/api/plugin_manager.hpp> #include <hex/api/plugin_manager.hpp>
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/views.hpp>
#include <hex/api/imhex_api/fonts.hpp> #include <hex/api/imhex_api/fonts.hpp>
#include <hex/api/layout_manager.hpp> #include <hex/api/layout_manager.hpp>
#include <hex/api/shortcut_manager.hpp> #include <hex/api/shortcut_manager.hpp>

View File

@ -5,7 +5,7 @@
#include <array> #include <array>
#include <memory> #include <memory>
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/data_formatter.hpp>
namespace hex::plugin::builtin::export_fmt { namespace hex::plugin::builtin::export_fmt {

View File

@ -4,6 +4,8 @@
#include <hex/providers/provider.hpp> #include <hex/providers/provider.hpp>
#include <hex/api/events/events_provider.hpp> #include <hex/api/events/events_provider.hpp>
#include <nlohmann/json.hpp>
namespace hex::plugin::builtin { namespace hex::plugin::builtin {
class NullProvider : public hex::prv::Provider { class NullProvider : public hex::prv::Provider {

View File

@ -6,7 +6,7 @@
#include <vector> #include <vector>
#include <hex/api/imhex_api/system.hpp> #include <hex/api/imhex_api/system.hpp>
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/command_palette.hpp>
#include <hex/helpers/utils.hpp> #include <hex/helpers/utils.hpp>
namespace hex::plugin::builtin { namespace hex::plugin::builtin {
@ -38,7 +38,7 @@ namespace hex::plugin::builtin {
struct CommandResult { struct CommandResult {
std::string displayResult; std::string displayResult;
std::string matchedCommand; std::string matchedCommand;
ContentRegistry::CommandPaletteCommands::impl::ExecuteCallback executeCallback; ContentRegistry::CommandPalette::impl::ExecuteCallback executeCallback;
}; };
bool m_commandPaletteOpen = false; bool m_commandPaletteOpen = false;

View File

@ -3,7 +3,8 @@
#include <hex/ui/view.hpp> #include <hex/ui/view.hpp>
#include <ui/visualizer_drawer.hpp> #include <ui/visualizer_drawer.hpp>
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/views.hpp>
#include <hex/api/content_registry/data_inspector.hpp>
#include <hex/api/task_manager.hpp> #include <hex/api/task_manager.hpp>
#include <bit> #include <bit>

View File

@ -11,7 +11,8 @@
#include <wolv/container/interval_tree.hpp> #include <wolv/container/interval_tree.hpp>
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/views.hpp>
#include <hex/api/content_registry/data_formatter.hpp>
namespace hex::plugin::builtin { namespace hex::plugin::builtin {

View File

@ -1,6 +1,5 @@
#pragma once #pragma once
#include <hex/api/content_registry.hpp>
#include <hex/ui/view.hpp> #include <hex/ui/view.hpp>
#include <list> #include <list>

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/data_information.hpp>
#include <hex/api/task_manager.hpp> #include <hex/api/task_manager.hpp>
#include <hex/ui/view.hpp> #include <hex/ui/view.hpp>
#include <ui/widgets.hpp> #include <ui/widgets.hpp>

View File

@ -1,6 +1,7 @@
#pragma once #pragma once
#include <hex/ui/view.hpp> #include <hex/ui/view.hpp>
#include <hex/api/content_registry/views.hpp>
#include <ui/pattern_drawer.hpp> #include <ui/pattern_drawer.hpp>

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/settings.hpp>
#include <hex/ui/view.hpp> #include <hex/ui/view.hpp>
namespace hex::plugin::builtin { namespace hex::plugin::builtin {

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/tools.hpp>
#include <hex/ui/view.hpp> #include <hex/ui/view.hpp>
#include <vector> #include <vector>

View File

@ -1,6 +1,7 @@
#include <hex/api/imhex_api/provider.hpp> #include <hex/api/imhex_api/provider.hpp>
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/communication_interface.hpp>
#include <hex/api/localization_manager.hpp> #include <hex/api/content_registry/settings.hpp>
#include <hex/api/content_registry/background_services.hpp>
#include <hex/api/events/events_provider.hpp> #include <hex/api/events/events_provider.hpp>
#include <hex/api/events/events_lifecycle.hpp> #include <hex/api/events/events_lifecycle.hpp>
#include <hex/api/project_file_manager.hpp> #include <hex/api/project_file_manager.hpp>

View File

@ -1,8 +1,9 @@
#include <content/command_line_interface.hpp> #include <content/command_line_interface.hpp>
#include <hex/api/content_registry.hpp>
#include <hex/api/imhex_api/system.hpp> #include <hex/api/imhex_api/system.hpp>
#include <hex/api/imhex_api/hex_editor.hpp> #include <hex/api/imhex_api/hex_editor.hpp>
#include <hex/api/content_registry/settings.hpp>
#include <hex/api/content_registry/views.hpp>
#include <hex/api/events/requests_interaction.hpp> #include <hex/api/events/requests_interaction.hpp>
#include <hex/api/events/requests_gui.hpp> #include <hex/api/events/requests_gui.hpp>
#include <hex/api/plugin_manager.hpp> #include <hex/api/plugin_manager.hpp>

View File

@ -1,7 +1,9 @@
#include <hex/api/content_registry.hpp>
#include <hex/api/imhex_api/hex_editor.hpp> #include <hex/api/imhex_api/hex_editor.hpp>
#include <hex/api/localization_manager.hpp> #include <hex/api/localization_manager.hpp>
#include <hex/api/content_registry/command_palette.hpp>
#include <hex/api/content_registry/settings.hpp>
#include <hex/api/content_registry/user_interface.hpp>
#include <hex/api/content_registry/views.hpp>
#include <hex/ui/view.hpp> #include <hex/ui/view.hpp>
@ -250,8 +252,8 @@ namespace hex::plugin::builtin {
void registerCommandPaletteCommands() { void registerCommandPaletteCommands() {
ContentRegistry::CommandPaletteCommands::add( ContentRegistry::CommandPalette::add(
ContentRegistry::CommandPaletteCommands::Type::SymbolCommand, ContentRegistry::CommandPalette::Type::SymbolCommand,
"=", "=",
"hex.builtin.command.calc.desc", "hex.builtin.command.calc.desc",
[](auto input) { [](auto input) {
@ -279,8 +281,8 @@ namespace hex::plugin::builtin {
} }
}); });
ContentRegistry::CommandPaletteCommands::add( ContentRegistry::CommandPalette::add(
ContentRegistry::CommandPaletteCommands::Type::SymbolCommand, ContentRegistry::CommandPalette::Type::SymbolCommand,
"@", "@",
"hex.builtin.command.goto.desc", "hex.builtin.command.goto.desc",
[](auto input) { [](auto input) {
@ -307,8 +309,8 @@ namespace hex::plugin::builtin {
return std::nullopt; return std::nullopt;
}); });
ContentRegistry::CommandPaletteCommands::add( ContentRegistry::CommandPalette::add(
ContentRegistry::CommandPaletteCommands::Type::KeywordCommand, ContentRegistry::CommandPalette::Type::KeywordCommand,
"/web", "/web",
"hex.builtin.command.web.desc", "hex.builtin.command.web.desc",
[](auto input) { [](auto input) {
@ -319,8 +321,8 @@ namespace hex::plugin::builtin {
return std::nullopt; return std::nullopt;
}); });
ContentRegistry::CommandPaletteCommands::add( ContentRegistry::CommandPalette::add(
ContentRegistry::CommandPaletteCommands::Type::SymbolCommand, ContentRegistry::CommandPalette::Type::SymbolCommand,
"$", "$",
"hex.builtin.command.cmd.desc", "hex.builtin.command.cmd.desc",
[](auto input) { [](auto input) {
@ -349,13 +351,13 @@ namespace hex::plugin::builtin {
return std::nullopt; return std::nullopt;
}); });
ContentRegistry::CommandPaletteCommands::addHandler( ContentRegistry::CommandPalette::addHandler(
ContentRegistry::CommandPaletteCommands::Type::SymbolCommand, ContentRegistry::CommandPalette::Type::SymbolCommand,
">", ">",
[](const auto &input) { [](const auto &input) {
std::vector<ContentRegistry::CommandPaletteCommands::impl::QueryResult> result; std::vector<ContentRegistry::CommandPalette::impl::QueryResult> result;
for (const auto &[priority, entry] : ContentRegistry::Interface::impl::getMenuItems()) { for (const auto &[priority, entry] : ContentRegistry::UserInterface::impl::getMenuItems()) {
if (!entry.enabledCallback()) if (!entry.enabledCallback())
continue; continue;
@ -367,8 +369,8 @@ namespace hex::plugin::builtin {
std::vector<std::string> names; std::vector<std::string> names;
std::transform(entry.unlocalizedNames.begin(), entry.unlocalizedNames.end(), std::back_inserter(names), [](auto &name) { return Lang(name); }); 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)) { 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::CommandPaletteCommands::impl::QueryResult { result.emplace_back(ContentRegistry::CommandPalette::impl::QueryResult {
std::move(combined), std::move(combined),
[&entry](const auto&) { entry.callback(); } [&entry](const auto&) { entry.callback(); }
}); });
@ -381,11 +383,11 @@ namespace hex::plugin::builtin {
return fmt::format("Menu Item: {}", input.data()); return fmt::format("Menu Item: {}", input.data());
}); });
ContentRegistry::CommandPaletteCommands::addHandler( ContentRegistry::CommandPalette::addHandler(
ContentRegistry::CommandPaletteCommands::Type::SymbolCommand, ContentRegistry::CommandPalette::Type::SymbolCommand,
".", ".",
[](const auto &input) { [](const auto &input) {
std::vector<ContentRegistry::CommandPaletteCommands::impl::QueryResult> result; std::vector<ContentRegistry::CommandPalette::impl::QueryResult> result;
u32 index = 0; u32 index = 0;
for (const auto &provider : ImHexApi::Provider::getProviders()) { for (const auto &provider : ImHexApi::Provider::getProviders()) {
@ -395,7 +397,7 @@ namespace hex::plugin::builtin {
if (!hex::containsIgnoreCase(name, input)) if (!hex::containsIgnoreCase(name, input))
continue; continue;
result.emplace_back(ContentRegistry::CommandPaletteCommands::impl::QueryResult { result.emplace_back(ContentRegistry::CommandPalette::impl::QueryResult {
provider->getName(), provider->getName(),
[index](const auto&) { ImHexApi::Provider::setCurrentProvider(index); } [index](const auto&) { ImHexApi::Provider::setCurrentProvider(index); }
}); });
@ -407,17 +409,17 @@ namespace hex::plugin::builtin {
return fmt::format("Data Source: {}", input.data()); return fmt::format("Data Source: {}", input.data());
}); });
ContentRegistry::CommandPaletteCommands::add( ContentRegistry::CommandPalette::add(
ContentRegistry::CommandPaletteCommands::Type::SymbolCommand, ContentRegistry::CommandPalette::Type::SymbolCommand,
"%", "%",
"hex.builtin.command.convert.desc", "hex.builtin.command.convert.desc",
handleConversionCommand); handleConversionCommand);
ContentRegistry::CommandPaletteCommands::addHandler( ContentRegistry::CommandPalette::addHandler(
ContentRegistry::CommandPaletteCommands::Type::SymbolCommand, ContentRegistry::CommandPalette::Type::SymbolCommand,
"+", "+",
[](const auto &input) { [](const auto &input) {
std::vector<ContentRegistry::CommandPaletteCommands::impl::QueryResult> result; std::vector<ContentRegistry::CommandPalette::impl::QueryResult> result;
for (const auto &[unlocalizedName, view] : ContentRegistry::Views::impl::getEntries()) { for (const auto &[unlocalizedName, view] : ContentRegistry::Views::impl::getEntries()) {
if (!view->shouldProcess()) if (!view->shouldProcess())

View File

@ -1,5 +1,5 @@
#include <hex/api/imhex_api/system.hpp> #include <hex/api/imhex_api/system.hpp>
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/communication_interface.hpp>
#include <hex/api/events/requests_interaction.hpp> #include <hex/api/events/requests_interaction.hpp>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>

View File

@ -1,4 +1,4 @@
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/data_formatter.hpp>
#include <hex/api/achievement_manager.hpp> #include <hex/api/achievement_manager.hpp>
#include <hex/providers/provider.hpp> #include <hex/providers/provider.hpp>

View File

@ -1,4 +1,5 @@
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/data_information.hpp>
#include <hex/api/content_registry/settings.hpp>
#include <hex/helpers/magic.hpp> #include <hex/helpers/magic.hpp>
#include <hex/providers/provider.hpp> #include <hex/providers/provider.hpp>

View File

@ -1,6 +1,6 @@
#include <hex/api/imhex_api/provider.hpp> #include <hex/api/imhex_api/provider.hpp>
#include <hex/api/imhex_api/hex_editor.hpp> #include <hex/api/imhex_api/hex_editor.hpp>
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/data_inspector.hpp>
#include <hex/helpers/utils.hpp> #include <hex/helpers/utils.hpp>
#include <hex/helpers/crypto.hpp> #include <hex/helpers/crypto.hpp>

View File

@ -1,5 +1,5 @@
#include <algorithm> #include <algorithm>
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/data_processor.hpp>
#include <hex/api/localization_manager.hpp> #include <hex/api/localization_manager.hpp>
#include <hex/helpers/utils.hpp> #include <hex/helpers/utils.hpp>
#include <hex/helpers/scaling.hpp> #include <hex/helpers/scaling.hpp>
@ -263,13 +263,13 @@ namespace hex::plugin::builtin {
}; };
void registerBasicDataProcessorNodes() { void registerBasicDataProcessorNodes() {
ContentRegistry::DataProcessorNode::add<NodeInteger>("hex.builtin.nodes.constants", "hex.builtin.nodes.constants.int"); ContentRegistry::DataProcessor::add<NodeInteger>("hex.builtin.nodes.constants", "hex.builtin.nodes.constants.int");
ContentRegistry::DataProcessorNode::add<NodeFloat>("hex.builtin.nodes.constants", "hex.builtin.nodes.constants.float"); ContentRegistry::DataProcessor::add<NodeFloat>("hex.builtin.nodes.constants", "hex.builtin.nodes.constants.float");
ContentRegistry::DataProcessorNode::add<NodeNullptr>("hex.builtin.nodes.constants", "hex.builtin.nodes.constants.nullptr"); ContentRegistry::DataProcessor::add<NodeNullptr>("hex.builtin.nodes.constants", "hex.builtin.nodes.constants.nullptr");
ContentRegistry::DataProcessorNode::add<NodeBuffer>("hex.builtin.nodes.constants", "hex.builtin.nodes.constants.buffer"); ContentRegistry::DataProcessor::add<NodeBuffer>("hex.builtin.nodes.constants", "hex.builtin.nodes.constants.buffer");
ContentRegistry::DataProcessorNode::add<NodeString>("hex.builtin.nodes.constants", "hex.builtin.nodes.constants.string"); ContentRegistry::DataProcessor::add<NodeString>("hex.builtin.nodes.constants", "hex.builtin.nodes.constants.string");
ContentRegistry::DataProcessorNode::add<NodeRGBA8>("hex.builtin.nodes.constants", "hex.builtin.nodes.constants.rgba8"); ContentRegistry::DataProcessor::add<NodeRGBA8>("hex.builtin.nodes.constants", "hex.builtin.nodes.constants.rgba8");
ContentRegistry::DataProcessorNode::add<NodeComment>("hex.builtin.nodes.constants", "hex.builtin.nodes.constants.comment"); ContentRegistry::DataProcessor::add<NodeComment>("hex.builtin.nodes.constants", "hex.builtin.nodes.constants.comment");
} }
} }

View File

@ -1,4 +1,4 @@
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/data_processor.hpp>
#include <hex/data_processor/node.hpp> #include <hex/data_processor/node.hpp>
namespace hex::plugin::builtin { namespace hex::plugin::builtin {
@ -148,14 +148,14 @@ namespace hex::plugin::builtin {
}; };
void registerControlDataProcessorNodes() { void registerControlDataProcessorNodes() {
ContentRegistry::DataProcessorNode::add<NodeIf>("hex.builtin.nodes.control_flow", "hex.builtin.nodes.control_flow.if"); ContentRegistry::DataProcessor::add<NodeIf>("hex.builtin.nodes.control_flow", "hex.builtin.nodes.control_flow.if");
ContentRegistry::DataProcessorNode::add<NodeEquals>("hex.builtin.nodes.control_flow", "hex.builtin.nodes.control_flow.equals"); ContentRegistry::DataProcessor::add<NodeEquals>("hex.builtin.nodes.control_flow", "hex.builtin.nodes.control_flow.equals");
ContentRegistry::DataProcessorNode::add<NodeNot>("hex.builtin.nodes.control_flow", "hex.builtin.nodes.control_flow.not"); ContentRegistry::DataProcessor::add<NodeNot>("hex.builtin.nodes.control_flow", "hex.builtin.nodes.control_flow.not");
ContentRegistry::DataProcessorNode::add<NodeGreaterThan>("hex.builtin.nodes.control_flow", "hex.builtin.nodes.control_flow.gt"); ContentRegistry::DataProcessor::add<NodeGreaterThan>("hex.builtin.nodes.control_flow", "hex.builtin.nodes.control_flow.gt");
ContentRegistry::DataProcessorNode::add<NodeLessThan>("hex.builtin.nodes.control_flow", "hex.builtin.nodes.control_flow.lt"); ContentRegistry::DataProcessor::add<NodeLessThan>("hex.builtin.nodes.control_flow", "hex.builtin.nodes.control_flow.lt");
ContentRegistry::DataProcessorNode::add<NodeBoolAND>("hex.builtin.nodes.control_flow", "hex.builtin.nodes.control_flow.and"); ContentRegistry::DataProcessor::add<NodeBoolAND>("hex.builtin.nodes.control_flow", "hex.builtin.nodes.control_flow.and");
ContentRegistry::DataProcessorNode::add<NodeBoolOR>("hex.builtin.nodes.control_flow", "hex.builtin.nodes.control_flow.or"); ContentRegistry::DataProcessor::add<NodeBoolOR>("hex.builtin.nodes.control_flow", "hex.builtin.nodes.control_flow.or");
ContentRegistry::DataProcessorNode::add<NodeLoop>("hex.builtin.nodes.control_flow", "hex.builtin.nodes.control_flow.loop"); ContentRegistry::DataProcessor::add<NodeLoop>("hex.builtin.nodes.control_flow", "hex.builtin.nodes.control_flow.loop");
} }
} }

View File

@ -1,5 +1,5 @@
#include <algorithm> #include <algorithm>
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/data_processor.hpp>
#include <hex/api/localization_manager.hpp> #include <hex/api/localization_manager.hpp>
#include <hex/helpers/scaling.hpp> #include <hex/helpers/scaling.hpp>
#include <hex/helpers/crypto.hpp> #include <hex/helpers/crypto.hpp>
@ -145,9 +145,9 @@ namespace hex::plugin::builtin {
}; };
void registerDecodeDataProcessorNodes() { void registerDecodeDataProcessorNodes() {
ContentRegistry::DataProcessorNode::add<NodeDecodingBase64>("hex.builtin.nodes.decoding", "hex.builtin.nodes.decoding.base64"); ContentRegistry::DataProcessor::add<NodeDecodingBase64>("hex.builtin.nodes.decoding", "hex.builtin.nodes.decoding.base64");
ContentRegistry::DataProcessorNode::add<NodeDecodingHex>("hex.builtin.nodes.decoding", "hex.builtin.nodes.decoding.hex"); ContentRegistry::DataProcessor::add<NodeDecodingHex>("hex.builtin.nodes.decoding", "hex.builtin.nodes.decoding.hex");
ContentRegistry::DataProcessorNode::add<NodeCryptoAESDecrypt>("hex.builtin.nodes.crypto", "hex.builtin.nodes.crypto.aes"); ContentRegistry::DataProcessor::add<NodeCryptoAESDecrypt>("hex.builtin.nodes.crypto", "hex.builtin.nodes.crypto.aes");
} }
} }

View File

@ -1,4 +1,4 @@
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/data_processor.hpp>
#include <hex/data_processor/node.hpp> #include <hex/data_processor/node.hpp>
#include <ranges> #include <ranges>
@ -166,14 +166,14 @@ namespace hex::plugin::builtin {
}; };
void registerLogicDataProcessorNodes() { void registerLogicDataProcessorNodes() {
ContentRegistry::DataProcessorNode::add<NodeBitwiseADD>("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.add"); ContentRegistry::DataProcessor::add<NodeBitwiseADD>("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.add");
ContentRegistry::DataProcessorNode::add<NodeBitwiseAND>("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.and"); ContentRegistry::DataProcessor::add<NodeBitwiseAND>("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.and");
ContentRegistry::DataProcessorNode::add<NodeBitwiseOR>("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.or"); ContentRegistry::DataProcessor::add<NodeBitwiseOR>("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.or");
ContentRegistry::DataProcessorNode::add<NodeBitwiseXOR>("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.xor"); ContentRegistry::DataProcessor::add<NodeBitwiseXOR>("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.xor");
ContentRegistry::DataProcessorNode::add<NodeBitwiseNOT>("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.not"); ContentRegistry::DataProcessor::add<NodeBitwiseNOT>("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.not");
ContentRegistry::DataProcessorNode::add<NodeBitwiseShiftLeft>("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.shift_left"); ContentRegistry::DataProcessor::add<NodeBitwiseShiftLeft>("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.shift_left");
ContentRegistry::DataProcessorNode::add<NodeBitwiseShiftRight>("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.shift_right"); ContentRegistry::DataProcessor::add<NodeBitwiseShiftRight>("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.shift_right");
ContentRegistry::DataProcessorNode::add<NodeBitwiseSwap>("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.swap"); ContentRegistry::DataProcessor::add<NodeBitwiseSwap>("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.swap");
} }
} }

View File

@ -1,4 +1,4 @@
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/data_processor.hpp>
#include <hex/data_processor/node.hpp> #include <hex/data_processor/node.hpp>
#include <numeric> #include <numeric>
@ -152,16 +152,16 @@ namespace hex::plugin::builtin {
}; };
void registerMathDataProcessorNodes() { void registerMathDataProcessorNodes() {
ContentRegistry::DataProcessorNode::add<NodeArithmeticAdd>("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.add"); ContentRegistry::DataProcessor::add<NodeArithmeticAdd>("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.add");
ContentRegistry::DataProcessorNode::add<NodeArithmeticSubtract>("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.sub"); ContentRegistry::DataProcessor::add<NodeArithmeticSubtract>("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.sub");
ContentRegistry::DataProcessorNode::add<NodeArithmeticMultiply>("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.mul"); ContentRegistry::DataProcessor::add<NodeArithmeticMultiply>("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.mul");
ContentRegistry::DataProcessorNode::add<NodeArithmeticDivide>("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.div"); ContentRegistry::DataProcessor::add<NodeArithmeticDivide>("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.div");
ContentRegistry::DataProcessorNode::add<NodeArithmeticModulus>("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.mod"); ContentRegistry::DataProcessor::add<NodeArithmeticModulus>("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.mod");
ContentRegistry::DataProcessorNode::add<NodeArithmeticAverage>("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.average"); ContentRegistry::DataProcessor::add<NodeArithmeticAverage>("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.average");
ContentRegistry::DataProcessorNode::add<NodeArithmeticMedian>("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.median"); ContentRegistry::DataProcessor::add<NodeArithmeticMedian>("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.median");
ContentRegistry::DataProcessorNode::add<NodeArithmeticCeil>("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.ceil"); ContentRegistry::DataProcessor::add<NodeArithmeticCeil>("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.ceil");
ContentRegistry::DataProcessorNode::add<NodeArithmeticFloor>("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.floor"); ContentRegistry::DataProcessor::add<NodeArithmeticFloor>("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.floor");
ContentRegistry::DataProcessorNode::add<NodeArithmeticRound>("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.round"); ContentRegistry::DataProcessor::add<NodeArithmeticRound>("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.round");
} }
} }

View File

@ -1,5 +1,6 @@
#include <hex/api/imhex_api/provider.hpp> #include <hex/api/imhex_api/provider.hpp>
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/pattern_language.hpp>
#include <hex/api/content_registry/data_processor.hpp>
#include <hex/api/achievement_manager.hpp> #include <hex/api/achievement_manager.hpp>
#include <hex/api/events/events_interaction.hpp> #include <hex/api/events/events_interaction.hpp>
@ -12,6 +13,8 @@
#include <content/helpers/diagrams.hpp> #include <content/helpers/diagrams.hpp>
#include <pl/patterns/pattern.hpp> #include <pl/patterns/pattern.hpp>
#include <nlohmann/json.hpp>
namespace hex::plugin::builtin { namespace hex::plugin::builtin {
class NodeReadData : public dp::Node { class NodeReadData : public dp::Node {
@ -461,30 +464,30 @@ namespace hex::plugin::builtin {
}; };
void registerOtherDataProcessorNodes() { void registerOtherDataProcessorNodes() {
ContentRegistry::DataProcessorNode::add<NodeReadData>("hex.builtin.nodes.data_access", "hex.builtin.nodes.data_access.read"); ContentRegistry::DataProcessor::add<NodeReadData>("hex.builtin.nodes.data_access", "hex.builtin.nodes.data_access.read");
ContentRegistry::DataProcessorNode::add<NodeWriteData>("hex.builtin.nodes.data_access", "hex.builtin.nodes.data_access.write"); ContentRegistry::DataProcessor::add<NodeWriteData>("hex.builtin.nodes.data_access", "hex.builtin.nodes.data_access.write");
ContentRegistry::DataProcessorNode::add<NodeDataSize>("hex.builtin.nodes.data_access", "hex.builtin.nodes.data_access.size"); ContentRegistry::DataProcessor::add<NodeDataSize>("hex.builtin.nodes.data_access", "hex.builtin.nodes.data_access.size");
ContentRegistry::DataProcessorNode::add<NodeDataSelection>("hex.builtin.nodes.data_access", "hex.builtin.nodes.data_access.selection"); ContentRegistry::DataProcessor::add<NodeDataSelection>("hex.builtin.nodes.data_access", "hex.builtin.nodes.data_access.selection");
ContentRegistry::DataProcessorNode::add<NodeCastIntegerToBuffer>("hex.builtin.nodes.casting", "hex.builtin.nodes.casting.int_to_buffer"); ContentRegistry::DataProcessor::add<NodeCastIntegerToBuffer>("hex.builtin.nodes.casting", "hex.builtin.nodes.casting.int_to_buffer");
ContentRegistry::DataProcessorNode::add<NodeCastBufferToInteger>("hex.builtin.nodes.casting", "hex.builtin.nodes.casting.buffer_to_int"); ContentRegistry::DataProcessor::add<NodeCastBufferToInteger>("hex.builtin.nodes.casting", "hex.builtin.nodes.casting.buffer_to_int");
ContentRegistry::DataProcessorNode::add<NodeCastFloatToBuffer>("hex.builtin.nodes.casting", "hex.builtin.nodes.casting.float_to_buffer"); ContentRegistry::DataProcessor::add<NodeCastFloatToBuffer>("hex.builtin.nodes.casting", "hex.builtin.nodes.casting.float_to_buffer");
ContentRegistry::DataProcessorNode::add<NodeCastBufferToFloat>("hex.builtin.nodes.casting", "hex.builtin.nodes.casting.buffer_to_float"); ContentRegistry::DataProcessor::add<NodeCastBufferToFloat>("hex.builtin.nodes.casting", "hex.builtin.nodes.casting.buffer_to_float");
ContentRegistry::DataProcessorNode::add<NodeBufferCombine>("hex.builtin.nodes.buffer", "hex.builtin.nodes.buffer.combine"); ContentRegistry::DataProcessor::add<NodeBufferCombine>("hex.builtin.nodes.buffer", "hex.builtin.nodes.buffer.combine");
ContentRegistry::DataProcessorNode::add<NodeBufferSlice>("hex.builtin.nodes.buffer", "hex.builtin.nodes.buffer.slice"); ContentRegistry::DataProcessor::add<NodeBufferSlice>("hex.builtin.nodes.buffer", "hex.builtin.nodes.buffer.slice");
ContentRegistry::DataProcessorNode::add<NodeBufferRepeat>("hex.builtin.nodes.buffer", "hex.builtin.nodes.buffer.repeat"); ContentRegistry::DataProcessor::add<NodeBufferRepeat>("hex.builtin.nodes.buffer", "hex.builtin.nodes.buffer.repeat");
ContentRegistry::DataProcessorNode::add<NodeBufferPatch>("hex.builtin.nodes.buffer", "hex.builtin.nodes.buffer.patch"); ContentRegistry::DataProcessor::add<NodeBufferPatch>("hex.builtin.nodes.buffer", "hex.builtin.nodes.buffer.patch");
ContentRegistry::DataProcessorNode::add<NodeBufferSize>("hex.builtin.nodes.buffer", "hex.builtin.nodes.buffer.size"); ContentRegistry::DataProcessor::add<NodeBufferSize>("hex.builtin.nodes.buffer", "hex.builtin.nodes.buffer.size");
ContentRegistry::DataProcessorNode::add<NodeBufferByteSwap>("hex.builtin.nodes.buffer", "hex.builtin.nodes.buffer.byte_swap"); ContentRegistry::DataProcessor::add<NodeBufferByteSwap>("hex.builtin.nodes.buffer", "hex.builtin.nodes.buffer.byte_swap");
ContentRegistry::DataProcessorNode::add<NodeVisualizerDigram>("hex.builtin.nodes.visualizer", "hex.builtin.nodes.visualizer.digram"); ContentRegistry::DataProcessor::add<NodeVisualizerDigram>("hex.builtin.nodes.visualizer", "hex.builtin.nodes.visualizer.digram");
ContentRegistry::DataProcessorNode::add<NodeVisualizerLayeredDistribution>("hex.builtin.nodes.visualizer", "hex.builtin.nodes.visualizer.layered_dist"); ContentRegistry::DataProcessor::add<NodeVisualizerLayeredDistribution>("hex.builtin.nodes.visualizer", "hex.builtin.nodes.visualizer.layered_dist");
ContentRegistry::DataProcessorNode::add<NodeVisualizerImage>("hex.builtin.nodes.visualizer", "hex.builtin.nodes.visualizer.image"); ContentRegistry::DataProcessor::add<NodeVisualizerImage>("hex.builtin.nodes.visualizer", "hex.builtin.nodes.visualizer.image");
ContentRegistry::DataProcessorNode::add<NodeVisualizerImageRGBA>("hex.builtin.nodes.visualizer", "hex.builtin.nodes.visualizer.image_rgba"); ContentRegistry::DataProcessor::add<NodeVisualizerImageRGBA>("hex.builtin.nodes.visualizer", "hex.builtin.nodes.visualizer.image_rgba");
ContentRegistry::DataProcessorNode::add<NodeVisualizerByteDistribution>("hex.builtin.nodes.visualizer", "hex.builtin.nodes.visualizer.byte_distribution"); ContentRegistry::DataProcessor::add<NodeVisualizerByteDistribution>("hex.builtin.nodes.visualizer", "hex.builtin.nodes.visualizer.byte_distribution");
ContentRegistry::DataProcessorNode::add<NodePatternLanguageOutVariable>("hex.builtin.nodes.pattern_language", "hex.builtin.nodes.pattern_language.out_var"); ContentRegistry::DataProcessor::add<NodePatternLanguageOutVariable>("hex.builtin.nodes.pattern_language", "hex.builtin.nodes.pattern_language.out_var");
} }
} }

View File

@ -1,6 +1,6 @@
#include <hex/data_processor/node.hpp> #include <hex/data_processor/node.hpp>
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/data_processor.hpp>
#include <hex/ui/imgui_imhex_extensions.h> #include <hex/ui/imgui_imhex_extensions.h>
@ -184,11 +184,11 @@ namespace hex::plugin::builtin {
}; };
void registerVisualDataProcessorNodes() { void registerVisualDataProcessorNodes() {
ContentRegistry::DataProcessorNode::add<NodeDisplayInteger>("hex.builtin.nodes.display", "hex.builtin.nodes.display.int"); ContentRegistry::DataProcessor::add<NodeDisplayInteger>("hex.builtin.nodes.display", "hex.builtin.nodes.display.int");
ContentRegistry::DataProcessorNode::add<NodeDisplayFloat>("hex.builtin.nodes.display", "hex.builtin.nodes.display.float"); ContentRegistry::DataProcessor::add<NodeDisplayFloat>("hex.builtin.nodes.display", "hex.builtin.nodes.display.float");
ContentRegistry::DataProcessorNode::add<NodeDisplayBuffer>("hex.builtin.nodes.display", "hex.builtin.nodes.display.buffer"); ContentRegistry::DataProcessor::add<NodeDisplayBuffer>("hex.builtin.nodes.display", "hex.builtin.nodes.display.buffer");
ContentRegistry::DataProcessorNode::add<NodeDisplayString>("hex.builtin.nodes.display", "hex.builtin.nodes.display.string"); ContentRegistry::DataProcessor::add<NodeDisplayString>("hex.builtin.nodes.display", "hex.builtin.nodes.display.string");
ContentRegistry::DataProcessorNode::add<NodeDisplayBits>("hex.builtin.nodes.display", "hex.builtin.nodes.display.bits"); ContentRegistry::DataProcessor::add<NodeDisplayBits>("hex.builtin.nodes.display", "hex.builtin.nodes.display.bits");
} }
} }

View File

@ -1,4 +1,4 @@
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/hex_editor.hpp>
#include <imgui.h> #include <imgui.h>
#include <hex/ui/imgui_imhex_extensions.h> #include <hex/ui/imgui_imhex_extensions.h>

View File

@ -7,7 +7,8 @@
#include <hex/api/events/requests_gui.hpp> #include <hex/api/events/requests_gui.hpp>
#include <hex/api/localization_manager.hpp> #include <hex/api/localization_manager.hpp>
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/settings.hpp>
#include <hex/api/content_registry/file_type_handler.hpp>
#include <hex/api/project_file_manager.hpp> #include <hex/api/project_file_manager.hpp>
#include <hex/api/achievement_manager.hpp> #include <hex/api/achievement_manager.hpp>
#include <hex/api/workspace_manager.hpp> #include <hex/api/workspace_manager.hpp>
@ -262,7 +263,7 @@ namespace hex::plugin::builtin {
EventFileDropped::subscribe([](const std::fs::path &path) { EventFileDropped::subscribe([](const std::fs::path &path) {
// Check if a custom file handler can handle the file // Check if a custom file handler can handle the file
bool handled = false; 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) { for (const auto &extension : extensions) {
if (path.extension() == extension) { if (path.extension() == extension) {
// Pass the file to the handler and check if it was successful // Pass the file to the handler and check if it was successful

View File

@ -1,4 +1,4 @@
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/file_type_handler.hpp>
#include <hex/api/project_file_manager.hpp> #include <hex/api/project_file_manager.hpp>
#include <hex/helpers/default_paths.hpp> #include <hex/helpers/default_paths.hpp>
@ -9,11 +9,11 @@ namespace hex::plugin::builtin {
void registerFileHandlers() { void registerFileHandlers() {
ContentRegistry::FileHandler::add({ ".hexproj" }, [](const std::fs::path &path) { ContentRegistry::FileTypeHandler::add({ ".hexproj" }, [](const std::fs::path &path) {
return ProjectFile::load(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()) { for (const auto &folder : paths::Layouts.write()) {
if (wolv::io::fs::copyFile(path, folder / path.filename())) if (wolv::io::fs::copyFile(path, folder / path.filename()))
return true; return true;
@ -22,7 +22,7 @@ namespace hex::plugin::builtin {
return false; return false;
}); });
ContentRegistry::FileHandler::add({ ".mgc" }, [](const auto &path) { ContentRegistry::FileTypeHandler::add({ ".mgc" }, [](const auto &path) {
for (const auto &destPath : paths::Magic.write()) { for (const auto &destPath : paths::Magic.write()) {
if (wolv::io::fs::copyFile(path, destPath / path.filename(), std::fs::copy_options::overwrite_existing)) { 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); ui::ToastInfo::open("hex.builtin.view.information.magic_db_added"_lang);

View File

@ -1,5 +1,6 @@
#include <hex/api/imhex_api/system.hpp> #include <hex/api/imhex_api/system.hpp>
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/settings.hpp>
#include <hex/api/content_registry/user_interface.hpp>
#include <hex/api/events/events_gui.hpp> #include <hex/api/events/events_gui.hpp>
#include <hex/api_urls.hpp> #include <hex/api_urls.hpp>
@ -37,7 +38,7 @@ namespace hex::plugin::builtin {
return; return;
TaskManager::doLater([updateString] { 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); ImHexApi::System::updateImHex(ImHexApi::System::isNightlyBuild() ? ImHexApi::System::UpdateType::Nightly : ImHexApi::System::UpdateType::Stable);
}); });

View File

@ -1,5 +1,10 @@
#include <hex/api/imhex_api/provider.hpp> #include <hex/api/imhex_api/provider.hpp>
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/user_interface.hpp>
#include <hex/api/content_registry/data_formatter.hpp>
#include <hex/api/content_registry/reports.hpp>
#include <hex/api/content_registry/views.hpp>
#include <hex/api/content_registry/provider.hpp>
#include <hex/api/content_registry/settings.hpp>
#include <imgui.h> #include <imgui.h>
#include <implot.h> #include <implot.h>
@ -367,10 +372,10 @@ namespace hex::plugin::builtin {
static void createFileMenu() { static void createFileMenu() {
ContentRegistry::Interface::registerMainMenuItem("hex.builtin.menu.file", 1000); ContentRegistry::UserInterface::registerMainMenuItem("hex.builtin.menu.file", 1000);
/* Create File */ /* 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); auto newProvider = hex::ImHexApi::Provider::createProvider("hex.builtin.provider.mem_file", true);
if (newProvider != nullptr && !newProvider->open()) if (newProvider != nullptr && !newProvider->open())
hex::ImHexApi::Provider::remove(newProvider); hex::ImHexApi::Provider::remove(newProvider);
@ -379,12 +384,12 @@ namespace hex::plugin::builtin {
}, noRunningTasks); }, noRunningTasks);
/* Open File */ /* 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"); RequestOpenWindow::post("Open File");
}, noRunningTasks, ContentRegistry::Views::getViewByName("hex.builtin.view.hex_editor.name")); }, noRunningTasks, ContentRegistry::Views::getViewByName("hex.builtin.view.hex_editor.name"));
/* Open Other */ /* 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()) { for (const auto &[unlocalizedProviderName, icon] : ContentRegistry::Provider::impl::getEntries()) {
if (menu::menuItemEx(Lang(unlocalizedProviderName), icon)) if (menu::menuItemEx(Lang(unlocalizedProviderName), icon))
ImHexApi::Provider::createProvider(unlocalizedProviderName); ImHexApi::Provider::createProvider(unlocalizedProviderName);
@ -392,7 +397,7 @@ namespace hex::plugin::builtin {
}, noRunningTasks); }, noRunningTasks);
/* Reload Provider */ /* 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(); auto provider = ImHexApi::Provider::get();
provider->close(); provider->close();
@ -404,41 +409,41 @@ namespace hex::plugin::builtin {
/* Project open / save */ /* 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, CTRL + ALT + Keys::O + AllowWhileTyping,
openProject, noRunningTasks); 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, CTRL + ALT + Keys::S + AllowWhileTyping,
saveProject, [&] { return noRunningTaskAndValidProvider() && ProjectFile::hasPath(); }); 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, ALT + SHIFT + Keys::S + AllowWhileTyping,
saveProjectAs, noRunningTaskAndValidProvider); saveProjectAs, noRunningTaskAndValidProvider);
ContentRegistry::Interface::addMenuItemSeparator({ "hex.builtin.menu.file" }, 2000); ContentRegistry::UserInterface::addMenuItemSeparator({ "hex.builtin.menu.file" }, 2000);
/* Import */ /* 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 */ /* 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, Shortcut::None,
importIPSPatch, importIPSPatch,
noRunningTaskAndWritableProvider); noRunningTaskAndWritableProvider);
/* IPS32 */ /* 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, Shortcut::None,
importIPS32Patch, importIPS32Patch,
noRunningTaskAndWritableProvider); noRunningTaskAndWritableProvider);
/* Modified File */ /* 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, Shortcut::None,
importModifiedFile, importModifiedFile,
noRunningTaskAndWritableProvider); noRunningTaskAndWritableProvider);
@ -447,68 +452,68 @@ namespace hex::plugin::builtin {
/* Export */ /* Export */
/* Only make them accessible if the current provider is dumpable */ /* 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 */ /* 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, Shortcut::None,
exportSelectionToFile, exportSelectionToFile,
ImHexApi::HexEditor::isSelectionValid); ImHexApi::HexEditor::isSelectionValid);
/* Base 64 */ /* 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, Shortcut::None,
exportBase64, exportBase64,
isProviderDumpable); isProviderDumpable);
/* Language */ /* 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, drawExportLanguageMenu,
isProviderDumpable); isProviderDumpable);
/* Report */ /* 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, Shortcut::None,
exportReport, exportReport,
ImHexApi::Provider::isValid); 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 */ /* 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, Shortcut::None,
exportIPSPatch, exportIPSPatch,
isProviderDumpable); isProviderDumpable);
/* IPS32 */ /* 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, Shortcut::None,
exportIPS32Patch, exportIPS32Patch,
isProviderDumpable); isProviderDumpable);
} }
ContentRegistry::Interface::addMenuItemSeparator({ "hex.builtin.menu.file" }, 10000); ContentRegistry::UserInterface::addMenuItemSeparator({ "hex.builtin.menu.file" }, 10000);
/* Close Provider */ /* 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()); ImHexApi::Provider::remove(ImHexApi::Provider::get());
}, noRunningTaskAndValidProvider); }, noRunningTaskAndValidProvider);
/* Quit ImHex */ /* 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(); ImHexApi::System::closeImHex();
}); });
} }
static void createEditMenu() { static void createEditMenu() {
ContentRegistry::Interface::registerMainMenuItem("hex.builtin.menu.edit", 2000); ContentRegistry::UserInterface::registerMainMenuItem("hex.builtin.menu.edit", 2000);
} }
static void createViewMenu() { static void createViewMenu() {
ContentRegistry::Interface::registerMainMenuItem("hex.builtin.menu.view", 3000); ContentRegistry::UserInterface::registerMainMenuItem("hex.builtin.menu.view", 3000);
#if !defined(OS_WEB) #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; static bool state = false;
state = !state; state = !state;
@ -517,7 +522,7 @@ namespace hex::plugin::builtin {
#endif #endif
#if !defined(OS_MACOS) && !defined(OS_WEB) #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 bool state = false;
static ImVec2 position, size; static ImVec2 position, size;
@ -542,10 +547,10 @@ namespace hex::plugin::builtin {
#endif #endif
#if !defined(OS_WEB) #if !defined(OS_WEB)
ContentRegistry::Interface::addMenuItemSeparator({ "hex.builtin.menu.view" }, 3000); ContentRegistry::UserInterface::addMenuItemSeparator({ "hex.builtin.menu.view" }, 3000);
#endif #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()) { for (auto &[name, view] : ContentRegistry::Views::impl::getEntries()) {
if (view->hasViewMenuItemEntry()) { if (view->hasViewMenuItemEntry()) {
auto &state = view->getWindowOpenState(); auto &state = view->getWindowOpenState();
@ -561,15 +566,15 @@ namespace hex::plugin::builtin {
static void createLayoutMenu() { static void createLayoutMenu() {
LayoutManager::reload(); 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) { ui::PopupTextInput::open("hex.builtin.popup.save_layout.title", "hex.builtin.popup.save_layout.desc", [](const std::string &name) {
LayoutManager::save(name); LayoutManager::save(name);
}); });
}, ImHexApi::Provider::isValid); }, 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(); bool locked = LayoutManager::isLayoutLocked();
if (menu::menuItemEx("hex.builtin.menu.workspace.layout.lock"_lang, ICON_VS_LOCK, Shortcut::None, locked, ImHexApi::Provider::isValid())) { if (menu::menuItemEx("hex.builtin.menu.workspace.layout.lock"_lang, ICON_VS_LOCK, Shortcut::None, locked, ImHexApi::Provider::isValid())) {
LayoutManager::lockLayout(!locked); 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")) { for (const auto &path : romfs::list("layouts")) {
if (menu::menuItem(wolv::util::capitalizeString(path.stem().string()).c_str(), Shortcut::None, false, ImHexApi::Provider::isValid())) { 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())); LayoutManager::loadFromString(std::string(romfs::get(path).string()));
@ -601,19 +606,19 @@ namespace hex::plugin::builtin {
} }
static void createWorkspaceMenu() { static void createWorkspaceMenu() {
ContentRegistry::Interface::registerMainMenuItem("hex.builtin.menu.workspace", 4000); ContentRegistry::UserInterface::registerMainMenuItem("hex.builtin.menu.workspace", 4000);
createLayoutMenu(); 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) { ui::PopupTextInput::open("hex.builtin.popup.create_workspace.title", "hex.builtin.popup.create_workspace.desc", [](const std::string &name) {
WorkspaceManager::createWorkspace(name); WorkspaceManager::createWorkspace(name);
}); });
}, ImHexApi::Provider::isValid); }, ImHexApi::Provider::isValid);
ContentRegistry::Interface::addMenuItemSubMenu({ "hex.builtin.menu.workspace" }, 3200, [] { ContentRegistry::UserInterface::addMenuItemSubMenu({ "hex.builtin.menu.workspace" }, 3200, [] {
const auto &workspaces = WorkspaceManager::getWorkspaces(); const auto &workspaces = WorkspaceManager::getWorkspaces();
bool shiftPressed = ImGui::GetIO().KeyShift; bool shiftPressed = ImGui::GetIO().KeyShift;
@ -634,11 +639,11 @@ namespace hex::plugin::builtin {
} }
static void createExtrasMenu() { 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", [] { TaskManager::createBackgroundTask("Checking for updates", [] {
auto versionString = ImHexApi::System::checkForUpdate(); auto versionString = ImHexApi::System::checkForUpdate();
if (!versionString.has_value()) { if (!versionString.has_value()) {
@ -653,18 +658,18 @@ namespace hex::plugin::builtin {
}); });
if (ImHexApi::System::isNightlyBuild()) { 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); ImHexApi::System::updateImHex(ImHexApi::System::UpdateType::Stable);
}); });
} else { } 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); ImHexApi::System::updateImHex(ImHexApi::System::UpdateType::Nightly);
}); });
} }
} }
static void createHelpMenu() { static void createHelpMenu() {
ContentRegistry::Interface::registerMainMenuItem("hex.builtin.menu.help", 6000); ContentRegistry::UserInterface::registerMainMenuItem("hex.builtin.menu.help", 6000);
} }

View File

@ -1,4 +1,4 @@
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/hex_editor.hpp>
#include <imgui.h> #include <imgui.h>
#include <imgui_internal.h> #include <imgui_internal.h>
@ -9,9 +9,6 @@
#include <pl/patterns/pattern.hpp> #include <pl/patterns/pattern.hpp>
#include <wolv/utils/lock.hpp> #include <wolv/utils/lock.hpp>
#include <wolv/utils/string.hpp>
namespace hex::plugin::builtin { namespace hex::plugin::builtin {
namespace { namespace {

View File

@ -1,4 +1,4 @@
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/settings.hpp>
#include <hex/api/events/events_lifecycle.hpp> #include <hex/api/events/events_lifecycle.hpp>
#include <hex/api/events/events_gui.hpp> #include <hex/api/events/events_gui.hpp>
#include <hex/api/task_manager.hpp> #include <hex/api/task_manager.hpp>

View File

@ -1,6 +1,6 @@
#include <hex/api/imhex_api/hex_editor.hpp> #include <hex/api/imhex_api/hex_editor.hpp>
#include <hex/api/imhex_api/provider.hpp> #include <hex/api/imhex_api/provider.hpp>
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/pattern_language.hpp>
#include <hex/providers/provider.hpp> #include <hex/providers/provider.hpp>
#include <hex/helpers/http_requests.hpp> #include <hex/helpers/http_requests.hpp>

View File

@ -1,4 +1,4 @@
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/pattern_language.hpp>
#include <hex/helpers/encoding_file.hpp> #include <hex/helpers/encoding_file.hpp>
#include <hex/providers/provider.hpp> #include <hex/providers/provider.hpp>

View File

@ -1,5 +1,5 @@
#include <hex/api/imhex_api/provider.hpp> #include <hex/api/imhex_api/provider.hpp>
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/pattern_language.hpp>
#include <hex/providers/provider.hpp> #include <hex/providers/provider.hpp>
#include <hex/helpers/magic.hpp> #include <hex/helpers/magic.hpp>

View File

@ -1,4 +1,4 @@
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/pattern_language.hpp>
#include <pl/core/evaluator.hpp> #include <pl/core/evaluator.hpp>

View File

@ -2,6 +2,7 @@
#include "content/views/view_hex_editor.hpp" #include "content/views/view_hex_editor.hpp"
#include <hex/api/content_registry/views.hpp>
#include <hex/helpers/crypto.hpp> #include <hex/helpers/crypto.hpp>
#include <hex/helpers/utils.hpp> #include <hex/helpers/utils.hpp>
#include <hex/providers/buffered_reader.hpp> #include <hex/providers/buffered_reader.hpp>

View File

@ -8,7 +8,6 @@
#include <hex/api/project_file_manager.hpp> #include <hex/api/project_file_manager.hpp>
#include <hex/api/localization_manager.hpp> #include <hex/api/localization_manager.hpp>
#include <hex/api/achievement_manager.hpp> #include <hex/api/achievement_manager.hpp>
#include <hex/api/content_registry.hpp>
#include <hex/api/events/events_lifecycle.hpp> #include <hex/api/events/events_lifecycle.hpp>
#include <hex/api/events/requests_gui.hpp> #include <hex/api/events/requests_gui.hpp>

View File

@ -1,4 +1,4 @@
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/provider.hpp>
#include "content/providers/gdb_provider.hpp" #include "content/providers/gdb_provider.hpp"
#include "content/providers/file_provider.hpp" #include "content/providers/file_provider.hpp"

View File

@ -1,7 +1,7 @@
#include "content/providers/file_provider.hpp" #include "content/providers/file_provider.hpp"
#include "content/providers/memory_file_provider.hpp" #include "content/providers/memory_file_provider.hpp"
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/settings.hpp>
#include <hex/api/imhex_api/provider.hpp> #include <hex/api/imhex_api/provider.hpp>
#include <hex/api/localization_manager.hpp> #include <hex/api/localization_manager.hpp>
#include <hex/api/project_file_manager.hpp> #include <hex/api/project_file_manager.hpp>

View File

@ -3,7 +3,8 @@
#include <hex/api/events/events_provider.hpp> #include <hex/api/events/events_provider.hpp>
#include <hex/api/events/events_lifecycle.hpp> #include <hex/api/events/events_lifecycle.hpp>
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/settings.hpp>
#include <hex/api/content_registry/user_interface.hpp>
#include <hex/api/imhex_api/provider.hpp> #include <hex/api/imhex_api/provider.hpp>
#include <hex/api/project_file_manager.hpp> #include <hex/api/project_file_manager.hpp>
#include <hex/api/task_manager.hpp> #include <hex/api/task_manager.hpp>
@ -359,7 +360,7 @@ namespace hex::plugin::builtin::recent {
return; return;
#endif #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())) { 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 // Copy to avoid changing list while iteration
auto recentEntries = s_recentEntries; auto recentEntries = s_recentEntries;

View File

@ -1,4 +1,4 @@
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/reports.hpp>
#include <hex/helpers/fmt.hpp> #include <hex/helpers/fmt.hpp>
#include <hex/helpers/utils.hpp> #include <hex/helpers/utils.hpp>

View File

@ -1,5 +1,8 @@
#include <hex/api/imhex_api/system.hpp> #include <hex/api/imhex_api/system.hpp>
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/settings.hpp>
#include <hex/api/content_registry/user_interface.hpp>
#include <hex/api/content_registry/experiments.hpp>
#include <hex/api/content_registry/views.hpp>
#include <hex/api/localization_manager.hpp> #include <hex/api/localization_manager.hpp>
#include <hex/api/theme_manager.hpp> #include <hex/api/theme_manager.hpp>
#include <hex/api/shortcut_manager.hpp> #include <hex/api/shortcut_manager.hpp>
@ -412,7 +415,7 @@ namespace hex::plugin::builtin {
bool draw(const std::string &) override { bool draw(const std::string &) override {
bool changed = false; 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; return entry.second.toolbarIndex != -1;
}); });
@ -429,7 +432,7 @@ namespace hex::plugin::builtin {
ImGui::TableNextColumn(); ImGui::TableNextColumn();
// Loop over all available menu items // 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); ImGui::PushID(&menuItem);
ON_SCOPE_EXIT { ImGui::PopID(); }; ON_SCOPE_EXIT { ImGui::PopID(); };
@ -441,9 +444,9 @@ namespace hex::plugin::builtin {
const auto &unlocalizedName = menuItem.unlocalizedNames.back(); const auto &unlocalizedName = menuItem.unlocalizedNames.back();
if (menuItem.unlocalizedNames.size() > 2) if (menuItem.unlocalizedNames.size() > 2)
continue; continue;
if (unlocalizedName.get() == ContentRegistry::Interface::impl::SeparatorValue) if (unlocalizedName.get() == ContentRegistry::UserInterface::impl::SeparatorValue)
continue; continue;
if (unlocalizedName.get() == ContentRegistry::Interface::impl::SubMenuValue) if (unlocalizedName.get() == ContentRegistry::UserInterface::impl::SubMenuValue)
continue; continue;
if (menuItem.toolbarIndex != -1) if (menuItem.toolbarIndex != -1)
continue; continue;
@ -478,7 +481,7 @@ namespace hex::plugin::builtin {
// Handle dropping menu items from the toolbar box // Handle dropping menu items from the toolbar box
if (ImGui::BeginDragDropTarget()) { if (ImGui::BeginDragDropTarget()) {
if (auto payload = ImGui::AcceptDragDropPayload("TOOLBAR_ITEM_PAYLOAD"); payload != nullptr) { if (auto payload = ImGui::AcceptDragDropPayload("TOOLBAR_ITEM_PAYLOAD"); payload != nullptr) {
auto &menuItem = *static_cast<ContentRegistry::Interface::impl::MenuItem **>(payload->Data); auto &menuItem = *static_cast<ContentRegistry::UserInterface::impl::MenuItem **>(payload->Data);
menuItem->toolbarIndex = -1; menuItem->toolbarIndex = -1;
changed = true; changed = true;
@ -497,8 +500,8 @@ namespace hex::plugin::builtin {
ImGui::TableNextRow(); ImGui::TableNextRow();
// Find all menu items that are in the toolbar and sort them by their toolbar index // Find all menu items that are in the toolbar and sort them by their toolbar index
std::vector<ContentRegistry::Interface::impl::MenuItem*> toolbarItems; std::vector<ContentRegistry::UserInterface::impl::MenuItem*> toolbarItems;
for (auto &[priority, menuItem] : ContentRegistry::Interface::impl::getMenuItemsMutable()) { for (auto &[priority, menuItem] : ContentRegistry::UserInterface::impl::getMenuItemsMutable()) {
if (menuItem.toolbarIndex == -1) if (menuItem.toolbarIndex == -1)
continue; continue;
@ -520,7 +523,7 @@ namespace hex::plugin::builtin {
const auto &unlocalizedName = menuItem->unlocalizedNames.back(); const auto &unlocalizedName = menuItem->unlocalizedNames.back();
if (menuItem->unlocalizedNames.size() > 2) if (menuItem->unlocalizedNames.size() > 2)
continue; continue;
if (unlocalizedName.get() == ContentRegistry::Interface::impl::SubMenuValue) if (unlocalizedName.get() == ContentRegistry::UserInterface::impl::SubMenuValue)
continue; continue;
if (menuItem->toolbarIndex == -1) if (menuItem->toolbarIndex == -1)
continue; continue;
@ -542,10 +545,10 @@ namespace hex::plugin::builtin {
// Handle dropping toolbar items onto each other to reorder them // Handle dropping toolbar items onto each other to reorder them
if (ImGui::BeginDragDropTarget()) { if (ImGui::BeginDragDropTarget()) {
if (auto payload = ImGui::AcceptDragDropPayload("TOOLBAR_ITEM_PAYLOAD"); payload != nullptr) { if (auto payload = ImGui::AcceptDragDropPayload("TOOLBAR_ITEM_PAYLOAD"); payload != nullptr) {
auto &otherMenuItem = *static_cast<ContentRegistry::Interface::impl::MenuItem **>(payload->Data); auto &otherMenuItem = *static_cast<ContentRegistry::UserInterface::impl::MenuItem **>(payload->Data);
// Get all toolbar items sorted by toolbarIndex // Get all toolbar items sorted by toolbarIndex
std::vector<ContentRegistry::Interface::impl::MenuItem*> newToolbarItems = toolbarItems; std::vector<ContentRegistry::UserInterface::impl::MenuItem*> newToolbarItems = toolbarItems;
// Remove otherMenuItem from its current position // Remove otherMenuItem from its current position
auto it = std::ranges::find(newToolbarItems, otherMenuItem); auto it = std::ranges::find(newToolbarItems, otherMenuItem);
@ -636,7 +639,7 @@ namespace hex::plugin::builtin {
// Handle dropping menu items onto the toolbar box // Handle dropping menu items onto the toolbar box
if (ImGui::BeginDragDropTarget()) { if (ImGui::BeginDragDropTarget()) {
if (auto payload = ImGui::AcceptDragDropPayload("MENU_ITEM_PAYLOAD"); payload != nullptr) { if (auto payload = ImGui::AcceptDragDropPayload("MENU_ITEM_PAYLOAD"); payload != nullptr) {
auto &menuItem = *static_cast<ContentRegistry::Interface::impl::MenuItem **>(payload->Data); auto &menuItem = *static_cast<ContentRegistry::UserInterface::impl::MenuItem **>(payload->Data);
menuItem->toolbarIndex = currIndex; menuItem->toolbarIndex = currIndex;
changed = true; changed = true;
@ -649,7 +652,7 @@ namespace hex::plugin::builtin {
} }
if (changed) { if (changed) {
ContentRegistry::Interface::updateToolbarItems(); ContentRegistry::UserInterface::updateToolbarItems();
} }
return changed; return changed;
@ -658,7 +661,7 @@ namespace hex::plugin::builtin {
nlohmann::json store() override { nlohmann::json store() override {
std::map<i32, std::pair<std::string, u32>> items; std::map<i32, std::pair<std::string, u32>> items;
for (const auto &[priority, menuItem] : ContentRegistry::Interface::impl::getMenuItems()) { for (const auto &[priority, menuItem] : ContentRegistry::UserInterface::impl::getMenuItems()) {
if (menuItem.toolbarIndex != -1) if (menuItem.toolbarIndex != -1)
items.emplace(menuItem.toolbarIndex, std::make_pair(menuItem.unlocalizedNames.back().get(), menuItem.icon.color)); 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()) if (data.is_array() && data.empty())
return; return;
for (auto &[priority, menuItem] : ContentRegistry::Interface::impl::getMenuItemsMutable()) for (auto &[priority, menuItem] : ContentRegistry::UserInterface::impl::getMenuItemsMutable())
menuItem.toolbarIndex = -1; menuItem.toolbarIndex = -1;
auto toolbarItems = data.get<std::map<i32, std::pair<std::string, u32>>>(); auto toolbarItems = data.get<std::map<i32, std::pair<std::string, u32>>>();
if (toolbarItems.empty()) if (toolbarItems.empty())
return; return;
for (auto &[priority, menuItem] : ContentRegistry::Interface::impl::getMenuItemsMutable()) { for (auto &[priority, menuItem] : ContentRegistry::UserInterface::impl::getMenuItemsMutable()) {
for (const auto &[index, value] : toolbarItems) { for (const auto &[index, value] : toolbarItems) {
const auto &[name, color] = value; const auto &[name, color] = value;
if (menuItem.unlocalizedNames.back().get() == name) { if (menuItem.unlocalizedNames.back().get() == name) {
@ -691,7 +694,7 @@ namespace hex::plugin::builtin {
} }
} }
ContentRegistry::Interface::updateToolbarItems(); ContentRegistry::UserInterface::updateToolbarItems();
} }
}; };

View File

@ -1,4 +1,4 @@
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/settings.hpp>
#include <hex/api/localization_manager.hpp> #include <hex/api/localization_manager.hpp>
#include <hex/helpers/utils.hpp> #include <hex/helpers/utils.hpp>
#include <hex/helpers/scaling.hpp> #include <hex/helpers/scaling.hpp>

View File

@ -1,4 +1,4 @@
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/settings.hpp>
#include <hex/helpers/http_requests.hpp> #include <hex/helpers/http_requests.hpp>
#include <hex/api/localization_manager.hpp> #include <hex/api/localization_manager.hpp>

View File

@ -1,4 +1,4 @@
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/tools.hpp>
#include <hex/api/localization_manager.hpp> #include <hex/api/localization_manager.hpp>

View File

@ -1,4 +1,5 @@
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/user_interface.hpp>
#include <hex/api/content_registry/settings.hpp>
#include <hex/api/imhex_api/system.hpp> #include <hex/api/imhex_api/system.hpp>
#include <hex/api/localization_manager.hpp> #include <hex/api/localization_manager.hpp>
#include <hex/api/task_manager.hpp> #include <hex/api/task_manager.hpp>
@ -29,7 +30,7 @@ namespace hex::plugin::builtin {
void addTitleBarButtons() { void addTitleBarButtons() {
if (dbg::debugModeEnabled()) { 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) { if (ImGui::GetIO().KeyShift) {
RequestOpenPopup::post("DebugMenu"); RequestOpenPopup::post("DebugMenu");
} else { } 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"); hex::openWebpage("https://github.com/WerWolv/ImHex/discussions/categories/feedback");
}); });
@ -223,7 +224,7 @@ namespace hex::plugin::builtin {
void addFooterItems() { void addFooterItems() {
if (hex::isProcessElevated()) { if (hex::isProcessElevated()) {
ContentRegistry::Interface::addFooterItem([] { ContentRegistry::UserInterface::addFooterItem([] {
ImGui::PushStyleColor(ImGuiCol_Text, ImGuiExt::GetCustomColorU32(ImGuiCustomCol_Highlight)); ImGui::PushStyleColor(ImGuiCol_Text, ImGuiExt::GetCustomColorU32(ImGuiCustomCol_Highlight));
ImGui::TextUnformatted(ICON_VS_SHIELD); ImGui::TextUnformatted(ICON_VS_SHIELD);
ImGui::PopStyleColor(); ImGui::PopStyleColor();
@ -231,7 +232,7 @@ namespace hex::plugin::builtin {
} }
if (dbg::debugModeEnabled()) { if (dbg::debugModeEnabled()) {
ContentRegistry::Interface::addFooterItem([] { ContentRegistry::UserInterface::addFooterItem([] {
static float framerate = 0; static float framerate = 0;
if (ImGuiExt::HasSecondPassed()) { if (ImGuiExt::HasSecondPassed()) {
framerate = 1.0F / ImGui::GetIO().DeltaTime; framerate = 1.0F / ImGui::GetIO().DeltaTime;
@ -273,7 +274,7 @@ namespace hex::plugin::builtin {
}); });
} }
ContentRegistry::Interface::addFooterItem([] { ContentRegistry::UserInterface::addFooterItem([] {
static bool shouldResetProgress = false; static bool shouldResetProgress = false;
auto taskCount = TaskManager::getRunningTaskCount(); auto taskCount = TaskManager::getRunningTaskCount();
@ -452,11 +453,11 @@ namespace hex::plugin::builtin {
}); });
// Toolbar items // 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(); const auto &unlocalizedItemName = menuItem->unlocalizedNames.back();
if (unlocalizedItemName.get() == ContentRegistry::Interface::impl::SeparatorValue) { if (unlocalizedItemName.get() == ContentRegistry::UserInterface::impl::SeparatorValue) {
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical); ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);
continue; continue;
} }
@ -472,7 +473,7 @@ namespace hex::plugin::builtin {
}); });
// Provider switcher // Provider switcher
ContentRegistry::Interface::addToolbarItem([] { ContentRegistry::UserInterface::addToolbarItem([] {
const bool providerValid = ImHexApi::Provider::get() != nullptr; const bool providerValid = ImHexApi::Provider::get() != nullptr;
const bool tasksRunning = TaskManager::getRunningTaskCount() > 0; const bool tasksRunning = TaskManager::getRunningTaskCount() > 0;
@ -549,13 +550,13 @@ namespace hex::plugin::builtin {
}); });
EventImHexStartupFinished::subscribe([] { EventImHexStartupFinished::subscribe([] {
ContentRegistry::Interface::addMenuItemToToolbar("hex.builtin.view.hex_editor.menu.edit.undo", ImGuiCustomCol_ToolbarBlue); ContentRegistry::UserInterface::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::UserInterface::addMenuItemToToolbar("hex.builtin.view.hex_editor.menu.edit.redo", ImGuiCustomCol_ToolbarBlue);
ContentRegistry::Interface::addMenuItemToToolbar("hex.builtin.menu.file.create_file", ImGuiCustomCol_ToolbarGray); ContentRegistry::UserInterface::addMenuItemToToolbar("hex.builtin.menu.file.create_file", ImGuiCustomCol_ToolbarGray);
ContentRegistry::Interface::addMenuItemToToolbar("hex.builtin.menu.file.open_file", ImGuiCustomCol_ToolbarBrown); ContentRegistry::UserInterface::addMenuItemToToolbar("hex.builtin.menu.file.open_file", ImGuiCustomCol_ToolbarBrown);
ContentRegistry::Interface::addMenuItemToToolbar("hex.builtin.view.hex_editor.menu.file.save", ImGuiCustomCol_ToolbarBlue); ContentRegistry::UserInterface::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::UserInterface::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.menu.edit.bookmark.create", ImGuiCustomCol_ToolbarGreen);
}); });
} }

View File

@ -1,6 +1,6 @@
#include <content/views/fullscreen/view_fullscreen_save_editor.hpp> #include <content/views/fullscreen/view_fullscreen_save_editor.hpp>
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/pattern_language.hpp>
#include <fonts/vscode_icons.hpp> #include <fonts/vscode_icons.hpp>
#include <toasts/toast_notification.hpp> #include <toasts/toast_notification.hpp>

View File

@ -2,7 +2,7 @@
#include "hex/ui/popup.hpp" #include "hex/ui/popup.hpp"
#include <hex/api_urls.hpp> #include <hex/api_urls.hpp>
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/user_interface.hpp>
#include <hex/api/achievement_manager.hpp> #include <hex/api/achievement_manager.hpp>
#include <hex/api/plugin_manager.hpp> #include <hex/api/plugin_manager.hpp>
@ -11,16 +11,15 @@
#include <hex/helpers/utils.hpp> #include <hex/helpers/utils.hpp>
#include <hex/helpers/http_requests.hpp> #include <hex/helpers/http_requests.hpp>
#include <hex/helpers/default_paths.hpp> #include <hex/helpers/default_paths.hpp>
#include <hex/helpers/menu_items.hpp>
#include <content/popups/popup_docs_question.hpp>
#include <fonts/vscode_icons.hpp> #include <fonts/vscode_icons.hpp>
#include <romfs/romfs.hpp> #include <romfs/romfs.hpp>
#include <wolv/utils/string.hpp> #include <wolv/utils/string.hpp>
#include <nlohmann/json.hpp>
#include <string> #include <string>
#include <hex/helpers/menu_items.hpp>
namespace hex::plugin::builtin { 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) { ViewAbout::ViewAbout() : View::Modal("hex.builtin.view.help.about.name", ICON_VS_HEART) {
// Add "About" menu item to the help menu // 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; 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()) if (menu::isNativeMenuBarUsed())
return; return;
@ -100,11 +99,11 @@ namespace hex::plugin::builtin {
ImGui::PopStyleVar(); 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 // 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"); hex::openWebpage("https://docs.werwolv.net/imhex");
AchievementManager::unlockAchievement("hex.builtin.achievement.starting_out", "hex.builtin.achievement.starting_out.docs.name"); AchievementManager::unlockAchievement("hex.builtin.achievement.starting_out", "hex.builtin.achievement.starting_out.docs.name");
}); });

View File

@ -1,6 +1,7 @@
#include "content/views/view_achievements.hpp" #include "content/views/view_achievements.hpp"
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/user_interface.hpp>
#include <hex/api/content_registry/settings.hpp>
#include <hex/api/task_manager.hpp> #include <hex/api/task_manager.hpp>
#include <hex/api/events/requests_gui.hpp> #include <hex/api/events/requests_gui.hpp>
#include <hex/api/events/events_interaction.hpp> #include <hex/api/events/events_interaction.hpp>
@ -14,7 +15,7 @@ namespace hex::plugin::builtin {
ViewAchievements::ViewAchievements() : View::Floating("hex.builtin.view.achievements.name", ICON_VS_SPARKLE) { ViewAchievements::ViewAchievements() : View::Floating("hex.builtin.view.achievements.name", ICON_VS_SPARKLE) {
// Add achievements menu item to Extas menu // 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; this->getWindowOpenState() = true;
}); });

View File

@ -1,6 +1,8 @@
#include "content/views/view_bookmarks.hpp" #include "content/views/view_bookmarks.hpp"
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/reports.hpp>
#include <hex/api/content_registry/views.hpp>
#include <hex/api/content_registry/user_interface.hpp>
#include <hex/api/project_file_manager.hpp> #include <hex/api/project_file_manager.hpp>
#include <hex/api/achievement_manager.hpp> #include <hex/api/achievement_manager.hpp>
#include <hex/api/task_manager.hpp> #include <hex/api/task_manager.hpp>
@ -600,7 +602,7 @@ namespace hex::plugin::builtin {
void ViewBookmarks::registerMenuItems() { void ViewBookmarks::registerMenuItems() {
/* Create bookmark */ /* 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()) if (!ImHexApi::HexEditor::isSelectionValid())
return; return;
@ -610,10 +612,10 @@ namespace hex::plugin::builtin {
ContentRegistry::Views::getViewByName("hex.builtin.view.hex_editor.name")); 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 */ /* 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) { fs::openFileBrowser(fs::DialogMode::Open, { { "Bookmarks File", "hexbm"} }, [&, this](const std::fs::path &path) {
try { try {
this->importBookmarks(ImHexApi::Provider::get(), nlohmann::json::parse(wolv::io::File(path, wolv::io::File::Mode::Read).readString())); 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); }, 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 */ /* 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) { fs::openFileBrowser(fs::DialogMode::Save, { { "Bookmarks File", "hexbm"} }, [&, this](const std::fs::path &path) {
nlohmann::json json; nlohmann::json json;
this->exportBookmarks(ImHexApi::Provider::get(), json); this->exportBookmarks(ImHexApi::Provider::get(), json);

View File

@ -1,6 +1,6 @@
#include "content/views/view_command_palette.hpp" #include "content/views/view_command_palette.hpp"
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/command_palette.hpp>
#include <wolv/utils/guards.hpp> #include <wolv/utils/guards.hpp>
#include <hex/api/events/requests_gui.hpp> #include <hex/api/events/requests_gui.hpp>
#include <hex/api/events/events_interaction.hpp> #include <hex/api/events/events_interaction.hpp>
@ -177,7 +177,7 @@ namespace hex::plugin::builtin {
std::vector<CommandResult> results; std::vector<CommandResult> results;
// Loop over every registered command and check if the input matches it // 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) { auto AutoComplete = [this, currCommand = command](auto) {
this->focusInputTextBox(); this->focusInputTextBox();
@ -187,7 +187,7 @@ namespace hex::plugin::builtin {
return std::nullopt; return std::nullopt;
}; };
if (type == ContentRegistry::CommandPaletteCommands::Type::SymbolCommand) { if (type == ContentRegistry::CommandPalette::Type::SymbolCommand) {
// Handle symbol commands // Handle symbol commands
// These commands are used by entering a single symbol and then any input // 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 }); results.push_back({ displayCallback(matchedCommand), matchedCommand, executeCallback });
} }
} }
} else if (type == ContentRegistry::CommandPaletteCommands::Type::KeywordCommand) { } else if (type == ContentRegistry::CommandPalette::Type::KeywordCommand) {
// Handle keyword commands // Handle keyword commands
// These commands are used by entering a keyword followed by a space and then any input // 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 // 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; const auto &[type, command, queryCallback, displayCallback] = handler;
auto processedInput = input; auto processedInput = input;
@ -223,11 +223,11 @@ namespace hex::plugin::builtin {
processedInput = wolv::util::trim(processedInput.substr(command.length())); processedInput = wolv::util::trim(processedInput.substr(command.length()));
for (const auto &[description, callback] : queryCallback(processedInput)) { 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) { 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; } }); 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) { 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; } }); results.push_back({ fmt::format("{} ({})", command, description), "", [callback](auto ... args){ callback(args...); return std::nullopt; } });
} }

View File

@ -1,6 +1,7 @@
#include "content/views/view_data_inspector.hpp" #include "content/views/view_data_inspector.hpp"
#include <hex/api/achievement_manager.hpp> #include <hex/api/achievement_manager.hpp>
#include <hex/api/content_registry/settings.hpp>
#include <hex/providers/provider.hpp> #include <hex/providers/provider.hpp>
#include <hex/helpers/logger.hpp> #include <hex/helpers/logger.hpp>
#include <hex/helpers/default_paths.hpp> #include <hex/helpers/default_paths.hpp>

View File

@ -1,7 +1,9 @@
#include "content/views/view_data_processor.hpp" #include "content/views/view_data_processor.hpp"
#include <toasts/toast_notification.hpp> #include <toasts/toast_notification.hpp>
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/data_processor.hpp>
#include <hex/api/content_registry/user_interface.hpp>
#include <hex/api/content_registry/file_type_handler.hpp>
#include <hex/api/project_file_manager.hpp> #include <hex/api/project_file_manager.hpp>
#include <hex/api/achievement_manager.hpp> #include <hex/api/achievement_manager.hpp>
@ -355,9 +357,9 @@ namespace hex::plugin::builtin {
}; };
ViewDataProcessor::ViewDataProcessor() : View::Window("hex.builtin.view.data_processor.name", ICON_VS_CHIP) { ViewDataProcessor::ViewDataProcessor() : View::Window("hex.builtin.view.data_processor.name", ICON_VS_CHIP) {
ContentRegistry::DataProcessorNode::add<NodeCustom>("hex.builtin.nodes.custom", "hex.builtin.nodes.custom.custom", this); ContentRegistry::DataProcessor::add<NodeCustom>("hex.builtin.nodes.custom", "hex.builtin.nodes.custom.custom", this);
ContentRegistry::DataProcessorNode::add<NodeCustomInput>("hex.builtin.nodes.custom", "hex.builtin.nodes.custom.input"); ContentRegistry::DataProcessor::add<NodeCustomInput>("hex.builtin.nodes.custom", "hex.builtin.nodes.custom.input");
ContentRegistry::DataProcessorNode::add<NodeCustomOutput>("hex.builtin.nodes.custom", "hex.builtin.nodes.custom.output"); ContentRegistry::DataProcessor::add<NodeCustomOutput>("hex.builtin.nodes.custom", "hex.builtin.nodes.custom.output");
ProjectFile::registerPerProviderHandler({ ProjectFile::registerPerProviderHandler({
.basePath = "data_processor.json", .basePath = "data_processor.json",
@ -398,7 +400,7 @@ namespace hex::plugin::builtin {
}); });
/* Import Nodes */ /* 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" } }, fs::openFileBrowser(fs::DialogMode::Open, { {"hex.builtin.view.data_processor.name"_lang, "hexnode" } },
[&](const std::fs::path &path) { [&](const std::fs::path &path) {
wolv::io::File file(path, wolv::io::File::Mode::Read); wolv::io::File file(path, wolv::io::File::Mode::Read);
@ -410,7 +412,7 @@ namespace hex::plugin::builtin {
}, ImHexApi::Provider::isValid); }, ImHexApi::Provider::isValid);
/* Export Nodes */ /* 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" } }, fs::openFileBrowser(fs::DialogMode::Save, { {"hex.builtin.view.data_processor.name"_lang, "hexnode" } },
[&, this](const std::fs::path &path) { [&, this](const std::fs::path &path) {
wolv::io::File file(path, wolv::io::File::Mode::Create); 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(); 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); wolv::io::File file(path, wolv::io::File::Mode::Read);
if (!file.isValid()) return false; if (!file.isValid()) return false;
@ -685,7 +687,7 @@ namespace hex::plugin::builtin {
} }
// Draw all nodes that are registered in the content registry // 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()) { if (unlocalizedCategory.empty() && unlocalizedName.empty()) {
// Draw a separator if the node has no category and no name // Draw a separator if the node has no category and no name
ImGui::Separator(); ImGui::Separator();
@ -1147,7 +1149,7 @@ namespace hex::plugin::builtin {
std::unique_ptr<dp::Node> ViewDataProcessor::loadNode(nlohmann::json data) { std::unique_ptr<dp::Node> ViewDataProcessor::loadNode(nlohmann::json data) {
try { try {
auto &nodeEntries = ContentRegistry::DataProcessorNode::impl::getEntries(); auto &nodeEntries = ContentRegistry::DataProcessor::impl::getEntries();
std::unique_ptr<dp::Node> newNode; std::unique_ptr<dp::Node> newNode;
for (auto &entry : nodeEntries) { for (auto &entry : nodeEntries) {

View File

@ -1,6 +1,9 @@
#include "content/views/view_hex_editor.hpp" #include "content/views/view_hex_editor.hpp"
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/settings.hpp>
#include <hex/api/content_registry/user_interface.hpp>
#include <hex/api/content_registry/data_formatter.hpp>
#include <hex/api/content_registry/pattern_language.hpp>
#include <hex/api/shortcut_manager.hpp> #include <hex/api/shortcut_manager.hpp>
#include <hex/api/project_file_manager.hpp> #include <hex/api/project_file_manager.hpp>
#include <hex/api/achievement_manager.hpp> #include <hex/api/achievement_manager.hpp>
@ -1195,7 +1198,7 @@ namespace hex::plugin::builtin {
showSelectionInWindowFooter = !show; showSelectionInWindowFooter = !show;
}); });
ContentRegistry::Interface::addFooterItem([] { ContentRegistry::UserInterface::addFooterItem([] {
if (!showSelectionInWindowFooter) return; if (!showSelectionInWindowFooter) return;
if (auto selection = ImHexApi::HexEditor::getSelection(); selection.has_value()) { if (auto selection = ImHexApi::HexEditor::getSelection(); selection.has_value()) {
@ -1210,23 +1213,23 @@ namespace hex::plugin::builtin {
void ViewHexEditor::registerMenuItems() { void ViewHexEditor::registerMenuItems() {
/* Undo */ /* 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(); auto provider = ImHexApi::Provider::get();
provider->undo(); provider->undo();
}, [&] { return ImHexApi::Provider::isValid() && ImHexApi::Provider::get()->canUndo(); }, }, [&] { return ImHexApi::Provider::isValid() && ImHexApi::Provider::get()->canUndo(); },
this); this);
/* Redo */ /* 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(); auto provider = ImHexApi::Provider::get();
provider->redo(); provider->redo();
}, [&] { return ImHexApi::Provider::isValid() && ImHexApi::Provider::get()->canRedo(); }, }, [&] { return ImHexApi::Provider::isValid() && ImHexApi::Provider::get()->canRedo(); },
this); this);
ContentRegistry::Interface::addMenuItemSeparator({ "hex.builtin.menu.file" }, 1300); ContentRegistry::UserInterface::addMenuItemSeparator({ "hex.builtin.menu.file" }, 1300);
/* Save */ /* 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, CTRLCMD + Keys::S,
save, save,
[] { [] {
@ -1238,7 +1241,7 @@ namespace hex::plugin::builtin {
this); this);
/* Save As */ /* 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, CTRLCMD + SHIFT + Keys::S,
saveAs, saveAs,
[] { [] {
@ -1250,7 +1253,7 @@ namespace hex::plugin::builtin {
this); this);
/* Load Encoding File */ /* 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]{ [this]{
const auto basePaths = paths::Encodings.read(); const auto basePaths = paths::Encodings.read();
std::vector<std::fs::path> paths; std::vector<std::fs::path> paths;
@ -1278,10 +1281,10 @@ namespace hex::plugin::builtin {
ImHexApi::Provider::isValid, ImHexApi::Provider::isValid,
this); this);
ContentRegistry::Interface::addMenuItemSeparator({ "hex.builtin.menu.file" }, 1500, this); ContentRegistry::UserInterface::addMenuItemSeparator({ "hex.builtin.menu.file" }, 1500, this);
/* Search */ /* 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, CTRLCMD + Keys::F,
[this] { [this] {
this->openPopup<PopupFind>(this); this->openPopup<PopupFind>(this);
@ -1290,7 +1293,7 @@ namespace hex::plugin::builtin {
this); this);
/* Goto */ /* 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, CTRLCMD + Keys::G,
[this] { [this] {
this->openPopup<PopupGoto>(); this->openPopup<PopupGoto>();
@ -1299,12 +1302,12 @@ namespace hex::plugin::builtin {
this); this);
/* Skip until */ /* 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); canSearchForDifferingByte);
/* Skip until previous differing byte */ /* Skip until previous differing byte */
ContentRegistry::Interface::addMenuItem({ ContentRegistry::UserInterface::addMenuItem({
"hex.builtin.menu.file", "hex.builtin.menu.file",
"hex.builtin.view.hex_editor.menu.file.skip_until", "hex.builtin.view.hex_editor.menu.file.skip_until",
"hex.builtin.view.hex_editor.menu.file.skip_until.previous_differing_byte" "hex.builtin.view.hex_editor.menu.file.skip_until.previous_differing_byte"
@ -1343,7 +1346,7 @@ namespace hex::plugin::builtin {
canSearchForDifferingByte); canSearchForDifferingByte);
/* Skip until next differing byte */ /* Skip until next differing byte */
ContentRegistry::Interface::addMenuItem({ ContentRegistry::UserInterface::addMenuItem({
"hex.builtin.menu.file", "hex.builtin.menu.file",
"hex.builtin.view.hex_editor.menu.file.skip_until", "hex.builtin.view.hex_editor.menu.file.skip_until",
"hex.builtin.view.hex_editor.menu.file.skip_until.next_differing_byte" "hex.builtin.view.hex_editor.menu.file.skip_until.next_differing_byte"
@ -1382,10 +1385,10 @@ namespace hex::plugin::builtin {
canSearchForDifferingByte); canSearchForDifferingByte);
ContentRegistry::Interface::addMenuItemSeparator({ "hex.builtin.menu.edit" }, 1100, this); ContentRegistry::UserInterface::addMenuItemSeparator({ "hex.builtin.menu.edit" }, 1100, this);
/* Copy */ /* 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, CurrentView + CTRLCMD + Keys::C,
[] { [] {
auto selection = ImHexApi::HexEditor::getSelection(); auto selection = ImHexApi::HexEditor::getSelection();
@ -1395,10 +1398,10 @@ namespace hex::plugin::builtin {
ImHexApi::HexEditor::isSelectionValid, ImHexApi::HexEditor::isSelectionValid,
this); 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 */ /* 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, CurrentView + CTRLCMD + ALT + Keys::C,
[] { [] {
auto selection = ImHexApi::HexEditor::getSelection(); auto selection = ImHexApi::HexEditor::getSelection();
@ -1409,7 +1412,7 @@ namespace hex::plugin::builtin {
this); this);
/* Copy address */ /* 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, Shortcut::None,
[] { [] {
auto selection = ImHexApi::HexEditor::getSelection(); auto selection = ImHexApi::HexEditor::getSelection();
@ -1420,7 +1423,7 @@ namespace hex::plugin::builtin {
this); this);
/* Copy custom encoding */ /* 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, SHIFT + ALT + Keys::C,
[this] { [this] {
auto selection = ImHexApi::HexEditor::getSelection(); auto selection = ImHexApi::HexEditor::getSelection();
@ -1433,10 +1436,10 @@ namespace hex::plugin::builtin {
}, },
this); 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... */ /* 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 selection = ImHexApi::HexEditor::getSelection();
auto provider = ImHexApi::Provider::get(); auto provider = ImHexApi::Provider::get();
@ -1476,7 +1479,7 @@ namespace hex::plugin::builtin {
}, this); }, this);
/* Paste */ /* 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] { [this] {
processPasteBehaviour(ImHexApi::HexEditor::getSelection().value_or( ImHexApi::HexEditor::ProviderRegion(Region { 0, 0 }, ImHexApi::Provider::get()))); processPasteBehaviour(ImHexApi::HexEditor::getSelection().value_or( ImHexApi::HexEditor::ProviderRegion(Region { 0, 0 }, ImHexApi::Provider::get())));
}, },
@ -1484,10 +1487,10 @@ namespace hex::plugin::builtin {
this); this);
/* Paste... */ /* 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 */ /* 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); 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); this);
/* Paste... > Paste all as string */ /* 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, Shortcut::None,
[] { [] {
pasteBytes(ImHexApi::HexEditor::getSelection().value_or( ImHexApi::HexEditor::ProviderRegion(Region { 0, 0 }, ImHexApi::Provider::get())), false, true); 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); this);
/* Select */ /* 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, CTRLCMD + SHIFT + Keys::A,
[this] { [this] {
auto selection = ImHexApi::HexEditor::getSelection().value_or(ImHexApi::HexEditor::ProviderRegion{ { 0, 1 }, nullptr }); auto selection = ImHexApi::HexEditor::getSelection().value_or(ImHexApi::HexEditor::ProviderRegion{ { 0, 1 }, nullptr });
@ -1514,7 +1517,7 @@ namespace hex::plugin::builtin {
this); this);
/* Select All */ /* 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(); auto provider = ImHexApi::Provider::get();
ImHexApi::HexEditor::setSelection(provider->getBaseAddress(), provider->getActualSize()); ImHexApi::HexEditor::setSelection(provider->getBaseAddress(), provider->getActualSize());
@ -1523,10 +1526,10 @@ namespace hex::plugin::builtin {
this); this);
ContentRegistry::Interface::addMenuItemSeparator({ "hex.builtin.menu.edit" }, 1600, this); ContentRegistry::UserInterface::addMenuItemSeparator({ "hex.builtin.menu.edit" }, 1600, this);
/* Set Base Address */ /* 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] { [this] {
auto provider = ImHexApi::Provider::get(); auto provider = ImHexApi::Provider::get();
this->openPopup<PopupBaseAddress>(provider->getBaseAddress()); this->openPopup<PopupBaseAddress>(provider->getBaseAddress());
@ -1535,7 +1538,7 @@ namespace hex::plugin::builtin {
this); this);
/* Resize */ /* 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] { [this] {
auto provider = ImHexApi::Provider::get(); auto provider = ImHexApi::Provider::get();
this->openPopup<PopupResize>(provider->getActualSize()); this->openPopup<PopupResize>(provider->getActualSize());
@ -1544,7 +1547,7 @@ namespace hex::plugin::builtin {
this); this);
/* Insert */ /* 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] { [this] {
auto selection = ImHexApi::HexEditor::getSelection(); auto selection = ImHexApi::HexEditor::getSelection();
@ -1554,7 +1557,7 @@ namespace hex::plugin::builtin {
this); this);
/* Remove */ /* 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] { [this] {
auto selection = ImHexApi::HexEditor::getSelection(); auto selection = ImHexApi::HexEditor::getSelection();
@ -1564,7 +1567,7 @@ namespace hex::plugin::builtin {
this); this);
/* Fill */ /* 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] { [this] {
auto selection = ImHexApi::HexEditor::getSelection(); auto selection = ImHexApi::HexEditor::getSelection();
@ -1574,7 +1577,7 @@ namespace hex::plugin::builtin {
this); this);
/* Toggle Overwrite/Insert mode */ /* 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] { [this] {
if (m_hexEditor.getMode() == ui::HexEditor::Mode::Insert) if (m_hexEditor.getMode() == ui::HexEditor::Mode::Insert)
m_hexEditor.setMode(ui::HexEditor::Mode::Overwrite); m_hexEditor.setMode(ui::HexEditor::Mode::Overwrite);
@ -1593,7 +1596,7 @@ namespace hex::plugin::builtin {
this); this);
/* Jump to */ /* 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(); auto provider = ImHexApi::Provider::get();
if (provider == nullptr) if (provider == nullptr)
@ -1639,7 +1642,7 @@ namespace hex::plugin::builtin {
this); this);
/* Set Page Size */ /* 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] { [this] {
auto provider = ImHexApi::Provider::get(); auto provider = ImHexApi::Provider::get();
this->openPopup<PopupPageSize>(provider->getPageSize()); this->openPopup<PopupPageSize>(provider->getPageSize());
@ -1647,10 +1650,10 @@ namespace hex::plugin::builtin {
[] { return ImHexApi::Provider::isValid() && ImHexApi::Provider::get()->isReadable(); }, [] { return ImHexApi::Provider::isValid() && ImHexApi::Provider::get()->isReadable(); },
this); this);
ContentRegistry::Interface::addMenuItemSeparator({ "hex.builtin.menu.edit" }, 1900, this); ContentRegistry::UserInterface::addMenuItemSeparator({ "hex.builtin.menu.edit" }, 1900, this);
/* Open in new provider */ /* 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(); auto selection = ImHexApi::HexEditor::getSelection();

View File

@ -1,15 +1,16 @@
#include "content/views/view_highlight_rules.hpp" #include "content/views/view_highlight_rules.hpp"
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/user_interface.hpp>
#include <hex/api/content_registry/views.hpp>
#include <hex/api/project_file_manager.hpp> #include <hex/api/project_file_manager.hpp>
#include <hex/api/events/events_provider.hpp> #include <hex/api/events/events_provider.hpp>
#include <hex/api/events/events_interaction.hpp> #include <hex/api/events/events_interaction.hpp>
#include <imgui_internal.h>
#include <wolv/utils/guards.hpp>
#include <fonts/vscode_icons.hpp> #include <fonts/vscode_icons.hpp>
#include <imgui_internal.h>
#include <wolv/utils/guards.hpp>
#include <nlohmann/json.hpp>
namespace hex::plugin::builtin { 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) { 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; this->getWindowOpenState() = true;
}, ImHexApi::Provider::isValid, }, ImHexApi::Provider::isValid,
ContentRegistry::Views::getViewByName("hex.builtin.view.hex_editor.name")); ContentRegistry::Views::getViewByName("hex.builtin.view.hex_editor.name"));

View File

@ -1,15 +1,16 @@
#include "content/views/view_information.hpp" #include "content/views/view_information.hpp"
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/data_information.hpp>
#include <hex/api/achievement_manager.hpp> #include <hex/api/achievement_manager.hpp>
#include <hex/api/project_file_manager.hpp> #include <hex/api/project_file_manager.hpp>
#include <hex/providers/provider.hpp> #include <hex/providers/provider.hpp>
#include <hex/helpers/magic.hpp> #include <hex/helpers/magic.hpp>
#include <toasts/toast_notification.hpp> #include <toasts/toast_notification.hpp>
#include <nlohmann/json.hpp>
namespace hex::plugin::builtin { namespace hex::plugin::builtin {
using namespace hex::literals; using namespace hex::literals;

View File

@ -1,6 +1,6 @@
#include "content/views/view_logs.hpp" #include "content/views/view_logs.hpp"
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/user_interface.hpp>
#include <hex/helpers/logger.hpp> #include <hex/helpers/logger.hpp>
#include <fonts/vscode_icons.hpp> #include <fonts/vscode_icons.hpp>
@ -8,7 +8,7 @@
namespace hex::plugin::builtin { namespace hex::plugin::builtin {
ViewLogs::ViewLogs() : View::Floating("hex.builtin.view.logs.name", ICON_VS_DEBUG_LINE_BY_LINE) { 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; this->getWindowOpenState() = true;
}); });
} }

View File

@ -1,6 +1,6 @@
#include <content/views/view_pattern_data.hpp> #include <content/views/view_pattern_data.hpp>
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/settings.hpp>
#include <hex/providers/memory_provider.hpp> #include <hex/providers/memory_provider.hpp>
#include <hex/api/events/requests_interaction.hpp> #include <hex/api/events/requests_interaction.hpp>
#include <hex/api/events/events_interaction.hpp> #include <hex/api/events/events_interaction.hpp>

View File

@ -1,7 +1,11 @@
#include "content/views/view_pattern_editor.hpp" #include "content/views/view_pattern_editor.hpp"
#include <fonts/blender_icons.hpp> #include <fonts/blender_icons.hpp>
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/user_interface.hpp>
#include <hex/api/content_registry/file_type_handler.hpp>
#include <hex/api/content_registry/settings.hpp>
#include <hex/api/content_registry/views.hpp>
#include <hex/api/content_registry/reports.hpp>
#include <hex/api/project_file_manager.hpp> #include <hex/api/project_file_manager.hpp>
#include <hex/api/events/events_provider.hpp> #include <hex/api/events/events_provider.hpp>
@ -1994,13 +1998,13 @@ namespace hex::plugin::builtin {
/* Open File */ /* 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); m_openPatternFile(true);
}, [] { return ImHexApi::Provider::isValid(); }, }, [] { return ImHexApi::Provider::isValid(); },
this); this);
/* Save */ /* 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); m_savePatternFile(true);
},[this] { },[this] {
auto provider = ImHexApi::Provider::get(); auto provider = ImHexApi::Provider::get();
@ -2011,24 +2015,24 @@ namespace hex::plugin::builtin {
this); this);
/* Save As */ /* 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); m_savePatternAsFile(true);
},[] { },[] {
return ImHexApi::Provider::isValid(); return ImHexApi::Provider::isValid();
}, },
this); this);
ContentRegistry::Interface::addMenuItemSeparator({ "hex.builtin.menu.file" }, 1500, this); ContentRegistry::UserInterface::addMenuItemSeparator({ "hex.builtin.menu.file" }, 1500, this);
/* Find */ /* 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_replaceMode = false;
m_openFindReplacePopUp = true; m_openFindReplacePopUp = true;
}, [] { return true; }, }, [] { return true; },
this); this);
/* Find Next */ /* 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) { if (auto editor = getEditorFromFocusedWindow(); editor != nullptr) {
ui::TextEditor::FindReplaceHandler *findReplaceHandler = editor->getFindReplaceHandler(); ui::TextEditor::FindReplaceHandler *findReplaceHandler = editor->getFindReplaceHandler();
findReplaceHandler->findMatch(editor, true); findReplaceHandler->findMatch(editor, true);
@ -2046,7 +2050,7 @@ namespace hex::plugin::builtin {
this); this);
/* Find Previous */ /* 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) { if (auto editor = getEditorFromFocusedWindow(); editor != nullptr) {
ui::TextEditor::FindReplaceHandler *findReplaceHandler = editor->getFindReplaceHandler(); ui::TextEditor::FindReplaceHandler *findReplaceHandler = editor->getFindReplaceHandler();
findReplaceHandler->findMatch(editor, false); findReplaceHandler->findMatch(editor, false);
@ -2064,74 +2068,74 @@ namespace hex::plugin::builtin {
this); this);
/* Replace */ /* 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_replaceMode = true;
m_openFindReplacePopUp = true; m_openFindReplacePopUp = true;
}, [this] { return m_focusedSubWindowName.contains(textEditorView); }, }, [this] { return m_focusedSubWindowName.contains(textEditorView); },
this); this);
/* Replace Next */ /* 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); m_textEditor->getFindReplaceHandler()->replace(&*m_textEditor, true);
}, [this] { return ImHexApi::Provider::isValid() && !m_textEditor->getFindReplaceHandler()->getReplaceWord().empty() && m_focusedSubWindowName.contains(textEditorView); }, }, [this] { return ImHexApi::Provider::isValid() && !m_textEditor->getFindReplaceHandler()->getReplaceWord().empty() && m_focusedSubWindowName.contains(textEditorView); },
[]{ return false; }, []{ return false; },
this); this);
/* Replace Previous */ /* 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); m_textEditor->getFindReplaceHandler()->replace(&*m_textEditor, false);
}, [this] { return ImHexApi::Provider::isValid() && !m_textEditor->getFindReplaceHandler()->getReplaceWord().empty() && m_focusedSubWindowName.contains(textEditorView); }, }, [this] { return ImHexApi::Provider::isValid() && !m_textEditor->getFindReplaceHandler()->getReplaceWord().empty() && m_focusedSubWindowName.contains(textEditorView); },
[]{ return false; }, []{ return false; },
this); this);
/* Replace All */ /* 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); m_textEditor->getFindReplaceHandler()->replaceAll(&*m_textEditor);
}, [this] { return ImHexApi::Provider::isValid() && !m_textEditor->getFindReplaceHandler()->getReplaceWord().empty() && m_focusedSubWindowName.contains(textEditorView); }, }, [this] { return ImHexApi::Provider::isValid() && !m_textEditor->getFindReplaceHandler()->getReplaceWord().empty() && m_focusedSubWindowName.contains(textEditorView); },
this); this);
/* Goto Line */ /* 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; m_openGotoLinePopUp = true;
}, [] { return true; }, }, [] { return true; },
this); this);
/* Import Pattern */ /* 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); m_openPatternFile(false);
}, ImHexApi::Provider::isValid); }, ImHexApi::Provider::isValid);
/* Export Pattern */ /* 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); m_savePatternFile(false);
}, [this] { }, [this] {
return ImHexApi::Provider::isValid() && !wolv::util::trim(m_textEditor->getText()).empty(); return ImHexApi::Provider::isValid() && !wolv::util::trim(m_textEditor->getText()).empty();
}); });
/* Undo */ /* 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(); m_textEditor->undo();
}, [this] { return ImHexApi::Provider::isValid() && m_textEditor->canUndo() && m_focusedSubWindowName.contains(textEditorView); }, }, [this] { return ImHexApi::Provider::isValid() && m_textEditor->canUndo() && m_focusedSubWindowName.contains(textEditorView); },
this); this);
/* Redo */ /* 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(); m_textEditor->redo();
}, [this] { return ImHexApi::Provider::isValid() && m_textEditor->canRedo() && m_focusedSubWindowName.contains(textEditorView); }, }, [this] { return ImHexApi::Provider::isValid() && m_textEditor->canRedo() && m_focusedSubWindowName.contains(textEditorView); },
this); this);
ContentRegistry::Interface::addMenuItemSeparator({ "hex.builtin.menu.edit" }, 1280, this); ContentRegistry::UserInterface::addMenuItemSeparator({ "hex.builtin.menu.edit" }, 1280, this);
/* Cut */ /* 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(); m_textEditor->cut();
}, [this] { return ImHexApi::Provider::isValid() && m_textEditor->hasSelection() && m_focusedSubWindowName.contains(textEditorView); }, }, [this] { return ImHexApi::Provider::isValid() && m_textEditor->hasSelection() && m_focusedSubWindowName.contains(textEditorView); },
this); this);
/* Copy */ /* 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) { if (auto editor = getEditorFromFocusedWindow(); editor != nullptr) {
editor->copy(); editor->copy();
} else { } else {
@ -2146,23 +2150,23 @@ namespace hex::plugin::builtin {
this); this);
/* Paste */ /* 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(); m_textEditor->paste();
}, [this] { return m_focusedSubWindowName.contains(textEditorView); }, }, [this] { return m_focusedSubWindowName.contains(textEditorView); },
this); this);
/* Select All */ /* 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) if (auto editor = getEditorFromFocusedWindow(); editor != nullptr)
editor->selectAll(); editor->selectAll();
}, [] { return ImHexApi::Provider::isValid(); }, }, [] { return ImHexApi::Provider::isValid(); },
this); this);
ContentRegistry::Interface::addMenuItemSeparator({ "hex.builtin.menu.edit" }, 1700, this); ContentRegistry::UserInterface::addMenuItemSeparator({ "hex.builtin.menu.edit" }, 1700, this);
/* Add Breakpoint */ /* 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 line = m_textEditor.get(ImHexApi::Provider::get()).getCursorPosition().m_line + 1;
const auto &runtime = ContentRegistry::PatternLanguage::getRuntime(); const auto &runtime = ContentRegistry::PatternLanguage::getRuntime();
@ -2181,7 +2185,7 @@ namespace hex::plugin::builtin {
this); this);
/* Trigger Evaluation */ /* 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(); auto &runtime = ContentRegistry::PatternLanguage::getRuntime();
if (runtime.isRunning()) { if (runtime.isRunning()) {
m_breakpointHit = false; m_breakpointHit = false;
@ -2192,7 +2196,7 @@ namespace hex::plugin::builtin {
this); this);
/* Continue debugger */ /* 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(); const auto &runtime = ContentRegistry::PatternLanguage::getRuntime();
if (runtime.isRunning()) if (runtime.isRunning())
m_breakpointHit = false; m_breakpointHit = false;
@ -2200,7 +2204,7 @@ namespace hex::plugin::builtin {
this); this);
/* Step debugger */ /* 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(); const auto &runtime = ContentRegistry::PatternLanguage::getRuntime();
if (runtime.isRunning()) { if (runtime.isRunning()) {
runtime.getInternals().evaluator->pauseNextLine(); runtime.getInternals().evaluator->pauseNextLine();
@ -2217,7 +2221,7 @@ namespace hex::plugin::builtin {
}}; }};
/* Place pattern... */ /* 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] { [&, 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"_lang)) {
if (menu::beginMenu("hex.builtin.view.pattern_editor.menu.edit.place_pattern.builtin.single"_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() { 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); wolv::io::File file(path, wolv::io::File::Mode::Read);
if (file.isValid()) { if (file.isValid()) {

View File

@ -1,7 +1,7 @@
#include "content/views/view_provider_settings.hpp" #include "content/views/view_provider_settings.hpp"
#include <hex/api/imhex_api/hex_editor.hpp> #include <hex/api/imhex_api/hex_editor.hpp>
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/user_interface.hpp>
#include <hex/api/task_manager.hpp> #include <hex/api/task_manager.hpp>
#include <hex/api/events/events_provider.hpp> #include <hex/api/events/events_provider.hpp>
#include <hex/providers/provider.hpp> #include <hex/providers/provider.hpp>
@ -16,7 +16,7 @@ namespace hex::plugin::builtin {
this->getWindowOpenState() = true; this->getWindowOpenState() = true;
}); });
ContentRegistry::Interface::addSidebarItem(ICON_VS_SERVER_PROCESS, [] { ContentRegistry::UserInterface::addSidebarItem(ICON_VS_SERVER_PROCESS, [] {
auto provider = hex::ImHexApi::Provider::get(); auto provider = hex::ImHexApi::Provider::get();
if (auto *sidebarInterfaceProvider = dynamic_cast<prv::IProviderSidebarInterface*>(provider); sidebarInterfaceProvider != nullptr) if (auto *sidebarInterfaceProvider = dynamic_cast<prv::IProviderSidebarInterface*>(provider); sidebarInterfaceProvider != nullptr)

View File

@ -1,7 +1,7 @@
#include "content/views/view_settings.hpp" #include "content/views/view_settings.hpp"
#include <fonts/fonts.hpp> #include <fonts/fonts.hpp>
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/user_interface.hpp>
#include <hex/api/events/requests_gui.hpp> #include <hex/api/events/requests_gui.hpp>
#include <hex/helpers/logger.hpp> #include <hex/helpers/logger.hpp>
@ -23,8 +23,8 @@ namespace hex::plugin::builtin {
}); });
// Add the settings menu item to the Extras menu // Add the settings menu item to the Extras menu
ContentRegistry::Interface::addMenuItemSeparator({ "hex.builtin.menu.extras" }, 3000); ContentRegistry::UserInterface::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::addMenuItem({ "hex.builtin.menu.extras", "hex.builtin.view.settings.name" }, ICON_VS_SETTINGS_GEAR, 4000, CTRLCMD + Keys::Comma, [&, this] {
this->getWindowOpenState() = true; this->getWindowOpenState() = true;
}); });

View File

@ -3,7 +3,8 @@
#include <hex/api/achievement_manager.hpp> #include <hex/api/achievement_manager.hpp>
#include <hex/api_urls.hpp> #include <hex/api_urls.hpp>
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/user_interface.hpp>
#include <hex/api/content_registry/settings.hpp>
#include <hex/api/events/events_interaction.hpp> #include <hex/api/events/events_interaction.hpp>
#include <popups/popup_notification.hpp> #include <popups/popup_notification.hpp>
@ -30,7 +31,7 @@ namespace hex::plugin::builtin {
using namespace std::literals::chrono_literals; using namespace std::literals::chrono_literals;
ViewStore::ViewStore() : View::Floating("hex.builtin.view.store.name", ICON_VS_EXTENSIONS) { 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) if (m_requestStatus == RequestStatus::NotAttempted)
this->refresh(); this->refresh();

View File

@ -1,6 +1,6 @@
#include "content/views/view_theme_manager.hpp" #include "content/views/view_theme_manager.hpp"
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/user_interface.hpp>
#include <hex/api/theme_manager.hpp> #include <hex/api/theme_manager.hpp>
#include <hex/api/events/events_interaction.hpp> #include <hex/api/events/events_interaction.hpp>
@ -10,7 +10,7 @@
namespace hex::plugin::builtin { namespace hex::plugin::builtin {
ViewThemeManager::ViewThemeManager() : View::Floating("hex.builtin.view.theme_manager.name", ICON_VS_SYMBOL_COLOR) { 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; this->getWindowOpenState() = true;
}); });
} }

View File

@ -1,7 +1,7 @@
#include "content/views/view_tools.hpp" #include "content/views/view_tools.hpp"
#include <imgui_internal.h> #include <imgui_internal.h>
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/tools.hpp>
#include <hex/api/layout_manager.hpp> #include <hex/api/layout_manager.hpp>
#include <fonts/vscode_icons.hpp> #include <fonts/vscode_icons.hpp>

View File

@ -1,6 +1,6 @@
#include "content/views/view_tutorials.hpp" #include "content/views/view_tutorials.hpp"
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/user_interface.hpp>
#include <hex/api/tutorial_manager.hpp> #include <hex/api/tutorial_manager.hpp>
#include <hex/api/task_manager.hpp> #include <hex/api/task_manager.hpp>
#include <hex/api/events/requests_gui.hpp> #include <hex/api/events/requests_gui.hpp>
@ -12,7 +12,7 @@
namespace hex::plugin::builtin { namespace hex::plugin::builtin {
ViewTutorials::ViewTutorials() : View::Floating("hex.builtin.view.tutorials.name", ICON_VS_BOOK) { 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; this->getWindowOpenState() = true;
}); });

View File

@ -1,7 +1,10 @@
#include <hex.hpp> #include <hex.hpp>
#include <hex/api/workspace_manager.hpp> #include <hex/api/workspace_manager.hpp>
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/settings.hpp>
#include <hex/api/content_registry/views.hpp>
#include <hex/api/content_registry/provider.hpp>
#include <hex/api/content_registry/user_interface.hpp>
#include <hex/api/localization_manager.hpp> #include <hex/api/localization_manager.hpp>
#include <hex/api/theme_manager.hpp> #include <hex/api/theme_manager.hpp>
#include <hex/api/layout_manager.hpp> #include <hex/api/layout_manager.hpp>
@ -430,7 +433,7 @@ namespace hex::plugin::builtin {
} }
ImGuiExt::EndSubWindow(); ImGuiExt::EndSubWindow();
auto extraWelcomeScreenEntries = ContentRegistry::Interface::impl::getWelcomeScreenEntries(); auto extraWelcomeScreenEntries = ContentRegistry::UserInterface::impl::getWelcomeScreenEntries();
if (!extraWelcomeScreenEntries.empty()) { if (!extraWelcomeScreenEntries.empty()) {
ImGui::TableNextRow(ImGuiTableRowFlags_None, ImGui::GetTextLineHeightWithSpacing() * 5); ImGui::TableNextRow(ImGuiTableRowFlags_None, ImGui::GetTextLineHeightWithSpacing() * 5);
ImGui::TableNextColumn(); ImGui::TableNextColumn();
@ -514,7 +517,7 @@ namespace hex::plugin::builtin {
static bool hovered = false; static bool hovered = false;
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, hovered ? 1.0F : 0.3F); 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()) { if (!quickSettings.empty()) {
const auto padding = ImGui::GetStyle().FramePadding.y; 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) }; 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; s_simplifiedWelcomeScreen = state;
WorkspaceManager::switchWorkspace(s_simplifiedWelcomeScreen ? "Minimal" : "Default"); WorkspaceManager::switchWorkspace(s_simplifiedWelcomeScreen ? "Minimal" : "Default");
}); });
EventImHexStartupFinished::subscribe([]() { EventImHexStartupFinished::subscribe([]() {
for (const auto &quickSetting : ContentRegistry::Interface::impl::getWelcomeScreenQuickSettingsToggles()) { for (const auto &quickSetting : ContentRegistry::UserInterface::impl::getWelcomeScreenQuickSettingsToggles()) {
auto &setting = quickSetting.unlocalizedTooltip; auto &setting = quickSetting.unlocalizedTooltip;
ContentRegistry::Settings::onChange("hex.builtin.settings.quick_settings", setting, [setting](const ContentRegistry::Settings::SettingsValue &value) { 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) { if (unlocalizedTooltip == setting) {
state = value.get<bool>(state); state = value.get<bool>(state);
toggleCallback(state); toggleCallback(state);

View File

@ -1,4 +1,6 @@
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry/user_interface.hpp>
#include <hex/api/content_registry/views.hpp>
#include <hex/api/content_registry/settings.hpp>
#include <hex/api/shortcut_manager.hpp> #include <hex/api/shortcut_manager.hpp>
#include <hex/api/task_manager.hpp> #include <hex/api/task_manager.hpp>
#include <hex/api/project_file_manager.hpp> #include <hex/api/project_file_manager.hpp>
@ -49,15 +51,15 @@ namespace hex::plugin::builtin {
ImGui::GetWindowDrawList()->AddShadowCircle(pos, diameter / 2, ImGui::GetColorU32(ImGuiCol_ButtonActive, 0.8F), diameter / 4, ImVec2()); ImGui::GetWindowDrawList()->AddShadowCircle(pos, diameter / 2, ImGui::GetColorU32(ImGuiCol_ButtonActive, 0.8F), diameter / 4, ImVec2());
} }
void createNestedMenu(std::span<const UnlocalizedString> 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<const UnlocalizedString> 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(); const auto &name = menuItems.front();
if (name.get() == ContentRegistry::Interface::impl::SeparatorValue) { if (name.get() == ContentRegistry::UserInterface::impl::SeparatorValue) {
menu::menuSeparator(); menu::menuSeparator();
return; return;
} }
if (name.get() == ContentRegistry::Interface::impl::SubMenuValue) { if (name.get() == ContentRegistry::UserInterface::impl::SubMenuValue) {
if (enabledCallback()) { if (enabledCallback()) {
callback(); callback();
} }
@ -74,9 +76,9 @@ namespace hex::plugin::builtin {
} }
} }
} else { } 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); createNestedMenu({ std::next(menuItems.begin()), menuItems.end() }, icon, shortcut, view, callback, enabledCallback, selectedCallback);
menu::endMenu(); menu::endMenu();
} }
@ -89,7 +91,7 @@ namespace hex::plugin::builtin {
ImGui::Separator(); ImGui::Separator();
ImGui::SetCursorPosX(8); 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 y = ImGui::GetCursorPosY();
const auto prevIdx = drawList->_VtxCurrentIdx; const auto prevIdx = drawList->_VtxCurrentIdx;
callback(); callback();
@ -110,7 +112,7 @@ namespace hex::plugin::builtin {
u32 index = 0; u32 index = 0;
u32 drawIndex = 1; u32 drawIndex = 1;
ImGui::PushID("SideBarWindows"); 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::SetCursorPosY(sidebarPos.y + sidebarWidth * drawIndex);
ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetColorU32(ImGuiCol_MenuBarBg)); ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetColorU32(ImGuiCol_MenuBarBg));
@ -234,7 +236,7 @@ namespace hex::plugin::builtin {
#endif #endif
} }
const auto &titleBarButtons = ContentRegistry::Interface::impl::getTitlebarButtons(); const auto &titleBarButtons = ContentRegistry::UserInterface::impl::getTitlebarButtons();
// Draw custom title bar buttons // Draw custom title bar buttons
if (!titleBarButtons.empty()) { 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(); const auto lastFocusedView = View::getLastFocusedView();
if (lastFocusedView == nullptr && menuItem.view != nullptr) { if (lastFocusedView == nullptr && menuItem.view != nullptr) {
return false; return false;
@ -325,7 +327,7 @@ namespace hex::plugin::builtin {
std::set<UnlocalizedString> getVisibleMainMenus() { std::set<UnlocalizedString> getVisibleMainMenus() {
std::set<UnlocalizedString> result; std::set<UnlocalizedString> result;
for (auto &[priority, menuItem] : ContentRegistry::Interface::impl::getMenuItems()) { for (auto &[priority, menuItem] : ContentRegistry::UserInterface::impl::getMenuItems()) {
if (isMenuItemVisible(menuItem)) { if (isMenuItemVisible(menuItem)) {
result.emplace(menuItem.unlocalizedNames.front()); result.emplace(menuItem.unlocalizedNames.front());
} }
@ -335,7 +337,7 @@ namespace hex::plugin::builtin {
} }
void populateMenu(const UnlocalizedString &menuName) { 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 (!menuName.empty()) {
if (menuItem.unlocalizedNames[0] != menuName) if (menuItem.unlocalizedNames[0] != menuName)
continue; continue;
@ -383,7 +385,7 @@ namespace hex::plugin::builtin {
} }
void drawMenu() { void drawMenu() {
const auto &menuItems = ContentRegistry::Interface::impl::getMainMenuItems(); const auto &menuItems = ContentRegistry::UserInterface::impl::getMainMenuItems();
const auto visibleMainMenus = getVisibleMainMenus(); const auto visibleMainMenus = getVisibleMainMenus();
if (menu::isNativeMenuBarUsed()) { if (menu::isNativeMenuBarUsed()) {
@ -561,7 +563,7 @@ namespace hex::plugin::builtin {
ImGui::BeginDisabled(ContentRegistry::Views::impl::getFullScreenView() != nullptr); ImGui::BeginDisabled(ContentRegistry::Views::impl::getFullScreenView() != nullptr);
{ {
for (const auto &callback : ContentRegistry::Interface::impl::getToolbarItems()) { for (const auto &callback : ContentRegistry::UserInterface::impl::getToolbarItems()) {
callback(); callback();
ImGui::SameLine(); ImGui::SameLine();
} }
@ -582,7 +584,7 @@ namespace hex::plugin::builtin {
} }
bool anySidebarItemsAvailable() { bool anySidebarItemsAvailable() {
if (const auto &items = ContentRegistry::Interface::impl::getSidebarItems(); items.empty()) { if (const auto &items = ContentRegistry::UserInterface::impl::getSidebarItems(); items.empty()) {
return false; return false;
} else { } else {
return std::any_of(items.begin(), items.end(), [](const auto &item) { return std::any_of(items.begin(), items.end(), [](const auto &item) {
@ -670,7 +672,7 @@ namespace hex::plugin::builtin {
ImGui::PopStyleVar(2); ImGui::PopStyleVar(2);
// Draw main menu popups // 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; const auto &unlocalizedNames = menuItem.unlocalizedName;
if (ImGui::BeginPopup(unlocalizedNames.get().c_str())) { if (ImGui::BeginPopup(unlocalizedNames.get().c_str())) {
populateMenu(unlocalizedNames); populateMenu(unlocalizedNames);

Some files were not shown because too many files have changed in this diff Show More