本文整理汇总了C++中AnsiString::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ AnsiString::empty方法的具体用法?C++ AnsiString::empty怎么用?C++ AnsiString::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnsiString
的用法示例。
在下文中一共展示了AnsiString::empty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: textHeightDraw
int BaseFontBitmap::textHeightDraw(const byte *text, int x, int y, int width, TTextAlign align, bool draw, int maxHeight, int maxLength) {
if (maxLength == 0) {
return 0;
}
if (text == nullptr || text[0] == '\0') {
return _tileHeight;
}
AnsiString str;
if (_gameRef->_textEncoding == TEXT_UTF8) {
WideString wstr = StringUtil::utf8ToWide(Utf8String((const char *)text));
str = StringUtil::wideToAnsi(wstr);
} else {
str = AnsiString((const char *)text);
}
if (str.empty()) {
return 0;
}
int lineLength = 0;
int realLength = 0;
int numLines = 0;
int i;
int index = -1;
int start = 0;
int end = 0;
int last_end = 0;
bool done = false;
bool newLine = false;
bool longLine = false;
if (draw) {
_gameRef->_renderer->startSpriteBatch();
}
while (!done) {
if (maxHeight > 0 && (numLines + 1)*_tileHeight > maxHeight) {
if (draw) {
_gameRef->_renderer->endSpriteBatch();
}
return numLines * _tileHeight;
}
index++;
if (str[index] == ' ' && (maxHeight < 0 || maxHeight / _tileHeight > 1)) {
end = index - 1;
realLength = lineLength;
}
if (str[index] == '\n') {
end = index - 1;
realLength = lineLength;
newLine = true;
}
if (lineLength + getCharWidth(str[index]) > width && last_end == end) {
end = index - 1;
realLength = lineLength;
newLine = true;
longLine = true;
}
if ((int)str.size() == (index + 1) || (maxLength >= 0 && index == maxLength - 1)) {
done = true;
if (!newLine) {
end = index;
lineLength += getCharWidth(str[index]);
realLength = lineLength;
}
} else {
lineLength += getCharWidth(str[index]);
}
if ((lineLength > width) || done || newLine) {
if (end < 0) {
done = true;
}
int startX;
switch (align) {
case TAL_CENTER:
startX = x + (width - realLength) / 2;
break;
case TAL_RIGHT:
startX = x + width - realLength;
break;
case TAL_LEFT:
startX = x;
break;
default:
error("BaseFontBitmap::TextHeightDraw - Unhandled enum");
break;
}
for (i = start; i < end + 1; i++) {
if (draw) {
//.........这里部分代码省略.........