Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CCLabel Renamed CCSGLabel and cc.Label Renamed _ccsg.Label #58

Merged
merged 1 commit into from
Dec 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
CCLabel Renamed CCSGLabel and cc.Label Renamed _ccsg.Label
  • Loading branch information
knoxHuang committed Dec 16, 2015
commit a4c3ee5a98298ac7381b029fe84ad2ca850dcde3
2 changes: 1 addition & 1 deletion cocos2d/core/platform/CCConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ cc.DIRECTOR_FPS_INTERVAL = 0.5;

/**
* <p>
* If enabled, the ccsg.Node objects (cc.Sprite, cc.Label,etc) will be able to render in subpixels.<br/>
* If enabled, the ccsg.Node objects (cc.Sprite, _ccsg.Label,etc) will be able to render in subpixels.<br/>
* If disabled, integer pixels will be used.<br/>
* <br/>
* To enable set it to 1. Enabled by default.<br/>
Expand Down
2 changes: 1 addition & 1 deletion cocos2d/labels/CCLabelAtlas.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
****************************************************************************/

/**
* using image file to print text label on the screen, might be a bit slower than cc.Label, similar to cc.LabelBMFont
* using image file to print text label on the screen, might be a bit slower than _ccsg.Label, similar to cc.LabelBMFont
* @class
* @extends cc.AtlasNode
*
Expand Down
6 changes: 3 additions & 3 deletions cocos2d/labels/CCLabelBMFont.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ cc.LABEL_AUTOMATIC_WIDTH = -1;
* - All inner characters are using an anchorPoint of (0.5, 0.5) and it is not recommend to change it
* because it might affect the rendering</p>
*
* <p>cc.LabelBMFont implements the protocol cc.LabelProtocol, like cc.Label and cc.LabelAtlas.<br/>
* cc.LabelBMFont has the flexibility of cc.Label, the speed of cc.LabelAtlas and all the features of cc.Sprite.<br/>
* If in doubt, use cc.LabelBMFont instead of cc.LabelAtlas / cc.Label.</p>
* <p>cc.LabelBMFont implements the protocol cc.LabelProtocol, like _ccsg.Label and cc.LabelAtlas.<br/>
* cc.LabelBMFont has the flexibility of _ccsg.Label, the speed of cc.LabelAtlas and all the features of cc.Sprite.<br/>
* If in doubt, use cc.LabelBMFont instead of cc.LabelAtlas / _ccsg.Label.</p>
*
* <p>Supported editors:<br/>
* http://glyphdesigner.71squared.com/ (Commercial, Mac OS X)<br/>
Expand Down
60 changes: 30 additions & 30 deletions cocos2d/labels/CCLabel.js → cocos2d/labels/CCSGLabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ cc.LetterInfo = function() {
this._lineIndex = 0;
};

cc.Label = _ccsg.Node.extend({
_ccsg.Label = _ccsg.Node.extend({
_hAlign: cc.TextAlignment.LEFT, //0 left, 1 center, 2 right
_vAlign: cc.VerticalTextAlignment.TOP, //0 bottom,1 center, 2 top
_string: "",
Expand Down Expand Up @@ -233,7 +233,7 @@ cc.Label = _ccsg.Node.extend({
enableWrapText: function(enabled) {
if (this._isWrapText === enabled) return;
//when label is in resize mode, wrap is disabled.
if (this._overFlow === cc.Label.Overflow.RESIZE) {
if (this._overFlow === _ccsg.Label.Overflow.RESIZE) {
return;
}
this._isWrapText = enabled;
Expand All @@ -260,7 +260,7 @@ cc.Label = _ccsg.Node.extend({
setOverflow: function(overflow) {
if (this._overFlow === overflow) return;
this._overFlow = overflow;
if (this._overFlow === cc.Label.Overflow.RESIZE) {
if (this._overFlow === _ccsg.Label.Overflow.RESIZE) {
this._setDimensions(this._labelDimensions.width, 0);
this._isWrapText = true;
}
Expand Down Expand Up @@ -304,7 +304,7 @@ cc.Label = _ccsg.Node.extend({
//specify font family name directly
if (extName === null) {
this._fontHandle = fontHandle;
this._labelType = cc.Label.Type.TTF;
this._labelType = _ccsg.Label.Type.TTF;
this._notifyLabelSkinDirty();
this._isUseSystemFont = true;
return;
Expand All @@ -314,11 +314,11 @@ cc.Label = _ccsg.Node.extend({

this._isUseSystemFont = false;
if (extName === ".ttf") {
this._labelType = cc.Label.Type.TTF;
this._labelType = _ccsg.Label.Type.TTF;
this._fontHandle = this._loadTTFFont(fontHandle);
} else if (extName === ".fnt") {
//todo add bmfont here
this._labelType = cc.Label.Type.BMFont;
this._labelType = _ccsg.Label.Type.BMFont;
this._initBMFontWithString(this._string, fontHandle);
}
},
Expand Down Expand Up @@ -372,7 +372,7 @@ cc.Label = _ccsg.Node.extend({
setContentSize: function(size, height) {
var oldWidth = this._contentSize.width;
var oldHeight = this._contentSize.height;
if (this._labelType === cc.Label.Type.TTF) {
if (this._labelType === _ccsg.Label.Type.TTF) {
_ccsg.Node.prototype.setContentSize.call(this, size, height);
if (oldWidth === this._contentSize.width && oldHeight === this._contentSize.height) {
return;
Expand All @@ -387,7 +387,7 @@ cc.Label = _ccsg.Node.extend({
this._maxLineWidth = newWidth;

this._notifyLabelSkinDirty();
} else if (this._labelType === cc.Label.Type.BMFont) {
} else if (this._labelType === _ccsg.Label.Type.BMFont) {
if (!height) {
if (oldWidth === size.width && oldHeight === size.height) {
return;
Expand Down Expand Up @@ -420,11 +420,11 @@ cc.Label = _ccsg.Node.extend({

_notifyLabelSkinDirty: function() {
if (CC_EDITOR) {
if (this._labelType === cc.Label.Type.BMFont) {
if (this._labelType === _ccsg.Label.Type.BMFont) {
this._updateContent();
this.setColor(this.color);
this._labelSkinDirty = false;
} else if (this._labelType === cc.Label.Type.TTF) {
} else if (this._labelType === _ccsg.Label.Type.TTF) {
this._labelSkinDirty = true;
}
} else {
Expand All @@ -433,14 +433,14 @@ cc.Label = _ccsg.Node.extend({
},
_createRenderCmd: function() {
if (cc._renderType === cc.game.RENDER_TYPE_WEBGL)
return new cc.Label.WebGLRenderCmd(this);
return new _ccsg.Label.WebGLRenderCmd(this);
else
return new cc.Label.CanvasRenderCmd(this);
return new _ccsg.Label.CanvasRenderCmd(this);
},

getContentSize: function(foreceUpdate) {
if (foreceUpdate) {
if (this._labelType === cc.Label.Type.BMFont && this._labelSkinDirty) {
if (this._labelType === _ccsg.Label.Type.BMFont && this._labelSkinDirty) {
this._updateContent();
}
}
Expand All @@ -467,7 +467,7 @@ cc.BMFontHelper = {
this._computeAlignmentOffset();

//shrink
if (this._overFlow === cc.Label.Overflow.SHRINK) {
if (this._overFlow === _ccsg.Label.Overflow.SHRINK) {
var fontSize = this.getFontSize();

if (fontSize > 0 && this._isVerticalClamp()) {
Expand All @@ -477,7 +477,7 @@ cc.BMFontHelper = {

if (!this._updateQuads()) {
ret = false;
if (this._overFlow === cc.Label.Overflow.SHRINK) {
if (this._overFlow === _ccsg.Label.Overflow.SHRINK) {
this._shrinkLabelToContentSize(this._isHorizontalClamp.bind(this));
}
break;
Expand Down Expand Up @@ -535,9 +535,9 @@ cc.BMFontHelper = {

if (this._labelWidth > 0) {
if (this._isHorizontalClamped(px, lineIndex)) {
if (this._overFlow === cc.Label.Overflow.CLAMP) {
if (this._overFlow === _ccsg.Label.Overflow.CLAMP) {
this._reusedRect.width = 0;
} else if (this._overFlow === cc.Label.Overflow.SHRINK) {
} else if (this._overFlow === _ccsg.Label.Overflow.SHRINK) {
if (this._contentSize.width > letterDef._width) {
letterClamp = true;
ret = false;
Expand Down Expand Up @@ -582,7 +582,7 @@ cc.BMFontHelper = {
},

_updateLetterSpriteScale: function(sprite) {
if (this._labelType === cc.Label.Type.BMFont && this._fontSize > 0) {
if (this._labelType === _ccsg.Label.Type.BMFont && this._fontSize > 0) {
sprite.setScale(this._bmfontScale);
}
},
Expand Down Expand Up @@ -612,7 +612,7 @@ cc.BMFontHelper = {
},

_setDimensions: function(width, height) {
if (this._overFlow === cc.Label.Overflow.RESIZE) {
if (this._overFlow === _ccsg.Label.Overflow.RESIZE) {
height = 0;
}
if (height !== this._labelHeight || width !== this._labelWidth) {
Expand All @@ -622,7 +622,7 @@ cc.BMFontHelper = {
this._labelDimensions.height = height;

this._maxLineWidth = width;
if (this._overFlow === cc.Label.Overflow.SHRINK) {
if (this._overFlow === _ccsg.Label.Overflow.SHRINK) {
if (this._bmFontSize > 0) {
this._restoreFontSize();
}
Expand All @@ -632,7 +632,7 @@ cc.BMFontHelper = {
},

_restoreFontSize: function() {
if (this._labelType === cc.Label.Type.BMFont) {
if (this._labelType === _ccsg.Label.Type.BMFont) {
this._fontSize = this._bmFontSize;
}
},
Expand Down Expand Up @@ -861,7 +861,7 @@ cc.BMFontHelper = {
_scaleFontSizeDown: function(fontSize) {
var shouldUpdateContent = true;
//1 is BMFont
if (this._labelType === cc.Label.Type.BMFont) {
if (this._labelType === _ccsg.Label.Type.BMFont) {
if (!fontSize) {
fontSize = 0.1;
shouldUpdateContent = false;
Expand Down Expand Up @@ -959,7 +959,7 @@ cc.BMFontHelper = {
},

_updateBMFontScale: function() {
if (this._labelType === cc.Label.Type.BMFont) {
if (this._labelType === _ccsg.Label.Type.BMFont) {
var originalFontSize = this._fontAtlas._fontSize;
this._bmfontScale = this._fontSize * cc.contentScaleFactor() / originalFontSize;
} else {
Expand All @@ -971,7 +971,7 @@ cc.BMFontHelper = {
_initBMFontWithString: function(str, fntFile) {
var self = this;
if (self._config) {
cc.log("cc.Label._initBMFontWithString(): re-init is no longer supported");
cc.log("_ccsg.Label._initBMFontWithString(): re-init is no longer supported");
return false;
}
this._string = str;
Expand Down Expand Up @@ -1027,7 +1027,7 @@ cc.BMFontHelper = {

_rescaleWithOriginalFontSize: function() {
var renderingFontSize = this.getFontSize();
if (this._bmFontSize - renderingFontSize >= 1 && this._overFlow === cc.Label.Overflow.SHRINK) {
if (this._bmFontSize - renderingFontSize >= 1 && this._overFlow === _ccsg.Label.Overflow.SHRINK) {
this._scaleFontSizeDown(this._bmFontSize);
}
},
Expand All @@ -1053,14 +1053,14 @@ cc.BMFontHelper = {
if (filename) {
this._fontHandle = filename;
var self = this;
if (this._labelType === cc.Label.Type.BMFont) {
if (this._labelType === _ccsg.Label.Type.BMFont) {

this._resetBMFont();

var texture;
cc.loader.load(this._fontHandle, function(err, results) {
if (err) {
cc.log("cc.Label._initBMFontWithString(): Impossible to create font. Please check file");
cc.log("_ccsg.Label._initBMFontWithString(): Impossible to create font. Please check file");
}

self._config = results[0];
Expand Down Expand Up @@ -1088,15 +1088,15 @@ cc.BMFontHelper = {
};


var _p = cc.Label.prototype;
var _p = _ccsg.Label.prototype;
cc.js.addon(_p, EventTarget.prototype);
cc.js.mixin(_p, cc.BMFontHelper);

cc.Label.Type = cc.Enum({
_ccsg.Label.Type = cc.Enum({
TTF: 0,
BMFont: 1
});
cc.Label.Overflow = cc.Enum({
_ccsg.Label.Overflow = cc.Enum({
CLAMP: 0,
SHRINK: 1,
RESIZE: 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
http://www.angelcode.com/products/bmfont/ (Free, Windows only)
****************************************************************************/
(function() {
cc.Label.TTFLabelBaker = function() {
_ccsg.Label.TTFLabelBaker = function() {

};
var proto = cc.Label.TTFLabelBaker.prototype = Object.create(Object.prototype);
var proto = _ccsg.Label.TTFLabelBaker.prototype = Object.create(Object.prototype);
proto._getLineHeight = function() {
//todo refine it
var nodeSpacingY = this._node.getLineHeight();
Expand Down Expand Up @@ -139,7 +139,7 @@
paragraphLength.push(textMetric.width);
}

if (cc.Label.Overflow.CLAMP == node._overFlow) {
if (_ccsg.Label.Overflow.CLAMP == node._overFlow) {
if (node._isWrapText) {
this._splitedStrings = [];
for (var i = 0; i < paragraphedStrings.length; ++i) {
Expand All @@ -148,7 +148,7 @@
} else {
this._splitedStrings = paragraphedStrings;
}
} else if (cc.Label.Overflow.RESIZE == node._overFlow) {
} else if (_ccsg.Label.Overflow.RESIZE == node._overFlow) {
//todo fix it
if (node._isWrapText) {
this._splitedStrings = [];
Expand Down Expand Up @@ -251,7 +251,7 @@
proto._rebuildLabelSkin = function() {
var node = this._node;
if (node._labelSkinDirty) {
if(node._labelType === cc.Label.Type.TTF){
if(node._labelType === _ccsg.Label.Type.TTF){
this._bakeLabel();
this._prepareQuad();
}else {
Expand All @@ -263,7 +263,7 @@
})();

(function() {
cc.Label.CanvasRenderCmd = function(renderableObject) {
_ccsg.Label.CanvasRenderCmd = function(renderableObject) {
_ccsg.Node.CanvasRenderCmd.call(this, renderableObject);
this._needDraw = true;
this._labelTexture = new cc.Texture2D();
Expand All @@ -278,17 +278,17 @@
this._drawFontsize = 0;
};

var proto = cc.Label.CanvasRenderCmd.prototype = Object.create(_ccsg.Node.CanvasRenderCmd.prototype);
cc.js.mixin(proto, cc.Label.TTFLabelBaker.prototype);
var proto = _ccsg.Label.CanvasRenderCmd.prototype = Object.create(_ccsg.Node.CanvasRenderCmd.prototype);
cc.js.mixin(proto, _ccsg.Label.TTFLabelBaker.prototype);

proto.constructor = cc.Label.CanvasRenderCmd;
proto.constructor = _ccsg.Label.CanvasRenderCmd;

proto.rendering = function(ctx, scaleX, scaleY) {
this._rebuildLabelSkin();

var node = this._node;

if (node._labelType === cc.Label.Type.TTF) {
if (node._labelType === _ccsg.Label.Type.TTF) {
var locDisplayOpacity = this._displayedOpacity;
var alpha = locDisplayOpacity / 255;
//var locTexture = this._labelTexture;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
****************************************************************************/

(function(){
cc.Label.WebGLRenderCmd = function(renderableObject){
_ccsg.Label.WebGLRenderCmd = function(renderableObject){
_ccsg.Node.WebGLRenderCmd.call(this, renderableObject);
this._needDraw = true;

Expand All @@ -51,16 +51,16 @@
this._drawFontsize = 0;
};

var proto = cc.Label.WebGLRenderCmd.prototype = Object.create(_ccsg.Node.WebGLRenderCmd.prototype);
cc.js.mixin(proto, cc.Label.TTFLabelBaker.prototype);
var proto = _ccsg.Label.WebGLRenderCmd.prototype = Object.create(_ccsg.Node.WebGLRenderCmd.prototype);
cc.js.mixin(proto, _ccsg.Label.TTFLabelBaker.prototype);

proto.constructor = cc.Label.WebGLRenderCmd;
proto.constructor = _ccsg.Label.WebGLRenderCmd;

proto.rendering = function (ctx) {
var node = this._node;
this._rebuildLabelSkin();

if(node._labelType === cc.Label.Type.TTF){
if(node._labelType === _ccsg.Label.Type.TTF){
var gl = ctx || cc._renderContext ;

this._shaderProgram.use();
Expand Down
6 changes: 3 additions & 3 deletions gulp/tasks/build-cocos2d.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,15 @@ var srcs = [
"./cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js",
"./cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js",

"./cocos2d/labels/CCLabel.js",
"./cocos2d/labels/CCSGLabel.js",
"./cocos2d/labels/CCLabelAtlas.js",
"./cocos2d/labels/CCLabelAtlasCanvasRenderCmd.js",
"./cocos2d/labels/CCLabelAtlasWebGLRenderCmd.js",
"./cocos2d/labels/CCLabelBMFont.js",
"./cocos2d/labels/CCLabelBMFontCanvasRenderCmd.js",
"./cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js",
"./cocos2d/labels/CCLabelCanvasRenderCmd.js",
"./cocos2d/labels/CCLabelWebGLRenderCmd.js",
"./cocos2d/labels/CCSGLabelCanvasRenderCmd.js",
"./cocos2d/labels/CCSGLabelWebGLRenderCmd.js",
"./cocos2d/shape-nodes/CCDrawNode.js",
"./cocos2d/shape-nodes/CCDrawNodeCanvasRenderCmd.js",
"./cocos2d/shape-nodes/CCDrawNodeWebGLRenderCmd.js",
Expand Down
2 changes: 2 additions & 0 deletions jsb_polyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,4 +389,6 @@ window._ccsg = {
Node: cc.Node,
Scene: cc.Scene,
ParticleSystem: cc.ParticleSystem,
Label: cc.Label,

};
Loading