mirror of https://github.com/axmolengine/axmol.git
Merge pull request #5703 from Dhilan007/develop_label
label:fixed crash and incorrect getter.
This commit is contained in:
commit
ca27bc4d6f
|
@ -273,6 +273,8 @@ Label::Label(FontAtlas *atlas, TextHAlignment alignment, bool useDistanceField,b
|
|||
, _textSprite(nullptr)
|
||||
, _contentDirty(false)
|
||||
, _currentLabelType(LabelType::STRING_TEXTURE)
|
||||
, _currLabelEffect(LabelEffect::NORMAL)
|
||||
, _shadowBlurRadius(0)
|
||||
{
|
||||
_cascadeColorEnabled = true;
|
||||
_batchNodes.push_back(this);
|
||||
|
@ -938,7 +940,7 @@ void Label::updateContent()
|
|||
|
||||
void Label::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated)
|
||||
{
|
||||
if (! _visible)
|
||||
if (! _visible || _originalUTF8String.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -999,6 +1001,17 @@ void Label::setFontName(const std::string& fontName)
|
|||
}
|
||||
}
|
||||
|
||||
const std::string& Label::getFontName() const
|
||||
{
|
||||
switch (_currentLabelType)
|
||||
{
|
||||
case LabelType::TTF:
|
||||
return _fontConfig.fontFilePath;
|
||||
default:
|
||||
return _fontDefinition._fontName;
|
||||
}
|
||||
}
|
||||
|
||||
void Label::setFontSize(int fontSize)
|
||||
{
|
||||
if (_currentLabelType == LabelType::TTF)
|
||||
|
@ -1027,6 +1040,19 @@ void Label::setFontSize(int fontSize)
|
|||
}
|
||||
}
|
||||
|
||||
int Label::getFontSize() const
|
||||
{
|
||||
switch (_currentLabelType)
|
||||
{
|
||||
case LabelType::TTF:
|
||||
return _fontConfig.fontSize;
|
||||
case LabelType::STRING_TEXTURE:
|
||||
return _fontDefinition._fontSize;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
///// PROTOCOL STUFF
|
||||
Sprite * Label::getLetter(int lettetIndex)
|
||||
{
|
||||
|
|
|
@ -197,10 +197,10 @@ public:
|
|||
virtual void updateContent();
|
||||
|
||||
virtual void setFontName(const std::string& fontName);
|
||||
virtual const std::string& getFontName() const { return _fontDefinition._fontName;}
|
||||
virtual const std::string& getFontName() const;
|
||||
|
||||
virtual void setFontSize(int fontSize);
|
||||
virtual int getFontSize() const { return _fontDefinition._fontSize;}
|
||||
virtual int getFontSize() const;
|
||||
|
||||
virtual bool isOpacityModifyRGB() const override;
|
||||
virtual void setOpacityModifyRGB(bool isOpacityModifyRGB) override;
|
||||
|
|
Loading…
Reference in New Issue