1
0
mirror of synced 2024-12-15 17:21:16 +01:00
ImHex/lib/libimhex/include/hex/helpers/shared_data.hpp

136 lines
4.3 KiB
C++
Raw Normal View History

#pragma once
#include <any>
#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>
#include <mutex>
2021-01-20 20:16:24 +01:00
#include <vector>
#include <hex/api/content_registry.hpp>
2021-01-20 20:16:24 +01:00
#include <hex/api/imhex_api.hpp>
#include <hex/api/task.hpp>
2021-02-03 00:56:33 +01:00
#include <hex/views/view.hpp>
#include <imgui.h>
2021-01-27 00:44:10 +01:00
#include <nlohmann/json_fwd.hpp>
namespace hex {
class SharedData;
}
namespace hex::plugin::internal {
void initializePlugin(SharedData &sharedData);
}
namespace hex {
namespace prv {
class Provider;
}
namespace dp {
class Node;
}
namespace pl {
class PatternData;
}
class View;
class SharedData {
SharedData() = default;
public:
SharedData(const SharedData &) = delete;
SharedData(SharedData &&) = delete;
friend class Window;
template<typename T>
static T &getVariable(std::string variableName) {
return std::any_cast<T &>(SharedData::sharedVariables[variableName]);
}
template<typename T>
static void setVariable(std::string variableName, T value) {
SharedData::sharedVariables[variableName] = value;
}
static void clearVariables() {
SharedData::sharedVariables.clear();
}
public:
static std::vector<std::function<void()>> deferredCalls;
static std::vector<prv::Provider *> providers;
static u32 currentProvider;
static std::map<std::string, std::vector<ContentRegistry::Settings::Entry>> settingsEntries;
static nlohmann::json settingsJson;
static std::vector<ContentRegistry::CommandPaletteCommands::Entry> commandPaletteCommands;
static std::map<std::string, ContentRegistry::PatternLanguage::Function> patternLanguageFunctions;
static std::map<std::string, View *> views;
static std::vector<ContentRegistry::Tools::impl::Entry> toolsEntries;
static std::vector<ContentRegistry::DataInspector::impl::Entry> dataInspectorEntries;
static u32 patternPaletteOffset;
static std::string popupMessage;
2021-01-20 20:16:24 +01:00
static std::list<ImHexApi::Bookmarks::Entry> bookmarkEntries;
static std::vector<pl::PatternData *> patternData;
static u32 selectableFileIndex;
static std::vector<fs::path> selectableFiles;
static std::function<void(fs::path)> selectableFileOpenCallback;
static std::vector<nfdfilteritem_t> selectableFilesValidExtensions;
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;
static ImGuiID dockSpaceId;
static std::multimap<u32, ContentRegistry::Interface::impl::MainMenuItem> mainMenuItems;
static std::multimap<u32, ContentRegistry::Interface::impl::MenuItem> menuItems;
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;
static std::vector<ContentRegistry::Interface::impl::Layout> layouts;
static std::map<Shortcut, std::function<void()>> globalShortcuts;
static std::mutex tasksMutex;
static std::list<Task *> runningTasks;
2021-12-07 22:47:41 +01:00
static std::vector<std::string> providerNames;
static std::vector<ContentRegistry::DataProcessorNode::impl::Entry> dataProcessorNodes;
static u32 dataProcessorNodeIdCounter;
static u32 dataProcessorLinkIdCounter;
static u32 dataProcessorAttrIdCounter;
static std::vector<ContentRegistry::DataFormatter::impl::Entry> dataFormatters;
static std::vector<ContentRegistry::FileHandler::impl::Entry> fileHandlers;
static std::list<fs::path> recentFilePaths;
2021-04-13 08:41:59 +02:00
static int mainArgc;
static char **mainArgv;
static char **mainEnvp;
2021-08-31 15:22:00 +02:00
static ImFontAtlas *fontAtlas;
static ImFontConfig fontConfig;
static ImVec2 windowPos;
static ImVec2 windowSize;
2021-08-31 15:22:00 +02:00
static float globalScale;
static float fontScale;
private:
static std::map<std::string, std::any> sharedVariables;
};
}