示例#1
0
SaveControl::SaveControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
	: Control(engine, key, CONTROL_SAVE),
	  _saveControl(false) {
	// Loop until we find the closing brace
	Common::String line = stream.readLine();
	trimCommentsAndWhiteSpace(&line);
	Common::String param;
	Common::String values;
	getParams(line, param, values);

	while (!stream.eos() && !line.contains('}')) {
		if (param.matchString("savebox", true)) {
			int saveId;
			int inputId;

			sscanf(values.c_str(), "%d %d", &saveId, &inputId);
			saveElement elmnt;
			elmnt.inputKey = inputId;
			elmnt.saveId = saveId;
			elmnt.exist = false;
			_inputs.push_back(elmnt);
		} else if (param.matchString("control_type", true)) {
			if (values.contains("save"))
				_saveControl = true;
			else
				_saveControl = false;
		}

		line = stream.readLine();
		trimCommentsAndWhiteSpace(&line);
		getParams(line, param, values);
	}

	for (saveElmntList::iterator iter = _inputs.begin(); iter != _inputs.end(); ++iter) {
		Control *ctrl = _engine->getScriptManager()->getControl(iter->inputKey);
		if (ctrl && ctrl->getType() == Control::CONTROL_INPUT) {
			InputControl *inp = (InputControl *)ctrl;
			inp->setReadOnly(!_saveControl);
			Common::SeekableReadStream *save = _engine->getSaveManager()->getSlotFile(iter->saveId);
			if (save) {
				SaveGameHeader header;
				_engine->getSaveManager()->readSaveGameHeader(save, header);
				delete save;
				inp->setText(header.saveName);
				iter->exist = true;
			}
		}
	}
}
示例#2
0
void Lua_V1::TextFileGetLine() {
	char textBuf[1000];
	lua_Object nameObj = lua_getparam(1);
	lua_Object posObj = lua_getparam(2);
	Common::SeekableReadStream *file;

	if (lua_isnil(nameObj) || lua_isnil(posObj)) {
		lua_pushnil();
		return;
	}

	const char *filename = lua_getstring(nameObj);
	Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
	file = saveFileMan->openForLoading(filename);
	if (!file) {
		lua_pushnil();
		return;
	}

	int pos = (int)lua_getnumber(posObj);
	file->seek(pos, SEEK_SET);
	memset(textBuf, 0, 1000);
	file->readLine(textBuf, 1000);
	delete file;

	lua_pushstring(textBuf);
}
示例#3
0
void ScriptManager::parsePuzzle(Puzzle *puzzle, Common::SeekableReadStream &stream) {
	Common::String line = stream.readLine();
	trimCommentsAndWhiteSpace(&line);

	while (!stream.eos() && !line.contains('}')) {
		if (line.matchString("criteria {", true)) {
			parseCriteria(stream, puzzle->criteriaList);
		} else if (line.matchString("results {", true)) {
			parseResults(stream, puzzle->resultActions);
		} else if (line.matchString("flags {", true)) {
			setStateFlags(puzzle->key, parseFlags(stream));
		}

		line = stream.readLine();
		trimCommentsAndWhiteSpace(&line);
	}
}
示例#4
0
LeverControl::LeverControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
	: Control(engine, key, CONTROL_LEVER),
	  _frameInfo(0),
	  _frameCount(0),
	  _startFrame(0),
	  _currentFrame(0),
	  _lastRenderedFrame(0),
	  _mouseIsCaptured(false),
	  _isReturning(false),
	  _accumulatedTime(0),
	  _returnRoutesCurrentFrame(0),
	  _animation(NULL),
	  _cursor(CursorIndex_Active),
	  _mirrored(false) {

	// Loop until we find the closing brace
	Common::String line = stream.readLine();
	_engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);

	Common::String param;
	Common::String values;
	getParams(line, param, values);

	while (!stream.eos() && !line.contains('}')) {
		if (param.matchString("descfile", true)) {
			char levFileName[25];
			sscanf(values.c_str(), "%24s", levFileName);

			parseLevFile(levFileName);
		} else if (param.matchString("cursor", true)) {
			char cursorName[25];
			sscanf(values.c_str(), "%24s", cursorName);

			_cursor = _engine->getCursorManager()->getCursorId(Common::String(cursorName));
		}

		line = stream.readLine();
		_engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
		getParams(line, param, values);
	}

	renderFrame(_currentFrame);
}
示例#5
0
uint ScriptManager::parseFlags(Common::SeekableReadStream &stream) const {
	uint flags = 0;

	// Loop until we find the closing brace
	Common::String line = stream.readLine();
	trimCommentsAndWhiteSpace(&line);

	while (!stream.eos() && !line.contains('}')) {
		if (line.matchString("ONCE_PER_INST", true)) {
			flags |= ONCE_PER_INST;
		} else if (line.matchString("DO_ME_NOW", true)) {
			flags |= DO_ME_NOW;
		} else if (line.matchString("DISABLED", true)) {
			flags |= DISABLED;
		}

		line = stream.readLine();
		trimCommentsAndWhiteSpace(&line);
	}

	return flags;
}
示例#6
0
TitlerControl::TitlerControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
	: Control(engine, key, CONTROL_TITLER) {

	_surface = NULL;
	_curString = -1;

	// Loop until we find the closing brace
	Common::String line = stream.readLine();
	trimCommentsAndWhiteSpace(&line);
	Common::String param;
	Common::String values;
	getParams(line, param, values);

	while (!stream.eos() && !line.contains('}')) {
		if (param.matchString("string_resource_file", true)) {
			readStringsFile(values);
		} else if (param.matchString("rectangle", true)) {
			int x;
			int y;
			int x2;
			int y2;

			sscanf(values.c_str(), "%d %d %d %d", &x, &y, &x2, &y2);

			_rectangle = Common::Rect(x, y, x2, y2);
		}

		line = stream.readLine();
		trimCommentsAndWhiteSpace(&line);
		getParams(line, param, values);
	}

	if (!_rectangle.isEmpty()) {
		_surface = new Graphics::Surface;
		_surface->create(_rectangle.width(), _rectangle.height(), _engine->_pixelFormat);
		_surface->fillRect(Common::Rect(_surface->w, _surface->h), 0);
	}
}
SourceListing *BasicSourceListingProvider::getListing(const Common::String &filename, ErrorCode &_err) {
	_err = OK;
	if (!_fsDirectory) {
		_err = SOURCE_PATH_NOT_SET;
		return nullptr;
	};

	Common::String unixFilename;

	for (uint i = 0; i < filename.size(); i++) {
		if (filename[i] == '\\') {
			unixFilename.insertChar('/', unixFilename.size());
		}  else {
			unixFilename.insertChar(filename[i], unixFilename.size());
		}
	}

	Common::SeekableReadStream *file = _fsDirectory->createReadStreamForMember(unixFilename);
	Common::Array<Common::String> strings;

	if (!file) {
		_err = NO_SUCH_SOURCE;
	} else {
		if (file->err()) {
			_err = UNKNOWN_ERROR;
		}
		while (!file->eos()) {
			strings.push_back(file->readLine());
			if (file->err()) {
				_err = UNKNOWN_ERROR;
			}
		}
	}

	if (_err == OK) {
		return new SourceListing(strings);
	} else {
		return nullptr;
	}
}
示例#8
0
void Lua_V1::TextFileGetLineCount() {
	char textBuf[1000];
	lua_Object nameObj = lua_getparam(1);

	if (lua_isnil(nameObj)) {
		lua_pushnil();
		return;
	}

	const char *filename = luaL_check_string(1);
	Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
	Common::SeekableReadStream *file = saveFileMan->openForLoading(filename);
	if (!file) {
		lua_pushnil();
		return;
	}

	lua_Object result = lua_createtable();

	int line = 0;
	for (;;) {
		if (file->eos())
			break;
		lua_pushobject(result);
		lua_pushnumber(line);
		int pos = file->pos();
		lua_pushnumber(pos);
		lua_settable();
		file->readLine(textBuf, 1000);
		line++;
	}
	delete file;

	lua_pushobject(result);
	lua_pushstring("count");
	lua_pushnumber(line);
	lua_settable();
	lua_pushobject(result);
}
示例#9
0
/**
 * This test does the following:
 * 1) acquires the game-data path
 * 2) In the game-root it navigates to "directory" and opens the file "file"
 *
 * The code accesses the appropriate file using the fileSystem API, creates a read stream of it and
 * compares the message contained in it, with what it expects.
 *
 */
bool FStests::readDataFromFile(Common::FSDirectory *directory, const char *file) {

	Common::SeekableReadStream *readStream = directory->createReadStreamForMember(file);

	if (!readStream) {
		Testsuite::logDetailedPrintf("Can't open game file for reading\n");
		return false;
	}

	Common::String msg = readStream->readLine();
	delete readStream;

	Testsuite::logDetailedPrintf("Message Extracted from %s/%s : %s\n", directory->getFSNode().getName().c_str(), file, msg.c_str());

	Common::String expectedMsg = "It works!";

	if (!msg.equals(expectedMsg)) {
		Testsuite::logDetailedPrintf("Can't read Correct data from file\n");
		return false;
	}

	return true;
}
示例#10
0
/**
 * This test creates a file testbed.out, writes a sample data and confirms if
 * it is same by reading the file again.
 */
TestExitStatus FStests::testWriteFile() {
	const Common::String &path = ConfMan.get("path");
	Common::FSNode gameRoot(path);
	if (!gameRoot.exists()) {
		Testsuite::logPrintf("Couldn't open the game data directory %s", path.c_str());
		 return kTestFailed;
	}

	Common::FSNode fileToWrite = gameRoot.getChild("testbed.out");

	Common::WriteStream *ws = fileToWrite.createWriteStream();

	if (!ws) {
		Testsuite::logDetailedPrintf("Can't open writable file in game data dir\n");
		 return kTestFailed;
	}

	ws->writeString("ScummVM Rocks!");
	ws->flush();
	delete ws;

	Common::SeekableReadStream *rs = fileToWrite.createReadStream();
	if (!rs) {
		Testsuite::logDetailedPrintf("Can't open recently written file testbed.out in game data dir\n");
		 return kTestFailed;
	}
	Common::String readFromFile = rs->readLine();
	delete rs;

	if (readFromFile.equals("ScummVM Rocks!")) {
		// All good
		Testsuite::logDetailedPrintf("Data written and read correctly\n");
		 return kTestPassed;
	}

	 return kTestFailed;
}
示例#11
0
PaintControl::PaintControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
    : Control(engine, key, CONTROL_PAINT) {

    _cursor = CursorIndex_Active;
    _paint = NULL;
    _bkg = NULL;
    _brush = NULL;
    _colorKey = 0;
    _mouseDown = false;

    // Loop until we find the closing brace
    Common::String line = stream.readLine();
    trimCommentsAndWhiteSpace(&line);
    Common::String param;
    Common::String values;
    getParams(line, param, values);

    while (!stream.eos() && !line.contains('}')) {
        if (param.matchString("rectangle", true)) {
            int x;
            int y;
            int width;
            int height;

            sscanf(values.c_str(), "%d %d %d %d", &x, &y, &width, &height);

            _rectangle = Common::Rect(x, y, width + x, height + y);
        } else if (param.matchString("cursor", true)) {
            _cursor = _engine->getCursorManager()->getCursorId(values);
        } else if (param.matchString("brush_file", true)) {
            _brush = _engine->getRenderManager()->loadImage(values, false);
        } else if (param.matchString("venus_id", true)) {
            _venusId = atoi(values.c_str());
        } else if (param.matchString("paint_file", true)) {
            _paint = _engine->getRenderManager()->loadImage(values, false);
        } else if (param.matchString("eligible_objects", true)) {
            char buf[256];
            memset(buf, 0, 256);
            strcpy(buf, values.c_str());

            char *curpos = buf;
            char *strend = buf + strlen(buf);
            while (true) {
                char *st = curpos;

                if (st >= strend)
                    break;

                while (*curpos != ' ' && curpos < strend)
                    curpos++;

                *curpos = 0;
                curpos++;

                int obj = atoi(st);

                _eligibleObjects.push_back(obj);
            }
        }

        line = stream.readLine();
        trimCommentsAndWhiteSpace(&line);
        getParams(line, param, values);
    }

    if (_paint) {
        _colorKey = _paint->format.RGBToColor(255, 0, 255);
        _bkg = new Graphics::Surface;
        _bkg->create(_rectangle.width(), _rectangle.height(), _paint->format);
        _bkg->fillRect(Common::Rect(_rectangle.width(), _rectangle.height()), _colorKey);

        Graphics::Surface *tmp = new Graphics::Surface;
        tmp->create(_rectangle.width(), _rectangle.height(), _paint->format);
        _engine->getRenderManager()->blitSurfaceToSurface(*_paint, _rectangle, *tmp, 0, 0);
        _paint->free();
        delete _paint;
        _paint = tmp;
    }
}
示例#12
0
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));

		strcpy(_vm->_game->_curTotFile, _vm->_startTot.c_str());

		_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) {
					_vm->_video->drawPackedSprite(sprite, 320, 200, 0, 0, 0,
							*_vm->_draw->_frontSurface);
					_vm->_palAnim->fade(_palDesc, 0, 0);
					_vm->_util->delay(500);

					delete[] sprite;
				}

				_vm->_draw->closeScreen();
			}
		}

		_vm->_game->start();

		_vm->_sound->cdStop();
		_vm->_sound->cdUnloadLIC();

	}

	delete _palDesc;
	_vm->_dataIO->closeArchive(true);
	_vm->_video->initPrimary(-1);
	cleanup();
}
示例#13
0
InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
	: Control(engine, key, CONTROL_INPUT),
	  _nextTabstop(0),
	  _focused(false),
	  _textChanged(false),
	  _cursorOffset(0),
	  _enterPressed(false),
	  _readOnly(false),
	  _txtWidth(0),
	  _animation(NULL) {
	// Loop until we find the closing brace
	Common::String line = stream.readLine();
	trimCommentsAndWhiteSpace(&line);
	Common::String param;
	Common::String values;
	getParams(line, param, values);

	while (!stream.eos() && !line.contains('}')) {
		if (param.matchString("rectangle", true)) {
			int x1;
			int y1;
			int x2;
			int y2;

			sscanf(values.c_str(), "%d %d %d %d", &x1, &y1, &x2, &y2);

			_textRectangle = Common::Rect(x1, y1, x2, y2);
		} else if (param.matchString("aux_hotspot", true)) {
			int x1;
			int y1;
			int x2;
			int y2;

			sscanf(values.c_str(), "%d %d %d %d", &x1, &y1, &x2, &y2);

			_headerRectangle = Common::Rect(x1, y1, x2, y2);
		} else if (param.matchString("string_init", true)) {
			uint fontFormatNumber;

			sscanf(values.c_str(), "%u", &fontFormatNumber);

			_stringInit.readAllStyle(_engine->getStringManager()->getTextLine(fontFormatNumber));
		} else if (param.matchString("chooser_init_string", true)) {
			uint fontFormatNumber;

			sscanf(values.c_str(), "%u", &fontFormatNumber);

			_stringChooserInit.readAllStyle(_engine->getStringManager()->getTextLine(fontFormatNumber));
		} else if (param.matchString("next_tabstop", true)) {
			sscanf(values.c_str(), "%u", &_nextTabstop);
		} else if (param.matchString("cursor_dimensions", true)) {
			// Ignore, use the dimensions in the animation file
		} else if (param.matchString("cursor_animation_frames", true)) {
			// Ignore, use the frame count in the animation file
		} else if (param.matchString("cursor_animation", true)) {
			char fileName[25];

			sscanf(values.c_str(), "%25s %*u", fileName);

			_animation = new MetaAnimation(fileName, _engine);
			_frame = -1;
			_frameDelay = 0;
		} else if (param.matchString("focus", true)) {
			_focused = true;
			_engine->getScriptManager()->setFocusControlKey(_key);
		} else if (param.matchString("venus_id", true)) {
			_venusId = atoi(values.c_str());
		}

		line = stream.readLine();
		trimCommentsAndWhiteSpace(&line);
		getParams(line, param, values);
	}
}
示例#14
0
bool WintermuteEngine::getGameInfo(const Common::FSList &fslist, Common::String &name, Common::String &caption) {
	bool retVal = false;
	caption = name = "(invalid)";
	Common::SeekableReadStream *stream = NULL;
	// Quick-fix, instead of possibly breaking the persistence-system, let's just roll with it
	BaseFileManager *fileMan = new BaseFileManager(Common::UNK_LANG);
	fileMan->registerPackages(fslist);
	stream = fileMan->openFile("startup.settings", false, false);

	// The process is as follows: Check the "GAME=" tag in startup.settings, to decide where the
	// game-settings are (usually "default.game"), then look into the game-settings to find
	// the NAME = and CAPTION = tags, to use them to generate a gameid and extras-field

	Common::String settingsGameFile = "default.game";
	// If the stream-open failed, lets at least attempt to open the default game file afterwards
	// so, we don't call it a failure yet.
	if (stream) {
		while (!stream->eos() && !stream->err()) {
			Common::String line = stream->readLine();
			line.trim(); // Get rid of indentation
			// Expect "SETTINGS {" or comment, or empty line
			if (line.size() == 0 || line[0] == ';' || (line.contains("{"))) {
				continue;
			} else {
				// We are looking for "GAME ="
				Common::StringTokenizer token(line, "=");
				Common::String key = token.nextToken();
				Common::String value = token.nextToken();
				if (value.size() == 0) {
					continue;
				}
				if (value[0] == '\"') {
					value.deleteChar(0);
				} else {
					continue;
				}
				if (value.lastChar() == '\"') {
					value.deleteLastChar();
				}
				if (key == "GAME") {
					settingsGameFile = value;
					break;
				}
			}
		}
	}

	delete stream;
	stream = fileMan->openFile(settingsGameFile, false, false);
	if (stream) {
		// We do some manual parsing here, as the engine needs gfx to be initalized to do that.
		while (!stream->eos() && !stream->err()) {
			Common::String line = stream->readLine();
			line.trim(); // Get rid of indentation
			// Expect "GAME {" or comment, or empty line
			if (line.size() == 0 || line[0] == ';' || (line.contains("{"))) {
				continue;
			} else {
				Common::StringTokenizer token(line, "=");
				Common::String key = token.nextToken();
				Common::String value = token.nextToken();
				if (value.size() == 0) {
					continue;
				}
				if (value[0] == '\"') {
					value.deleteChar(0);
				} else {
					continue;    // not a string
				}
				if (value.lastChar() == '\"') {
					value.deleteLastChar();
				}
				if (key == "NAME") {
					retVal = true;
					name = value;
				} else if (key == "CAPTION") {
					retVal = true;
					caption = value;
				}
			}
		}
		delete stream;
	}
	delete fileMan;
	BaseEngine::destroy();
	return retVal;
}
示例#15
0
SlotControl::SlotControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
	: Control(engine, key, CONTROL_SLOT),
	  _cursor(CursorIndex_Active),
	  _distanceId('0') {

	_renderedItem = 0;
	_bkg = NULL;

	// Loop until we find the closing brace
	Common::String line = stream.readLine();
	_engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
	Common::String param;
	Common::String values;
	getParams(line, param, values);

	while (!stream.eos() && !line.contains('}')) {
		if (param.matchString("hotspot", true)) {
			int x;
			int y;
			int width;
			int height;

			sscanf(values.c_str(), "%d %d %d %d", &x, &y, &width, &height);

			_hotspot = Common::Rect(x, y, width, height);
		} else if (param.matchString("rectangle", true)) {
			int x;
			int y;
			int width;
			int height;

			sscanf(values.c_str(), "%d %d %d %d", &x, &y, &width, &height);

			_rectangle = Common::Rect(x, y, width, height);
		} else if (param.matchString("cursor", true)) {
			_cursor = _engine->getCursorManager()->getCursorId(values);
		} else if (param.matchString("distance_id", true)) {
			sscanf(values.c_str(), "%c", &_distanceId);
		} else if (param.matchString("venus_id", true)) {
			_venusId = atoi(values.c_str());
		} else if (param.matchString("eligible_objects", true)) {
			char buf[256];
			memset(buf, 0, 256);
			strncpy(buf, values.c_str(), 255);

			char *curpos = buf;
			char *strend = buf + strlen(buf);
			while (true) {
				char *st = curpos;

				if (st >= strend)
					break;

				while (*curpos != ' ' && curpos < strend)
					curpos++;

				*curpos = 0;
				curpos++;

				int obj = atoi(st);

				_eligibleObjects.push_back(obj);
			}
		}

		line = stream.readLine();
		_engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
		getParams(line, param, values);
	}

	if (_hotspot.isEmpty() || _rectangle.isEmpty()) {
		warning("Slot %u was parsed incorrectly", key);
	}
}
示例#16
0
void dumpEveryResultAction(const Common::String &destFile) {
	Common::HashMap<Common::String, byte> count;
	Common::HashMap<Common::String, bool> fileAlreadyUsed;

	Common::DumpFile output;
	output.open(destFile);

	// Find scr files
	Common::ArchiveMemberList list;
	SearchMan.listMatchingMembers(list, "*.scr");

	for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) {
		Common::SeekableReadStream *stream = (*iter)->createReadStream();

		Common::String line = stream->readLine();
		trimCommentsAndWhiteSpace(&line);

		while (!stream->eos()) {
			if (line.matchString("*:add*", true)) {
				tryToDumpLine("add", line, &count, &fileAlreadyUsed, output);
			} else if (line.matchString("*:animplay*", true)) {
				tryToDumpLine("animplay", line, &count, &fileAlreadyUsed, output);
			} else if (line.matchString("*:animpreload*", true)) {
				tryToDumpLine("animpreload", line, &count, &fileAlreadyUsed, output);
			} else if (line.matchString("*:animunload*", true)) {
				tryToDumpLine("animunload", line, &count, &fileAlreadyUsed, output);
			} else if (line.matchString("*:attenuate*", true)) {
				tryToDumpLine("attenuate", line, &count, &fileAlreadyUsed, output);
			} else if (line.matchString("*:assign*", true)) {
				tryToDumpLine("assign", line, &count, &fileAlreadyUsed, output);
			} else if (line.matchString("*:change_location*", true)) {
				tryToDumpLine("change_location", line, &count, &fileAlreadyUsed, output);
			} else if (line.matchString("*:crossfade*", true) && !fileAlreadyUsed["add"]) {
				tryToDumpLine("crossfade", line, &count, &fileAlreadyUsed, output);
			} else if (line.matchString("*:debug*", true)) {
				tryToDumpLine("debug", line, &count, &fileAlreadyUsed, output);
			} else if (line.matchString("*:delay_render*", true)) {
				tryToDumpLine("delay_render", line, &count, &fileAlreadyUsed, output);
			} else if (line.matchString("*:disable_control*", true)) {
				tryToDumpLine("disable_control", line, &count, &fileAlreadyUsed, output);
			} else if (line.matchString("*:disable_venus*", true)) {
				tryToDumpLine("disable_venus", line, &count, &fileAlreadyUsed, output);
			} else if (line.matchString("*:display_message*", true)) {
				tryToDumpLine("display_message", line, &count, &fileAlreadyUsed, output);
			} else if (line.matchString("*:dissolve*", true)) {
				tryToDumpLine("dissolve", line, &count, &fileAlreadyUsed, output);
			} else if (line.matchString("*:distort*", true)) {
				tryToDumpLine("distort", line, &count, &fileAlreadyUsed, output);
			} else if (line.matchString("*:enable_control*", true)) {
				tryToDumpLine("enable_control", line, &count, &fileAlreadyUsed, output);
			} else if (line.matchString("*:flush_mouse_events*", true)) {
				tryToDumpLine("flush_mouse_events", line, &count, &fileAlreadyUsed, output);
			} else if (line.matchString("*:inventory*", true)) {
				tryToDumpLine("inventory", line, &count, &fileAlreadyUsed, output);
			} else if (line.matchString("*:kill*", true)) {
				tryToDumpLine("kill", line, &count, &fileAlreadyUsed, output);
			} else if (line.matchString("*:menu_bar_enable*", true)) {
				tryToDumpLine("menu_bar_enable", line, &count, &fileAlreadyUsed, output);
			} else if (line.matchString("*:music*", true)) {
				tryToDumpLine("music", line, &count, &fileAlreadyUsed, output);
			} else if (line.matchString("*:pan_track*", true)) {
				tryToDumpLine("pan_track", line, &count, &fileAlreadyUsed, output);
			} else if (line.matchString("*:playpreload*", true)) {
				tryToDumpLine("playpreload", line, &count, &fileAlreadyUsed, output);
			} else if (line.matchString("*:preferences*", true)) {
				tryToDumpLine("preferences", line, &count, &fileAlreadyUsed, output);
			} else if (line.matchString("*:quit*", true)) {
				tryToDumpLine("quit", line, &count, &fileAlreadyUsed, output);
			} else if (line.matchString("*:random*", true)) {
				tryToDumpLine("random", line, &count, &fileAlreadyUsed, output);
			} else if (line.matchString("*:region*", true)) {
				tryToDumpLine("region", line, &count, &fileAlreadyUsed, output);
			} else if (line.matchString("*:restore_game*", true)) {
				tryToDumpLine("restore_game", line, &count, &fileAlreadyUsed, output);
			} else if (line.matchString("*:rotate_to*", true)) {
				tryToDumpLine("rotate_to", line, &count, &fileAlreadyUsed, output);
			} else if (line.matchString("*:save_game*", true)) {
				tryToDumpLine("save_game", line, &count, &fileAlreadyUsed, output);
			} else if (line.matchString("*:set_partial_screen*", true)) {
				tryToDumpLine("set_partial_screen", line, &count, &fileAlreadyUsed, output);
			} else if (line.matchString("*:set_screen*", true)) {
				tryToDumpLine("set_screen", line, &count, &fileAlreadyUsed, output);
			} else if (line.matchString("*:set_venus*", true)) {
				tryToDumpLine("set_venus", line, &count, &fileAlreadyUsed, output);
			} else if (line.matchString("*:stop*", true)) {
				tryToDumpLine("stop", line, &count, &fileAlreadyUsed, output);
			} else if (line.matchString("*:streamvideo*", true)) {
				tryToDumpLine("streamvideo", line, &count, &fileAlreadyUsed, output);
			} else if (line.matchString("*:syncsound*", true)) {
				tryToDumpLine("syncsound", line, &count, &fileAlreadyUsed, output);
			} else if (line.matchString("*:timer*", true)) {
				tryToDumpLine("timer", line, &count, &fileAlreadyUsed, output);
			} else if (line.matchString("*:ttytext*", true)) {
				tryToDumpLine("ttytext", line, &count, &fileAlreadyUsed, output);
			} else if (line.matchString("*:universe_music*", true)) {
				tryToDumpLine("universe_music", line, &count, &fileAlreadyUsed, output);
			}

			line = stream->readLine();
			trimCommentsAndWhiteSpace(&line);
		}

		for (Common::HashMap<Common::String, bool>::iterator fileUsedIter = fileAlreadyUsed.begin(); fileUsedIter != fileAlreadyUsed.end(); ++fileUsedIter) {
			fileUsedIter->_value = false;
		}
	}

	output.close();
}
示例#17
0
void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::List<ResultAction *> &actionList) const {
	// Loop until we find the closing brace
	Common::String line = stream.readLine();
	trimCommentsAndWhiteSpace(&line);

	// TODO: Re-order the if-then statements in order of highest occurrence
	while (!stream.eos() && !line.contains('}')) {
		if (line.empty()) {
			line = stream.readLine();
			trimCommentsAndWhiteSpace(&line);

			continue;
		}

		// Parse for the action type
		if (line.matchString("*:add*", true)) {
			actionList.push_back(new ActionAdd(line));
		} else if (line.matchString("*:animplay*", true)) {
			actionList.push_back(new ActionPlayAnimation(line));
		} else if (line.matchString("*:animpreload*", true)) {
			actionList.push_back(new ActionPreloadAnimation(line));
		} else if (line.matchString("*:animunload*", true)) {
			//actionList.push_back(new ActionUnloadAnimation(line));
		} else if (line.matchString("*:attenuate*", true)) {
			// TODO: Implement ActionAttenuate
		} else if (line.matchString("*:assign*", true)) {
			actionList.push_back(new ActionAssign(line));
		} else if (line.matchString("*:change_location*", true)) {
			actionList.push_back(new ActionChangeLocation(line));
		} else if (line.matchString("*:crossfade*", true)) {
			// TODO: Implement ActionCrossfade
		} else if (line.matchString("*:debug*", true)) {
			// TODO: Implement ActionDebug
		} else if (line.matchString("*:delay_render*", true)) {
			// TODO: Implement ActionDelayRender
		} else if (line.matchString("*:disable_control*", true)) {
			actionList.push_back(new ActionDisableControl(line));
		} else if (line.matchString("*:disable_venus*", true)) {
			// TODO: Implement ActionDisableVenus
		} else if (line.matchString("*:display_message*", true)) {
			// TODO: Implement ActionDisplayMessage
		} else if (line.matchString("*:dissolve*", true)) {
			// TODO: Implement ActionDissolve
		} else if (line.matchString("*:distort*", true)) {
			// TODO: Implement ActionDistort
		} else if (line.matchString("*:enable_control*", true)) {
			actionList.push_back(new ActionEnableControl(line));
		} else if (line.matchString("*:flush_mouse_events*", true)) {
			// TODO: Implement ActionFlushMouseEvents
		} else if (line.matchString("*:inventory*", true)) {
			// TODO: Implement ActionInventory
		} else if (line.matchString("*:kill*", true)) {
			// TODO: Implement ActionKill
		} else if (line.matchString("*:menu_bar_enable*", true)) {
			// TODO: Implement ActionMenuBarEnable
		} else if (line.matchString("*:music*", true)) {
			actionList.push_back(new ActionMusic(line));
		} else if (line.matchString("*:pan_track*", true)) {
			// TODO: Implement ActionPanTrack
		} else if (line.matchString("*:playpreload*", true)) {
			actionList.push_back(new ActionPlayPreloadAnimation(line));
		} else if (line.matchString("*:preferences*", true)) {
			// TODO: Implement ActionPreferences
		} else if (line.matchString("*:quit*", true)) {
			actionList.push_back(new ActionQuit());
		} else if (line.matchString("*:random*", true)) {
			actionList.push_back(new ActionRandom(line));
		} else if (line.matchString("*:region*", true)) {
			// TODO: Implement ActionRegion
		} else if (line.matchString("*:restore_game*", true)) {
			// TODO: Implement ActionRestoreGame
		} else if (line.matchString("*:rotate_to*", true)) {
			// TODO: Implement ActionRotateTo
		} else if (line.matchString("*:save_game*", true)) {
			// TODO: Implement ActionSaveGame
		} else if (line.matchString("*:set_partial_screen*", true)) {
			actionList.push_back(new ActionSetPartialScreen(line));
		} else if (line.matchString("*:set_screen*", true)) {
			actionList.push_back(new ActionSetScreen(line));
		} else if (line.matchString("*:set_venus*", true)) {
			// TODO: Implement ActionSetVenus
		} else if (line.matchString("*:stop*", true)) {
			// TODO: Implement ActionStop
		} else if (line.matchString("*:streamvideo*", true)) {
			actionList.push_back(new ActionStreamVideo(line));
		} else if (line.matchString("*:syncsound*", true)) {
			// TODO: Implement ActionSyncSound
		} else if (line.matchString("*:timer*", true)) {
			actionList.push_back(new ActionTimer(line));
		} else if (line.matchString("*:ttytext*", true)) {
			// TODO: Implement ActionTTYText
		} else if (line.matchString("*:universe_music*", true)) {
			// TODO: Implement ActionUniverseMusic
		} else if (line.matchString("*:copy_file*", true)) {
			// Not used. Purposely left empty
		} else {
			warning("Unhandled result action type: %s", line.c_str());
		}

		line = stream.readLine();
		trimCommentsAndWhiteSpace(&line);
	}

	return;
}
示例#18
0
SafeControl::SafeControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
	: Control(engine, key, CONTROL_SAFE) {
	_statesCount = 0;
	_curState = 0;
	_animation = NULL;
	_innerRaduis = 0;
	_innerRadiusSqr = 0;
	_outerRadius = 0;
	_outerRadiusSqr = 0;
	_zeroPointer = 0;
	_startPointer = 0;
	_targetFrame = 0;

	// Loop until we find the closing brace
	Common::String line = stream.readLine();
	_engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
	Common::String param;
	Common::String values;
	getParams(line, param, values);

	while (!stream.eos() && !line.contains('}')) {
		if (param.matchString("animation", true)) {
			_animation = _engine->loadAnimation(values);
			_animation->start();
		} else if (param.matchString("rectangle", true)) {
			int x;
			int y;
			int width;
			int height;

			sscanf(values.c_str(), "%d %d %d %d", &x, &y, &width, &height);

			_rectangle = Common::Rect(x, y, width, height);
		} else if (param.matchString("num_states", true)) {
			_statesCount = atoi(values.c_str());
		} else if (param.matchString("center", true)) {
			int x;
			int y;

			sscanf(values.c_str(), "%d %d", &x, &y);
			_center = Common::Point(x, y);
		} else if (param.matchString("dial_inner_radius", true)) {
			_innerRaduis = atoi(values.c_str());
			_innerRadiusSqr = _innerRaduis * _innerRaduis;
		} else if (param.matchString("radius", true)) {
			_outerRadius = atoi(values.c_str());
			_outerRadiusSqr = _outerRadius * _outerRadius;
		} else if (param.matchString("zero_radians_offset", true)) {
			_zeroPointer = atoi(values.c_str());
		} else if (param.matchString("pointer_offset", true)) {
			_startPointer = atoi(values.c_str());
			_curState = _startPointer;
		} else if (param.matchString("cursor", true)) {
			// Not used
		} else if (param.matchString("mirrored", true)) {
			// Not used
		} else if (param.matchString("venus_id", true)) {
			_venusId = atoi(values.c_str());
		}

		line = stream.readLine();
		_engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
		getParams(line, param, values);
	}

	if (_animation)
		_animation->seekToFrame(_curState);
}