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


C++ String::setChar方法代码示例

本文整理汇总了C++中common::String::setChar方法的典型用法代码示例。如果您正苦于以下问题:C++ String::setChar方法的具体用法?C++ String::setChar怎么用?C++ String::setChar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在common::String的用法示例。


在下文中一共展示了String::setChar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ScriptingEffect

SyncSoundNode::SyncSoundNode(ZVision *engine, uint32 key, Common::String &filename, int32 syncto)
	: ScriptingEffect(engine, key, SCRIPTING_EFFECT_AUDIO) {
	_syncto = syncto;
	_sub = NULL;

	Audio::RewindableAudioStream *audioStream = NULL;

	if (filename.contains(".wav")) {
		Common::File *file = new Common::File();
		if (_engine->getSearchManager()->openFile(*file, filename)) {
			audioStream = Audio::makeWAVStream(file, DisposeAfterUse::YES);
		}
	} else {
		audioStream = makeRawZorkStream(filename, _engine);
	}

	_engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, audioStream);

	Common::String subname = filename;
	subname.setChar('s', subname.size() - 3);
	subname.setChar('u', subname.size() - 2);
	subname.setChar('b', subname.size() - 1);

	if (_engine->getSearchManager()->hasFile(subname))
		_sub = new Subtitle(_engine, subname);
}
开发者ID:86400,项目名称:scummvm,代码行数:26,代码来源:syncsound_effect.cpp

示例2: execute

bool ActionStreamVideo::execute() {
	Video::VideoDecoder *decoder;
	Common::Rect destRect = Common::Rect(_x1, _y1, _x2 + 1, _y2 + 1);
	Common::String subname = _fileName;
	subname.setChar('s', subname.size() - 3);
	subname.setChar('u', subname.size() - 2);
	subname.setChar('b', subname.size() - 1);
	bool subtitleExists = _engine->getSearchManager()->hasFile(subname);
	bool switchToHires = false;

// NOTE: We only show the hires MPEG2 videos when libmpeg2 is compiled in,
// otherwise we fall back to the lowres ones
#ifdef USE_MPEG2
	Common::String hiresFileName = _fileName;
	hiresFileName.setChar('d', hiresFileName.size() - 8);
	hiresFileName.setChar('v', hiresFileName.size() - 3);
	hiresFileName.setChar('o', hiresFileName.size() - 2);
	hiresFileName.setChar('b', hiresFileName.size() - 1);

	if (_engine->getScriptManager()->getStateValue(StateKey_MPEGMovies) == 1 &&_engine->getSearchManager()->hasFile(hiresFileName)) {
		// TODO: Enable once AC3 support is implemented
		if (!_engine->getSearchManager()->hasFile(_fileName))	// Check for the regular video
			return true;
		warning("The hires videos of the DVD version of ZGI aren't supported yet, using lowres");
		//_fileName = hiresFileName;
		//switchToHires = true;
	} else if (!_engine->getSearchManager()->hasFile(_fileName))
		return true;
#else
	if (!_engine->getSearchManager()->hasFile(_fileName))
		return true;
#endif

	decoder = _engine->loadAnimation(_fileName);
	Subtitle *sub = (subtitleExists) ? new Subtitle(_engine, subname, switchToHires) : NULL;

	_engine->getCursorManager()->showMouse(false);

	if (switchToHires) {
		_engine->initHiresScreen();
		destRect = Common::Rect(40, -40, 760, 440);
		Common::Rect workingWindow = _engine->_workingWindow;
		workingWindow.translate(0, -40);
		_engine->getRenderManager()->initSubArea(HIRES_WINDOW_WIDTH, HIRES_WINDOW_HEIGHT, workingWindow);
	}

	_engine->playVideo(*decoder, destRect, _skippable, sub);

	if (switchToHires) {
		_engine->initScreen();
		_engine->getRenderManager()->initSubArea(WINDOW_WIDTH, WINDOW_HEIGHT, _engine->_workingWindow);
	}

	_engine->getCursorManager()->showMouse(true);

	delete decoder;
	delete sub;

	return true;
}
开发者ID:Marisa-Chan,项目名称:scummvm,代码行数:60,代码来源:actions.cpp

示例3: tokenizer

Audio::RewindableAudioStream *makeRawZorkStream(const Common::String &filePath, ZVision *engine) {
	Common::File *file = new Common::File();
	Common::String actualName = filePath;
	bool found = engine->getSearchManager()->openFile(*file, actualName);
	bool isRaw = actualName.hasSuffix(".raw");

	if ((!found && isRaw) || (found && isRaw && file->size() < 10)) {
		if (found)
			file->close();

		// Check for an audio patch (.src)
		actualName.setChar('s', actualName.size() - 3);
		actualName.setChar('r', actualName.size() - 2);
		actualName.setChar('c', actualName.size() - 1);

		if (!engine->getSearchManager()->openFile(*file, actualName))
			return NULL;
	} else if (!found && !isRaw) {
		return NULL;
	}

	// Get the file name
	Common::StringTokenizer tokenizer(actualName, "/\\");
	Common::String fileName;
	while (!tokenizer.empty()) {
		fileName = tokenizer.nextToken();
	}

	fileName.toLowercase();

	const SoundParams *soundParams = NULL;

	if (engine->getGameId() == GID_NEMESIS) {
		for (int i = 0; i < 32; ++i) {
			if (RawZorkStream::_zNemSoundParamLookupTable[i].identifier == (fileName[6]))
				soundParams = &RawZorkStream::_zNemSoundParamLookupTable[i];
		}
	} else if (engine->getGameId() == GID_GRANDINQUISITOR) {
		for (int i = 0; i < 24; ++i) {
			if (RawZorkStream::_zgiSoundParamLookupTable[i].identifier == (fileName[7]))
				soundParams = &RawZorkStream::_zgiSoundParamLookupTable[i];
		}
	}

	if (soundParams == NULL)
		return NULL;

	if (soundParams->packed) {
		return makeRawZorkStream(wrapBufferedSeekableReadStream(file, 2048, DisposeAfterUse::YES), soundParams->rate, soundParams->stereo, DisposeAfterUse::YES);
	} else {
		byte flags = 0;
		if (soundParams->bits16)
			flags |= Audio::FLAG_16BITS | Audio::FLAG_LITTLE_ENDIAN;
		if (soundParams->stereo)
			flags |= Audio::FLAG_STEREO;

		return Audio::makePCMStream(file, soundParams->rate, flags, DisposeAfterUse::YES);
	}
}
开发者ID:project-cabal,项目名称:cabal,代码行数:59,代码来源:zork_raw.cpp

示例4:

Common::String HiRes4Engine_Atari::formatNounError(const Common::String &verb, const Common::String &noun) const {
	Common::String err = _strings.nounError;
	for (uint i = 0; i < verb.size(); ++i)
		err.setChar(verb[i], i + 8);
	for (uint i = 0; i < noun.size(); ++i)
		err.setChar(noun[i], i + 19);
	return err;
}
开发者ID:OmerMor,项目名称:scummvm,代码行数:8,代码来源:hires4.cpp

示例5: cmdDumpImage

bool Console::cmdDumpImage(int argc, const char **argv) {
	if (argc != 2) {
		debugPrintf("Use %s <TGA/TGZ name> to dump a Z-Vision TGA/TGZ image into a regular BMP image\n", argv[0]);
		return true;
	}

	Common::String fileName = argv[1];
	if (!fileName.hasSuffix(".tga")) {
		debugPrintf("%s is not an image file", argv[1]);
	}

	Common::File f;
	if (!_engine->getSearchManager()->openFile(f, argv[1])) {
		warning("File not found: %s", argv[1]);
		return true;
	}

	Graphics::Surface surface;
	_engine->getRenderManager()->readImageToSurface(argv[1], surface, false);

	// Open file
	Common::DumpFile out;

	fileName.setChar('b', fileName.size() - 3);
	fileName.setChar('m', fileName.size() - 2);
	fileName.setChar('p', fileName.size() - 1);

	out.open(fileName);

	// Write BMP header
	out.writeByte('B');
	out.writeByte('M');
	out.writeUint32LE(surface.h * surface.pitch + 54);
	out.writeUint32LE(0);
	out.writeUint32LE(54);
	out.writeUint32LE(40);
	out.writeUint32LE(surface.w);
	out.writeUint32LE(surface.h);
	out.writeUint16LE(1);
	out.writeUint16LE(16);
	out.writeUint32LE(0);
	out.writeUint32LE(0);
	out.writeUint32LE(0);
	out.writeUint32LE(0);
	out.writeUint32LE(0);
	out.writeUint32LE(0);

	// Write pixel data to BMP
	out.write(surface.getPixels(), surface.pitch * surface.h);

	out.flush();
	out.close();

	surface.free();

	return true;
}
开发者ID:Cruel,项目名称:scummvm,代码行数:57,代码来源:console.cpp

示例6:

void Inter_v6::probe16bitMusic(Common::String &fileName) {
	if (fileName[fileName.size() - 1] != '8')
		return;

	fileName.setChar('V', fileName.size() - 1);

	if (_vm->_dataIO->hasFile(fileName))
		return;

	fileName.setChar('8', fileName.size() - 1);
}
开发者ID:Templier,项目名称:scummvm-test,代码行数:11,代码来源:inter_v6.cpp

示例7: MusicNodeBASE

MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool loop, int8 volume)
	: MusicNodeBASE(engine, key, SCRIPTING_EFFECT_AUDIO) {
	_loop = loop;
	_volume = volume;
	_crossfade = false;
	_crossfadeTarget = 0;
	_crossfadeTime = 0;
	_attenuate = 0;
	_pantrack = false;
	_pantrackPosition = 0;
	_sub = NULL;
	_stereo = false;
	_loaded = false;

	Audio::RewindableAudioStream *audioStream = NULL;

	if (filename.contains(".wav")) {
		Common::File *file = new Common::File();
		if (_engine->getSearchManager()->openFile(*file, filename)) {
			audioStream = Audio::makeWAVStream(file, DisposeAfterUse::YES);
		}
	} else {
		audioStream = makeRawZorkStream(filename, _engine);
	}

	if (audioStream) {
		_stereo = audioStream->isStereo();

		if (_loop) {
			Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES);
			_engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, loopingAudioStream, -1, _volume);
		} else {
			_engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, audioStream, -1, _volume);
		}

		if (_key != StateKey_NotSet)
			_engine->getScriptManager()->setStateValue(_key, 1);

		// Change filename.raw into filename.sub
		Common::String subname = filename;
		subname.setChar('s', subname.size() - 3);
		subname.setChar('u', subname.size() - 2);
		subname.setChar('b', subname.size() - 1);

		if (_engine->getSearchManager()->hasFile(subname))
			_sub = new Subtitle(_engine, subname);

		_loaded = true;
	}
}
开发者ID:superg,项目名称:scummvm,代码行数:50,代码来源:music_effect.cpp

示例8:

int AdlEngine_v2::o2_tellTime(ScriptEnv &e) {
	OP_DEBUG_0("\tTELL_TIME()");

	Common::String time = _strings_v2.time;

	time.setChar(APPLECHAR('0') + _state.time.hours / 10, 12);
	time.setChar(APPLECHAR('0') + _state.time.hours % 10, 13);
	time.setChar(APPLECHAR('0') + _state.time.minutes / 10, 15);
	time.setChar(APPLECHAR('0') + _state.time.minutes % 10, 16);

	printString(time);

	return 0;
}
开发者ID:WinterGrascph,项目名称:scummvm,代码行数:14,代码来源:adl_v2.cpp

示例9: Cmd_DumpVocab

bool Debugger::Cmd_DumpVocab(int argc, const char **argv) {
	Common::DumpFile outFile;
	outFile.open("vocab.txt");

	for (uint32 i = 0; i < _vm->_game->_scene.getVocabStringsCount(); i++) {
		Common::String curId = Common::String::format("%x", i + 1);
		Common::String curVocab = _vm->_game->_scene.getVocab(i + 1);
		curVocab.toUppercase();

		for (uint j = 0; j < curVocab.size(); j++) {
			if (curVocab[j] == ' ' || curVocab[j] == '-')
				curVocab.setChar('_', j);
		}

		Common::String cur = "\tNOUN_" + curVocab + " = 0x" + curId + ",\n";

		outFile.writeString(cur.c_str());
	}

	outFile.flush();
	outFile.close();

	debugPrintf("Game vocab dumped\n");

	return true;
}
开发者ID:AReim1982,项目名称:scummvm,代码行数:26,代码来源:debugger.cpp

示例10: Cmd_DumpItems

bool Debugger::Cmd_DumpItems(int argc, const char **argv) {
	InventoryObjects &objects = _vm->_game->_objects;

	Common::DumpFile outFile;
	outFile.open("items.txt");

	for (uint32 i = 0; i < objects.size(); i++) {
		Common::String curId = Common::String::format("%d", i);
		Common::String desc = _vm->_game->_scene.getVocab(objects[i]._descId);
		desc.toUppercase();

		for (uint j = 0; j < desc.size(); j++) {
			if (desc[j] == ' ' || desc[j] == '-')
				desc.setChar('_', j);
		}

		Common::String cur = "\tOBJ_" + desc + " = " + curId + ",\n";

		outFile.writeString(cur.c_str());
	}

	outFile.flush();
	outFile.close();

	debugPrintf("Game items dumped\n");

	return true;
}
开发者ID:AReim1982,项目名称:scummvm,代码行数:28,代码来源:debugger.cpp

示例11: oGeisha_checkData

void Inter_Geisha::oGeisha_checkData(OpFuncParams &params) {
	Common::String file = _vm->_game->_script->evalString();
	int16 varOff = _vm->_game->_script->readVarIndex();

	file.toLowercase();
	if (file.hasSuffix(".0ot"))
		file.setChar('t', file.size() - 3);

	bool exists = false;

	SaveLoad::SaveMode mode = _vm->_saveLoad->getSaveMode(file.c_str());
	if (mode == SaveLoad::kSaveModeNone) {

		exists = _vm->_dataIO->hasFile(file);
		if (!exists) {
			// NOTE: Geisha looks if fin.tot exists to check if it needs to open disk3.stk.
			//       This is completely normal, so don't print a warning.
			if (file != "fin.tot")
				warning("File \"%s\" not found", file.c_str());
		}

	} else if (mode == SaveLoad::kSaveModeSave)
		exists = _vm->_saveLoad->getSize(file.c_str()) >= 0;
	else if (mode == SaveLoad::kSaveModeExists)
		exists = true;

	WRITE_VAR_OFFSET(varOff, exists ? 50 : (uint32)-1);
}
开发者ID:AReim1982,项目名称:scummvm,代码行数:28,代码来源:inter_geisha.cpp

示例12: appendVocab

void MADSAction::appendVocab(int vocabId, bool capitalize) {
	Common::String vocabStr = _vm->_game->_scene.getVocab(vocabId);
	if (capitalize)
		vocabStr.setChar(toupper(vocabStr[0]), 0);

	_statusText += vocabStr;
	_statusText += " ";
}
开发者ID:CobaltBlues,项目名称:scummvm,代码行数:8,代码来源:action.cpp

示例13: checkMob

int PrinceEngine::checkMob(Graphics::Surface *screen, Common::Array<Mob> &mobList, bool usePriorityList) {
	if (_mouseFlag == 0 || _mouseFlag == 3) {
		return -1;
	}
	Common::Point mousePos = _system->getEventManager()->getMousePos();
	int mobNumber = getMob(mobList, usePriorityList, mousePos.x + _picWindowX, mousePos.y);

	if (mobNumber != -1) {
		Common::String mobName = mobList[mobNumber]._name;

		if (getLanguage() == Common::DE_DEU) {
			for (uint i = 0; i < mobName.size(); i++) {
				switch (mobName[i]) {
				case '\xc4':
					mobName.setChar('\x83', i);
					break;
				case '\xd6':
					mobName.setChar('\x84', i);
					break;
				case '\xdc':
					mobName.setChar('\x85', i);
					break;
				case '\xdf':
					mobName.setChar('\x7f', i);
					break;
				case '\xe4':
					mobName.setChar('\x80', i);
					break;
				case '\xf6':
					mobName.setChar('\x81', i);
					break;
				case '\xfc':
					mobName.setChar('\x82', i);
					break;
				}
			}
		}

		uint16 textW = getTextWidth(mobName.c_str());

		uint16 x = mousePos.x - textW / 2;
		if (x > screen->w) {
			x = 0;
		}

		if (x + textW > screen->w) {
			x = screen->w - textW;
		}

		uint16 y = mousePos.y - _font->getFontHeight();
		if (y > screen->h) {
			y = _font->getFontHeight() - 2;
		}

		_font->drawString(screen, mobName, x, y, screen->w, 216);
	}

	return mobNumber;
}
开发者ID:BenCastricum,项目名称:scummvm,代码行数:59,代码来源:mob.cpp

示例14: stringToCamelCase

Common::String DefinitionRegistry::stringToCamelCase(const Common::String &input) {
	Common::String clean = input;

	// First replace all non alphanumerical characters with spaces
	for (uint i = 0; i < clean.size(); i++) {
		if (!Common::isAlnum(clean[i])) {
			clean.setChar(' ', i);
		}
	}

	// Then turn the string into camel case
	Common::String output;
	Common::StringTokenizer tokens = Common::StringTokenizer(clean);
	while (!tokens.empty()) {
		Common::String token = tokens.nextToken();

		char upperFirstLetter = toupper(token[0]);
		token.setChar(upperFirstLetter, 0);

		output += token;
	}

	return output;
}
开发者ID:Botje,项目名称:residualvm,代码行数:24,代码来源:command.cpp

示例15: handleFanmadeSciAudio

/**
 * Handles the sciAudio calls in fanmade games.
 * sciAudio is an external .NET library for playing MP3 files in fanmade games.
 * It runs in the background, and obtains sound commands from the
 * currently running game via text files (called "conductor files").
 * For further info, check: http://sciprogramming.com/community/index.php?topic=634.0
 */
void AudioPlayer::handleFanmadeSciAudio(reg_t sciAudioObject, SegManager *segMan) {
	// TODO: This is a bare bones implementation. Only the play/playx and stop commands
	// are handled for now - the other commands haven't been observed in any fanmade game
	// yet. All the volume related and fading functionality is currently missing.

	Kernel *kernel = g_sci->getKernel();

	reg_t commandReg = readSelector(segMan, sciAudioObject, kernel->findSelector("command"));
	Common::String command = segMan->getString(commandReg);

	if (command == "play" || command == "playx") {
#ifdef USE_MAD
		reg_t fileNameReg = readSelector(segMan, sciAudioObject, kernel->findSelector("fileName"));
		Common::String fileName = segMan->getString(fileNameReg);

		int16 loopCount = (int16)readSelectorValue(segMan, sciAudioObject, kernel->findSelector("loopCount"));
		// When loopCount is -1, we treat it as infinite looping, else no looping is done.
		// This is observed by game scripts, which can set loopCount to all sorts of random values.
		// Adjust loopCount for ScummVM's LoopingAudioStream semantics
		loopCount = (loopCount == -1) ? 0 : 1;

		// Determine sound type
		Audio::Mixer::SoundType soundType = Audio::Mixer::kSFXSoundType;
		if (fileName.hasPrefix("music"))
			soundType = Audio::Mixer::kMusicSoundType;
		else if (fileName.hasPrefix("speech"))
			soundType = Audio::Mixer::kSpeechSoundType;

		Common::File *sciAudio = new Common::File();
		// Replace backwards slashes
		for (uint i = 0; i < fileName.size(); i++) {
			if (fileName[i] == '\\')
				fileName.setChar('/', i);
		}
		sciAudio->open("sciAudio/" + fileName);

		Audio::SeekableAudioStream *audioStream = Audio::makeMP3Stream(sciAudio, DisposeAfterUse::YES);

		// We only support one audio handle
		_mixer->playStream(soundType, &_audioHandle,
							Audio::makeLoopingAudioStream((Audio::RewindableAudioStream *)audioStream, loopCount));
#endif
	} else if (command == "stop") {
		_mixer->stopHandle(_audioHandle);
	} else {
		warning("Unhandled sciAudio command: %s", command.c_str());
	}
}
开发者ID:project-cabal,项目名称:cabal,代码行数:55,代码来源:audio.cpp


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