mirror of https://github.com/axmolengine/axmol.git
ccTextDefinition becomes CCTextDefinition
This commit is contained in:
parent
2430d79642
commit
ed981aee7e
|
@ -138,7 +138,7 @@ bool CCLabelTTF::initWithString(const char *string, const char *fontName, float
|
|||
return false;
|
||||
}
|
||||
|
||||
bool CCLabelTTF::initWithStringAndTextDefinition(const char *string, ccTextDefinition & textDefinition)
|
||||
bool CCLabelTTF::initWithStringAndTextDefinition(const char *string, CCTextDefinition * textDefinition)
|
||||
{
|
||||
if (CCSprite::init())
|
||||
{
|
||||
|
@ -146,7 +146,7 @@ bool CCLabelTTF::initWithStringAndTextDefinition(const char *string, ccTextDefin
|
|||
this->setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(SHADER_PROGRAM));
|
||||
|
||||
// prepare everythin needed to render the label
|
||||
_updateWithTextDefinition(textDefinition, false);
|
||||
_updateWithTextDefinition(*textDefinition, false);
|
||||
|
||||
// set the string
|
||||
this->setString(string);
|
||||
|
@ -161,7 +161,6 @@ bool CCLabelTTF::initWithStringAndTextDefinition(const char *string, ccTextDefin
|
|||
}
|
||||
|
||||
|
||||
|
||||
void CCLabelTTF::setString(const char *string)
|
||||
{
|
||||
CCAssert(string != NULL, "Invalid string");
|
||||
|
@ -292,8 +291,8 @@ bool CCLabelTTF::updateTexture()
|
|||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||
|
||||
ccTextDefinition texDef = _prepareTextDefinition();
|
||||
tex->initWithStringShadowStroke( m_string.c_str(), texDef );
|
||||
CCTextDefinition texDef = _prepareTextDefinition();
|
||||
tex->initWithStringShadowStroke( m_string.c_str(), &texDef );
|
||||
|
||||
#else
|
||||
|
||||
|
@ -448,7 +447,7 @@ void CCLabelTTF::setFontFillColor(const ccColor3B &tintColor, bool updateTexture
|
|||
#endif
|
||||
}
|
||||
|
||||
void CCLabelTTF::setTextDefinition(ccTextDefinition *theDefinition)
|
||||
void CCLabelTTF::setTextDefinition(CCTextDefinition *theDefinition)
|
||||
{
|
||||
if (theDefinition)
|
||||
{
|
||||
|
@ -456,14 +455,14 @@ void CCLabelTTF::setTextDefinition(ccTextDefinition *theDefinition)
|
|||
}
|
||||
}
|
||||
|
||||
ccTextDefinition *CCLabelTTF::getTextDefinition()
|
||||
CCTextDefinition *CCLabelTTF::getTextDefinition()
|
||||
{
|
||||
ccTextDefinition *tempDefinition = new ccTextDefinition;
|
||||
CCTextDefinition *tempDefinition = new CCTextDefinition;
|
||||
*tempDefinition = _prepareTextDefinition();
|
||||
return tempDefinition;
|
||||
}
|
||||
|
||||
void CCLabelTTF::_updateWithTextDefinition(ccTextDefinition & textDefinition, bool mustUpdateTexture)
|
||||
void CCLabelTTF::_updateWithTextDefinition(CCTextDefinition & textDefinition, bool mustUpdateTexture)
|
||||
{
|
||||
m_tDimensions = CCSizeMake(textDefinition.m_dimensions.width, textDefinition.m_dimensions.height);
|
||||
m_hAlignment = textDefinition.m_alignment;
|
||||
|
@ -495,9 +494,9 @@ void CCLabelTTF::_updateWithTextDefinition(ccTextDefinition & textDefinition, bo
|
|||
updateTexture();
|
||||
}
|
||||
|
||||
ccTextDefinition CCLabelTTF::_prepareTextDefinition()
|
||||
CCTextDefinition CCLabelTTF::_prepareTextDefinition()
|
||||
{
|
||||
ccTextDefinition texDef;
|
||||
CCTextDefinition texDef;
|
||||
|
||||
texDef.m_fontSize = m_fFontSize * CC_CONTENT_SCALE_FACTOR();
|
||||
texDef.m_fontName = *m_pFontName;
|
||||
|
|
|
@ -83,15 +83,15 @@ public:
|
|||
CCVerticalTextAlignment vAlignment);
|
||||
|
||||
/** initializes the CCLabelTTF with a font name, alignment, dimension and font size */
|
||||
bool initWithStringAndTextDefinition(const char *string, ccTextDefinition & textDefinition);
|
||||
bool initWithStringAndTextDefinition(const char *string, CCTextDefinition * textDefinition);
|
||||
|
||||
|
||||
|
||||
/** set the text definition used by this label */
|
||||
void setTextDefinition(ccTextDefinition *theDefinition);
|
||||
void setTextDefinition(CCTextDefinition *theDefinition);
|
||||
|
||||
/** get the text definition used by this label */
|
||||
ccTextDefinition * getTextDefinition();
|
||||
CCTextDefinition * getTextDefinition();
|
||||
|
||||
|
||||
|
||||
|
@ -146,8 +146,8 @@ private:
|
|||
protected:
|
||||
|
||||
/** set the text definition for this label */
|
||||
void _updateWithTextDefinition(ccTextDefinition & textDefinition, bool mustUpdateTexture = true);
|
||||
ccTextDefinition _prepareTextDefinition();
|
||||
void _updateWithTextDefinition(CCTextDefinition & textDefinition, bool mustUpdateTexture = true);
|
||||
CCTextDefinition _prepareTextDefinition();
|
||||
|
||||
/** Dimensions of the label in Points */
|
||||
CCSize m_tDimensions;
|
||||
|
|
|
@ -430,7 +430,7 @@ bool CCTexture2D::initWithString(const char *text, const char *fontName, float f
|
|||
{
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||
|
||||
ccTextDefinition tempDef;
|
||||
CCTextDefinition tempDef;
|
||||
|
||||
tempDef.m_shadow.m_shadowEnabled = false;
|
||||
tempDef.m_stroke.m_strokeEnabled = false;
|
||||
|
@ -446,7 +446,7 @@ bool CCTexture2D::initWithString(const char *text, const char *fontName, float f
|
|||
tempDef.m_fontTint.m_tintColor.g = 255;
|
||||
tempDef.m_fontTint.m_tintColor.b = 255;
|
||||
|
||||
return initWithStringShadowStroke(text, tempDef);
|
||||
return initWithStringShadowStroke(text, &tempDef);
|
||||
|
||||
|
||||
#else
|
||||
|
@ -499,7 +499,7 @@ bool CCTexture2D::initWithString(const char *text, const char *fontName, float f
|
|||
|
||||
}
|
||||
|
||||
bool CCTexture2D::initWithStringShadowStroke(const char *text, ccTextDefinition &textDefinition)
|
||||
bool CCTexture2D::initWithStringShadowStroke(const char *text, CCTextDefinition *textDefinition)
|
||||
{
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||
|
||||
|
@ -511,20 +511,20 @@ bool CCTexture2D::initWithStringShadowStroke(const char *text, ccTextDefinition
|
|||
bool bRet = false;
|
||||
CCImage::ETextAlign eAlign;
|
||||
|
||||
if (kCCVerticalTextAlignmentTop == textDefinition.m_vertAlignment)
|
||||
if (kCCVerticalTextAlignmentTop == textDefinition->m_vertAlignment)
|
||||
{
|
||||
eAlign = (kCCTextAlignmentCenter == textDefinition.m_alignment) ? CCImage::kAlignTop
|
||||
: (kCCTextAlignmentLeft == textDefinition.m_alignment) ? CCImage::kAlignTopLeft : CCImage::kAlignTopRight;
|
||||
eAlign = (kCCTextAlignmentCenter == textDefinition->m_alignment) ? CCImage::kAlignTop
|
||||
: (kCCTextAlignmentLeft == textDefinition->m_alignment) ? CCImage::kAlignTopLeft : CCImage::kAlignTopRight;
|
||||
}
|
||||
else if (kCCVerticalTextAlignmentCenter == textDefinition.m_vertAlignment)
|
||||
else if (kCCVerticalTextAlignmentCenter == textDefinition->m_vertAlignment)
|
||||
{
|
||||
eAlign = (kCCTextAlignmentCenter == textDefinition.m_alignment) ? CCImage::kAlignCenter
|
||||
: (kCCTextAlignmentLeft == textDefinition.m_alignment) ? CCImage::kAlignLeft : CCImage::kAlignRight;
|
||||
eAlign = (kCCTextAlignmentCenter == textDefinition->m_alignment) ? CCImage::kAlignCenter
|
||||
: (kCCTextAlignmentLeft == textDefinition->m_alignment) ? CCImage::kAlignLeft : CCImage::kAlignRight;
|
||||
}
|
||||
else if (kCCVerticalTextAlignmentBottom == textDefinition.m_vertAlignment)
|
||||
else if (kCCVerticalTextAlignmentBottom == textDefinition->m_vertAlignment)
|
||||
{
|
||||
eAlign = (kCCTextAlignmentCenter == textDefinition.m_alignment) ? CCImage::kAlignBottom
|
||||
: (kCCTextAlignmentLeft == textDefinition.m_alignment) ? CCImage::kAlignBottomLeft : CCImage::kAlignBottomRight;
|
||||
eAlign = (kCCTextAlignmentCenter == textDefinition->m_alignment) ? CCImage::kAlignBottom
|
||||
: (kCCTextAlignmentLeft == textDefinition->m_alignment) ? CCImage::kAlignBottomLeft : CCImage::kAlignBottomRight;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -539,13 +539,13 @@ bool CCTexture2D::initWithStringShadowStroke(const char *text, ccTextDefinition
|
|||
float shadowBlur = 0.0;
|
||||
float shadowOpacity = 0.0;
|
||||
|
||||
if ( textDefinition.m_shadow.m_shadowEnabled )
|
||||
if ( textDefinition->m_shadow.m_shadowEnabled )
|
||||
{
|
||||
shadowEnabled = true;
|
||||
shadowDX = textDefinition.m_shadow.m_shadowOffset.width;
|
||||
shadowDY = textDefinition.m_shadow.m_shadowOffset.height;
|
||||
shadowBlur = textDefinition.m_shadow.m_shadowBlur;
|
||||
shadowOpacity = textDefinition.m_shadow.m_shadowOpacity;
|
||||
shadowDX = textDefinition->m_shadow.m_shadowOffset.width;
|
||||
shadowDY = textDefinition->m_shadow.m_shadowOffset.height;
|
||||
shadowBlur = textDefinition->m_shadow.m_shadowBlur;
|
||||
shadowOpacity = textDefinition->m_shadow.m_shadowOpacity;
|
||||
}
|
||||
|
||||
// handle stroke parameters
|
||||
|
@ -555,13 +555,13 @@ bool CCTexture2D::initWithStringShadowStroke(const char *text, ccTextDefinition
|
|||
float strokeColorB = 0.0;
|
||||
float strokeSize = 0.0;
|
||||
|
||||
if ( textDefinition.m_stroke.m_strokeEnabled )
|
||||
if ( textDefinition->m_stroke.m_strokeEnabled )
|
||||
{
|
||||
strokeEnabled = true;
|
||||
strokeColorR = textDefinition.m_stroke.m_strokeColor.r / 255;
|
||||
strokeColorG = textDefinition.m_stroke.m_strokeColor.g / 255;
|
||||
strokeColorB = textDefinition.m_stroke.m_strokeColor.b / 255;
|
||||
strokeSize = textDefinition.m_stroke.m_strokeSize;
|
||||
strokeColorR = textDefinition->m_stroke.m_strokeColor.r / 255;
|
||||
strokeColorG = textDefinition->m_stroke.m_strokeColor.g / 255;
|
||||
strokeColorB = textDefinition->m_stroke.m_strokeColor.b / 255;
|
||||
strokeSize = textDefinition->m_stroke.m_strokeSize;
|
||||
}
|
||||
|
||||
CCImage* pImage = new CCImage();
|
||||
|
@ -570,14 +570,14 @@ bool CCTexture2D::initWithStringShadowStroke(const char *text, ccTextDefinition
|
|||
CC_BREAK_IF(NULL == pImage);
|
||||
|
||||
bRet = pImage->initWithStringShadowStroke(text,
|
||||
(int)textDefinition.m_dimensions.width,
|
||||
(int)textDefinition.m_dimensions.height,
|
||||
(int)textDefinition->m_dimensions.width,
|
||||
(int)textDefinition->m_dimensions.height,
|
||||
eAlign,
|
||||
textDefinition.m_fontName.c_str(),
|
||||
textDefinition.m_fontSize,
|
||||
textDefinition.m_fontTint.m_tintColor.r / 255,
|
||||
textDefinition.m_fontTint.m_tintColor.g / 255,
|
||||
textDefinition.m_fontTint.m_tintColor.b / 255,
|
||||
textDefinition->m_fontName.c_str(),
|
||||
textDefinition->m_fontSize,
|
||||
textDefinition->m_fontTint.m_tintColor.r / 255,
|
||||
textDefinition->m_fontTint.m_tintColor.g / 255,
|
||||
textDefinition->m_fontTint.m_tintColor.b / 255,
|
||||
shadowEnabled,
|
||||
shadowDX,
|
||||
shadowDY,
|
||||
|
|
|
@ -142,11 +142,11 @@ public:
|
|||
} ccTextTint;
|
||||
|
||||
// text attributes
|
||||
typedef class _ccTextDefinition : public CCObject
|
||||
class CCTextDefinition : public CCObject
|
||||
{
|
||||
public:
|
||||
|
||||
_ccTextDefinition(): m_alignment(kCCTextAlignmentCenter),
|
||||
CCTextDefinition(): m_alignment(kCCTextAlignmentCenter),
|
||||
m_vertAlignment(kCCVerticalTextAlignmentTop)
|
||||
{ m_dimensions = CCSizeMake(0,0); }
|
||||
|
||||
|
@ -159,7 +159,7 @@ public:
|
|||
ccTextShadow m_shadow;
|
||||
ccTextStroke m_stroke;
|
||||
|
||||
} ccTextDefinition;
|
||||
} ;
|
||||
|
||||
|
||||
//CLASS INTERFACES:
|
||||
|
@ -210,7 +210,7 @@ public:
|
|||
/** Initializes a texture from a string with font name and font size */
|
||||
bool initWithString(const char *text, const char *fontName, float fontSize);
|
||||
/** Initializes a texture from a string with dimensions, alignment, font name and font size shadow and stroke*/
|
||||
bool initWithStringShadowStroke(const char *text, ccTextDefinition &textDefinition);
|
||||
bool initWithStringShadowStroke(const char *text, CCTextDefinition *textDefinition);
|
||||
|
||||
/** Initializes a texture from a PVR file */
|
||||
bool initWithPVRFile(const char* file);
|
||||
|
|
Loading…
Reference in New Issue