Skip to content

Commit e93b5fa

Browse files
committed
fix load func
1 parent 7abe925 commit e93b5fa

10 files changed

Lines changed: 140 additions & 32 deletions

File tree

ext/ExtArmature.js

Lines changed: 46 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,38 +27,44 @@ ExtArmature.GenNodeByData = function (data, parent) {
2727
node._className = ExtArmature.name
2828
ExtArmature.SetBaseNodeProp(node, data)
2929
// data.ignoreSetProp = true
30-
if(data.uuid) {
31-
node.uuid = data.uuid;
30+
if (data.uuid) {
31+
node.uuid = data.uuid
3232
}
3333
var fullImagePath = getFullPathForName(data.imagePath)
3434
var fullPlistPath = getFullPathForName(data.plistPath)
3535
var fullConfigPath = getFullPathForName(data.configFilePath)
3636
if (!fullImagePath || !fullPlistPath || !fullConfigPath || !data.actionName) {
3737
return node
3838
}
39-
40-
cc.loader.load([fullImagePath, fullPlistPath, fullConfigPath],
41-
function (results, count, loadedCount) {
42-
if(count == loadedCount + 1) {
43-
39+
// cc.loader.load([fullImagePath, fullPlistPath, fullConfigPath],
40+
// function (results, count, loadedCount) {
41+
// if (count == loadedCount + 1) {
42+
// }
43+
// }, function () {
44+
ccs.armatureDataManager.addArmatureFileInfo(fullImagePath, fullPlistPath, fullConfigPath)
45+
// if(!node.getParent() && parent) {
46+
// parent.addChild(node)
47+
// }
48+
node.init(data.actionName)
49+
if (node.getAnimation()) {
50+
node.getAnimation().play('stand', -1, 1)
4451
}
45-
46-
}, function () {
47-
ccs.armatureDataManager.addArmatureFileInfo(fullImagePath, fullPlistPath, fullConfigPath);
48-
node.init(data.actionName);
49-
if(node.getAnimation()) {
50-
node.getAnimation().play('stand', -1, 1)
51-
}
52-
// var newNode = new ccs.Armature(data.actionName)
53-
// newNode._className = ExtArmature.name
54-
// node.uuid = data.uuid || gen_uuid();
55-
// data.uuid = node.uuid
56-
// node.ignoreAddToParent = true
57-
// newNode.getAnimation().play('stand', -1, 1)
58-
// cocosGenNodeByData(data, parent, newNode)
59-
// ReplaceNode(node, newNode, parent)
60-
// ExtArmature.SetBaseNodeProp(newNode, data)
61-
})
52+
53+
console.log("parent111 = ", parent)
54+
console.log("parent = ", node.getParent())
55+
console.log("getNodeToParentTransform = ", node.getNodeToParentTransform())
56+
console.log("_offsetPoint = ", node._offsetPoint)
57+
cocosGenNodeByDataBase(data, node, parent)
58+
// var newNode = new ccs.Armature(data.actionName)
59+
// newNode._className = ExtArmature.name
60+
// node.uuid = data.uuid || gen_uuid()
61+
// data.uuid = node.uuid
62+
// node.ignoreAddToParent = true
63+
// newNode.getAnimation().play('stand', -1, 1)
64+
// cocosGenNodeByData(data, parent, newNode)
65+
//
66+
// ExtArmature.SetBaseNodeProp(newNode, data)
67+
// })
6268
return node
6369
}
6470

@@ -86,9 +92,19 @@ ExtArmature.ExportNodeData = function (node, data) {
8692
node.imagePath && (data.imagePath = node.imagePath)
8793
node.plistPath && (data.plistPath = node.plistPath)
8894
node.configFilePath && (data.configFilePath = node.configFilePath)
89-
90-
data['anchorX'] = node.anchorX
95+
96+
data['anchorX'] = node.anchorX
9197
data['anchorY'] = node.anchorY
98+
99+
// data['anchorX'] = null
100+
// data['anchorY'] = null
101+
}
102+
103+
ExtArmature.PropCantChange = function (node, path, value, target) {
104+
// if(path == "anchor.x" || path == "anchor.y") {
105+
// return true
106+
// }
107+
return false
92108
}
93109

94110
ExtArmature.SetPropChange = function (control, path, value, target) {
@@ -97,6 +113,10 @@ ExtArmature.SetPropChange = function (control, path, value, target) {
97113
ExtArmature.ResetPropByData(control, data)
98114
}
99115

116+
ExtArmature.GetLoadImages = function(data) {
117+
return [data['imagePath'], data['plistPath'], data['configFilePath']]
118+
}
119+
100120
ExtArmature.NodifyPropChange = function (control) {
101121
SetNodifyPropChange(control)
102122
}

ext/ExtButton.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ ExtButton.SetPropChange = function (control, path, value) {
5555
SetDefaultPropChange(control, path, value)
5656
}
5757

58+
ExtButton.GetLoadImages = function(data) {
59+
return [data['bgNormal'], data['bgSelect'], data['bgDisable']]
60+
}
61+
5862
ExtButton.NodifyPropChange = function (control) {
5963
SetNodifyPropChange(control)
6064
}

ext/ExtCheckBox.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ ExtCheckBox.SetPropChange = function (control, path, value) {
5252
SetDefaultPropChange(control, path, value)
5353
}
5454

55+
ExtCheckBox.GetLoadImages = function(data) {
56+
return [data['back'], data['backSelect'], data['active'], data['backDisable'], data['activeDisable']]
57+
}
58+
5559
ExtCheckBox.NodifyPropChange = function (control) {
5660
SetNodifyPropChange(control)
5761
}

ext/ExtImage.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ ExtImage.SetPropChange = function (control, path, value) {
4242
SetDefaultPropChange(control, path, value)
4343
}
4444

45+
ExtImage.GetLoadImages = function(data) {
46+
return [data['spriteFrame']]
47+
}
48+
4549
ExtImage.NodifyPropChange = function (control) {
4650
SetNodifyPropChange(control)
4751
}

ext/ExtInput.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ ExtInput.SetNodePropByData = function (node, data, parent) {
5555
ExtInput.SetSpriteFrame(node, data.spriteFrame)
5656
}
5757

58+
ExtInput.GetLoadImages = function(data) {
59+
return [data['spriteFrame']]
60+
}
61+
62+
5863
ExtInput.ExportNodeData = function (node, data) {
5964
(node.string.length > 0) && (data['string'] = node.string)
6065
let value = null

ext/ExtScale9.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ ExtScale9.SetNodePropByData = function (node, data, parent) {
4949
ExtScale9.ResetPropByData({ _node: node }, data, parent)
5050
}
5151

52+
ExtScale9.GetLoadImages = function(data) {
53+
return [data['spriteFrame']]
54+
}
55+
5256
ExtScale9.ExportNodeData = function (node, data) {
5357
node._spriteFrame && (data['spriteFrame'] = node._spriteFrame)
5458
node.insetLeft && (data.insetLeft = node.insetLeft)

ext/ExtSlider.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ ExtSlider.SetPropChange = function (control, path, value) {
5151
SetDefaultPropChange(control, path, value)
5252
}
5353

54+
ExtSlider.GetLoadImages = function(data) {
55+
return [data['barBg'], data['barProgress'], data['barNormalBall'], data['barSelectBall'], data['barDisableBall']]
56+
}
57+
58+
5459
ExtSlider.NodifyPropChange = function (control) {
5560
SetNodifyPropChange(control)
5661
}

ext/ExtTextAtlas.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ ExtTextAtlas.ExportNodeData = function (node, data) {
6868
// ExtTextAtlas.ResetPropByData(control, data)
6969
// }
7070

71+
ExtTextAtlas.GetLoadImages = function(data) {
72+
return [data['charMapFile']]
73+
}
74+
7175
ExtTextAtlas.SetPropChange = function (control, path, value) {
7276
SetDefaultPropChange(control, path, value)
7377
}

js/cocosUtil.js

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ cocosGetItemByUUID = function (node, uuid) {
2020
return recursiveGetChild(node, uuid)
2121
}
2222

23+
function IsSubPath (name) {
24+
return startWith(name, 'SubPath:')
25+
}
26+
2327
function isBaseTypeByName (name) {
2428
if (startWith(name, 'SubPath:')) {
2529
return true
@@ -270,11 +274,21 @@ function cocosGenSubUINode (path, parent) {
270274
if (checkPathRepeat(parent, path)) {
271275
return null
272276
}
273-
cocosGenNodeByData(getPathData(path), parent, node)
277+
var data = getPathData(path)
278+
var result = CalcNeedLoadImage(data)
279+
cc.loader.load(TableKeyToArray(result.imageTable), function() {
280+
cocosGenNodeByData(data, parent, node)
281+
})
274282
node._className = 'SubPath:' + path
275283
return node
276284
}
277285

286+
function CalcDataSize(node ,data, parent) {
287+
let widthRet = calcWidth(node, data.width, parent)
288+
let heightRet = calcHeight(node, data.height, parent)
289+
return cc.size(widthRet.width, heightRet.height)
290+
}
291+
278292
function cocosGenNodeByDataBase (data, node, parent) {
279293
if (!isNull(data.width) || !isNull(data.height)) {
280294
let setFn = node.setPreferredSize ? node.setPreferredSize : node.setContentSize
@@ -397,7 +411,14 @@ function loadSceneFromFile (filename) {
397411
let content = fs.readFileSync(filename)
398412
let data = JSON.parse(content || '{}')
399413
data._sceneSubPath = calcRelativePath(window.projectFolder, filename)
400-
return cocosGenNodeByData(data, null)
414+
415+
var scene = ExtScene.GenEmptyNode()
416+
scene.setContentSize(CalcDataSize(scene, data))
417+
var result = CalcNeedLoadImage(data)
418+
cc.loader.load(TableKeyToArray(result.imageTable), function() {
419+
cocosGenNodeByData(data, null, scene)
420+
})
421+
return scene
401422
}
402423

403424
function getFullRealPathForName (name) {
@@ -583,3 +604,43 @@ function SetNodifyPropChange (control) {
583604
let data = cocosExportNodeData(control._node, {uuid: true})
584605
ResetNodePropByData(control, data)
585606
}
607+
608+
function TableKeyToArray(table) {
609+
table = table || {}
610+
var array = []
611+
for(var k in table) {
612+
array.push(k)
613+
}
614+
return array
615+
}
616+
617+
function CalcNeedLoadImage (data, result) {
618+
result = result || {}
619+
result.imageTable = result.imageTable || {}
620+
621+
// result.loadUi = result.loadUi || {}
622+
// if (IsSubPath(child.type || '')) {
623+
// if(result.loadUi[child.path]) {
624+
// return result
625+
// }
626+
// CalcNeedLoadImage(getPathData(child.path), result)
627+
// result.loadUi[child.path] = true
628+
// return result
629+
// }
630+
let extControl = GetExtNodeControl(data.type)
631+
if (extControl && extControl.GetLoadImages) {
632+
var list = extControl.GetLoadImages(data)
633+
for (var i = 0; i < list.length; i++) {
634+
var fullpath = getFullPathForName(list[i] || '')
635+
if (fullpath) {
636+
result.imageTable[fullpath] = true
637+
}
638+
}
639+
}
640+
data.children = data.children || []
641+
for (var i = 0; i < data.children.length; i++) {
642+
var child = data.children[i]
643+
CalcNeedLoadImage(child, result)
644+
}
645+
return result
646+
}

prop/data/nodedata.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ NodeData.prototype = {
255255
}
256256
},
257257

258-
259258
get __props__() {
260259
return [
261260
this.tag,
@@ -301,8 +300,7 @@ NodeData.prototype = {
301300
if (this._node._path && !extControl) {
302301
extControl = GetExtNodeControl(this._node._path)
303302
}
304-
if(extControl && extControl.PropCantChange && extControl.PropCantChange(this._node, path, value)) {
305-
303+
if (extControl && extControl.PropCantChange && extControl.PropCantChange(this._node, path, value)) {
306304
} else if (path == 'tag') {
307305
addNodeCommand(this._node, '_name', this._node._name, value)
308306
this._node._name = value
@@ -697,5 +695,4 @@ TouchData.prototype = {
697695
// }
698696
// },
699697

700-
701698
// }

0 commit comments

Comments
 (0)