2023-05-15 11:30:24 +02:00
|
|
|
#include <hex/api/content_registry.hpp>
|
|
|
|
|
|
|
|
#include <nlohmann/json.hpp>
|
|
|
|
|
|
|
|
namespace hex::plugin::builtin {
|
|
|
|
|
|
|
|
void registerNetworkEndpoints() {
|
|
|
|
ContentRegistry::CommunicationInterface::registerNetworkEndpoint("pattern_editor/set_code", [](const nlohmann::json &data) -> nlohmann::json {
|
2023-05-16 11:20:46 +02:00
|
|
|
auto code = data.at("code").get<std::string>();
|
2023-05-15 11:30:24 +02:00
|
|
|
|
|
|
|
EventManager::post<RequestSetPatternLanguageCode>(code);
|
|
|
|
|
|
|
|
return { };
|
|
|
|
});
|
2023-05-16 11:01:40 +02:00
|
|
|
|
|
|
|
ContentRegistry::CommunicationInterface::registerNetworkEndpoint("imhex/capabilities", [](const nlohmann::json &) -> nlohmann::json {
|
|
|
|
nlohmann::json result;
|
|
|
|
|
|
|
|
result["build"] = {
|
|
|
|
{ "version", IMHEX_VERSION },
|
2023-05-16 12:02:17 +02:00
|
|
|
#if defined(GIT_COMMIT_HASH_LONG)
|
|
|
|
{ "commit", GIT_COMMIT_HASH_LONG },
|
|
|
|
#endif
|
|
|
|
#if defined(GIT_BRANCH)
|
|
|
|
{ "branch", GIT_BRANCH },
|
|
|
|
#endif
|
2023-05-16 11:01:40 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<std::string> commands;
|
|
|
|
for (const auto&[command, callback] : ContentRegistry::CommunicationInterface::impl::getNetworkEndpoints())
|
|
|
|
commands.emplace_back(command);
|
|
|
|
|
|
|
|
result["commands"] = commands;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
});
|
2023-05-15 11:30:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|