2021-01-04 00:19:56 +01:00
|
|
|
#pragma once
|
|
|
|
|
2021-01-11 20:31:40 +01:00
|
|
|
#include <any>
|
2021-01-04 00:19:56 +01:00
|
|
|
#include <functional>
|
2021-01-20 20:16:24 +01:00
|
|
|
#include <list>
|
2021-01-11 21:11:03 +01:00
|
|
|
#include <map>
|
2021-02-03 00:56:33 +01:00
|
|
|
#include <memory>
|
2021-12-16 23:48:52 +01:00
|
|
|
#include <mutex>
|
2021-01-20 20:16:24 +01:00
|
|
|
#include <vector>
|
2021-01-04 00:19:56 +01:00
|
|
|
|
2021-01-13 17:28:27 +01:00
|
|
|
#include <hex/api/content_registry.hpp>
|
2021-01-20 20:16:24 +01:00
|
|
|
#include <hex/api/imhex_api.hpp>
|
2021-12-16 23:48:52 +01:00
|
|
|
#include <hex/api/task.hpp>
|
2021-02-03 00:56:33 +01:00
|
|
|
#include <hex/views/view.hpp>
|
2021-01-11 20:31:40 +01:00
|
|
|
|
2021-01-04 00:19:56 +01:00
|
|
|
#include <imgui.h>
|
2021-01-27 00:44:10 +01:00
|
|
|
|
2021-08-29 14:18:45 +02:00
|
|
|
#include <nlohmann/json_fwd.hpp>
|
2021-01-04 00:19:56 +01:00
|
|
|
|
2022-01-24 20:53:17 +01:00
|
|
|
namespace hex {
|
|
|
|
class SharedData;
|
|
|
|
}
|
2021-01-04 00:19:56 +01:00
|
|
|
|
|
|
|
namespace hex::plugin::internal {
|
|
|
|
void initializePlugin(SharedData &sharedData);
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace hex {
|
|
|
|
|
2022-01-24 20:53:17 +01:00
|
|
|
namespace prv {
|
|
|
|
class Provider;
|
|
|
|
}
|
|
|
|
namespace dp {
|
|
|
|
class Node;
|
|
|
|
}
|
|
|
|
namespace pl {
|
|
|
|
class PatternData;
|
|
|
|
}
|
2021-04-20 21:46:48 +02:00
|
|
|
|
2021-01-27 14:26:24 +01:00
|
|
|
class View;
|
2021-01-04 00:19:56 +01:00
|
|
|
|
|
|
|
class SharedData {
|
|
|
|
SharedData() = default;
|
2022-01-24 20:53:17 +01:00
|
|
|
|
2021-01-04 00:19:56 +01:00
|
|
|
public:
|
2022-01-24 20:53:17 +01:00
|
|
|
SharedData(const SharedData &) = delete;
|
|
|
|
SharedData(SharedData &&) = delete;
|
2021-01-04 00:19:56 +01:00
|
|
|
|
|
|
|
friend class Window;
|
|
|
|
|
2021-01-11 20:31:40 +01:00
|
|
|
template<typename T>
|
2022-01-24 20:53:17 +01:00
|
|
|
static T &getVariable(std::string variableName) {
|
|
|
|
return std::any_cast<T &>(SharedData::sharedVariables[variableName]);
|
2021-01-11 20:31:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename T>
|
2021-01-12 23:28:41 +01:00
|
|
|
static void setVariable(std::string variableName, T value) {
|
|
|
|
SharedData::sharedVariables[variableName] = value;
|
2021-01-04 00:19:56 +01:00
|
|
|
}
|
|
|
|
|
2021-07-31 17:11:10 +02:00
|
|
|
static void clearVariables() {
|
|
|
|
SharedData::sharedVariables.clear();
|
|
|
|
}
|
|
|
|
|
2021-01-04 00:19:56 +01:00
|
|
|
public:
|
2021-01-12 23:28:41 +01:00
|
|
|
static std::vector<std::function<void()>> deferredCalls;
|
2021-09-21 02:29:54 +02:00
|
|
|
|
2022-01-24 20:53:17 +01:00
|
|
|
static std::vector<prv::Provider *> providers;
|
2021-09-21 02:29:54 +02:00
|
|
|
static u32 currentProvider;
|
|
|
|
|
2021-01-12 23:28:41 +01:00
|
|
|
static std::map<std::string, std::vector<ContentRegistry::Settings::Entry>> settingsEntries;
|
|
|
|
static nlohmann::json settingsJson;
|
|
|
|
static std::vector<ContentRegistry::CommandPaletteCommands::Entry> commandPaletteCommands;
|
2021-12-20 20:40:28 +01:00
|
|
|
static std::map<std::string, ContentRegistry::PatternLanguage::Function> patternLanguageFunctions;
|
2022-01-24 20:53:17 +01:00
|
|
|
static std::map<std::string, View *> views;
|
2021-12-12 11:52:58 +01:00
|
|
|
static std::vector<ContentRegistry::Tools::impl::Entry> toolsEntries;
|
|
|
|
static std::vector<ContentRegistry::DataInspector::impl::Entry> dataInspectorEntries;
|
2021-01-13 23:08:41 +01:00
|
|
|
static u32 patternPaletteOffset;
|
2021-09-22 17:56:06 +02:00
|
|
|
static std::string popupMessage;
|
2021-01-20 20:16:24 +01:00
|
|
|
static std::list<ImHexApi::Bookmarks::Entry> bookmarkEntries;
|
2022-01-24 20:53:17 +01:00
|
|
|
static std::vector<pl::PatternData *> patternData;
|
2021-02-11 00:35:30 +01:00
|
|
|
|
2022-01-23 21:52:43 +01:00
|
|
|
static u32 selectableFileIndex;
|
|
|
|
static std::vector<fs::path> selectableFiles;
|
|
|
|
static std::function<void(fs::path)> selectableFileOpenCallback;
|
|
|
|
static std::vector<nfdfilteritem_t> selectableFilesValidExtensions;
|
|
|
|
|
2021-02-11 00:35:30 +01:00
|
|
|
static std::map<std::string, std::string> languageNames;
|
|
|
|
static std::map<std::string, std::vector<LanguageDefinition>> languageDefinitions;
|
|
|
|
static std::map<std::string, std::string> loadedLanguageStrings;
|
2021-01-12 23:28:41 +01:00
|
|
|
|
2022-01-18 00:10:10 +01:00
|
|
|
static ImGuiID dockSpaceId;
|
|
|
|
|
2022-01-23 20:45:51 +01:00
|
|
|
static std::multimap<u32, ContentRegistry::Interface::impl::MainMenuItem> mainMenuItems;
|
2022-01-23 02:28:38 +01:00
|
|
|
static std::multimap<u32, ContentRegistry::Interface::impl::MenuItem> menuItems;
|
2022-01-18 00:10:10 +01:00
|
|
|
static std::vector<ContentRegistry::Interface::impl::DrawCallback> welcomeScreenEntries;
|
|
|
|
static std::vector<ContentRegistry::Interface::impl::DrawCallback> footerItems;
|
|
|
|
static std::vector<ContentRegistry::Interface::impl::DrawCallback> toolbarItems;
|
2022-01-22 22:03:19 +01:00
|
|
|
static std::vector<ContentRegistry::Interface::impl::SidebarItem> sidebarItems;
|
2022-01-18 00:10:10 +01:00
|
|
|
static std::vector<ContentRegistry::Interface::impl::Layout> layouts;
|
2021-02-18 12:09:19 +01:00
|
|
|
|
2021-12-23 15:11:38 +01:00
|
|
|
static std::map<Shortcut, std::function<void()>> globalShortcuts;
|
|
|
|
|
2021-12-16 23:48:52 +01:00
|
|
|
static std::mutex tasksMutex;
|
2022-01-24 20:53:17 +01:00
|
|
|
static std::list<Task *> runningTasks;
|
2021-12-16 23:48:52 +01:00
|
|
|
|
2021-12-07 22:47:41 +01:00
|
|
|
static std::vector<std::string> providerNames;
|
|
|
|
|
2021-12-12 11:52:58 +01:00
|
|
|
static std::vector<ContentRegistry::DataProcessorNode::impl::Entry> dataProcessorNodes;
|
2021-01-30 22:39:06 +01:00
|
|
|
static u32 dataProcessorNodeIdCounter;
|
2021-05-17 23:17:58 +02:00
|
|
|
static u32 dataProcessorLinkIdCounter;
|
|
|
|
static u32 dataProcessorAttrIdCounter;
|
2021-01-30 22:39:06 +01:00
|
|
|
|
2022-01-13 00:27:31 +01:00
|
|
|
static std::vector<ContentRegistry::DataFormatter::impl::Entry> dataFormatters;
|
2022-01-13 14:34:19 +01:00
|
|
|
static std::vector<ContentRegistry::FileHandler::impl::Entry> fileHandlers;
|
2022-01-13 00:27:31 +01:00
|
|
|
|
2022-01-16 01:51:31 +01:00
|
|
|
static std::list<fs::path> recentFilePaths;
|
2021-04-13 08:41:59 +02:00
|
|
|
|
2021-01-12 23:28:41 +01:00
|
|
|
static int mainArgc;
|
|
|
|
static char **mainArgv;
|
2021-12-22 13:16:51 +01:00
|
|
|
static char **mainEnvp;
|
2021-01-12 23:28:41 +01:00
|
|
|
|
2021-08-31 15:22:00 +02:00
|
|
|
static ImFontAtlas *fontAtlas;
|
|
|
|
static ImFontConfig fontConfig;
|
2021-01-12 23:28:41 +01:00
|
|
|
static ImVec2 windowPos;
|
|
|
|
static ImVec2 windowSize;
|
2021-01-11 20:31:40 +01:00
|
|
|
|
2021-08-31 15:22:00 +02:00
|
|
|
static float globalScale;
|
|
|
|
static float fontScale;
|
|
|
|
|
2021-01-11 20:31:40 +01:00
|
|
|
private:
|
2021-01-12 23:28:41 +01:00
|
|
|
static std::map<std::string, std::any> sharedVariables;
|
2021-01-04 00:19:56 +01:00
|
|
|
};
|
|
|
|
|
2021-12-22 13:16:51 +01:00
|
|
|
}
|