mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 15:52:40 +08:00
Merge pull request #612 from knoxHuang/master
Label.file change to .font
This commit is contained in:
@@ -229,29 +229,35 @@ var Label = cc.Class({
|
||||
tooltip: 'i18n:COMPONENT.label.wrap',
|
||||
},
|
||||
|
||||
// 这个保存了旧项目的 file 数据
|
||||
_N$file: null,
|
||||
|
||||
/**
|
||||
* !#en The font URL of label.
|
||||
* !#zh 文本字体的 url。
|
||||
* @property {cc.Font} file
|
||||
* !#en The font of label.
|
||||
* !#zh 文本字体。
|
||||
* @property {cc.Font} font
|
||||
*/
|
||||
file: {
|
||||
default: null,
|
||||
type: cc.Font,
|
||||
tooltip: 'i18n:COMPONENT.label.file',
|
||||
notify: function () {
|
||||
font: {
|
||||
get: function () {
|
||||
return this._N$file;
|
||||
},
|
||||
set: function (value) {
|
||||
this._N$file = value;
|
||||
if (this._sgNode) {
|
||||
|
||||
if ( typeof this.file === 'string' ) {
|
||||
if ( typeof value === 'string' ) {
|
||||
cc.warn('Sorry, the cc.Font has been modified from Raw Asset to Asset.' +
|
||||
'Please load the font asset before using.');
|
||||
}
|
||||
|
||||
var isAsset = this.file instanceof cc.Font;
|
||||
var fntRawUrl = isAsset ? this.file.rawUrl : '';
|
||||
var textureUrl = isAsset ? this.file.texture : '';
|
||||
var isAsset = value instanceof cc.Font;
|
||||
var fntRawUrl = isAsset ? value.rawUrl : '';
|
||||
var textureUrl = isAsset ? value.texture : '';
|
||||
this._sgNode.setFontFileOrFamily(fntRawUrl, textureUrl);
|
||||
}
|
||||
},
|
||||
type: cc.Font,
|
||||
tooltip: 'i18n:COMPONENT.label.font',
|
||||
animatable: false
|
||||
},
|
||||
|
||||
@@ -272,7 +278,7 @@ var Label = cc.Class({
|
||||
set: function(value){
|
||||
this._isSystemFontUsed = value;
|
||||
if (value) {
|
||||
this.file = null;
|
||||
this.font = null;
|
||||
if (this._sgNode) {
|
||||
this._sgNode.setSystemFontUsed(value);
|
||||
}
|
||||
@@ -334,14 +340,14 @@ var Label = cc.Class({
|
||||
|
||||
_initSgNode: function () {
|
||||
|
||||
if ( typeof this.file === 'string' ) {
|
||||
if ( typeof this.font === 'string' ) {
|
||||
cc.warn('Sorry, the cc.Font has been modified from Raw Asset to Asset.' +
|
||||
'Please load the font asset before using.');
|
||||
}
|
||||
|
||||
var isAsset = this.file instanceof cc.Font;
|
||||
var fntRawUrl = isAsset ? this.file.rawUrl : '';
|
||||
var textureUrl = isAsset ? this.file.texture : '';
|
||||
var isAsset = this.font instanceof cc.Font;
|
||||
var fntRawUrl = isAsset ? this.font.rawUrl : '';
|
||||
var textureUrl = isAsset ? this.font.texture : '';
|
||||
|
||||
this._sgNode = new _ccsg.Label(this.string, fntRawUrl, textureUrl);
|
||||
this._sgNode.retain();
|
||||
|
||||
@@ -499,19 +499,25 @@ js.set = function (obj, prop, setter, enumerable) {
|
||||
*/
|
||||
js.obsolete = function (obj, obsoleted, newPropName, writable) {
|
||||
var oldName = obsoleted.split('.').slice(-1);
|
||||
js.get(obj, oldName, function () {
|
||||
function get () {
|
||||
if (CC_DEV) {
|
||||
cc.warn('"%s" is deprecated, use "%s" instead please.', obsoleted, newPropName);
|
||||
}
|
||||
return obj[newPropName];
|
||||
});
|
||||
return this[newPropName];
|
||||
}
|
||||
if (writable) {
|
||||
js.set(obj, oldName, function (value) {
|
||||
if (CC_DEV) {
|
||||
cc.warn('"%s" is deprecated, use "%s" instead please.', obsoleted, newPropName);
|
||||
js.getset(obj, oldName,
|
||||
get,
|
||||
function (value) {
|
||||
if (CC_DEV) {
|
||||
cc.warn('"%s" is deprecated, use "%s" instead please.', obsoleted, newPropName);
|
||||
}
|
||||
this[newPropName] = value;
|
||||
}
|
||||
obj[newPropName] = value;
|
||||
});
|
||||
);
|
||||
}
|
||||
else {
|
||||
js.get(obj, oldName, get);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
var js = cc.js;
|
||||
|
||||
// Label
|
||||
js.obsolete(cc.Label.prototype, 'cc.Label.file', 'font', true);
|
||||
|
||||
if (CC_DEV) {
|
||||
var js = cc.js;
|
||||
|
||||
var INFO = cc._LogInfos.deprecated;
|
||||
|
||||
@@ -546,9 +550,9 @@ if (CC_DEV) {
|
||||
});
|
||||
|
||||
//ui
|
||||
cc.js.obsolete(cc.Layout.prototype, 'Layout.layoutType', 'type');
|
||||
cc.js.obsolete(cc.Layout.prototype, 'Layout.ResizeType', 'ResizeMode');
|
||||
cc.js.obsolete(cc.Layout.prototype, 'Layout.resize', 'resizeMode');
|
||||
js.obsolete(cc.Layout.prototype, 'cc.Layout.layoutType', 'type');
|
||||
js.obsolete(cc.Layout.prototype, 'cc.Layout.ResizeType', 'ResizeMode');
|
||||
js.obsolete(cc.Layout.prototype, 'cc.Layout.resize', 'resizeMode');
|
||||
|
||||
markAsRemoved(cc.Scale9Sprite, [
|
||||
'init',
|
||||
@@ -583,4 +587,3 @@ if (CC_DEV) {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user