当前位置: 首页>>代码示例>>C++>>正文


C++ common::Array类代码示例

本文整理汇总了C++中common::Array的典型用法代码示例。如果您正苦于以下问题:C++ Array类的具体用法?C++ Array怎么用?C++ Array使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Array类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的common::Array类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。