-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSampleEditorExtension.h
More file actions
52 lines (39 loc) · 1.84 KB
/
Copy pathSampleEditorExtension.h
File metadata and controls
52 lines (39 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//
// Created by engin on 6.04.2019.
//
#ifndef NODEGRAPH_SAMPLEEDITOREXTENSION_H
#define NODEGRAPH_SAMPLEEDITOREXTENSION_H
#include <string>
#include <iostream>
#include "../src/EditorExtension.h"
class SampleEditorExtension : public EditorExtension {
char inputBuffer[256];
public:
void drawDetailPane(NodeGraph* nodeGraph, const std::vector<const Node *>& nodes, const Node* selectedNode = nullptr) override;
std::string getName() {
return "SampleEditorExtension";
}
virtual void serialize(tinyxml2::XMLDocument &document, tinyxml2::XMLElement *parentElement) {
tinyxml2::XMLElement *nodeTypeElement = document.NewElement("EditorExtension");
parentElement->InsertEndChild(nodeTypeElement);
tinyxml2::XMLElement *nameElement = document.NewElement("Name");
nameElement->SetText(getName().c_str());
nodeTypeElement->InsertEndChild(nameElement);
tinyxml2::XMLElement *customInputElement = document.NewElement("CustomInput");
customInputElement->SetText(inputBuffer);
nodeTypeElement->InsertEndChild(customInputElement);
}
void deserialize(const std::string &fileName, tinyxml2::XMLElement *editorExtensionElement) override {
tinyxml2::XMLElement* customInput = editorExtensionElement->FirstChildElement("CustomInput");
if (customInput == nullptr) {
std::cerr << "Error loading XML "<< fileName << ": Custom input of Editor Extension is not found!" << std::endl;
} else {
if (customInput->GetText() == nullptr) {
std::cerr << "Error loading XML " << fileName << ": Custom input of Editor Extension has no text!" << std::endl;
} else {
strncpy(inputBuffer, customInput->GetText(), sizeof(inputBuffer));
}
}
}
};
#endif //NODEGRAPH_SAMPLEEDITOREXTENSION_H