2021-01-03 23:19:56 +00:00
|
|
|
#pragma once
|
|
|
|
|
2021-01-11 19:31:40 +00:00
|
|
|
#include <any>
|
2021-01-03 23:19:56 +00:00
|
|
|
#include <functional>
|
|
|
|
#include <vector>
|
2021-01-11 20:11:03 +00:00
|
|
|
#include <map>
|
2021-01-03 23:19:56 +00:00
|
|
|
|
2021-01-11 19:31:40 +00:00
|
|
|
#include <helpers/content_registry.hpp>
|
2021-01-12 15:50:15 +00:00
|
|
|
#include <helpers/event.hpp>
|
|
|
|
#include <views/view.hpp>
|
2021-01-11 19:31:40 +00:00
|
|
|
|
2021-01-03 23:19:56 +00:00
|
|
|
#include <imgui.h>
|
2021-01-11 19:31:40 +00:00
|
|
|
#include <nlohmann/json.hpp>
|
2021-01-03 23:19:56 +00:00
|
|
|
|
|
|
|
namespace hex { class SharedData; }
|
|
|
|
|
|
|
|
namespace hex::plugin::internal {
|
|
|
|
void initializePlugin(SharedData &sharedData);
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace hex {
|
|
|
|
|
|
|
|
namespace prv { class Provider; }
|
|
|
|
|
|
|
|
class SharedData {
|
|
|
|
SharedData() = default;
|
|
|
|
public:
|
|
|
|
SharedData(const SharedData&) = delete;
|
|
|
|
SharedData(SharedData&&) = delete;
|
|
|
|
|
|
|
|
friend class Window;
|
|
|
|
|
2021-01-11 19:31:40 +00:00
|
|
|
template<typename T>
|
2021-01-12 22:28:41 +00:00
|
|
|
static T& getVariable(std::string variableName) {
|
|
|
|
return std::any_cast<T&>(SharedData::sharedVariables[variableName]);
|
2021-01-11 19:31:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename T>
|
2021-01-12 22:28:41 +00:00
|
|
|
static void setVariable(std::string variableName, T value) {
|
|
|
|
SharedData::sharedVariables[variableName] = value;
|
2021-01-03 23:19:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2021-01-12 22:28:41 +00:00
|
|
|
static std::vector<EventHandler> eventHandlers;
|
|
|
|
static std::vector<std::function<void()>> deferredCalls;
|
|
|
|
static prv::Provider *currentProvider;
|
|
|
|
static std::map<std::string, std::vector<ContentRegistry::Settings::Entry>> settingsEntries;
|
|
|
|
static nlohmann::json settingsJson;
|
|
|
|
static std::map<std::string, Events> customEvents;
|
|
|
|
static u32 customEventsLastId;
|
|
|
|
static std::vector<ContentRegistry::CommandPaletteCommands::Entry> commandPaletteCommands;
|
|
|
|
static std::map<std::string, ContentRegistry::PatternLanguageFunctions::Function> patternLanguageFunctions;
|
|
|
|
static std::vector<View*> views;
|
|
|
|
static std::vector<std::function<void()>> tools;
|
|
|
|
|
|
|
|
static int mainArgc;
|
|
|
|
static char **mainArgv;
|
|
|
|
|
|
|
|
static ImVec2 windowPos;
|
|
|
|
static ImVec2 windowSize;
|
2021-01-11 19:31:40 +00:00
|
|
|
|
|
|
|
private:
|
2021-01-12 22:28:41 +00:00
|
|
|
static std::map<std::string, std::any> sharedVariables;
|
2021-01-03 23:19:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|