@@ -5,186 +5,179 @@ ExtButton.icon = 'app://res/control/Button.png'
55ExtButton . tag = 7
66ExtButton . defNormal = 'res/default/ButtonNormal.png'
77
8- ExtButton . GenEmptyNode = function ( ) {
9- node = new ccui . Button ( getFullPathForName ( ExtButton . defNormal ) )
10- node . _bgNormal = ExtButton . defNormal
11- node . _className = ExtButton . name
12- return node
8+ ExtButton . GenEmptyNode = function ( ) {
9+ node = new ccui . Button ( getFullPathForName ( ExtButton . defNormal ) )
10+ node . _bgNormal = ExtButton . defNormal
11+ node . _className = ExtButton . name
12+ return node
1313}
1414
15- ExtButton . SetButtonSpriteFrame = function ( path , value , node , func ) {
16- setNodeSpriteFrame ( path , value , node , function ( url ) {
17- func . call ( node , url )
18- } )
15+ ExtButton . SetButtonSpriteFrame = function ( path , value , node , func ) {
16+ setNodeSpriteFrame ( path , value , node , function ( url ) {
17+ func . call ( node , url )
18+ } )
1919}
2020
21- ExtButton . GenNodeByData = function ( data , parent ) {
22- node = new ccui . Button ( ) ;
23- node . _className = ExtButton . name ;
24- ExtButton . SetNodePropByData ( node , data , parent ) ;
25- return node
21+ ExtButton . GenNodeByData = function ( data , parent ) {
22+ node = new ccui . Button ( ) ;
23+ node . _className = ExtButton . name ;
24+ ExtButton . SetNodePropByData ( node , data , parent ) ;
25+ return node
2626}
2727
28- ExtButton . SetNodePropByData = function ( node , data , parent ) {
29- ( data [ 'scale9Enable' ] ) && ( node . setScale9Enabled ( data [ 'scale9Enable' ] ) ) ;
30- ExtButton . SetButtonSpriteFrame ( 'bgNormal' , data [ 'bgNormal' ] , node , node . loadTextureNormal ) ;
31- ExtButton . SetButtonSpriteFrame ( 'bgSelect' , data [ 'bgSelect' ] , node , node . loadTexturePressed ) ;
32- ExtButton . SetButtonSpriteFrame ( 'bgDisable' , data [ 'bgDisable' ] , node , node . loadTextureDisabled ) ;
28+ ExtButton . SetNodePropByData = function ( node , data , parent ) {
29+ ( data [ 'scale9Enable' ] ) && ( node . setScale9Enabled ( data [ 'scale9Enable' ] ) ) ;
30+ ExtButton . SetButtonSpriteFrame ( 'bgNormal' , data [ 'bgNormal' ] , node , node . loadTextureNormal ) ;
31+ ExtButton . SetButtonSpriteFrame ( 'bgSelect' , data [ 'bgSelect' ] , node , node . loadTexturePressed ) ;
32+ ExtButton . SetButtonSpriteFrame ( 'bgDisable' , data [ 'bgDisable' ] , node , node . loadTextureDisabled ) ;
3333
34- ( data [ 'titleText' ] ) && ( node . setTitleText ( data [ 'titleText' ] ) ) ;
35- ( data [ 'fontName' ] ) && ( node . setTitleFontName ( data [ 'fontName' ] ) ) ;
36- ( data [ 'fontSize' ] ) && ( node . setTitleFontSize ( data [ 'fontSize' ] ) ) ;
37- ( data [ 'fontColor' ] ) && ( node . setTitleColor ( covertToColor ( data [ 'fontColor' ] ) ) ) ;
34+ ( data [ 'titleText' ] ) && ( node . setTitleText ( data [ 'titleText' ] ) ) ;
35+ ( data [ 'fontName' ] ) && ( node . setTitleFontName ( data [ 'fontName' ] ) ) ;
36+ ( data [ 'fontSize' ] ) && ( node . setTitleFontSize ( data [ 'fontSize' ] ) ) ;
37+ ( data [ 'fontColor' ] ) && ( node . setTitleColor ( covertToColor ( data [ 'fontColor' ] ) ) ) ;
3838}
3939
40- ExtButton . ExportNodeData = function ( node , data ) {
41- ( node . isScale9Enabled ( ) ) && ( data [ 'scale9Enable' ] = node . isScale9Enabled ( ) )
42- ; ( node . _bgNormal ) && ( data [ 'bgNormal' ] = node . _bgNormal )
43- ; ( node . _bgSelect ) && ( data [ 'bgSelect' ] = node . _bgSelect )
44- ; ( node . _bgDisable ) && ( data [ 'bgDisable' ] = node . _bgDisable )
45- ; ( node . getTitleText ( ) . length > 0 ) && ( data [ 'titleText' ] = node . getTitleText ( ) )
46- ; ( node . getTitleFontName ( ) . length > 0 ) && ( data [ 'fontName' ] = node . getTitleFontName ( ) )
47- ; ( node . getTitleFontSize ( ) > 0 ) && ( data [ 'fontSize' ] = node . getTitleFontSize ( ) )
48- if ( ! cc . colorEqual ( node . getTitleColor ( ) , cc . color . WHITE ) ) {
49- let color = node . getTitleColor ( )
50- data [ 'fontColor' ] = [ color . r , color . g , color . b , color . a ]
51- }
40+ ExtButton . ExportNodeData = function ( node , data ) {
41+ ( node . isScale9Enabled ( ) ) && ( data [ 'scale9Enable' ] = node . isScale9Enabled ( ) ) ;
42+ ( node . _bgNormal ) && ( data [ 'bgNormal' ] = node . _bgNormal ) ;
43+ ( node . _bgSelect ) && ( data [ 'bgSelect' ] = node . _bgSelect ) ;
44+ ( node . _bgDisable ) && ( data [ 'bgDisable' ] = node . _bgDisable ) ;
45+ ( node . getTitleText ( ) . length > 0 ) && ( data [ 'titleText' ] = node . getTitleText ( ) ) ;
46+ ( node . getTitleFontName ( ) . length > 0 ) && ( data [ 'fontName' ] = node . getTitleFontName ( ) ) ;
47+ ( node . getTitleFontSize ( ) > 0 ) && ( data [ 'fontSize' ] = node . getTitleFontSize ( ) )
48+ if ( ! cc . colorEqual ( node . getTitleColor ( ) , cc . color . WHITE ) ) {
49+ let color = node . getTitleColor ( )
50+ data [ 'fontColor' ] = [ color . r , color . g , color . b , color . a ]
51+ }
5252}
5353
54- ExtButton . SetPropChange = function ( control , path , value ) {
55- SetDefaultPropChange ( control , path , value )
54+ ExtButton . SetPropChange = function ( control , path , value ) {
55+ SetDefaultPropChange ( control , path , value )
5656}
5757
5858ExtButton . GetLoadImages = function ( data ) {
59- return [ data [ 'bgNormal' ] , data [ 'bgSelect' ] , data [ 'bgDisable' ] ]
60- }
59+ return [ data [ 'bgNormal' ] , data [ 'bgSelect' ] , data [ 'bgDisable' ] ]
60+ }
6161
62- ExtButton . NodifyPropChange = function ( control ) {
63- SetNodifyPropChange ( control )
62+ ExtButton . NodifyPropChange = function ( control ) {
63+ SetNodifyPropChange ( control )
6464}
6565
66- ExtButton . ExportData = function ( node ) {
67- this . _node = node
66+ ExtButton . ExportData = function ( node ) {
67+ this . _node = node
6868}
6969
7070ExtButton . ExportData . prototype = {
71- __displayName__ : 'Button' ,
72- __type__ : 'cc.Button' ,
73-
74- get scale9Enable ( ) {
75- return {
76- path : 'scale9Enable' ,
77- type : 'checkbox' ,
78- name : 'scale9Enable' ,
79- attrs : {
80- } ,
81- value : this . _node . isScale9Enabled ( )
82- }
83- } ,
84-
85- get bgNormal ( ) {
86- return {
87- path : 'bgNormal' ,
88- type : 'asset' ,
89- name : 'bgNormal' ,
90- attrs : {
91- } ,
92- value : this . _node . _bgNormal
93- }
94- } ,
95-
96- get bgSelect ( ) {
97- return {
98- path : 'bgSelect' ,
99- type : 'asset' ,
100- name : 'bgSelect' ,
101- attrs : {
102- } ,
103- value : this . _node . _bgSelect
104- }
105- } ,
106-
107- get bgDisable ( ) {
108- return {
109- path : 'bgDisable' ,
110- type : 'asset' ,
111- name : 'bgDisable' ,
112- attrs : {
113- } ,
114- value : this . _node . _bgDisable
115- }
116- } ,
117-
118- get titleText ( ) {
119- return {
120- path : 'titleText' ,
121- type : 'input' ,
122- name : 'titleText' ,
123- attrs : {
124- } ,
125- value : this . _node . getTitleText ( )
126- }
127- } ,
128-
129- get fontName ( ) {
130- return {
131- path : 'fontName' ,
132- type : 'input' ,
133- name : 'fontName' ,
134- attrs : {
135- } ,
136- value : this . _node . getTitleFontName ( )
137- }
138- } ,
139-
140- get fontSize ( ) {
141- return {
142- path : 'fontSize' ,
143- type : 'unit-input' ,
144- name : 'fontSize' ,
145- attrs : {
146- expand : true ,
147- step : 1 ,
148- precision : 0 ,
149- min : 0 ,
150- max : 72
151- } ,
152- value : this . _node . getTitleFontSize ( )
153- }
154- } ,
155-
156- get fontColor ( ) {
157- return {
158- path : 'fontColor' ,
159- type : 'color' ,
160- name : 'fontColor' ,
161- attrs : {
162- } ,
163- value : this . _node . getTitleColor ( )
71+ __displayName__ : 'Button' ,
72+ __type__ : 'cc.Button' ,
73+
74+ get scale9Enable ( ) {
75+ return {
76+ path : 'scale9Enable' ,
77+ type : 'checkbox' ,
78+ name : 'scale9Enable' ,
79+ attrs : { } ,
80+ value : this . _node . isScale9Enabled ( )
81+ }
82+ } ,
83+
84+ get bgNormal ( ) {
85+ return {
86+ path : 'bgNormal' ,
87+ type : 'asset' ,
88+ name : 'bgNormal' ,
89+ attrs : { } ,
90+ value : this . _node . _bgNormal
91+ }
92+ } ,
93+
94+ get bgSelect ( ) {
95+ return {
96+ path : 'bgSelect' ,
97+ type : 'asset' ,
98+ name : 'bgSelect' ,
99+ attrs : { } ,
100+ value : this . _node . _bgSelect
101+ }
102+ } ,
103+
104+ get bgDisable ( ) {
105+ return {
106+ path : 'bgDisable' ,
107+ type : 'asset' ,
108+ name : 'bgDisable' ,
109+ attrs : { } ,
110+ value : this . _node . _bgDisable
111+ }
112+ } ,
113+
114+ get titleText ( ) {
115+ return {
116+ path : 'titleText' ,
117+ type : 'input' ,
118+ name : 'titleText' ,
119+ attrs : { } ,
120+ value : this . _node . getTitleText ( )
121+ }
122+ } ,
123+
124+ get fontName ( ) {
125+ return {
126+ path : 'fontName' ,
127+ type : 'input' ,
128+ name : 'fontName' ,
129+ attrs : { } ,
130+ value : this . _node . getTitleFontName ( )
131+ }
132+ } ,
133+
134+ get fontSize ( ) {
135+ return {
136+ path : 'fontSize' ,
137+ type : 'unit-input' ,
138+ name : 'fontSize' ,
139+ attrs : {
140+ expand : true ,
141+ step : 1 ,
142+ precision : 0 ,
143+ min : 0 ,
144+ max : 72
145+ } ,
146+ value : this . _node . getTitleFontSize ( )
147+ }
148+ } ,
149+
150+ get fontColor ( ) {
151+ return {
152+ path : 'fontColor' ,
153+ type : 'color' ,
154+ name : 'fontColor' ,
155+ attrs : { } ,
156+ value : this . _node . getTitleColor ( )
157+ }
158+ } ,
159+
160+ get __props__ ( ) {
161+ return [
162+ this . scale9Enable ,
163+ this . bgNormal ,
164+ this . bgSelect ,
165+ this . bgDisable ,
166+ this . titleText ,
167+ this . fontName ,
168+ this . fontSize ,
169+ this . fontColor
170+ ]
164171 }
165- } ,
166-
167- get __props__ ( ) {
168- return [
169- this . scale9Enable ,
170- this . bgNormal ,
171- this . bgSelect ,
172- this . bgDisable ,
173- this . titleText ,
174- this . fontName ,
175- this . fontSize ,
176- this . fontColor
177- ]
178- }
179172}
180173
181- ExtButton . PropComps = function ( node ) {
182- let datas = [ new WidgetData ( node ) ]
183- datas . push ( new TouchData ( node ) )
184- datas . push ( new ExtButton . ExportData ( node ) )
185- return datas
174+ ExtButton . PropComps = function ( node ) {
175+ let datas = [ new WidgetData ( node ) ]
176+ datas . push ( new TouchData ( node ) )
177+ datas . push ( new ExtButton . ExportData ( node ) )
178+ return datas
186179}
187180
188181module . exports = ExtButton
189182
190- RegisterExtNodeControl ( ExtButton . name , ExtButton )
183+ RegisterExtNodeControl ( ExtButton . name , ExtButton )
0 commit comments