mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 13:37:42 -05:00
Added settings registry and settings menu
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <any>
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
|
||||
#include <helpers/event.hpp>
|
||||
#include <helpers/content_registry.hpp>
|
||||
|
||||
#include <imgui.h>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
namespace hex { class SharedData; }
|
||||
|
||||
@@ -31,18 +35,34 @@ namespace hex {
|
||||
friend void hex::plugin::internal::initializePlugin(SharedData &sharedData);
|
||||
friend class Window;
|
||||
|
||||
template<typename T>
|
||||
T& getVariable(std::string variableName) {
|
||||
return std::any_cast<T&>((*this->sharedVariables)[variableName]);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void setVariable(std::string variableName, T value) {
|
||||
(*this->sharedVariables)[variableName] = value;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void initializeData() {
|
||||
static std::vector<EventHandler> eventHandlersStorage;
|
||||
static std::vector<std::function<void()>> deferredCallsStorage;
|
||||
static prv::Provider *currentProviderStorage;
|
||||
static std::map<std::string, std::vector<ContentRegistry::Settings::Entry>> settingsEntriesStorage;
|
||||
static std::map<std::string, std::any> sharedVariablesStorage;
|
||||
static ImVec2 windowPosStorage, windowSizeStorage;
|
||||
static nlohmann::json settingsJsonStorage;
|
||||
|
||||
this->imguiContext = ImGui::GetCurrentContext();
|
||||
this->eventHandlers = &eventHandlersStorage;
|
||||
this->deferredCalls = &deferredCallsStorage;
|
||||
this->currentProvider = ¤tProviderStorage;
|
||||
this->settingsEntries = &settingsEntriesStorage;
|
||||
this->sharedVariables = &sharedVariablesStorage;
|
||||
this->settingsJson = &settingsJsonStorage;
|
||||
|
||||
this->windowPos = &windowPosStorage;
|
||||
this->windowSize = &windowSizeStorage;
|
||||
@@ -53,6 +73,9 @@ namespace hex {
|
||||
this->eventHandlers = other.eventHandlers;
|
||||
this->deferredCalls = other.deferredCalls;
|
||||
this->currentProvider = other.currentProvider;
|
||||
this->settingsEntries = other.settingsEntries;
|
||||
this->sharedVariables = other.sharedVariables;
|
||||
this->settingsJson = other.settingsJson;
|
||||
|
||||
this->windowPos = other.windowPos;
|
||||
this->windowSize = other.windowSize;
|
||||
@@ -63,9 +86,14 @@ namespace hex {
|
||||
std::vector<EventHandler> *eventHandlers;
|
||||
std::vector<std::function<void()>> *deferredCalls;
|
||||
prv::Provider **currentProvider;
|
||||
std::map<std::string, std::vector<ContentRegistry::Settings::Entry>> *settingsEntries;
|
||||
nlohmann::json *settingsJson;
|
||||
|
||||
ImVec2 *windowPos;
|
||||
ImVec2 *windowSize;
|
||||
|
||||
private:
|
||||
std::map<std::string, std::any> *sharedVariables;
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user