|
261 | 261 |
|
262 | 262 | widget.setTag(json["Tag"] || 0); |
263 | 263 |
|
264 | | - var touchEnabled = json["TouchEnable"]; |
265 | | - if(touchEnabled) |
266 | | - widget.setTouchEnabled(true); |
| 264 | + var touchEnabled = json["TouchEnable"] || false; |
| 265 | + widget.setTouchEnabled(touchEnabled); |
267 | 266 |
|
268 | 267 | // -- var frameEvent = json["FrameEvent"]; |
269 | 268 |
|
|
387 | 386 | if(backGroundScale9Enabled != null) |
388 | 387 | widget.setBackGroundImageScale9Enabled(backGroundScale9Enabled); |
389 | 388 |
|
390 | | - var scale9OriginX = json["Scale9OriginX"] || 0; |
391 | | - var scale9OriginY = json["Scale9OriginY"] || 0; |
| 389 | + var opacity = json["Alpha"] || 255; |
| 390 | + widget.setOpacity(opacity); |
392 | 391 |
|
393 | | - var scale9Width = json["Scale9Width"] || 0; |
394 | | - var scale9Height = json["Scale9Height"] || 0; |
| 392 | + loadTexture(json["FileData"], resourcePath, function(path, type){ |
| 393 | + widget.setBackGroundImage(path, type); |
| 394 | + }); |
| 395 | + |
| 396 | + if(backGroundScale9Enabled){ |
| 397 | + var scale9OriginX = json["Scale9OriginX"] || 0; |
| 398 | + var scale9OriginY = json["Scale9OriginY"] || 0; |
| 399 | + |
| 400 | + var scale9Width = json["Scale9Width"] || 0; |
| 401 | + var scale9Height = json["Scale9Height"] || 0; |
| 402 | + |
| 403 | + widget.setBackGroundImageCapInsets(cc.rect( |
| 404 | + scale9OriginX, scale9OriginY, scale9Width, scale9Height |
| 405 | + )); |
| 406 | + |
| 407 | + setContentSize(widget, json["Size"]); |
| 408 | + }else{ |
| 409 | + if (!widget.isIgnoreContentAdaptWithSize()){ |
| 410 | + setContentSize(widget, json["Size"]); |
| 411 | + } |
| 412 | + |
| 413 | + } |
395 | 414 |
|
396 | 415 | var bgStartColor = json["FirstColor"]; |
397 | 416 | var bgEndColor = json["EndColor"]; |
|
407 | 426 | if(colorVector != null) |
408 | 427 | widget.setBackGroundColorVector(cc.p(colorVector["ScaleX"], colorVector["ScaleY"])); |
409 | 428 |
|
410 | | - loadTexture(json["FileData"], resourcePath, function(path, type){ |
411 | | - widget.setBackGroundImage(path, type); |
412 | | - }); |
413 | | - |
414 | 429 | return widget; |
415 | 430 | }; |
416 | 431 |
|
|
481 | 496 | var path = fontResource["Path"]; |
482 | 497 | //resoutceType = fontResource["Type"]; |
483 | 498 | if(path != null){ |
484 | | - if (cc.sys.isNative && cc.sys.os == cc.sys.OS_ANDROID) { |
| 499 | + if (cc.sys.isNative) { |
485 | 500 | fontName = cc.path.join(cc.loader.resPath, resourcePath, path); |
486 | 501 | } else { |
487 | 502 | fontName = path.match(/([^\/]+)\.ttf/); |
|
542 | 557 | if(fontName != null) |
543 | 558 | widget.setTitleFontName(fontName); |
544 | 559 |
|
545 | | - var displaystate = getParam(json["DisplayState"], true); |
546 | | - widget.setBright(displaystate); |
547 | | - widget.setEnabled(displaystate); |
548 | | - |
549 | 560 | var textColor = json["TextColor"]; |
550 | 561 | if(textColor != null) |
551 | 562 | widget.setTitleColor(getColor(textColor)); |
|
560 | 571 | widget.loadTextureDisabled(path, type); |
561 | 572 | }); |
562 | 573 |
|
| 574 | + var displaystate = getParam(json["DisplayState"], true); |
| 575 | + widget.setBright(displaystate); |
| 576 | + widget.setEnabled(displaystate); |
| 577 | + |
| 578 | + var fontResource = json["FontResource"]; |
563 | 579 | if(fontResource != null){ |
564 | 580 | var path = fontResource["Path"]; |
565 | 581 | //resoutceType = fontResource["Type"]; |
566 | 582 | if(path != null){ |
567 | | - if (cc.sys.isNative && cc.sys.os == cc.sys.OS_ANDROID) { |
| 583 | + if (cc.sys.isNative) { |
568 | 584 | fontName = cc.path.join(cc.loader.resPath, resourcePath, path); |
569 | 585 | } else { |
570 | 586 | fontName = path.match(/([^\/]+)\.ttf/); |
571 | 587 | fontName = fontName ? fontName[1] : ""; |
572 | 588 | } |
573 | | - widget._labelRenderer.setFontName(fontName); |
| 589 | + widget.setTitleFontName(fontName); |
574 | 590 | } |
575 | 591 | } |
576 | 592 |
|
|
1045 | 1061 | var path = fontResource["Path"]; |
1046 | 1062 | //resoutceType = fontResource["Type"]; |
1047 | 1063 | if(path != null){ |
1048 | | - if (cc.sys.isNative && cc.sys.os == cc.sys.OS_ANDROID) { |
| 1064 | + if (cc.sys.isNative) { |
1049 | 1065 | fontName = cc.path.join(cc.loader.resPath, resourcePath, path); |
1050 | 1066 | } else { |
1051 | 1067 | fontName = path.match(/([^\/]+)\.ttf/); |
|
1064 | 1080 |
|
1065 | 1081 | if (!widget.isIgnoreContentAdaptWithSize()) |
1066 | 1082 | setContentSize(widget, json["Size"]); |
1067 | | - //widget.getVirtualRenderer().setLineBreakWithoutSpace(true); |
| 1083 | + |
| 1084 | + if (cc.sys.isNative) |
| 1085 | + widget.getVirtualRenderer().setLineBreakWithoutSpace(true); |
1068 | 1086 |
|
1069 | 1087 | return widget; |
1070 | 1088 |
|
|
0 commit comments