From b15e2af7e3b6db83aee18c17fe6b4e6ece0c5c97 Mon Sep 17 00:00:00 2001 From: Jare Guo Date: Mon, 7 Dec 2015 15:53:59 +0800 Subject: [PATCH] update component menu --- cocos2d/core/assets/CCPrefab.js | 3 +- cocos2d/core/components/CCCanvas.js | 2 +- cocos2d/core/components/CCELabel.js | 2 +- cocos2d/core/components/CCSpriteRenderer.js | 2 +- cocos2d/core/components/CCWidget.js | 2 +- cocos2d/core/platform/prefab-info.js | 2 +- cocos2d/core/utils/base-node.js | 24 +++++----------- cocos2d/particle/CCEParticleSystem.js | 2 +- gulpfile.js | 2 +- test/qunit/unit/test-load-scene.js | 4 +++ test/qunit/unit/test-prefab.js | 4 +++ test/qunit/unit/test-record-object.js | 31 +++++++++++---------- 12 files changed, 41 insertions(+), 39 deletions(-) diff --git a/cocos2d/core/assets/CCPrefab.js b/cocos2d/core/assets/CCPrefab.js index e439c182cd..80af448f20 100644 --- a/cocos2d/core/assets/CCPrefab.js +++ b/cocos2d/core/assets/CCPrefab.js @@ -40,4 +40,5 @@ var Prefab = cc.Class({ } }); -cc._Prefab = module.exports = Prefab; +cc.Prefab = module.exports = Prefab; +cc.js.obsolete(cc, 'cc._Prefab', 'Prefab'); diff --git a/cocos2d/core/components/CCCanvas.js b/cocos2d/core/components/CCCanvas.js index 03f032dca3..a34d9917e0 100644 --- a/cocos2d/core/components/CCCanvas.js +++ b/cocos2d/core/components/CCCanvas.js @@ -50,7 +50,7 @@ var Canvas = cc.Class({ name: 'cc.Canvas', extends: require('./CCComponent'), editor: CC_EDITOR && { - menu: 'Canvas', + menu: 'UI/Canvas', executeInEditMode: true, disallowMultiple: true }, diff --git a/cocos2d/core/components/CCELabel.js b/cocos2d/core/components/CCELabel.js index 345009ca83..6651edab7b 100644 --- a/cocos2d/core/components/CCELabel.js +++ b/cocos2d/core/components/CCELabel.js @@ -54,7 +54,7 @@ var Label = cc.Class({ extends: cc._ComponentInSG, editor: CC_EDITOR && { - menu: 'UI/Label' + menu: 'Graphics/Label' }, properties: { diff --git a/cocos2d/core/components/CCSpriteRenderer.js b/cocos2d/core/components/CCSpriteRenderer.js index 4542339886..7eb5e83a63 100644 --- a/cocos2d/core/components/CCSpriteRenderer.js +++ b/cocos2d/core/components/CCSpriteRenderer.js @@ -53,7 +53,7 @@ var SpriteRenderer = cc.Class({ extends: require('./CCComponentInSG'), editor: CC_EDITOR && { - menu: 'Sprite', + menu: 'Graphics/Sprite', inspector: 'app://editor/page/inspector/sprite.html' }, diff --git a/cocos2d/core/components/CCWidget.js b/cocos2d/core/components/CCWidget.js index 188f11e2a5..f0770aaeea 100644 --- a/cocos2d/core/components/CCWidget.js +++ b/cocos2d/core/components/CCWidget.js @@ -43,7 +43,7 @@ var Widget = cc.Class({ name: 'cc.Widget', extends: require('./CCComponent'), editor: CC_EDITOR && { - menu: 'Widget', + menu: 'UI/Widget', executeInEditMode: true, disallowMultiple: true, inspector: 'app://editor/page/inspector/widget/index.html' diff --git a/cocos2d/core/platform/prefab-info.js b/cocos2d/core/platform/prefab-info.js index 1f6df52d7e..79bfd1eefb 100644 --- a/cocos2d/core/platform/prefab-info.js +++ b/cocos2d/core/platform/prefab-info.js @@ -12,7 +12,7 @@ var PrefabInfo = cc.Class({ default: null, }, - // 所属的 prefab 资源对象 (cc._Prefab) + // 所属的 prefab 资源对象 (cc.Prefab) // (这个属性在场景中是会保存的,但是不会保存在 prefab 里面,因为创建 prefab 时还不知道自己的 uuid 是多少。) asset: { default: null, diff --git a/cocos2d/core/utils/base-node.js b/cocos2d/core/utils/base-node.js index 26c4db590e..9f186b6bf1 100644 --- a/cocos2d/core/utils/base-node.js +++ b/cocos2d/core/utils/base-node.js @@ -265,22 +265,6 @@ var BaseNode = cc.Class(/** @lends cc.ENode# */{ }, }, - /** - * position of node. - * @property position - * @type {Vec2} - */ - position: { - get: SGProto.getPosition, - set: function (value) { - this._position.x = value.x; - this._sgNode.x = value.x; - - this._position.y = value.y; - this._sgNode.y = value.y; - } - }, - /** * x axis position of node. * @property x @@ -1224,7 +1208,7 @@ var BaseNode = cc.Class(/** @lends cc.ENode# */{ // Define public getter and setter methods to ensure api compatibility. - var SameNameGetSets = ['name', 'skewX', 'skewY', 'rotation', 'rotationX', 'rotationY', + var SameNameGetSets = ['name', 'skewX', 'skewY', 'position', 'rotation', 'rotationX', 'rotationY', 'scale', 'scaleX', 'scaleY', 'children', 'childrenCount', 'parent', 'running', /*'actionManager',*/ 'scheduler', /*'shaderProgram',*/ 'opacity', 'color', 'tag']; var DiffNameGetSets = { @@ -1268,6 +1252,12 @@ var BaseNode = cc.Class(/** @lends cc.ENode# */{ } })(); +/** + * position of node. + * @property position + * @type {Vec2} + */ + /** * Scale of node * @property scale diff --git a/cocos2d/particle/CCEParticleSystem.js b/cocos2d/particle/CCEParticleSystem.js index 04abe4bc77..c474ee082f 100644 --- a/cocos2d/particle/CCEParticleSystem.js +++ b/cocos2d/particle/CCEParticleSystem.js @@ -534,7 +534,7 @@ var ParticleSystem = cc.Class({ name: 'cc.ParticleSystem', extends: cc._ComponentInSG, editor: CC_EDITOR && { - menu: 'ParticleSystem', + menu: 'Graphics/ParticleSystem', inspector: 'app://editor/page/inspector/particle-system/index.html', playOnFocus: true, }, diff --git a/gulpfile.js b/gulpfile.js index 198e7be325..71a6697063 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -25,7 +25,7 @@ paths = { test: { src: 'test/qunit/unit/**/*.js', runner: 'test/qunit/lib/qunit-runner.html', - jsEntryEditorExtends: '../../editor/share/engine-extends/index.js', // only available in editor + jsEntryEditorExtends: '../editor/share/engine-extends/index.js', // only available in editor dest: 'bin/cocos2d-js-for-test.js', destEditorExtends: 'bin/cocos2d-js-extends-for-test.js' }, diff --git a/test/qunit/unit/test-load-scene.js b/test/qunit/unit/test-load-scene.js index b09cf24ada..3b20779bba 100644 --- a/test/qunit/unit/test-load-scene.js +++ b/test/qunit/unit/test-load-scene.js @@ -1,5 +1,9 @@ (function () { + if (!TestEditorExtends) { + return; + } + var Script; module('test scene serialization', { diff --git a/test/qunit/unit/test-prefab.js b/test/qunit/unit/test-prefab.js index a7c7cc5d00..dfcf48b0e0 100644 --- a/test/qunit/unit/test-prefab.js +++ b/test/qunit/unit/test-prefab.js @@ -1,5 +1,9 @@ (function () { + if (!TestEditorExtends) { + return; + } + //var testingCompCallback = false; var MyComponent = cc.Class({ diff --git a/test/qunit/unit/test-record-object.js b/test/qunit/unit/test-record-object.js index 85fdd6d320..755407bd36 100644 --- a/test/qunit/unit/test-record-object.js +++ b/test/qunit/unit/test-record-object.js @@ -1,17 +1,20 @@ +if (TestEditorExtends) { -test('undo destroy', function () { - var Type = cc.Class({ - extends: cc.Object + test('undo destroy', function () { + var Type = cc.Class({ + extends: cc.Object + }); + var obj1 = new Type(); + var record = Editor._recordObject(obj1); + obj1.destroy(); + Editor._restoreObject(obj1, record); + cc.Object._deferredDestroy(); + ok(obj1.isValid, 'it should be valid if restored before _deferredDestroy'); + + obj1.destroy(); + cc.Object._deferredDestroy(); + Editor._restoreObject(obj1, record); + ok(obj1.isValid, 'it should be valid if restored after _deferredDestroy'); }); - var obj1 = new Type(); - var record = Editor._recordObject(obj1); - obj1.destroy(); - Editor._restoreObject(obj1, record); - cc.Object._deferredDestroy(); - ok(obj1.isValid, 'it should be valid if restored before _deferredDestroy'); - obj1.destroy(); - cc.Object._deferredDestroy(); - Editor._restoreObject(obj1, record); - ok(obj1.isValid, 'it should be valid if restored after _deferredDestroy'); -}); +}