本文整理汇总了C++中common::String类的典型用法代码示例。如果您正苦于以下问题:C++ String类的具体用法?C++ String怎么用?C++ String使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了String类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
extern "C" int scummvm_main(int argc, const char * const argv[]) {
Common::String specialDebug;
Common::String command;
// Verify that the backend has been initialized (i.e. g_system has been set).
assert(g_system);
OSystem &system = *g_system;
// Register config manager defaults
Base::registerDefaults();
// Parse the command line
Common::StringMap settings;
command = Base::parseCommandLine(settings, argc, argv);
// Load the config file (possibly overridden via command line):
if (settings.contains("config")) {
ConfMan.loadConfigFile(settings["config"]);
settings.erase("config");
} else {
ConfMan.loadDefaultConfigFile();
}
// Update the config file
ConfMan.set("versioninfo", Cabal::getVersion(), Common::ConfigManager::kApplicationDomain);
// Load and setup the debuglevel and the debug flags. We do this at the
// soonest possible moment to ensure debug output starts early on, if
// requested.
if (settings.contains("debuglevel")) {
gDebugLevel = (int)strtol(settings["debuglevel"].c_str(), 0, 10);
printf("Debuglevel (from command line): %d\n", gDebugLevel);
settings.erase("debuglevel"); // This option should not be passed to ConfMan.
} else if (ConfMan.hasKey("debuglevel"))
gDebugLevel = ConfMan.getInt("debuglevel");
if (settings.contains("debugflags")) {
specialDebug = settings["debugflags"];
settings.erase("debugflags");
}
PluginManager::instance().init();
PluginManager::instance().loadAllPlugins(); // load plugins for cached plugin manager
// If we received an invalid music parameter via command line we check this here.
// We can't check this before loading the music plugins.
// On the other hand we cannot load the plugins before we know the file paths (in case of external plugins).
if (settings.contains("music-driver")) {
if (MidiDriver::getMusicType(MidiDriver::getDeviceHandle(settings["music-driver"])) == MT_INVALID) {
warning("Unrecognized music driver '%s'. Switching to default device", settings["music-driver"].c_str());
settings["music-driver"] = "auto";
}
}
// Process the remaining command line settings. Must be done after the
// config file and the plugins have been loaded.
Common::Error res;
// TODO: deal with settings that require plugins to be loaded
if (Base::processSettings(command, settings, res)) {
if (res.getCode() != Common::kNoError)
warning("%s", res.getDesc().c_str());
return res.getCode();
}
// Init the backend. Must take place after all config data (including
// the command line params) was read.
system.initBackend();
// If we received an invalid graphics mode parameter via command line
// we check this here. We can't do it until after the backend is inited,
// or there won't be a graphics manager to ask for the supported modes.
if (settings.contains("gfx-mode")) {
const OSystem::GraphicsMode *gm = g_system->getSupportedGraphicsModes();
Common::String option = settings["gfx-mode"];
bool isValid = false;
while (gm->name && !isValid) {
isValid = !scumm_stricmp(gm->name, option.c_str());
gm++;
}
if (!isValid) {
warning("Unrecognized graphics mode '%s'. Switching to default mode", option.c_str());
settings["gfx-mode"] = "default";
}
}
if (settings.contains("disable-display")) {
ConfMan.setInt("disable-display", 1, Common::ConfigManager::kTransientDomain);
}
setupGraphics(system);
// Init the different managers that are used by the engines.
// Do it here to prevent fragmentation later
system.getAudioCDManager();
MusicManager::instance();
Common::DebugManager::instance();
// Init the event manager. As the virtual keyboard is loaded here, it must
// take place after the backend is initiated and the screen has been setup
//.........这里部分代码省略.........
示例2: Cmd_TestDecompiler
bool Console::Cmd_TestDecompiler(int argc, const char **argv) {
_testDecompilerTotalScripts = 0;
_testDecompilerOKScripts = 0;
ArchiveLoader *archiveLoader = new ArchiveLoader();
// Temporarily replace the global archive loader with our instance
ArchiveLoader *gameArchiveLoader = StarkArchiveLoader;
StarkArchiveLoader = archiveLoader;
archiveLoader->load("x.xarc");
Resources::Root *root = archiveLoader->useRoot<Resources::Root>("x.xarc");
// Find all the levels
Common::Array<Resources::Level *> levels = root->listChildren<Resources::Level>();
// Loop over the levels
for (uint i = 0; i < levels.size(); i++) {
Resources::Level *level = levels[i];
Common::String levelArchive = archiveLoader->buildArchiveName(level);
debug("%s - %s", levelArchive.c_str(), level->getName().c_str());
// Load the detailed level archive
archiveLoader->load(levelArchive);
level = archiveLoader->useRoot<Resources::Level>(levelArchive);
// Decompile all the scripts in the level archive
decompileScriptChildren(level);
Common::Array<Resources::Location *> locations = level->listChildren<Resources::Location>();
// Loop over the locations
for (uint j = 0; j < locations.size(); j++) {
Resources::Location *location = locations[j];
Common::String locationArchive = archiveLoader->buildArchiveName(level, location);
debug("%s - %s", locationArchive.c_str(), location->getName().c_str());
// Load the detailed location archive
archiveLoader->load(locationArchive);
location = archiveLoader->useRoot<Resources::Location>(locationArchive);
// Decompile all the scripts in the location archive
decompileScriptChildren(location);
archiveLoader->returnRoot(locationArchive);
archiveLoader->unloadUnused();
}
archiveLoader->returnRoot(levelArchive);
archiveLoader->unloadUnused();
}
// Restore the global archive loader
StarkArchiveLoader = gameArchiveLoader;
delete archiveLoader;
debugPrintf("Successfully decompiled %d scripts out of %d\n", _testDecompilerOKScripts, _testDecompilerTotalScripts);
return true;
}
示例3: initGame
void Init::initGame() {
initVideo();
updateConfig();
if (!_vm->isDemo()) {
if (_vm->_dataIO->hasFile(_vm->_startStk))
_vm->_dataIO->openArchive(_vm->_startStk, true);
}
_vm->_util->initInput();
_vm->_video->initPrimary(_vm->_global->_videoMode);
_vm->_global->_mouseXShift = 1;
_vm->_global->_mouseYShift = 1;
_palDesc = new Video::PalDesc;
_vm->validateVideoMode(_vm->_global->_videoMode);
_vm->_global->_setAllPalette = true;
_palDesc->vgaPal = _vm->_draw->_vgaPalette;
_palDesc->unused1 = _vm->_draw->_unusedPalette1;
_palDesc->unused2 = _vm->_draw->_unusedPalette2;
_vm->_video->setFullPalette(_palDesc);
for (int i = 0; i < 10; i++)
_vm->_draw->_fascinWin[i].id = -1;
_vm->_draw->_winCount = 0;
for (int i = 0; i < 8; i++)
_vm->_draw->_fonts[i] = 0;
if (_vm->isDemo()) {
doDemo();
delete _palDesc;
_vm->_video->initPrimary(-1);
cleanup();
return;
}
Common::SeekableReadStream *infFile = _vm->_dataIO->getFile("intro.inf");
if (!infFile) {
for (int i = 0; i < 4; i++)
_vm->_draw->loadFont(i, _fontNames[i]);
} else {
for (int i = 0; i < 8; i++) {
if (infFile->eos())
break;
Common::String font = infFile->readLine();
if (infFile->eos() && font.empty())
break;
font += ".let";
_vm->_draw->loadFont(i, font.c_str());
}
delete infFile;
}
if (_vm->_dataIO->hasFile(_vm->_startTot)) {
_vm->_inter->allocateVars(Script::getVariablesCount(_vm->_startTot.c_str(), _vm));
_vm->_game->_curTotFile = _vm->_startTot;
_vm->_sound->cdTest(1, "GOB");
_vm->_sound->cdLoadLIC("gob.lic");
// Search for a Coktel logo animation or image to display
if (_vm->_dataIO->hasFile("coktel.imd")) {
_vm->_draw->initScreen();
_vm->_draw->_cursorIndex = -1;
_vm->_util->longDelay(200); // Letting everything settle
VideoPlayer::Properties props;
int slot;
if ((slot = _vm->_vidPlayer->openVideo(true, "coktel.imd", props)) >= 0) {
_vm->_vidPlayer->play(slot, props);
_vm->_vidPlayer->closeVideo(slot);
}
_vm->_draw->closeScreen();
} else if (_vm->_dataIO->hasFile("coktel.clt")) {
Common::SeekableReadStream *stream = _vm->_dataIO->getFile("coktel.clt");
if (stream) {
_vm->_draw->initScreen();
_vm->_util->clearPalette();
stream->read((byte *)_vm->_draw->_vgaPalette, 768);
delete stream;
int32 size;
byte *sprite = _vm->_dataIO->getFile("coktel.ims", size);
if (sprite) {
//.........这里部分代码省略.........
示例4: setCounterValue
void Parallaction_br::setCounterValue(const Common::String &name, int value) {
int index = _countersNames->lookup(name.c_str());
if (index != Table::notFound) {
_counters[index - 1] = value;
}
}
示例5: getSlotSaveName
Common::String SaveLoad::getSlotSaveName(const Common::String &target, int slot) {
Common::String fileName = Common::String::format("%s.%03d", target.c_str(), slot);
return fileName;
}
示例6:
ActionTimer::ActionTimer(const Common::String &line) {
sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%u)", &_key, &_time);
}
示例7: counterExists
bool Parallaction_br::counterExists(const Common::String &name) {
return Table::notFound != _countersNames->lookup(name.c_str());
}
示例8: parseLevFile
void LeverControl::parseLevFile(const Common::String &fileName) {
Common::File file;
if (!file.open(fileName)) {
warning("LEV file %s could could be opened", fileName.c_str());
return;
}
Common::String line = file.readLine();
while (!file.eos()) {
if (line.matchString("*animation_id*", true)) {
// Not used
} else if (line.matchString("*filename*", true)) {
char fileNameBuffer[25];
sscanf(line.c_str(), "%*[^:]:%25[^~]~", fileNameBuffer);
Common::String animationFileName(fileNameBuffer);
if (animationFileName.hasSuffix(".avi")) {
_animation.avi = new ZorkAVIDecoder();
_animation.avi->loadFile(animationFileName);
_fileType = AVI;
} else if (animationFileName.hasSuffix(".rlf")) {
_animation.rlf = new RlfAnimation(animationFileName, false);
_fileType = RLF;
}
} else if (line.matchString("*skipcolor*", true)) {
// Not used
} else if (line.matchString("*anim_coords*", true)) {
int left, top, right, bottom;
sscanf(line.c_str(), "%*[^:]:%d %d %d %d~", &left, &top, &right, &bottom);
_animationCoords.left = left;
_animationCoords.top = top;
_animationCoords.right = right;
_animationCoords.bottom = bottom;
} else if (line.matchString("*mirrored*", true)) {
uint mirrored;
sscanf(line.c_str(), "%*[^:]:%u~", &mirrored);
_mirrored = mirrored == 0 ? false : true;
} else if (line.matchString("*frames*", true)) {
sscanf(line.c_str(), "%*[^:]:%u~", &_frameCount);
_frameInfo = new FrameInfo[_frameCount];
} else if (line.matchString("*elsewhere*", true)) {
// Not used
} else if (line.matchString("*out_of_control*", true)) {
// Not used
} else if (line.matchString("*start_pos*", true)) {
sscanf(line.c_str(), "%*[^:]:%u~", &_startFrame);
_currentFrame = _startFrame;
} else if (line.matchString("*hotspot_deltas*", true)) {
uint x;
uint y;
sscanf(line.c_str(), "%*[^:]:%u %u~", &x, &y);
_hotspotDelta.x = x;
_hotspotDelta.y = y;
} else {
uint frameNumber;
uint x, y;
if (sscanf(line.c_str(), "%u:%u %u", &frameNumber, &x, &y) == 3) {
_frameInfo[frameNumber].hotspot.left = x;
_frameInfo[frameNumber].hotspot.top = y;
_frameInfo[frameNumber].hotspot.right = x + _hotspotDelta.x;
_frameInfo[frameNumber].hotspot.bottom = y + _hotspotDelta.y;
}
Common::StringTokenizer tokenizer(line, " ^=()");
tokenizer.nextToken();
tokenizer.nextToken();
Common::String token = tokenizer.nextToken();
while (!tokenizer.empty()) {
if (token == "D") {
token = tokenizer.nextToken();
uint angle;
uint toFrame;
sscanf(token.c_str(), "%u,%u", &toFrame, &angle);
_frameInfo[frameNumber].directions.push_back(Direction(angle, toFrame));
} else if (token.hasPrefix("P")) {
// Format: P(<from> to <to>)
tokenizer.nextToken();
tokenizer.nextToken();
token = tokenizer.nextToken();
uint to = atoi(token.c_str());
_frameInfo[frameNumber].returnRoute.push_back(to);
}
token = tokenizer.nextToken();
}
}
line = file.readLine();
}
//.........这里部分代码省略.........
示例9: stream
void HiRes1Engine::runIntro() const {
StreamPtr stream(_files->createReadStream(IDS_HR1_EXE_0));
stream->seek(IDI_HR1_OFS_LOGO_0);
_display->setMode(DISPLAY_MODE_HIRES);
_display->loadFrameBuffer(*stream);
_display->updateHiResScreen();
delay(4000);
if (shouldQuit())
return;
_display->setMode(DISPLAY_MODE_TEXT);
StreamPtr basic(_files->createReadStream(IDS_HR1_LOADER));
Common::String str;
str = readStringAt(*basic, IDI_HR1_OFS_PD_TEXT_0, '"');
_display->printAsciiString(str + '\r');
str = readStringAt(*basic, IDI_HR1_OFS_PD_TEXT_1, '"');
_display->printAsciiString(str + "\r\r");
str = readStringAt(*basic, IDI_HR1_OFS_PD_TEXT_2, '"');
_display->printAsciiString(str + "\r\r");
str = readStringAt(*basic, IDI_HR1_OFS_PD_TEXT_3, '"');
_display->printAsciiString(str + '\r');
inputKey();
if (g_engine->shouldQuit())
return;
_display->setMode(DISPLAY_MODE_MIXED);
str = readStringAt(*stream, IDI_HR1_OFS_GAME_OR_HELP);
bool instructions = false;
while (1) {
_display->printString(str);
Common::String s = inputString();
if (g_engine->shouldQuit())
break;
if (s.empty())
continue;
if (s[0] == APPLECHAR('I')) {
instructions = true;
break;
} else if (s[0] == APPLECHAR('G')) {
break;
}
};
if (instructions) {
_display->setMode(DISPLAY_MODE_TEXT);
stream->seek(IDI_HR1_OFS_INTRO_TEXT);
const uint pages[] = { 6, 6, 4, 5, 8, 7, 0 };
uint page = 0;
while (pages[page] != 0) {
_display->home();
uint count = pages[page++];
for (uint i = 0; i < count; ++i) {
str = readString(*stream);
_display->printString(str);
stream->seek(3, SEEK_CUR);
}
inputString();
if (g_engine->shouldQuit())
return;
stream->seek(6, SEEK_CUR);
}
}
_display->printAsciiString("\r");
_display->setMode(DISPLAY_MODE_MIXED);
// Title screen shown during loading
stream.reset(_files->createReadStream(IDS_HR1_EXE_1));
stream->seek(IDI_HR1_OFS_LOGO_1);
_display->loadFrameBuffer(*stream);
_display->updateHiResScreen();
delay(2000);
}
示例10: splitString
void MacText::splitString(Common::String &str) {
const char *s = str.c_str();
Common::String tmp;
bool prevCR = false;
if (_textLines.empty()) {
_textLines.resize(1);
_textLines[0].chunks.push_back(_defaultFormatting);
}
int curLine = _textLines.size() - 1;
int curChunk = _textLines[curLine].chunks.size() - 1;
bool nextChunk = false;
MacFontRun previousFormatting;
while (*s) {
#if DEBUG
for (uint i = 0; i < _textLines.size(); i++) {
debugN(7, "%2d ", i);
for (uint j = 0; j < _textLines[i].chunks.size(); j++)
debugN(7, "[%d] \"%s\"", _textLines[i].chunks[j].fontId, _textLines[i].chunks[j].text.c_str());
debug(7, " --> %c %d, '%s'", (*s > 0x20 ? *s : ' '), (byte)*s, tmp.c_str());
}
#endif
if (*s == '\001') {
s++;
if (*s == '\001') {
// Copy it verbatim
} else {
if (*s++ != '\015')
error("MacText: formatting error");
uint16 fontId = *s++; fontId = (fontId << 8) | *s++;
byte textSlant = *s++;
byte unk3f = *s++;
uint16 fontSize = *s++; fontSize = (fontSize << 8) | *s++;
uint16 palinfo1 = *s++; palinfo1 = (palinfo1 << 8) | *s++;
uint16 palinfo2 = *s++; palinfo2 = (palinfo2 << 8) | *s++;
uint16 palinfo3 = *s++; palinfo3 = (palinfo3 << 8) | *s++;
debug(8, "******** splitString: fontId: %d, textSlant: %d, unk3: %d, fontSize: %d, p0: %x p1: %x p2: %x",
fontId, textSlant, unk3f, fontSize, palinfo1, palinfo2, palinfo3);
previousFormatting = _currentFormatting;
_currentFormatting.setValues(_wm, fontId, textSlant, unk3f, fontSize, palinfo1, palinfo2, palinfo3);
if (curLine == 0 && curChunk == 0 && tmp.empty())
previousFormatting = _currentFormatting;
nextChunk = true;
}
} else if (*s == '\n' && prevCR) { // trean \r\n as one
prevCR = false;
s++;
continue;
} else if (*s == '\r') {
prevCR = true;
}
if (*s == '\r' || *s == '\n' || nextChunk) {
Common::Array<Common::String> text;
if (!nextChunk)
previousFormatting = _currentFormatting;
int w = getLineWidth(curLine, true);
previousFormatting.getFont()->wordWrapText(tmp, _maxWidth, text, w);
tmp.clear();
if (text.size()) {
for (uint i = 0; i < text.size(); i++) {
_textLines[curLine].chunks[curChunk].text = text[i];
if ((text.size() > 1 || !nextChunk) && !(i == text.size() - 1 && nextChunk)) {
curLine++;
_textLines.resize(curLine + 1);
_textLines[curLine].chunks.push_back(previousFormatting);
curChunk = 0;
}
}
if (nextChunk) {
curChunk++;
_textLines[curLine].chunks.push_back(_currentFormatting);
} else {
_textLines[curLine].chunks[0] = _currentFormatting;
}
} else {
if (nextChunk) { // No text, replacing formatting
_textLines[curLine].chunks[curChunk] = _currentFormatting;
} else { // Otherwise it is an empty line
curLine++;
_textLines.resize(curLine + 1);
//.........这里部分代码省略.........
示例11: run
Common::Error GroovieEngine::run() {
// Initialize the graphics
initGraphics(640, 480, true);
// Create debugger. It requires GFX to be initialized
_debugger = new Debugger(this);
_script.setDebugger(_debugger);
// Create the graphics manager
_graphicsMan = new GraphicsMan(this);
// Create the resource and cursor managers and the video player
switch (_gameDescription->version) {
case kGroovieT7G:
_resMan = new ResMan_t7g();
_grvCursorMan = new GrvCursorMan_t7g(_system);
_videoPlayer = new VDXPlayer(this);
break;
case kGroovieV2:
_resMan = new ResMan_v2();
_grvCursorMan = new GrvCursorMan_v2(_system);
_videoPlayer = new ROQPlayer(this);
break;
}
// Create the music player
if (_gameDescription->desc.platform == Common::kPlatformMacintosh) {
_musicPlayer = new MusicPlayerMac(this);
} else {
_musicPlayer = new MusicPlayerXMI(this, _gameDescription->version == kGroovieT7G ? "fat" : "sample");
}
// Load volume levels
syncSoundSettings();
// Get the name of the main script
Common::String filename = _gameDescription->desc.filesDescriptions[0].fileName;
if (_gameDescription->version == kGroovieT7G) {
// Run The 7th Guest's demo if requested
if (ConfMan.hasKey("demo_mode") && ConfMan.getBool("demo_mode")) {
filename = Common::String("demo.grv");
}
} else if (_gameDescription->version == kGroovieV2) {
// Open the disk index
Common::File disk;
if (!disk.open(filename)) {
error("Couldn't open %s", filename.c_str());
return Common::kNoGameDataFoundError;
}
// Search the entry
bool found = false;
int index = 0;
while (!found && !disk.eos()) {
Common::String line = disk.readLine();
if (line.hasPrefix("title: ")) {
// A new entry
index++;
} else if (line.hasPrefix("boot: ") && index == _gameDescription->indexEntry) {
// It's the boot of the entry we're looking for,
// get the script filename
filename = line.c_str() + 6;
found = true;
}
}
// Couldn't find the entry
if (!found) {
error("Couldn't find entry %d in %s", _gameDescription->indexEntry, filename.c_str());
return Common::kUnknownError;
}
}
// Check the script file extension
if (!filename.hasSuffix(".grv")) {
error("%s isn't a valid script filename", filename.c_str());
return Common::kUnknownError;
}
// Load the script
if (!_script.loadScript(filename)) {
error("Couldn't load the script file %s", filename.c_str());
return Common::kUnknownError;
}
// Should I load a saved game?
if (ConfMan.hasKey("save_slot")) {
// Get the requested slot
int slot = ConfMan.getInt("save_slot");
_script.directGameLoad(slot);
}
// Check that the game files and the audio tracks aren't together run from
// the same cd
checkCD();
// Game timer counter
uint16 tmr = 0;
// Initialize the CD
//.........这里部分代码省略.........
示例12: open
bool InstallerArchive::open(const Common::String &filename) {
close();
_stream = SearchMan.createReadStreamForMember(filename);
if (!_stream)
return false;
// Check for the magic uint32
// No idea what it means, but it's how "file" recognizes them
if (_stream->readUint32BE() != 0x135D658C) {
close();
return false;
}
// Let's move to the directory
_stream->seek(41);
uint32 offset = _stream->readUint32LE();
_stream->seek(offset);
// Now read in each file from the directory
uint16 fileCount = _stream->readUint16LE();
debug(2, "File count = %d", fileCount);
_stream->skip(9);
Common::Array<DirectoryEntry> directories;
for (uint16 i = 0; i < fileCount;) {
uint16 dirFileCount = _stream->readUint16LE();
if (dirFileCount == 0) {
// We've found a file
FileEntry entry;
_stream->skip(1); // Unknown
entry.uncompressedSize = _stream->readUint32LE();
entry.compressedSize = _stream->readUint32LE();
entry.offset = _stream->readUint32LE();
_stream->skip(14); // Unknown
byte nameLength = _stream->readByte();
Common::String name;
while (nameLength--)
name += _stream->readByte();
_stream->skip(13); // Unknown
_map[name] = entry;
i++;
debug(3, "Found file '%s' at 0x%08x (Comp: 0x%08x, Uncomp: 0x%08x)", name.c_str(),
entry.offset, entry.compressedSize, entry.uncompressedSize);
} else {
// We've found a directory
DirectoryEntry dirEntry;
dirEntry.fileCount = dirFileCount;
/* uint16 entrySize = */ _stream->readUint16LE();
uint16 nameLength = _stream->readUint16LE();
while (nameLength--)
dirEntry.name += _stream->readByte();
directories.push_back(dirEntry);
_stream->skip(5); // Unknown
debug(3, "Ignoring directory '%s'", dirEntry.name.c_str());
}
}
// TODO: Handle files in directories
// Per directory found follows DirectoryEntry::fileCount files
return true;
}
示例13: addCode
void Lingo::addCode(const char *code, ScriptType type, uint16 id) {
debugC(2, kDebugLingoCompile, "Add code \"%s\" for type %d with id %d", code, type, id);
if (_scripts[type].contains(id)) {
delete _scripts[type][id];
}
_currentScript = new ScriptData;
_currentScriptType = type;
_scripts[type][id] = _currentScript;
_linenumber = _colnumber = 1;
_hadError = false;
const char *begin, *end;
if (!strncmp(code, "menu:", 5)) {
debugC(2, kDebugLingoCompile, "Parsing menu");
parseMenu(code);
return;
}
// macros and factories have conflicting grammar. Thus we ease life for the parser.
if ((begin = findNextDefinition(code))) {
bool first = true;
while ((end = findNextDefinition(begin + 1))) {
if (first) {
begin = code;
first = false;
}
Common::String chunk(begin, end);
if (chunk.hasPrefix("factory") || chunk.hasPrefix("method"))
_inFactory = true;
else if (chunk.hasPrefix("macro"))
_inFactory = false;
else
_inFactory = false;
debugC(2, kDebugLingoCompile, "Code chunk:\n#####\n%s#####", chunk.c_str());
parse(chunk.c_str());
if (debugChannelSet(3, kDebugLingoCompile)) {
uint pc = 0;
while (pc < _currentScript->size()) {
Common::String instr = decodeInstruction(pc, &pc);
debugC(3, kDebugLingoCompile, "[%5d] %s", pc, instr.c_str());
}
}
_currentScript->clear();
begin = end;
}
_hadError = true; // HACK: This is for preventing test execution
debugC(2, kDebugLingoCompile, "Code chunk:\n#####\n%s#####", begin);
parse(begin);
} else {
parse(code);
code1(STOP);
}
_inFactory = false;
if (debugChannelSet(3, kDebugLingoCompile)) {
if (_currentScript->size() && !_hadError)
Common::hexdump((byte *)&_currentScript->front(), _currentScript->size() * sizeof(inst));
uint pc = 0;
while (pc < _currentScript->size()) {
Common::String instr = decodeInstruction(pc, &pc);
debugC(3, kDebugLingoCompile, "[%5d] %s", pc, instr.c_str());
}
}
}
示例14: writeString
void OutputPersistenceBlock::writeString(const Common::String &string) {
writeMarker(STRING_MARKER);
write(string.size());
rawWrite(string.c_str(), string.size());
}
示例15: selectDirectories
bool DownloadDialog::selectDirectories() {
if (Networking::Connection::isLimited()) {
MessageDialog alert(_("It looks like your connection is limited. "
"Do you really want to download files with it?"), _("Yes"), _("No"));
if (alert.runModal() != GUI::kMessageOK)
return false;
}
//first user should select remote directory to download
if (_remoteBrowser->runModal() <= 0)
return false;
Cloud::StorageFile remoteDirectory = _remoteBrowser->getResult();
//now user should select local directory to download into
if (_browser->runModal() <= 0)
return false;
Common::FSNode dir(_browser->getResult());
Common::FSList files;
if (!dir.getChildren(files, Common::FSNode::kListAll)) {
MessageDialog alert(_("ScummVM couldn't open the specified directory!"));
alert.runModal();
return false;
}
//check that there is no file with the remote directory's name in the local one
for (Common::FSList::iterator i = files.begin(); i != files.end(); ++i) {
if (i->getName().equalsIgnoreCase(remoteDirectory.name())) {
//if there is, ask user whether it's OK
if (!i->isDirectory()) {
GUI::MessageDialog alert(_("Cannot create a directory to download - the specified directory has a file with the same name."), _("OK"));
alert.runModal();
return false;
}
GUI::MessageDialog alert(
Common::String::format(_("The \"%s\" already exists in the specified directory.\nDo you really want to download files into that directory?"), remoteDirectory.name().c_str()),
_("Yes"),
_("No")
);
if (alert.runModal() != GUI::kMessageOK)
return false;
break;
}
}
//make a local path
Common::String localPath = dir.getPath();
//simple heuristic to determine which path separator to use
if (localPath.size() && localPath.lastChar() != '/' && localPath.lastChar() != '\\') {
int backslashes = 0;
for (uint32 i = 0; i < localPath.size(); ++i)
if (localPath[i] == '/')
--backslashes;
else if (localPath[i] == '\\')
++backslashes;
if (backslashes > 0)
localPath += '\\' + remoteDirectory.name();
else
localPath += '/' + remoteDirectory.name();
} else {
localPath += remoteDirectory.name();
}
CloudMan.startDownload(remoteDirectory.path(), localPath);
CloudMan.setDownloadTarget(this);
_localDirectory = localPath;
return true;
}