2020-08-04 12:31:33 +08:00
|
|
|
|
#ifndef __FUILABEL_H__
|
|
|
|
|
#define __FUILABEL_H__
|
|
|
|
|
|
|
|
|
|
#include "cocos2d.h"
|
|
|
|
|
#include "FairyGUIMacros.h"
|
|
|
|
|
#include "TextFormat.h"
|
|
|
|
|
|
|
|
|
|
NS_FGUI_BEGIN
|
|
|
|
|
|
2022-08-08 18:02:17 +08:00
|
|
|
|
class FUILabel : public ax::Label
|
2020-08-04 12:31:33 +08:00
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
FUILabel();
|
|
|
|
|
virtual ~FUILabel();
|
|
|
|
|
|
|
|
|
|
CREATE_FUNC(FUILabel);
|
|
|
|
|
|
2021-12-01 03:35:34 +08:00
|
|
|
|
std::string_view getText() const { return getString(); }
|
|
|
|
|
void setText(std::string_view value);
|
2020-08-04 12:31:33 +08:00
|
|
|
|
|
|
|
|
|
TextFormat* getTextFormat() const { return _textFormat; }
|
|
|
|
|
void applyTextFormat();
|
|
|
|
|
|
2022-08-08 18:02:17 +08:00
|
|
|
|
void setUnderlineColor(const ax::Color3B& value);
|
2020-09-08 19:15:28 +08:00
|
|
|
|
|
2022-12-11 15:58:55 +08:00
|
|
|
|
#if defined(AX_VERSION)
|
|
|
|
|
bool setBMFontFilePath(std::string_view bmfontFilePath,
|
|
|
|
|
const ax::Rect& imageRect = ax::Rect::ZERO,
|
|
|
|
|
bool imageRotated = false,
|
|
|
|
|
float fontSize = 0) override;
|
|
|
|
|
#else
|
|
|
|
|
bool setBMFontFilePath(std::string_view bmfontFilePath,
|
|
|
|
|
const ax::Vec2& imageOffset = ax::Vec2::ZERO,
|
|
|
|
|
float fontSize = 0) override;
|
|
|
|
|
#endif
|
2020-08-04 12:31:33 +08:00
|
|
|
|
void setGrayed(bool value);
|
2022-12-11 15:58:55 +08:00
|
|
|
|
|
2020-08-04 12:31:33 +08:00
|
|
|
|
protected:
|
|
|
|
|
/*
|
2022-12-11 15:58:55 +08:00
|
|
|
|
注意!!!如果这里出现了编译错误,需要修改cocos2d的源码,文件2d/CCLabel.h,大约在672行,为updateBMFontScale函数打上virtual修饰符。
|
|
|
|
|
因为这个方法里有强制字体对象指针为FontFnt类型的代码,但我们不使用FontFnt(FontFnt只支持从外部文件中载入配置,更糟糕的是BMFontConfiguration是定义在cpp里的。)
|
|
|
|
|
所以需要重写这个方法。
|
2020-08-04 12:31:33 +08:00
|
|
|
|
*/
|
|
|
|
|
virtual void updateBMFontScale() override;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
TextFormat* _textFormat;
|
|
|
|
|
std::string _fontName;
|
|
|
|
|
int _fontSize;
|
|
|
|
|
bool _bmFontCanTint;
|
|
|
|
|
bool _grayed;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
NS_FGUI_END
|
|
|
|
|
|
|
|
|
|
#endif
|