本文整理汇总了C++中common::Array::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ Array::empty方法的具体用法?C++ Array::empty怎么用?C++ Array::empty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::Array
的用法示例。
在下文中一共展示了Array::empty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createTexture
void VisualText::createTexture() {
Common::CodePage codePage = StarkSettings->getTextCodePage();
Common::U32String unicodeText = Common::convertToU32String(_text.c_str(), codePage);
// Get the font and required metrics
const Graphics::Font *font = StarkFontProvider->getScaledFont(_fontType, _fontCustomIndex);
uint scaledLineHeight = StarkFontProvider->getScaledFontHeight(_fontType, _fontCustomIndex);
uint originalLineHeight = StarkFontProvider->getOriginalFontHeight(_fontType, _fontCustomIndex);
uint maxScaledLineWidth = StarkGfx->scaleWidthOriginalToCurrent(_targetWidth);
// Word wrap the text
Common::Array<Common::U32String> lines;
font->wordWrapText(unicodeText, maxScaledLineWidth, lines);
// Use the actual font bounding box to prevent text from being cut off
Common::Rect scaledRect;
if (!lines.empty()) {
scaledRect = font->getBoundingBox(lines[0]);
for (uint i = 1; i < lines.size(); i++) {
scaledRect.extend(font->getBoundingBox(lines[i], 0, scaledLineHeight * i));
}
}
// Make sure lines have approximately consistent height regardless of the characters they use
scaledRect.bottom = MAX<int16>(scaledRect.bottom, scaledLineHeight * lines.size());
if (!isBlank()) {
_originalRect.right = StarkGfx->scaleWidthCurrentToOriginal(scaledRect.right);
_originalRect.bottom = originalLineHeight * lines.size();
} else {
// For Empty text, preserve the original width and height for being used as clicking area
_originalRect.right = _targetWidth;
_originalRect.bottom = _targetHeight;
}
// Create a surface to render to
Graphics::Surface surface;
surface.create(scaledRect.right, scaledRect.bottom, Gfx::Driver::getRGBAPixelFormat());
uint32 color = surface.format.ARGBToColor(
_color.a, _color.r, _color.g, _color.b
);
uint32 bgColor = surface.format.ARGBToColor(
_backgroundColor.a, _backgroundColor.r, _backgroundColor.g, _backgroundColor.b
);
surface.fillRect(Common::Rect(surface.w, surface.h), bgColor);
// Render the lines to the surface
for (uint i = 0; i < lines.size(); i++) {
font->drawString(&surface, lines[i], 0, scaledLineHeight * i, surface.w, color, _align);
}
// Create a texture from the surface
_texture = _gfx->createTexture(&surface);
_texture->setSamplingFilter(Gfx::Texture::kNearest);
surface.free();
}
示例2: assureCached
void DefaultSaveFileManager::assureCached(const Common::String &savePathName) {
// Check that path exists and is usable.
checkPath(Common::FSNode(savePathName));
#ifdef USE_LIBCURL
Common::Array<Common::String> files = CloudMan.getSyncingFiles(); //returns empty array if not syncing
if (!files.empty()) updateSavefilesList(files); //makes this cache invalid
else _lockedFiles = files;
#endif
if (_cachedDirectory == savePathName) {
return;
}
_saveFileCache.clear();
_cachedDirectory.clear();
if (getError().getCode() != Common::kNoError) {
warning("DefaultSaveFileManager::assureCached: Can not cache path '%s': '%s'", savePathName.c_str(), getErrorDesc().c_str());
return;
}
// FSNode can cache its members, thus create it after checkPath to reflect
// actual file system state.
const Common::FSNode savePath(savePathName);
Common::FSList children;
if (!savePath.getChildren(children, Common::FSNode::kListFilesOnly)) {
return;
}
// Build the savefile name cache.
for (Common::FSList::const_iterator file = children.begin(), end = children.end(); file != end; ++file) {
if (_saveFileCache.contains(file->getName())) {
warning("DefaultSaveFileManager::assureCached: Name clash when building cache, ignoring file '%s'", file->getName().c_str());
} else {
_saveFileCache[file->getName()] = *file;
}
}
// Only now store that we cached 'savePathName' to indicate we successfully
// cached the directory.
_cachedDirectory = savePathName;
}
示例3: MKTAG
//.........这里部分代码省略.........
break;
case MKTAG('M','r','k','s'):
debugN(5, "CDToons: Mrks\n");
if (!(flags & 0x2))
error("CDToons: useless Mrks?");
// TODO
warning("CDToons: encountered Mrks, not implemented yet");
break;
case MKTAG('S','c','a','l'):
// TODO
warning("CDToons: encountered Scal, not implemented yet");
break;
case MKTAG('W','r','M','p'):
warning("CDToons: encountered WrMp, ignoring");
break;
case MKTAG('F','r','t','R'):
{
debugN(5, "CDToons: FrtR\n");
if (!(flags & 0x40))
error("CDToons: useless FrtR?");
uint16 count = stream->readUint16BE();
debugN(9, "CDToons FrtR: %d dirty rectangles\n", count);
for (uint i = 0; i < count; i++) {
Common::Rect dirtyRectFrtR = readRect(stream);
debugN(9, "CDToons FrtR dirtyRect: (%d, %d) to (%d, %d)\n",
dirtyRectFrtR.left, dirtyRectFrtR.top, dirtyRectFrtR.right, dirtyRectFrtR.bottom);
}
}
break;
case MKTAG('B','c','k','R'):
{
debugN(5, "CDToons: BckR\n");
if (!(flags & 0x20))
error("CDToons: useless BckR?");
uint16 count = stream->readUint16BE();
debugN(9, "CDToons BckR: %d subentries\n", count);
for (uint i = 0; i < count; i++) {
Common::Rect dirtyRectBckR = readRect(stream);
debugN(9, "CDToons BckR dirtyRect: (%d, %d) to (%d, %d)\n",
dirtyRectBckR.left, dirtyRectBckR.top, dirtyRectBckR.right, dirtyRectBckR.bottom);
}
}
break;
default:
warning("Unknown CDToons tag '%s'", tag2str(tag));
}
if (stream->pos() > nextPos)
error("CDToons ran off the end of a block while reading it (at %d, next block at %d)",
stream->pos(), nextPos);
if (stream->pos() != nextPos) {
warning("CDToons had %d unknown bytes after block", nextPos - stream->pos());
stream->seek(nextPos);
}
if (stream->pos() == stream->size())
break;
}
for (uint i = 0; i < diffs.size(); i++) {
renderBlock(diffs[i].data, diffs[i].size, diffs[i].rect.left, diffs[i].rect.top, diffs[i].rect.width(), diffs[i].rect.height());
delete[] diffs[i].data;
}
if (!diffs.empty())
return _surface;
for (uint i = 0; i < actions.size(); i++) {
CDToonsAction &action = actions[i];
if (i == 0 && action.blockId == 0)
memset(_surface->pixels, backgroundColor, _surface->w * _surface->h);
if (!_blocks.contains(action.blockId))
continue;
if (!action.rect.right)
continue;
if (i == 0 && !diffs.empty())
continue;
CDToonsBlock &block = _blocks[action.blockId];
uint16 width = READ_BE_UINT16(block.data + 2);
uint16 height = READ_BE_UINT16(block.data);
renderBlock(block.data + 14, block.size - 14, action.rect.left, action.rect.top, width, height);
}
if (paletteId && _currentPaletteId != paletteId) {
if (!_blocks.contains(paletteId))
error("CDToons: no block for palette %04x", paletteId);
if (_blocks[paletteId].size != 2 * 3 * 256)
error("CDToons: palette %04x is wrong size (%d)", paletteId, _blocks[paletteId].size);
_currentPaletteId = paletteId;
if (!paletteSet)
setPalette(_blocks[paletteId].data);
}
return _surface;
}