forked from tickbh/VisualUIEditor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExtArmature.js
More file actions
177 lines (151 loc) · 4.73 KB
/
ExtArmature.js
File metadata and controls
177 lines (151 loc) · 4.73 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
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
let ExtArmature = {}
ExtArmature.name = 'UIArmature'
ExtArmature.icon = 'app://res/control/Armature.png'
ExtArmature.tag = 10
ExtArmature.GenEmptyNode = function() {
node = new ccs.Armature()
node._className = ExtArmature.name
return node
}
ExtArmature.SetBaseNodeProp = function(node, data) {
data.actionName && (node.actionName = data.actionName)
data.imagePath && (node.imagePath = data.imagePath)
data.plistPath && (node.plistPath = data.plistPath)
data.configFilePath && (node.configFilePath = data.configFilePath)
}
ExtArmature.GenNodeByData = function(data, parent) {
// data.actionName = 'skill1'
// data.imagePath = 'fla/skill1.png'
// data.plistPath = 'fla/skill1.plist'
// data.configFilePath = 'fla/skill1.xml'
node = new ccs.Armature()
node._className = ExtArmature.name
ExtArmature.SetBaseNodeProp(node, data)
// data.ignoreSetProp = true
if (data.uuid) {
node.uuid = data.uuid
}
var fullImagePath = getFullPathForName(data.imagePath)
var fullPlistPath = getFullPathForName(data.plistPath)
var fullConfigPath = getFullPathForName(data.configFilePath)
if (!fullImagePath || !fullPlistPath || !fullConfigPath || !data.actionName) {
return node
}
// cc.loader.load([fullImagePath, fullPlistPath, fullConfigPath],
// function (results, count, loadedCount) {
// if (count == loadedCount + 1) {
// }
// }, function () {
ccs.armatureDataManager.addArmatureFileInfo(fullImagePath, fullPlistPath, fullConfigPath)
// if(!node.getParent() && parent) {
// parent.addChild(node)
// }
node.init(data.actionName)
if (node.getAnimation()) {
node.getAnimation().play('stand', -1, 1)
}
return node
}
ExtArmature.ResetPropByData = function(control, data, parent) {
if (data.ignoreSetProp) {
return
}
let node = control._node
parent = parent || node.getParent()
data.ignoreSetProp = true
data.uuid = node.uuid
let newNode = cocosGenNodeByData(data, parent)
node.ignoreAddToParent = true
ReplaceNode(node, newNode, parent)
control._node = newNode
}
ExtArmature.SetNodePropByData = function(node, data, parent) {
ExtArmature.ResetPropByData({ _node: node }, data, parent)
}
ExtArmature.ExportNodeData = function(node, data) {
node.actionName && (data.actionName = node.actionName)
node.imagePath && (data.imagePath = node.imagePath)
node.plistPath && (data.plistPath = node.plistPath)
node.configFilePath && (data.configFilePath = node.configFilePath)
data['anchorX'] = node.anchorX
data['anchorY'] = node.anchorY
// data['anchorX'] = null
// data['anchorY'] = null
}
ExtArmature.PropCantChange = function(node, path, value, target) {
// if(path == "anchor.x" || path == "anchor.y") {
// return true
// }
return false
}
ExtArmature.SetPropChange = function(control, path, value, target) {
let data = cocosExportNodeData(control._node, { uuid: true })
data[path] = value
ExtArmature.ResetPropByData(control, data)
}
ExtArmature.GetLoadImages = function(data) {
return [data['imagePath'], data['plistPath'], data['configFilePath']]
}
ExtArmature.NodifyPropChange = function(control) {
SetNodifyPropChange(control)
}
function ExtArmatureData(node) {
this._node = node
}
ExtArmatureData.prototype = {
__displayName__: 'ExtArmature',
__type__: 'ccui.ExtArmature',
get actionName() {
return {
path: 'actionName',
type: 'asset',
name: 'actionName',
attrs: {},
value: this._node.actionName
}
},
get imagePath() {
return {
path: 'imagePath',
type: 'asset',
name: 'imagePath',
attrs: {},
value: this._node.imagePath
}
},
get plistPath() {
return {
path: 'plistPath',
type: 'asset',
name: 'plistPath',
attrs: {},
value: this._node.plistPath
}
},
get configFilePath() {
return {
path: 'configFilePath',
type: 'asset',
name: 'configFilePath',
attrs: {},
value: this._node.configFilePath
}
},
get __props__() {
return [
this.actionName,
this.imagePath,
this.plistPath,
this.configFilePath
]
}
}
ExtArmature.ExtArmatureData = ExtArmatureData
ExtArmature.PropComps = function(node) {
let datas = [new WidgetData(node)]
datas.push(new TouchData(node))
datas.push(new ExtArmatureData(node))
return datas
}
module.exports = ExtArmature
RegisterExtNodeControl(ExtArmature.name, ExtArmature)