本文整理汇总了C++中common::Array类的典型用法代码示例。如果您正苦于以下问题:C++ Array类的具体用法?C++ Array怎么用?C++ Array使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Array类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: createTexture
void VisualText::createTexture() {
// 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 = StarkFontProvider->scaleWidthOriginalToCurrent(_originalRect.width());
// Word wrap the text and compute the scaled and original resolution bounding boxes
Common::Rect scaledRect;
Common::Array<Common::String> lines;
scaledRect.right = scaledRect.left + font->wordWrapText(_text, maxScaledLineWidth, lines);
scaledRect.bottom = scaledRect.top + scaledLineHeight * lines.size();
_originalRect.bottom = _originalRect.top + originalLineHeight * lines.size();
// Create a surface to render to
Graphics::Surface surface;
surface.create(scaledRect.width(), scaledRect.height(), _gfx->getScreenFormat());
surface.fillRect(scaledRect, _backgroundColor);
// Render the lines to the surface
for (uint i = 0; i < lines.size(); i++) {
font->drawString(&surface, lines[i], 0, scaledLineHeight * i, scaledRect.width(), _color);
}
// Create a texture from the surface
_texture = _gfx->createTexture(&surface);
surface.free();
}
开发者ID:ComputeLinux,项目名称:residualvm,代码行数:28,代码来源:text.cpp
示例2: init
void TestbedExitDialog::init() {
_xOffset = 25;
_yOffset = 0;
Common::String text = "Thank you for using ScummVM testbed! Here are yor summarized results:";
addText(450, 20, text, Graphics::kTextAlignCenter, _xOffset, 15);
Common::Array<Common::String> strArray;
GUI::ListWidget::ColorList colors;
for (Common::Array<Testsuite *>::const_iterator i = _testsuiteList.begin(); i != _testsuiteList.end(); ++i) {
strArray.push_back(Common::String::format("%s :", (*i)->getDescription()));
colors.push_back(GUI::ThemeEngine::kFontColorNormal);
if ((*i)->isEnabled()) {
strArray.push_back(Common::String::format("Passed: %d Failed: %d Skipped: %d", (*i)->getNumTestsPassed(), (*i)->getNumTestsFailed(), (*i)->getNumTestsSkipped()));
} else {
strArray.push_back("Skipped");
}
colors.push_back(GUI::ThemeEngine::kFontColorAlternate);
}
addList(0, _yOffset, 500, 200, strArray, &colors);
text = "More Details can be viewed in the Log file : " + ConfParams.getLogFilename();
addText(450, 20, text, Graphics::kTextAlignLeft, 0, 0);
if (ConfParams.getLogDirectory().size()) {
text = "Directory : " + ConfParams.getLogDirectory();
} else {
text = "Directory : .";
}
addText(500, 20, text, Graphics::kTextAlignLeft, 0, 0);
_yOffset += 5;
addButtonXY(_xOffset + 80, _yOffset, 120, 24, "Rerun test suite", kCmdRerunTestbed);
addButtonXY(_xOffset + 240, _yOffset, 60, 24, "Close", GUI::kCloseCmd);
}
开发者ID:AlbanBedel,项目名称:scummvm,代码行数:32,代码来源:testbed.cpp
示例3: updateState
void Inventory::updateState() {
Common::Array<uint16> items;
for (ItemList::iterator it = _inventory.begin(); it != _inventory.end(); it++)
items.push_back(it->var);
_vm->_state->updateInventory(items);
}
开发者ID:agharbi,项目名称:residual,代码行数:7,代码来源:inventory.cpp
示例4: loadState
bool BuriedEngine::loadState(Common::SeekableReadStream *saveFile, Location &location, GlobalFlags &flags, Common::Array<int> &inventoryItems) {
byte header[9];
saveFile->read(header, kSavedGameHeaderSize);
// Only compare the first 6 bytes
// Win95 version of the game output garbage as the last two bytes
if (saveFile->eos() || memcmp(header, s_savedGameHeader, kSavedGameHeaderSizeAlt) != 0)
return false;
Common::Serializer s(saveFile, 0);
if (!syncLocation(s, location))
return false;
if (saveFile->eos())
return false;
if (!syncGlobalFlags(s, flags))
return false;
if (saveFile->eos())
return false;
uint16 itemCount = saveFile->readUint16LE();
if (saveFile->eos())
return false;
inventoryItems.clear();
for (uint16 i = 0; i < itemCount; i++)
inventoryItems.push_back(saveFile->readUint16LE());
return !saveFile->eos();
}
开发者ID:project-cabal,项目名称:cabal,代码行数:34,代码来源:saveload.cpp
示例5: loadFromState
void Inventory::loadFromState() {
Common::Array<uint16> items = _vm->_state->getInventory();
_inventory.clear();
for (uint i = 0; i < items.size(); i++)
addItem(items[i], true);
}
开发者ID:agharbi,项目名称:residual,代码行数:7,代码来源:inventory.cpp
示例6: writeResourceTree
void StateProvider::writeResourceTree(Resources::Object *resource, Common::WriteStream *stream, bool current) {
// Explicit scope to control the lifespan of the memory stream
{
Common::MemoryWriteStreamDynamic resourceStream(DisposeAfterUse::YES);
ResourceSerializer serializer(nullptr, &resourceStream, kSaveVersion);
// Serialize the resource to a memory stream
if (current) {
resource->saveLoadCurrent(&serializer);
} else {
resource->saveLoad(&serializer);
}
// Write the resource to the target stream
stream->writeByte(resource->getType().get());
stream->writeByte(resource->getSubType());
stream->writeUint32LE(resourceStream.size());
stream->write(resourceStream.getData(), resourceStream.size());
}
// Serialize the resource children
Common::Array<Resources::Object *> children = resource->listChildren<Resources::Object>();
for (uint i = 0; i < children.size(); i++) {
writeResourceTree(children[i], stream, current);
}
}
开发者ID:DouglasLiuGamer,项目名称:residualvm,代码行数:26,代码来源:stateprovider.cpp
示例7:
Common::Array<AgeData> Database::loadAges(Common::ReadStreamEndian &s)
{
Common::Array<AgeData> ages;
for (uint i = 0; i < 10; i++) {
AgeData age;
if (_vm->getPlatform() == Common::kPlatformPS2) {
// Really 64-bit values
age.id = s.readUint32LE();
s.readUint32LE();
age.disk = s.readUint32LE();
s.readUint32LE();
age.roomCount = s.readUint32LE();
s.readUint32LE();
age.roomsOffset = s.readUint32LE() - _executableVersion->baseOffset;
s.readUint32LE();
age.labelId = s.readUint32LE();
s.readUint32LE();
} else {
age.id = s.readUint32();
age.disk = s.readUint32();
age.roomCount = s.readUint32();
age.roomsOffset = s.readUint32() - _executableVersion->baseOffset;
age.labelId = s.readUint32();
}
ages.push_back(age);
}
return ages;
}
开发者ID:Harrypoppins,项目名称:grim_mouse,代码行数:32,代码来源:database.cpp
示例8: Cmd_DecompileScript
bool Console::Cmd_DecompileScript(int argc, const char **argv) {
if (argc >= 2) {
uint index = atoi(argv[1]);
Common::Array<Resources::Script *> scripts = listAllLocationScripts();
if (index < scripts.size()) {
Resources::Script *script = scripts[index];
Tools::Decompiler *decompiler = new Tools::Decompiler(script);
if (decompiler->getError() != "") {
debugPrintf("Decompilation failure: %s\n", decompiler->getError().c_str());
}
debug("Script %d - %s:", index, script->getName().c_str());
decompiler->printDecompiled();
delete decompiler;
return true;
} else {
debugPrintf("Invalid index %d, only %d indices available\n", index, scripts.size());
}
} else {
debugPrintf("Too few args\n");
}
debugPrintf("Decompile a script. Use listScripts to get an id\n");
debugPrintf("Usage :\n");
debugPrintf("decompileScript [id]\n");
return true;
}
开发者ID:Botje,项目名称:residualvm,代码行数:31,代码来源:console.cpp
示例9:
Common::Array<reg_t> DataStack::listAllOutgoingReferences(reg_t object) const {
Common::Array<reg_t> tmp;
for (int i = 0; i < _capacity; i++)
tmp.push_back(_entries[i]);
return tmp;
}
开发者ID:rkmarvin,项目名称:scummvm,代码行数:7,代码来源:segment.cpp
示例10: Cmd_ForceScript
bool Console::Cmd_ForceScript(int argc, const char **argv) {
uint index = 0;
if (argc >= 2) {
index = atoi(argv[1]);
Common::Array<Resources::Script *> scripts = listAllLocationScripts();
if (index < scripts.size() ) {
Resources::Script *script = scripts[index];
script->enable(true);
script->goToNextCommand(); // Skip the begin command to avoid checks
script->execute(Resources::Script::kCallModePlayerAction);
return true;
} else {
debugPrintf("Invalid index %d, only %d indices available\n", index, scripts.size());
}
} else {
debugPrintf("Too few args\n");
}
debugPrintf("Force the execution of a script. Use listScripts to get an id\n");
debugPrintf("Usage :\n");
debugPrintf("forceScript [id]\n");
return true;
}
开发者ID:Botje,项目名称:residualvm,代码行数:25,代码来源:console.cpp
示例11: listSavegames
void listSavegames(Common::Array<SavegameDesc> &saves) {
Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager();
// Load all saves
Common::StringList saveNames = saveFileMan->listSavefiles(((SciEngine *)g_engine)->getSavegamePattern());
for (Common::StringList::const_iterator iter = saveNames.begin(); iter != saveNames.end(); ++iter) {
Common::String filename = *iter;
Common::SeekableReadStream *in;
if ((in = saveFileMan->openForLoading(filename))) {
SavegameMetadata meta;
if (!get_savegame_metadata(in, &meta)) {
// invalid
delete in;
continue;
}
delete in;
SavegameDesc desc;
desc.id = strtol(filename.end() - 3, NULL, 10);
desc.date = meta.savegame_date;
desc.time = meta.savegame_time;
debug(3, "Savegame in file %s ok, id %d", filename.c_str(), desc.id);
saves.push_back(desc);
}
}
// Sort the list by creation date of the saves
qsort(saves.begin(), saves.size(), sizeof(SavegameDesc), _savegame_index_struct_compare);
}
开发者ID:havlenapetr,项目名称:Scummvm,代码行数:31,代码来源:kfile.cpp
示例12: readResourceTree
void StateProvider::readResourceTree(Resources::Object *resource, Common::SeekableReadStream *stream, bool current, uint32 version) {
// Read the resource to the source stream
/* byte type = */ stream->readByte();
/* byte subType = */ stream->readByte();
uint32 size = stream->readUint32LE();
if (size > 0) {
Common::SeekableReadStream *resourceStream = stream->readStream(size);
ResourceSerializer serializer(resourceStream, nullptr, version);
// Deserialize the resource state from stream
if (current) {
resource->saveLoadCurrent(&serializer);
} else {
resource->saveLoad(&serializer);
}
delete resourceStream;
}
// Deserialize the resource children
Common::Array<Resources::Object *> children = resource->listChildren<Resources::Object>();
for (uint i = 0; i < children.size(); i++) {
readResourceTree(children[i], stream, current, version);
}
}
开发者ID:DouglasLiuGamer,项目名称:residualvm,代码行数:26,代码来源:stateprovider.cpp
示例13: getInfo
bool SaveReader::getInfo(Common::SeekableReadStream &stream, SavePartInfo &info) {
// Remeber the stream's starting position to seek back to
uint32 startPos = stream.pos();
// Get parts' basic information
Common::Array<SaveContainer::PartInfo> *partsInfo = getPartsInfo(stream);
// No parts => fail
if (!partsInfo) {
stream.seek(startPos);
return false;
}
bool result = false;
// Iterate over all parts
for (Common::Array<SaveContainer::PartInfo>::iterator it = partsInfo->begin();
it != partsInfo->end(); ++it) {
// Check for the info part
if (it->id == SavePartInfo::kID) {
if (!stream.seek(it->offset))
break;
// Read it
result = info.read(stream);
break;
}
}
stream.seek(startPos);
delete partsInfo;
return result;
}
开发者ID:St0rmcrow,项目名称:scummvm,代码行数:34,代码来源:savefile.cpp
示例14: computeVisibilityMatrix
void WalkRegion::computeVisibilityMatrix() {
// Initialize visibility matrix
_visibilityMatrix = Common::Array< Common::Array <int> >();
for (uint idx = 0; idx < _nodes.size(); ++idx) {
Common::Array<int> arr;
for (uint idx2 = 0; idx2 < _nodes.size(); ++idx2)
arr.push_back(Infinity);
_visibilityMatrix.push_back(arr);
}
// Calculate visibility been vertecies
for (uint j = 0; j < _nodes.size(); ++j) {
for (uint i = j; i < _nodes.size(); ++i) {
if (isLineOfSight(_nodes[i], _nodes[j])) {
// There is a line of sight, so save the distance between the two
int distance = _nodes[i].distance(_nodes[j]);
_visibilityMatrix[i][j] = distance;
_visibilityMatrix[j][i] = distance;
} else {
// There is no line of sight, so save Infinity as the distance
_visibilityMatrix[i][j] = Infinity;
_visibilityMatrix[j][i] = Infinity;
}
}
}
}
开发者ID:dergunov,项目名称:scummvm,代码行数:27,代码来源:walkregion.cpp
示例15: Cmd_EnableScript
bool Console::Cmd_EnableScript(int argc, const char **argv) {
uint index = 0;
if (argc >= 2) {
index = atoi(argv[1]);
bool value = true;
if (argc >= 3) {
value = atoi(argv[2]);
}
Common::Array<Resources::Script *> scripts = listAllLocationScripts();
if (index < scripts.size() ) {
Resources::Script *script = scripts[index];
script->enable(value);
return true;
} else {
debugPrintf("Invalid index %d, only %d indices available\n", index, scripts.size());
}
} else {
debugPrintf("Too few args\n");
}
debugPrintf("Enable or disable a script. Use listScripts to get an id\n");
debugPrintf("Usage :\n");
debugPrintf("enableScript [id] (value)\n");
return true;
}
开发者ID:Botje,项目名称:residualvm,代码行数:28,代码来源:console.cpp
示例16:
Common::Array<Common::String> SavesSyncRequest::getFilesToDownload() {
Common::Array<Common::String> result;
for (uint32 i = 0; i < _filesToDownload.size(); ++i)
result.push_back(_filesToDownload[i].name());
if (_currentDownloadingFile.name() != "")
result.push_back(_currentDownloadingFile.name());
return result;
}
开发者ID:86400,项目名称:scummvm,代码行数:8,代码来源:savessyncrequest.cpp
示例17: addNeighboursFromFace
void FloorEdge::addNeighboursFromFace(const FloorFace *face) {
Common::Array<FloorEdge *> faceEdges = face->getEdges();
for (uint i = 0; i < faceEdges.size(); i++) {
if (faceEdges[i] != this) {
_neighbours.push_back(faceEdges[i]);
}
}
}
开发者ID:residualvm,项目名称:residualvm,代码行数:8,代码来源:floor.cpp
示例18:
Common::Array<uint32> Archive::getResourceTypeList() const {
Common::Array<uint32> typeList;
for (TypeMap::const_iterator it = _types.begin(); it != _types.end(); it++)
typeList.push_back(it->_key);
return typeList;
}
开发者ID:bSr43,项目名称:scummvm,代码行数:8,代码来源:resource.cpp
示例19: StaticTextWidget
MessageDialog::MessageDialog(const Common::String &message, const char *defaultButton, const char *altButton)
: Dialog(30, 20, 260, 124) {
const int screenW = g_system->getOverlayWidth();
const int screenH = g_system->getOverlayHeight();
int buttonWidth = g_gui.xmlEval()->getVar("Globals.Button.Width", 0);
int buttonHeight = g_gui.xmlEval()->getVar("Globals.Button.Height", 0);
// First, determine the size the dialog needs. For this we have to break
// down the string into lines, and taking the maximum of their widths.
// Using this, and accounting for the space the button(s) need, we can set
// the real size of the dialog
Common::Array<Common::String> lines;
int lineCount, okButtonPos, cancelButtonPos;
int maxlineWidth = g_gui.getFont().wordWrapText(message, screenW - 2 * 20, lines);
// Calculate the desired dialog size (maxing out at 300*180 for now)
if (altButton)
_w = MAX(maxlineWidth, (2 * buttonWidth) + 10) + 20;
else
_w = MAX(maxlineWidth, buttonWidth) + 20;
lineCount = lines.size();
_h = 16;
if (defaultButton || altButton)
_h += buttonHeight + 8;
// Limit the number of lines so that the dialog still fits on the screen.
if (lineCount > (screenH - 20 - _h) / kLineHeight) {
lineCount = (screenH - 20 - _h) / kLineHeight;
}
_h += lineCount * kLineHeight;
// Center the dialog
_x = (screenW - _w) / 2;
_y = (screenH - _h) / 2;
// Each line is represented by one static text item.
for (int i = 0; i < lineCount; i++) {
new StaticTextWidget(this, 10, 10 + i * kLineHeight, maxlineWidth, kLineHeight,
lines[i], Graphics::kTextAlignCenter);
}
if (defaultButton && altButton) {
okButtonPos = (_w - (buttonWidth * 2)) / 2;
cancelButtonPos = ((_w - (buttonWidth * 2)) / 2) + buttonWidth + 10;
} else {
okButtonPos = cancelButtonPos = (_w - buttonWidth) / 2;
}
if (defaultButton)
new ButtonWidget(this, okButtonPos, _h - buttonHeight - 8, buttonWidth, buttonHeight, defaultButton, 0, kOkCmd, Common::ASCII_RETURN); // Confirm dialog
if (altButton)
new ButtonWidget(this, cancelButtonPos, _h - buttonHeight - 8, buttonWidth, buttonHeight, altButton, 0, kCancelCmd, Common::ASCII_ESCAPE); // Cancel dialog
}
开发者ID:AdamRi,项目名称:scummvm-pink,代码行数:58,代码来源:message.cpp
示例20:
Common::Array<const ASTCommand *> ASTBlock::listCommands(uint16 index) const {
Common::Array<const ASTCommand *> list;
for (uint i = 0; i < _children.size(); i++) {
list.push_back(_children[i]->listCommands(index));
}
return list;
}
开发者ID:Botje,项目名称:residualvm,代码行数:9,代码来源:abstractsyntaxtree.cpp
注:本文中的common::Array类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论