-
Notifications
You must be signed in to change notification settings - Fork 0
/
flowChartLink-element.html
188 lines (172 loc) · 5.68 KB
/
flowChartLink-element.html
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<link rel="import" href="flowChartLink-behavior.html"><script>
"use strict";
var QuestLink = new Polymer({
is: "questLink-element",
extends: "canvas",
behaviors: [FlowChartLinkBehavior],
properties: {
requiredToExitObjective: {
type: Boolean,
value: false
}
},
factoryImpl: function(startElement, endElement) {
this.startElement = startElement;
this.endElement = endElement;
},
attached: function() {
// noch später: https://github.com/Polymer/polymer/issues/1699#issuecomment-108112212
this.async(function() {
if(this.startElement !== undefined && this.endElement !== undefined) {
this.connect('#B22222');
}
});
},
fromXML: function(xml, nodesMap) {
var node;
for (var x = 0; x < xml.childNodes.length; x++) {
node = xml.childNodes[x];
if (node.nodeName == "FromNodeID") {
if (node.textContent === "0") {
this.startElement = nodesMap["QuestNode" + node.textContent];
} else if(node.textContent === "-10") {
this.startElement = nodesMap["GlobalQuestNode" + node.textContent];
} else if(nodesMap.hasOwnProperty("ObjectiveNode" + node.textContent)) {
this.startElement = nodesMap["ObjectiveNode" + node.textContent];
} else {
this.startElement = nodesMap["EndStateNode" + node.textContent];
}
}
if (node.nodeName == "ToNodeID") {
if(nodesMap.hasOwnProperty("ObjectiveNode" + node.textContent)) {
this.endElement = nodesMap["ObjectiveNode" + node.textContent];
} else if(nodesMap.hasOwnProperty("GlobalQuestNode" + node.textContent)) {
this.endElement = nodesMap["GlobalQuestNode" + node.textContent];
} else if(nodesMap.hasOwnProperty("EndStateNode" + node.textContent)) {
this.endElement = nodesMap["EndStateNode" + node.textContent];
}
}
if (node.nodeName == "PointsToGhost") {
this.pointsToGhost = node.textContent;
}
if (node.nodeName == "RequiredToExitObjective") {
this.requiredToExitObjective = node.textContent;
}
}
},
toXML: function() {
var xml = '<FlowChartLink xsi:type="QuestLink">'
+ '<FromNodeID>' + this.startElement.nodeId + '</FromNodeID>'
+ '<ToNodeID>' + this.endElement.nodeId + '</ToNodeID>'
+ '<PointsToGhost>' + this.pointsToGhost + '</PointsToGhost>'
+ '<ClassExtender><ExtendedProperties /></ClassExtender>' // immer leer
+ '<RequiredToExitObjective>' + this.requiredToExitObjective + '</RequiredToExitObjective>';
return xml + '</FlowChartLink>';
}
});
var DialogueLink = new Polymer({
is: "dialogueLink-element",
extends: "canvas",
behaviors: [FlowChartLinkBehavior],
properties: {
randomWeight: {
type: Number,
value: 1
},
playQuestionNodeVO: {
type: Boolean,
value: true
},
questionNodeTextDisplay: {
type: String,
value: "ShowOnce"
}
},
// ist vor dem Behavior dran
factoryImpl: function(startElement, endElement) {
this.startElement = startElement;
this.endElement = endElement;
},
attached: function() {
this.async(function() {
if(this.startElement !== undefined && this.endElement !== undefined) {
this.connect('#f00');
}
});
},
fromXML: function(xml, nodesMap) {
var node;
var types = ["TalkNode", "PlayerResponseNode", "TriggerConversationNode", "BankNode", "ScriptNode"];
for(var x = 0; x < xml.childNodes.length; x++) {
node = xml.childNodes[x];
if(node.nodeName == "FromNodeID") {
types.forEach(function (type) {
if(nodesMap[type + node.textContent] !== undefined) {
this.startElement = nodesMap[type + node.textContent];
}
}, this);
}
if(node.nodeName == "ToNodeID") {
types.forEach(function (type) {
if(nodesMap[type + node.textContent] !== undefined) {
this.endElement = nodesMap[type + node.textContent];
}
}, this);
}
if(node.nodeName == "PointsToGhost") {
this.pointsToGhost = node.textContent;
}
// classExtender ignorieren, ist sowieso überall leer
if(node.nodeName == "RandomWeight") {
this.randomWeight = node.textContent;
}
if(node.nodeName == "PlayQuestionNodeVO") {
this.playQuestionNodeVO = node.textContent;
}
if(node.nodeName == "QuestionNodeTextDisplay") {
this.questionNodeTextDisplay = node.textContent;
}
}
},
toXML: function() {
var xml = '<FlowChartLink xsi:type="DialogueLink">'
+ '<FromNodeID>' + this.startElement.nodeId + '</FromNodeID>'
+ '<ToNodeID>' + this.endElement.nodeId + '</ToNodeID>'
+ '<PointsToGhost>' + this.pointsToGhost + '</PointsToGhost>'
+ '<ClassExtender><ExtendedProperties /></ClassExtender>' // immer leer
+ '<RandomWeight>' + this.randomWeight + '</RandomWeight>'
+ '<PlayQuestionNodeVO>' + this.playQuestionNodeVO + '</PlayQuestionNodeVO>'
+ '<QuestionNodeTextDisplay>' + this.questionNodeTextDisplay + '</QuestionNodeTextDisplay>';
return xml + '</FlowChartLink>';
}
});
var ChildLink = new Polymer({
is: "childlink-element",
extends: "canvas",
behaviors: [FlowChartLinkBehavior],
properties: {
id: String
},
factoryImpl: function(startElement, endElement) {
this.startElement = startElement;
this.endElement = endElement;
},
attached: function() {
this.async(function() {
if(this.startElement !== undefined && this.endElement !== undefined) {
this.connect('#00f');
}
});
},
fromId: function(id, startNode, nodesMap) {
var node;
var types = ["TalkNode", "PlayerResponseNode", "TriggerConversationNode", "BankNode", "ScriptNode"];
this.startElement = startNode;
types.forEach(function (type) {
if(nodesMap[type + id] !== undefined) {
this.endElement = nodesMap[type + id];
}
}, this);
}
});
</script>