| 78 | CEdNodeGraph::~CEdNodeGraph() |
| 79 | { |
| 80 | } |
| 81 | |
| 82 | bool CEdNodeGraph::GraphSaveSettings(const char* data, size_t size, ax::NodeEditor::SaveReasonFlags Reason, void* userPointer) |
| 83 | { |
| 84 | CEdNodeGraph* ThisGraph = (CEdNodeGraph*)userPointer; |
| 85 | |
| 86 | if ( Reason == ax::NodeEditor::SaveReasonFlags::None |
| 87 | || Reason == ax::NodeEditor::SaveReasonFlags::Navigation |
| 88 | || Reason == ax::NodeEditor::SaveReasonFlags::Selection |
| 89 | || ThisGraph->bFirstDraw) |
| 90 | { |
| 91 | return true; |
| 92 | } |
| 93 | |
| 94 | // The graph is un-changed. |
| 95 | if (ThisGraph->GraphSaveData.size() == size && (size == 0 || Memory::Memcmp(ThisGraph->GraphSaveData.data(), data, size) == 0)) |
| 96 | { |
| 97 | return true; |
| 98 | } |
| 99 | |
| 100 | ThisGraph->GraphSaveData.assign(data, size); |
| 101 | ThisGraph->GetPackage()->MarkDirty(); |
| 102 | |
| 103 | return true; |
| 104 | } |
| 105 | |
| 106 | size_t CEdNodeGraph::GraphLoadSettings(char* Data, void* UserPointer) |
| 107 | { |
| 108 | CEdNodeGraph* ThisGraph = (CEdNodeGraph*)UserPointer; |
| 109 | if (Data) |
| 110 | { |
| 111 | Memory::Memcpy(Data, ThisGraph->GraphSaveData.data(), ThisGraph->GraphSaveData.size()); |
| 112 | } |
| 113 | return ThisGraph->GraphSaveData.size(); |
| 114 | } |
| 115 | |
| 116 | |
| 117 | void CEdNodeGraph::Initialize() |
| 118 | { |
| 119 | ax::NodeEditor::Config Config; |
| 120 | Config.EnableSmoothZoom = true; |
| 121 | Config.UserPointer = this; |
| 122 | Config.SaveSettings = GraphSaveSettings; |
| 123 | Config.LoadSettings = GraphLoadSettings; |
| 124 | Config.SettingsFile = nullptr; |
| 125 | Context = ax::NodeEditor::CreateEditor(&Config); |
| 126 | } |
| 127 | |
| 128 | void CEdNodeGraph::Shutdown() |
| 129 | { |
| 130 | // Otherwise closing the editor you copied from leaves a paste pointing at freed nodes. |
| 131 | for (const TObjectPtr<CEdGraphNode>& Node : Nodes) |
| 132 | { |
| 133 | if (Node.IsValid()) |
| 134 | { |
| 135 | ForgetClipboardNode(Node.Get()); |
| 136 | } |
| 137 | } |
no test coverage detected