本文整理汇总了C++中common::SeekableReadStream::readLine方法的典型用法代码示例。如果您正苦于以下问题:C++ SeekableReadStream::readLine方法的具体用法?C++ SeekableReadStream::readLine怎么用?C++ SeekableReadStream::readLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::SeekableReadStream
的用法示例。
在下文中一共展示了SeekableReadStream::readLine方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
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);
}
示例2: parsePuzzle
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);
}
}
示例3: Control
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);
}
示例4: parseFlags
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;
}
示例5: SourceListing
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;
}
}
示例6: getGameInfo
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;
}
示例7: Control
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);
}
}
示例8: dumpEveryResultAction
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);
//.........这里部分代码省略.........
示例9: parseResults
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();
//.........这里部分代码省略.........
示例10: Control
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);
}