#pragma once #include #include #include #include #include #include #include #include namespace hex::plugin::builtin { class ViewDataProcessor : public View { public: struct Workspace { Workspace() = default; std::unique_ptr context = { []{ ImNodesContext *ctx = ImNodes::CreateContext(); ctx->Style = ImNodes::GetStyle(); ctx->Io = ImNodes::GetIO(); ctx->AttributeFlagStack = GImNodes->AttributeFlagStack; return ctx; }(), ImNodes::DestroyContext }; std::list> nodes; std::list endNodes; std::list links; std::vector dataOverlays; std::optional currNodeError; }; public: ViewDataProcessor(); ~ViewDataProcessor() override; void drawContent() override; static nlohmann::json saveNode(const dp::Node *node); static nlohmann::json saveNodes(const Workspace &workspace); static std::unique_ptr loadNode(const nlohmann::json &data); static void loadNodes(Workspace &workspace, const nlohmann::json &data); static void eraseLink(Workspace &workspace, int id); static void eraseNodes(Workspace &workspace, const std::vector &ids); static void processNodes(Workspace &workspace); void reloadCustomNodes(); std::vector &getWorkspaceStack() { return *this->m_workspaceStack; } private: bool m_updateNodePositions = false; int m_rightClickedId = -1; ImVec2 m_rightClickedCoords; bool m_continuousEvaluation = false; struct CustomNode { std::string name; nlohmann::json data; }; std::vector m_customNodes; PerProvider m_mainWorkspace; PerProvider> m_workspaceStack; }; }