Merge pull request #612 from knoxHuang/master

Label.file change to .font
This commit is contained in:
Jare Guo
2016-04-20 18:09:57 +08:00
4 changed files with 46 additions and 31 deletions
+23 -17
View File
@@ -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();
+14 -8
View File
@@ -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);
}
};
+8 -5
View File
@@ -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) {
});
}
}
+1 -1
View File
@@ -72,7 +72,7 @@ if (CC_EDITOR) {
if (isMainProcess) {
Editor.versions['cocos2d'] = require('./package.json').version;
}
else if (CC_DEV) {
else {
require('./cocos2d/deprecated');
}