From 2b7cfb8cc5ff618fadf1ce1218485e21a7421659 Mon Sep 17 00:00:00 2001 From: zhangbin Date: Tue, 29 Mar 2016 17:29:44 +0800 Subject: [PATCH 1/4] Add component for importing Studio Project. --- extends.js | 4 + extensions/cocostudio/CCStudioComponent.js | 267 ++++++++++++++++++ .../cocostudio/editor/studio-component.html | 87 ++++++ 3 files changed, 358 insertions(+) create mode 100644 extensions/cocostudio/CCStudioComponent.js create mode 100644 extensions/cocostudio/editor/studio-component.html diff --git a/extends.js b/extends.js index f64d00069d..7e0d824640 100644 --- a/extends.js +++ b/extends.js @@ -37,6 +37,10 @@ if (!(CC_EDITOR && Editor.isCoreLevel)) { require('./cocos2d/tilemap/CCTiledLayer'); } +if (!(CC_EDITOR && Editor.isCoreLevel)) { + require('./extensions/cocostudio/CCStudioComponent'); +} + require('./extensions/spine'); if (!(CC_EDITOR && Editor.isCoreLevel)) { diff --git a/extensions/cocostudio/CCStudioComponent.js b/extensions/cocostudio/CCStudioComponent.js new file mode 100644 index 0000000000..d2b93ea462 --- /dev/null +++ b/extensions/cocostudio/CCStudioComponent.js @@ -0,0 +1,267 @@ + +var ComponentType = cc.Enum({ + NONE : 0, + CHECKBOX : 1, + TEXT_ATLAS : 2, + SLIDER_BAR : 3, + LIST_VIEW : 4, + PAGE_VIEW : 5 +}); + +var ListDirection = cc.Enum({ + VERTICAL : 0, + HORIZONTAL: 1 +}); + +var VerticalAlign = cc.Enum({ + TOP : 0, + CENTER: 1, + BOTTOM: 2 +}); + +var HorizontalAlign = cc.Enum({ + LEFT : 0, + CENTER: 1, + RIGHT: 2 +}); + +var StudioComponent = cc.Class({ + name: 'cc.StudioComponent', + extends: cc.Component, + + editor: CC_EDITOR && { + menu: 'i18n:MAIN_MENU.component.others/Cocos Studio', + inspector: 'app://engine/extensions/cocostudio/editor/studio-component.html' + }, + + properties: { + _type : ComponentType.NONE, + type : { + get: function () { + return this._type; + }, + set: function (value) { + this._type = value; + }, + readonly: true, + type: ComponentType + }, + + // props for checkbox + _checkNormalBackFrame: null, + checkNormalBackFrame: { + get: function () { + return this._checkNormalBackFrame; + }, + set: function (value) { + this._checkNormalBackFrame = value; + }, + readonly: true, + type: cc.SpriteFrame + }, + + _checkPressedBackFrame: null, + checkPressedBackFrame: { + get: function () { + return this._checkPressedBackFrame; + }, + set: function (value) { + this._checkPressedBackFrame = value; + }, + readonly: true, + type: cc.SpriteFrame + }, + + _checkDisableBackFrame: null, + checkDisableBackFrame: { + get: function () { + return this._checkDisableBackFrame; + }, + set: function (value) { + this._checkDisableBackFrame = value; + }, + readonly: true, + type: cc.SpriteFrame + }, + + _checkNormalFrame: null, + checkNormalFrame: { + get: function () { + return this._checkNormalFrame; + }, + set: function (value) { + this._checkNormalFrame = value; + }, + readonly: true, + type: cc.SpriteFrame + }, + + _checkDisableFrame: null, + checkDisableFrame: { + get: function () { + return this._checkDisableFrame; + }, + set: function (value) { + this._checkDisableFrame = value; + }, + readonly: true, + type: cc.SpriteFrame + }, + + checkInteractable : { + readonly: true, + default: true + }, + + isChecked : { + readonly: true, + default: true + }, + + // props for TextAtlas + _atlasFrame: null, + atlasFrame: { + get: function () { + return this._atlasFrame; + }, + set: function (value) { + this._atlasFrame = value; + }, + readonly: true, + type: cc.SpriteFrame + }, + + firstChar: { + readonly: true, + default: '.' + }, + + charWidth: { + readonly: true, + default: 0 + }, + + charHeight: { + readonly: true, + default: 0 + }, + + string: { + readonly: true, + default: '' + }, + + // props for SliderBar + _sliderBackFrame: null, + sliderBackFrame : { + get: function () { + return this._sliderBackFrame; + }, + set: function (value) { + this._sliderBackFrame = value; + }, + readonly: true, + type: cc.SpriteFrame + }, + + _sliderBarFrame: null, + sliderBarFrame : { + get: function () { + return this._sliderBarFrame; + }, + set: function (value) { + this._sliderBarFrame = value; + }, + readonly: true, + type: cc.SpriteFrame + }, + + _sliderBtnNormalFrame: null, + sliderBtnNormalFrame : { + get: function () { + return this._sliderBtnNormalFrame; + }, + set: function (value) { + this._sliderBtnNormalFrame = value; + }, + readonly: true, + type: cc.SpriteFrame + }, + + _sliderBtnPressedFrame: null, + sliderBtnPressedFrame : { + get: function () { + return this._sliderBtnPressedFrame; + }, + set: function (value) { + this._sliderBtnPressedFrame = value; + }, + readonly: true, + type: cc.SpriteFrame + }, + + _sliderBtnDisabledFrame: null, + sliderBtnDisabledFrame : { + get: function () { + return this._sliderBtnDisabledFrame; + }, + set: function (value) { + this._sliderBtnDisabledFrame = value; + }, + readonly: true, + type: cc.SpriteFrame + }, + + sliderInteractable : { + readonly: true, + default: true + }, + + sliderProgress: { + default: 0.5, + readonly: true, + type: 'Float', + range: [0, 1, 0.1] + }, + + // props for ListView + listInertia: { + readonly: true, + default: true, + animatable: false, + tooltip: 'i18n:COMPONENT.scrollview.inertia', + }, + + listDirection: { + readonly: true, + default: ListDirection.VERTICAL, + type: ListDirection + }, + + listHorizontalAlign: { + readonly: true, + default: HorizontalAlign.LEFT, + type: HorizontalAlign + }, + + listVerticalAlign: { + readonly: true, + default: VerticalAlign.TOP, + type: VerticalAlign + }, + + listPadding: { + readonly: true, + default: 0 + } + }, + + statics : { + ComponentType : ComponentType, + ListDirection : ListDirection, + VerticalAlign : VerticalAlign, + HorizontalAlign : HorizontalAlign + }, +}); + +cc.StudioComponent = module.exports = StudioComponent; diff --git a/extensions/cocostudio/editor/studio-component.html b/extensions/cocostudio/editor/studio-component.html new file mode 100644 index 0000000000..dded848038 --- /dev/null +++ b/extensions/cocostudio/editor/studio-component.html @@ -0,0 +1,87 @@ + + + + + From 65b6fe136cfde45130ccb0b0276e0f7aec1812d4 Mon Sep 17 00:00:00 2001 From: zhangbin Date: Thu, 7 Apr 2016 09:43:59 +0800 Subject: [PATCH 2/4] Remove the Studio Component from component menu. --- extensions/cocostudio/CCStudioComponent.js | 1 - 1 file changed, 1 deletion(-) diff --git a/extensions/cocostudio/CCStudioComponent.js b/extensions/cocostudio/CCStudioComponent.js index d2b93ea462..2c7722c52f 100644 --- a/extensions/cocostudio/CCStudioComponent.js +++ b/extensions/cocostudio/CCStudioComponent.js @@ -30,7 +30,6 @@ var StudioComponent = cc.Class({ extends: cc.Component, editor: CC_EDITOR && { - menu: 'i18n:MAIN_MENU.component.others/Cocos Studio', inspector: 'app://engine/extensions/cocostudio/editor/studio-component.html' }, From 2626f6e6c0da85f6c66cace1d7eb915f3e6cdf2a Mon Sep 17 00:00:00 2001 From: zhangbin Date: Thu, 7 Apr 2016 17:23:32 +0800 Subject: [PATCH 3/4] Improve the code for runtime. --- extensions/cocostudio/CCStudioComponent.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/cocostudio/CCStudioComponent.js b/extensions/cocostudio/CCStudioComponent.js index 2c7722c52f..1dc983092c 100644 --- a/extensions/cocostudio/CCStudioComponent.js +++ b/extensions/cocostudio/CCStudioComponent.js @@ -33,7 +33,7 @@ var StudioComponent = cc.Class({ inspector: 'app://engine/extensions/cocostudio/editor/studio-component.html' }, - properties: { + properties: CC_EDITOR && { _type : ComponentType.NONE, type : { get: function () { From 1037397c97f84d84a15be0e39804c7d20ac82ab6 Mon Sep 17 00:00:00 2001 From: zhangbin Date: Thu, 7 Apr 2016 18:28:42 +0800 Subject: [PATCH 4/4] Adjust code for the new environment of Creator. --- extends.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extends.js b/extends.js index 3d7ed08f8c..3a87020af8 100644 --- a/extends.js +++ b/extends.js @@ -37,7 +37,7 @@ if (!(CC_EDITOR && Editor.isMainProcess)) { require('./cocos2d/tilemap/CCTiledLayer'); } -if (!(CC_EDITOR && Editor.isCoreLevel)) { +if (!(CC_EDITOR && Editor.isMainProcess)) { require('./extensions/cocostudio/CCStudioComponent'); }