axmol/extensions/fairygui/display/FUILabel.h

46 lines
1.2 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef __FUILABEL_H__
#define __FUILABEL_H__
#include "cocos2d.h"
#include "FairyGUIMacros.h"
#include "TextFormat.h"
NS_FGUI_BEGIN
class FUILabel : public cocos2d::Label
{
public:
FUILabel();
virtual ~FUILabel();
CREATE_FUNC(FUILabel);
const std::string& getText() const { return getString(); }
void setText(const std::string& value);
TextFormat* getTextFormat() const { return _textFormat; }
void applyTextFormat();
virtual bool setBMFontFilePath(const std::string& bmfontFilePath, const cocos2d::Vec2& imageOffset = cocos2d::Vec2::ZERO, float fontSize = 0) override;
void setGrayed(bool value);
protected:
/*
注意如果这里出现了编译错误需要修改cocos2d的源码文件2d/CCLabel.h大约在672行为updateBMFontScale函数打上virtual修饰符。
因为这个方法里有强制字体对象指针为FontFnt类型的代码但我们不使用FontFntFontFnt只支持从外部文件中载入配置更糟糕的是BMFontConfiguration是定义在cpp里的。
所以需要重写这个方法。
*/
virtual void updateBMFontScale() override;
private:
TextFormat* _textFormat;
std::string _fontName;
int _fontSize;
bool _bmFontCanTint;
bool _grayed;
};
NS_FGUI_END
#endif