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


C++ BaseParser::scanStr方法代码示例

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


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

示例1: loadBuffer

TOKEN_DEF_END
//////////////////////////////////////////////////////////////////////////
bool AdScaleLevel::loadBuffer(byte *buffer, bool complete) {
	TOKEN_TABLE_START(commands)
	TOKEN_TABLE(SCALE_LEVEL)
	TOKEN_TABLE(TEMPLATE)
	TOKEN_TABLE(Y)
	TOKEN_TABLE(SCALE)
	TOKEN_TABLE(EDITOR_PROPERTY)
	TOKEN_TABLE_END

	byte *params;
	int cmd;
	BaseParser parser;

	if (complete) {
		if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_SCALE_LEVEL) {
			_gameRef->LOG(0, "'SCALE_LEVEL' keyword expected.");
			return STATUS_FAILED;
		}
		buffer = params;
	}

	while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)&params)) > 0) {
		switch (cmd) {
		case TOKEN_TEMPLATE:
			if (DID_FAIL(loadFile((char *)params))) {
				cmd = PARSERR_GENERIC;
			}
			break;

		case TOKEN_Y:
			parser.scanStr((char *)params, "%d", &_posY);
			break;

		case TOKEN_SCALE: {
			int i;
			parser.scanStr((char *)params, "%d", &i);
			_scale = (float)i;
		}
		break;

		case TOKEN_EDITOR_PROPERTY:
			parseEditorProperty(params, false);
			break;
		}
	}
	if (cmd == PARSERR_TOKENNOTFOUND) {
		_gameRef->LOG(0, "Syntax error in SCALE_LEVEL definition");
		return STATUS_FAILED;
	}

	return STATUS_OK;
}
开发者ID:MaddTheSane,项目名称:scummvm,代码行数:54,代码来源:ad_scale_level.cpp

示例2: loadBuffer

TOKEN_DEF_END
//////////////////////////////////////////////////////////////////////////
bool BaseRegion::loadBuffer(byte *buffer, bool complete) {
	TOKEN_TABLE_START(commands)
	TOKEN_TABLE(REGION)
	TOKEN_TABLE(TEMPLATE)
	TOKEN_TABLE(NAME)
	TOKEN_TABLE(ACTIVE)
	TOKEN_TABLE(POINT)
	TOKEN_TABLE(CAPTION)
	TOKEN_TABLE(SCRIPT)
	TOKEN_TABLE(EDITOR_SELECTED_POINT)
	TOKEN_TABLE(PROPERTY)
	TOKEN_TABLE_END

	byte *params;
	int cmd;
	BaseParser parser;

	if (complete) {
		if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_REGION) {
			_gameRef->LOG(0, "'REGION' keyword expected.");
			return STATUS_FAILED;
		}
		buffer = params;
	}

	for (uint32 i = 0; i < _points.size(); i++) {
		delete _points[i];
	}
	_points.clear();

	while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)&params)) > 0) {
		switch (cmd) {
		case TOKEN_TEMPLATE:
			if (DID_FAIL(loadFile((char *)params))) {
				cmd = PARSERR_GENERIC;
			}
			break;

		case TOKEN_NAME:
			setName((char *)params);
			break;

		case TOKEN_CAPTION:
			setCaption((char *)params);
			break;

		case TOKEN_ACTIVE:
			parser.scanStr((char *)params, "%b", &_active);
			break;

		case TOKEN_POINT: {
			int x, y;
			parser.scanStr((char *)params, "%d,%d", &x, &y);
			_points.add(new BasePoint(x, y));
		}
		break;

		case TOKEN_SCRIPT:
			addScript((char *)params);
			break;

		case TOKEN_EDITOR_SELECTED_POINT:
			parser.scanStr((char *)params, "%d", &_editorSelectedPoint);
			break;

		case TOKEN_PROPERTY:
			parseProperty(params, false);
			break;
		}
	}
	if (cmd == PARSERR_TOKENNOTFOUND) {
		_gameRef->LOG(0, "Syntax error in REGION definition");
		return STATUS_FAILED;
	}

	createRegion();

	return STATUS_OK;
}
开发者ID:CatalystG,项目名称:scummvm,代码行数:81,代码来源:base_region.cpp

示例3: loadBuffer

TOKEN_DEF_END
//////////////////////////////////////////////////////////////////////////
bool UIEdit::loadBuffer(byte *buffer, bool complete) {
	TOKEN_TABLE_START(commands)
	TOKEN_TABLE(TEMPLATE)
	TOKEN_TABLE(DISABLED)
	TOKEN_TABLE(VISIBLE)
	TOKEN_TABLE(BACK)
	TOKEN_TABLE(IMAGE)
	TOKEN_TABLE(FONT_SELECTED)
	TOKEN_TABLE(FONT)
	TOKEN_TABLE(TEXT)
	TOKEN_TABLE(X)
	TOKEN_TABLE(Y)
	TOKEN_TABLE(WIDTH)
	TOKEN_TABLE(HEIGHT)
	TOKEN_TABLE(CURSOR_BLINK_RATE)
	TOKEN_TABLE(CURSOR)
	TOKEN_TABLE(FRAME_WIDTH)
	TOKEN_TABLE(NAME)
	TOKEN_TABLE(SCRIPT)
	TOKEN_TABLE(PARENT_NOTIFY)
	TOKEN_TABLE(MAX_LENGTH)
	TOKEN_TABLE(EDITOR_PROPERTY)
	TOKEN_TABLE(EDIT)
	TOKEN_TABLE(CAPTION)
	TOKEN_TABLE_END

	byte *params;
	int cmd = 2;
	BaseParser parser;

	if (complete) {
		if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_EDIT) {
			_gameRef->LOG(0, "'EDIT' keyword expected.");
			return STATUS_FAILED;
		}
		buffer = params;
	}

	while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)&params)) > 0) {
		switch (cmd) {
		case TOKEN_TEMPLATE:
			if (DID_FAIL(loadFile((char *)params))) {
				cmd = PARSERR_GENERIC;
			}
			break;

		case TOKEN_NAME:
			setName((char *)params);
			break;

		case TOKEN_BACK:
			delete _back;
			_back = new UITiledImage(_gameRef);
			if (!_back || DID_FAIL(_back->loadFile((char *)params))) {
				delete _back;
				_back = NULL;
				cmd = PARSERR_GENERIC;
			}
			break;

		case TOKEN_IMAGE:
			delete _image;
			_image = new BaseSprite(_gameRef);
			if (!_image || DID_FAIL(_image->loadFile((char *)params))) {
				delete _image;
				_image = NULL;
				cmd = PARSERR_GENERIC;
			}
			break;

		case TOKEN_FONT:
			if (_font) {
				_gameRef->_fontStorage->removeFont(_font);
			}
			_font = _gameRef->_fontStorage->addFont((char *)params);
			if (!_font) {
				cmd = PARSERR_GENERIC;
			}
			break;

		case TOKEN_FONT_SELECTED:
			if (_fontSelected) {
				_gameRef->_fontStorage->removeFont(_fontSelected);
			}
			_fontSelected = _gameRef->_fontStorage->addFont((char *)params);
			if (!_fontSelected) {
				cmd = PARSERR_GENERIC;
			}
			break;

		case TOKEN_TEXT:
			setText((char *)params);
			_gameRef->_stringTable->expand(&_text);
			break;

		case TOKEN_X:
			parser.scanStr((char *)params, "%d", &_posX);
			break;
//.........这里部分代码省略.........
开发者ID:mokerjoke,项目名称:scummvm,代码行数:101,代码来源:ui_edit.cpp

示例4: loadBuffer

TOKEN_DEF_END
//////////////////////////////////////////////////////////////////////////
bool AdActor::loadBuffer(byte *buffer, bool complete) {
	TOKEN_TABLE_START(commands)
	TOKEN_TABLE(ACTOR)
	TOKEN_TABLE(X)
	TOKEN_TABLE(Y)
	TOKEN_TABLE(TEMPLATE)
	TOKEN_TABLE(NAME)
	TOKEN_TABLE(SCALABLE)
	TOKEN_TABLE(REGISTRABLE)
	TOKEN_TABLE(INTERACTIVE)
	TOKEN_TABLE(SHADOWABLE)
	TOKEN_TABLE(COLORABLE)
	TOKEN_TABLE(ACTIVE)
	TOKEN_TABLE(WALK)
	TOKEN_TABLE(STAND)
	TOKEN_TABLE(TALK_SPECIAL)
	TOKEN_TABLE(TALK)
	TOKEN_TABLE(TURN_LEFT)
	TOKEN_TABLE(TURN_RIGHT)
	TOKEN_TABLE(EVENTS)
	TOKEN_TABLE(FONT)
	TOKEN_TABLE(CURSOR)
	TOKEN_TABLE(SCRIPT)
	TOKEN_TABLE(SOUND_VOLUME)
	TOKEN_TABLE(SOUND_PANNING)
	TOKEN_TABLE(CAPTION)
	TOKEN_TABLE(PROPERTY)
	TOKEN_TABLE(BLOCKED_REGION)
	TOKEN_TABLE(WAYPOINTS)
	TOKEN_TABLE(IGNORE_ITEMS)
	TOKEN_TABLE(ROTABLE)
	TOKEN_TABLE(ROTATABLE)
	TOKEN_TABLE(ALPHA_COLOR)
	TOKEN_TABLE(SCALE)
	TOKEN_TABLE(RELATIVE_SCALE)
	TOKEN_TABLE(ALPHA)
	TOKEN_TABLE(EDITOR_PROPERTY)
	TOKEN_TABLE(ANIMATION)
	TOKEN_TABLE_END

	byte *params;
	int cmd;
	BaseParser parser;

	if (complete) {
		if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_ACTOR) {
			_gameRef->LOG(0, "'ACTOR' keyword expected.");
			return STATUS_FAILED;
		}
		buffer = params;
	}

	AdGame *adGame = (AdGame *)_gameRef;
	AdSpriteSet *spr = nullptr;
	int ar = 0, ag = 0, ab = 0, alpha = 0;
	while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)&params)) > 0) {
		switch (cmd) {
		case TOKEN_TEMPLATE:
			if (DID_FAIL(loadFile((char *)params))) {
				cmd = PARSERR_GENERIC;
			}
			break;

		case TOKEN_X:
			parser.scanStr((char *)params, "%d", &_posX);
			break;

		case TOKEN_Y:
			parser.scanStr((char *)params, "%d", &_posY);
			break;

		case TOKEN_NAME:
			setName((char *)params);
			break;

		case TOKEN_CAPTION:
			setCaption((char *)params);
			break;

		case TOKEN_FONT:
			setFont((char *)params);
			break;

		case TOKEN_SCALABLE:
			parser.scanStr((char *)params, "%b", &_zoomable);
			break;

		case TOKEN_ROTABLE:
		case TOKEN_ROTATABLE:
			parser.scanStr((char *)params, "%b", &_rotatable);
			break;

		case TOKEN_REGISTRABLE:
		case TOKEN_INTERACTIVE:
			parser.scanStr((char *)params, "%b", &_registrable);
			break;

		case TOKEN_SHADOWABLE:
//.........这里部分代码省略.........
开发者ID:Fyre91,项目名称:scummvm,代码行数:101,代码来源:ad_actor.cpp

示例5: loadBuffer

TOKEN_DEF_END
//////////////////////////////////////////////////////////////////////////
bool AdRegion::loadBuffer(byte *buffer, bool complete) {
	TOKEN_TABLE_START(commands)
	TOKEN_TABLE(REGION)
	TOKEN_TABLE(TEMPLATE)
	TOKEN_TABLE(NAME)
	TOKEN_TABLE(ACTIVE)
	TOKEN_TABLE(ZOOM)
	TOKEN_TABLE(SCALE)
	TOKEN_TABLE(BLOCKED)
	TOKEN_TABLE(DECORATION)
	TOKEN_TABLE(POINT)
	TOKEN_TABLE(ALPHA_COLOR)
	TOKEN_TABLE(ALPHA)
	TOKEN_TABLE(EDITOR_SELECTED_POINT)
	TOKEN_TABLE(EDITOR_SELECTED)
	TOKEN_TABLE(SCRIPT)
	TOKEN_TABLE(CAPTION)
	TOKEN_TABLE(PROPERTY)
	TOKEN_TABLE(EDITOR_PROPERTY)
	TOKEN_TABLE_END

	byte *params;
	int cmd;
	BaseParser parser;

	if (complete) {
		if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_REGION) {
			_gameRef->LOG(0, "'REGION' keyword expected.");
			return STATUS_FAILED;
		}
		buffer = params;
	}

	for (uint32 i = 0; i < _points.size(); i++) {
		delete _points[i];
	}
	_points.clear();

	int ar = 255, ag = 255, ab = 255, alpha = 255;

	while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)&params)) > 0) {
		switch (cmd) {
		case TOKEN_TEMPLATE:
			if (DID_FAIL(loadFile((char *)params))) {
				cmd = PARSERR_GENERIC;
			}
			break;

		case TOKEN_NAME:
			setName((char *)params);
			break;

		case TOKEN_CAPTION:
			setCaption((char *)params);
			break;

		case TOKEN_ACTIVE:
			parser.scanStr((char *)params, "%b", &_active);
			break;

		case TOKEN_BLOCKED:
			parser.scanStr((char *)params, "%b", &_blocked);
			break;

		case TOKEN_DECORATION:
			parser.scanStr((char *)params, "%b", &_decoration);
			break;

		case TOKEN_ZOOM:
		case TOKEN_SCALE: {
			int j;
			parser.scanStr((char *)params, "%d", &j);
			_zoom = (float)j;
		}
		break;

		case TOKEN_POINT: {
			int x, y;
			parser.scanStr((char *)params, "%d,%d", &x, &y);
			_points.add(new BasePoint(x, y));
		}
		break;

		case TOKEN_ALPHA_COLOR:
			parser.scanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab);
			break;

		case TOKEN_ALPHA:
			parser.scanStr((char *)params, "%d", &alpha);
			break;

		case TOKEN_EDITOR_SELECTED:
			parser.scanStr((char *)params, "%b", &_editorSelected);
			break;

		case TOKEN_EDITOR_SELECTED_POINT:
			parser.scanStr((char *)params, "%d", &_editorSelectedPoint);
			break;
//.........这里部分代码省略.........
开发者ID:mokerjoke,项目名称:scummvm,代码行数:101,代码来源:ad_region.cpp

示例6: loadBuffer

TOKEN_DEF_END
//////////////////////////////////////////////////////////////////////////
bool AdResponseBox::loadBuffer(byte *buffer, bool complete) {
    TOKEN_TABLE_START(commands)
    TOKEN_TABLE(RESPONSE_BOX)
    TOKEN_TABLE(TEMPLATE)
    TOKEN_TABLE(FONT_HOVER)
    TOKEN_TABLE(FONT)
    TOKEN_TABLE(AREA)
    TOKEN_TABLE(HORIZONTAL)
    TOKEN_TABLE(SPACING)
    TOKEN_TABLE(WINDOW)
    TOKEN_TABLE(CURSOR)
    TOKEN_TABLE(TEXT_ALIGN)
    TOKEN_TABLE(VERTICAL_ALIGN)
    TOKEN_TABLE(EDITOR_PROPERTY)
    TOKEN_TABLE_END


    byte *params;
    int cmd;
    BaseParser parser;

    if (complete) {
        if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_RESPONSE_BOX) {
            _gameRef->LOG(0, "'RESPONSE_BOX' keyword expected.");
            return STATUS_FAILED;
        }
        buffer = params;
    }

    while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)&params)) > 0) {
        switch (cmd) {
        case TOKEN_TEMPLATE:
            if (DID_FAIL(loadFile((char *)params))) {
                cmd = PARSERR_GENERIC;
            }
            break;

        case TOKEN_WINDOW:
            delete _window;
            _window = new UIWindow(_gameRef);
            if (!_window || DID_FAIL(_window->loadBuffer(params, false))) {
                delete _window;
                _window = nullptr;
                cmd = PARSERR_GENERIC;
            } else if (_shieldWindow) {
                _shieldWindow->_parent = _window;
            }
            break;

        case TOKEN_FONT:
            if (_font) {
                _gameRef->_fontStorage->removeFont(_font);
            }
            _font = _gameRef->_fontStorage->addFont((char *)params);
            if (!_font) {
                cmd = PARSERR_GENERIC;
            }
            break;

        case TOKEN_FONT_HOVER:
            if (_fontHover) {
                _gameRef->_fontStorage->removeFont(_fontHover);
            }
            _fontHover = _gameRef->_fontStorage->addFont((char *)params);
            if (!_fontHover) {
                cmd = PARSERR_GENERIC;
            }
            break;

        case TOKEN_AREA:
            parser.scanStr((char *)params, "%d,%d,%d,%d", &_responseArea.left, &_responseArea.top, &_responseArea.right, &_responseArea.bottom);
            break;

        case TOKEN_HORIZONTAL:
            parser.scanStr((char *)params, "%b", &_horizontal);
            break;

        case TOKEN_TEXT_ALIGN:
            if (scumm_stricmp((char *)params, "center") == 0) {
                _align = TAL_CENTER;
            } else if (scumm_stricmp((char *)params, "right") == 0) {
                _align = TAL_RIGHT;
            } else {
                _align = TAL_LEFT;
            }
            break;

        case TOKEN_VERTICAL_ALIGN:
            if (scumm_stricmp((char *)params, "top") == 0) {
                _verticalAlign = VAL_TOP;
            } else if (scumm_stricmp((char *)params, "center") == 0) {
                _verticalAlign = VAL_CENTER;
            } else {
                _verticalAlign = VAL_BOTTOM;
            }
            break;

        case TOKEN_SPACING:
//.........这里部分代码省略.........
开发者ID:rayzer86,项目名称:scummvm,代码行数:101,代码来源:ad_response_box.cpp

示例7: loadSettings

TOKEN_DEF_END

//////////////////////////////////////////////////////////////////////////
bool BaseGameSettings::loadSettings(const char *filename) {
	TOKEN_TABLE_START(commands)
	TOKEN_TABLE(SETTINGS)
	TOKEN_TABLE(GAME)
	TOKEN_TABLE(STRING_TABLE)
	TOKEN_TABLE(RESOLUTION)
	TOKEN_TABLE(REQUIRE_3D_ACCELERATION)
	TOKEN_TABLE(REQUIRE_SOUND)
	TOKEN_TABLE(HWTL_MODE)
	TOKEN_TABLE(ALLOW_WINDOWED_MODE)
	TOKEN_TABLE(ALLOW_ACCESSIBILITY_TAB)
	TOKEN_TABLE(ALLOW_ABOUT_TAB)
	TOKEN_TABLE(ALLOW_ADVANCED)
	TOKEN_TABLE(ALLOW_DESKTOP_RES)
	TOKEN_TABLE(REGISTRY_PATH)
	TOKEN_TABLE(RICH_SAVED_GAMES)
	TOKEN_TABLE(SAVED_GAME_EXT)
	TOKEN_TABLE(GUID)
	TOKEN_TABLE_END
	
	
	byte *origBuffer = BaseFileManager::getEngineInstance()->readWholeFile(filename);
	if (origBuffer == nullptr) {
		BaseEngine::LOG(0, "BaseGame::LoadSettings failed for file '%s'", filename);
		return STATUS_FAILED;
	}
	
	bool ret = STATUS_OK;
	
	byte *buffer = origBuffer;
	byte *params;
	int cmd;
	BaseParser parser;
	
	if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_SETTINGS) {
		BaseEngine::LOG(0, "'SETTINGS' keyword expected in game settings file.");
		return STATUS_FAILED;
	}
	buffer = params;
	while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)&params)) > 0) {
		switch (cmd) {
			case TOKEN_GAME:
				delete[] _gameFile;
				_gameFile = new char[strlen((char *)params) + 1];
				if (_gameFile) {
					strcpy(_gameFile, (char *)params);
				}
				break;
				
			case TOKEN_STRING_TABLE:
				if (DID_FAIL(_stringTable->loadFile((char *)params))) {
					cmd = PARSERR_GENERIC;
				}
				break;
				
			case TOKEN_RESOLUTION:
				parser.scanStr((char *)params, "%d,%d", &_resWidth, &_resHeight);
				break;
				
			case TOKEN_REQUIRE_3D_ACCELERATION:
				parser.scanStr((char *)params, "%b", &_requireAcceleration);
				break;
				
			case TOKEN_REQUIRE_SOUND:
				parser.scanStr((char *)params, "%b", &_requireSound);
				break;
				
			case TOKEN_HWTL_MODE:
				parser.scanStr((char *)params, "%d", &_TLMode);
				break;
				
			case TOKEN_ALLOW_WINDOWED_MODE:
				parser.scanStr((char *)params, "%b", &_allowWindowed);
				break;
				
			case TOKEN_ALLOW_DESKTOP_RES:
				parser.scanStr((char *)params, "%b", &_allowDesktopRes);
				break;
				
			case TOKEN_ALLOW_ADVANCED:
				parser.scanStr((char *)params, "%b", &_allowAdvanced);
				break;
				
			case TOKEN_ALLOW_ACCESSIBILITY_TAB:
				parser.scanStr((char *)params, "%b", &_allowAccessTab);
				break;
				
			case TOKEN_ALLOW_ABOUT_TAB:
				parser.scanStr((char *)params, "%b", &_allowAboutTab);
				break;
				
			case TOKEN_REGISTRY_PATH:
				//BaseEngine::instance().getRegistry()->setBasePath((char *)params);
				break;
				
			case TOKEN_RICH_SAVED_GAMES:
				parser.scanStr((char *)params, "%b", &_richSavedGames);
//.........这里部分代码省略.........
开发者ID:Fyre91,项目名称:scummvm,代码行数:101,代码来源:base_game_settings.cpp

示例8: loadBuffer

TOKEN_DEF_END
//////////////////////////////////////////////////////////////////////////
bool UIEntity::loadBuffer(byte *buffer, bool complete) {
	TOKEN_TABLE_START(commands)
	TOKEN_TABLE(ENTITY_CONTAINER)
	TOKEN_TABLE(TEMPLATE)
	TOKEN_TABLE(DISABLED)
	TOKEN_TABLE(VISIBLE)
	TOKEN_TABLE(X)
	TOKEN_TABLE(Y)
	TOKEN_TABLE(NAME)
	TOKEN_TABLE(ENTITY)
	TOKEN_TABLE(SCRIPT)
	TOKEN_TABLE(EDITOR_PROPERTY)
	TOKEN_TABLE_END

	byte *params;
	int cmd = 2;
	BaseParser parser;

	if (complete) {
		if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_ENTITY_CONTAINER) {
			_gameRef->LOG(0, "'ENTITY_CONTAINER' keyword expected.");
			return STATUS_FAILED;
		}
		buffer = params;
	}

	while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)&params)) > 0) {
		switch (cmd) {
		case TOKEN_TEMPLATE:
			if (DID_FAIL(loadFile((char *)params))) {
				cmd = PARSERR_GENERIC;
			}
			break;

		case TOKEN_NAME:
			setName((char *)params);
			break;

		case TOKEN_X:
			parser.scanStr((char *)params, "%d", &_posX);
			break;

		case TOKEN_Y:
			parser.scanStr((char *)params, "%d", &_posY);
			break;

		case TOKEN_DISABLED:
			parser.scanStr((char *)params, "%b", &_disable);
			break;

		case TOKEN_VISIBLE:
			parser.scanStr((char *)params, "%b", &_visible);
			break;

		case TOKEN_ENTITY:
			if (DID_FAIL(setEntity((char *)params))) {
				cmd = PARSERR_GENERIC;
			}
			break;

		case TOKEN_SCRIPT:
			addScript((char *)params);
			break;

		case TOKEN_EDITOR_PROPERTY:
			parseEditorProperty(params, false);
			break;
		}
	}
	if (cmd == PARSERR_TOKENNOTFOUND) {
		_gameRef->LOG(0, "Syntax error in ENTITY_CONTAINER definition");
		return STATUS_FAILED;
	}
	if (cmd == PARSERR_GENERIC) {
		_gameRef->LOG(0, "Error loading ENTITY_CONTAINER definition");
		return STATUS_FAILED;
	}

	correctSize();

	if (_gameRef->_editorMode) {
		_width = 50;
		_height = 50;
	}

	return STATUS_OK;
}
开发者ID:Fyre91,项目名称:scummvm,代码行数:89,代码来源:ui_entity.cpp

示例9: loadBuffer


//.........这里部分代码省略.........
				_image = nullptr;
				cmd = PARSERR_GENERIC;
			}
			break;

		case TOKEN_FONT:
			if (_font) {
				_gameRef->_fontStorage->removeFont(_font);
			}
			_font = _gameRef->_fontStorage->addFont((char *)params);
			if (!_font) {
				cmd = PARSERR_GENERIC;
			}
			break;

		case TOKEN_TEXT:
			setText((char *)params);
			_gameRef->expandStringByStringTable(&_text);
			break;

		case TOKEN_TEXT_ALIGN:
			if (scumm_stricmp((char *)params, "left") == 0) {
				_textAlign = TAL_LEFT;
			} else if (scumm_stricmp((char *)params, "right") == 0) {
				_textAlign = TAL_RIGHT;
			} else {
				_textAlign = TAL_CENTER;
			}
			break;

		case TOKEN_VERTICAL_ALIGN:
			if (scumm_stricmp((char *)params, "top") == 0) {
				_verticalAlign = VAL_TOP;
			} else if (scumm_stricmp((char *)params, "bottom") == 0) {
				_verticalAlign = VAL_BOTTOM;
			} else {
				_verticalAlign = VAL_CENTER;
			}
			break;

		case TOKEN_X:
			parser.scanStr((char *)params, "%d", &_posX);
			break;

		case TOKEN_Y:
			parser.scanStr((char *)params, "%d", &_posY);
			break;

		case TOKEN_WIDTH:
			parser.scanStr((char *)params, "%d", &_width);
			break;

		case TOKEN_HEIGHT:
			parser.scanStr((char *)params, "%d", &_height);
			break;

		case TOKEN_CURSOR:
			delete _cursor;
			_cursor = new BaseSprite(_gameRef);
			if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) {
				delete _cursor;
				_cursor = nullptr;
				cmd = PARSERR_GENERIC;
			}
			break;

		case TOKEN_SCRIPT:
			addScript((char *)params);
			break;

		case TOKEN_PARENT_NOTIFY:
			parser.scanStr((char *)params, "%b", &_parentNotify);
			break;

		case TOKEN_DISABLED:
			parser.scanStr((char *)params, "%b", &_disable);
			break;

		case TOKEN_VISIBLE:
			parser.scanStr((char *)params, "%b", &_visible);
			break;

		case TOKEN_EDITOR_PROPERTY:
			parseEditorProperty(params, false);
			break;
		}
	}
	if (cmd == PARSERR_TOKENNOTFOUND) {
		_gameRef->LOG(0, "Syntax error in STATIC definition");
		return STATUS_FAILED;
	}
	if (cmd == PARSERR_GENERIC) {
		_gameRef->LOG(0, "Error loading STATIC definition");
		return STATUS_FAILED;
	}

	correctSize();

	return STATUS_OK;
}
开发者ID:Fyre91,项目名称:scummvm,代码行数:101,代码来源:ui_text.cpp

示例10: loadBuffer


//.........这里部分代码省略.........
			}
			_fontDisable = _gameRef->_fontStorage->addFont((char *)params);
			if (!_fontDisable) {
				cmd = PARSERR_GENERIC;
			}
			break;

		case TOKEN_FONT_FOCUS:
			if (_fontFocus) {
				_gameRef->_fontStorage->removeFont(_fontFocus);
			}
			_fontFocus = _gameRef->_fontStorage->addFont((char *)params);
			if (!_fontFocus) {
				cmd = PARSERR_GENERIC;
			}
			break;

		case TOKEN_TEXT:
			setText((char *)params);
			_gameRef->_stringTable->expand(&_text);
			break;

		case TOKEN_TEXT_ALIGN:
			if (scumm_stricmp((char *)params, "left") == 0) {
				_align = TAL_LEFT;
			} else if (scumm_stricmp((char *)params, "right") == 0) {
				_align = TAL_RIGHT;
			} else {
				_align = TAL_CENTER;
			}
			break;

		case TOKEN_X:
			parser.scanStr((char *)params, "%d", &_posX);
			break;

		case TOKEN_Y:
			parser.scanStr((char *)params, "%d", &_posY);
			break;

		case TOKEN_WIDTH:
			parser.scanStr((char *)params, "%d", &_width);
			break;

		case TOKEN_HEIGHT:
			parser.scanStr((char *)params, "%d", &_height);
			break;

		case TOKEN_CURSOR:
			delete _cursor;
			_cursor = new BaseSprite(_gameRef);
			if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) {
				delete _cursor;
				_cursor = nullptr;
				cmd = PARSERR_GENERIC;
			}
			break;

		case TOKEN_SCRIPT:
			addScript((char *)params);
			break;

		case TOKEN_PARENT_NOTIFY:
			parser.scanStr((char *)params, "%b", &_parentNotify);
			break;
开发者ID:CatalystG,项目名称:scummvm,代码行数:66,代码来源:ui_button.cpp

示例11: loadBuffer

TOKEN_DEF_END
//////////////////////////////////////////////////////////////////////////
bool AdEntity::loadBuffer(byte *buffer, bool complete) {
	TOKEN_TABLE_START(commands)
	TOKEN_TABLE(ENTITY)
	TOKEN_TABLE(SPRITE)
	TOKEN_TABLE(X)
	TOKEN_TABLE(Y)
	TOKEN_TABLE(TEMPLATE)
	TOKEN_TABLE(NAME)
	TOKEN_TABLE(SCALABLE)
	TOKEN_TABLE(REGISTRABLE)
	TOKEN_TABLE(INTERACTIVE)
	TOKEN_TABLE(SHADOWABLE)
	TOKEN_TABLE(COLORABLE)
	TOKEN_TABLE(ACTIVE)
	TOKEN_TABLE(EVENTS)
	TOKEN_TABLE(FONT)
	TOKEN_TABLE(TALK_SPECIAL)
	TOKEN_TABLE(TALK)
	TOKEN_TABLE(CURSOR)
	TOKEN_TABLE(REGION)
	TOKEN_TABLE(BLOCKED_REGION)
	TOKEN_TABLE(EDITOR_SELECTED)
	TOKEN_TABLE(SCRIPT)
	TOKEN_TABLE(SOUND_START_TIME)
	TOKEN_TABLE(SOUND_VOLUME)
	TOKEN_TABLE(SOUND_PANNING)
	TOKEN_TABLE(SOUND)
	TOKEN_TABLE(SUBTYPE)
	TOKEN_TABLE(CAPTION)
	TOKEN_TABLE(PROPERTY)
	TOKEN_TABLE(WAYPOINTS)
	TOKEN_TABLE(IGNORE_ITEMS)
	TOKEN_TABLE(ROTABLE)
	TOKEN_TABLE(ROTATABLE)
	TOKEN_TABLE(ALPHA_COLOR)
	TOKEN_TABLE(SCALE)
	TOKEN_TABLE(RELATIVE_SCALE)
	TOKEN_TABLE(ALPHA)
	TOKEN_TABLE(EDITOR_PROPERTY)
	TOKEN_TABLE(ITEM)
	TOKEN_TABLE(WALK_TO_X)
	TOKEN_TABLE(WALK_TO_Y)
	TOKEN_TABLE(WALK_TO_DIR)
	TOKEN_TABLE(SAVE_STATE)
	TOKEN_TABLE_END

	byte *params;
	int cmd;
	BaseParser parser;

	if (complete) {
		if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_ENTITY) {
			_gameRef->LOG(0, "'ENTITY' keyword expected.");
			return STATUS_FAILED;
		}
		buffer = params;
	}

	AdGame *adGame = (AdGame *)_gameRef;
	BaseSprite *spr = nullptr;
	int ar = 0, ag = 0, ab = 0, alpha = 0;
	while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)&params)) > 0) {
		switch (cmd) {
		case TOKEN_TEMPLATE:
			if (DID_FAIL(loadFile((char *)params))) {
				cmd = PARSERR_GENERIC;
			}
			break;

		case TOKEN_X:
			parser.scanStr((char *)params, "%d", &_posX);
			break;

		case TOKEN_Y:
			parser.scanStr((char *)params, "%d", &_posY);
			break;

		case TOKEN_SPRITE: {
			delete _sprite;
			_sprite = nullptr;
			spr = new BaseSprite(_gameRef, this);
			if (!spr || DID_FAIL(spr->loadFile((char *)params))) {
				cmd = PARSERR_GENERIC;
			} else {
				_sprite = spr;
			}
		}
		break;

		case TOKEN_TALK: {
			spr = new BaseSprite(_gameRef, this);
			if (!spr || DID_FAIL(spr->loadFile((char *)params, adGame->_texTalkLifeTime))) {
				cmd = PARSERR_GENERIC;
			} else {
				_talkSprites.add(spr);
			}
		}
		break;
//.........这里部分代码省略.........
开发者ID:MaddTheSane,项目名称:scummvm,代码行数:101,代码来源:ad_entity.cpp

示例12: loadBuffer

TOKEN_DEF_END
//////////////////////////////////////////////////////////////////////////
bool AdTalkNode::loadBuffer(byte *buffer, bool complete) {
	TOKEN_TABLE_START(commands)
	TOKEN_TABLE(ACTION)
	TOKEN_TABLE(SPRITESET_FILE)
	TOKEN_TABLE(SPRITESET)
	TOKEN_TABLE(SPRITE)
	TOKEN_TABLE(START_TIME)
	TOKEN_TABLE(END_TIME)
	TOKEN_TABLE(COMMENT)
	TOKEN_TABLE(PRECACHE)
	TOKEN_TABLE(EDITOR_PROPERTY)
	TOKEN_TABLE_END

	byte *params;
	int cmd;
	BaseParser parser;

	if (complete) {
		if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_ACTION) {
			_gameRef->LOG(0, "'ACTION' keyword expected.");
			return STATUS_FAILED;
		}
		buffer = params;
	}

	_endTime = 0;
	_playToEnd = false;
	_preCache = false;

	while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)&params)) > 0) {
		switch (cmd) {
		case TOKEN_SPRITE:
			BaseUtils::setString(&_spriteFilename, (char *)params);
			break;

		case TOKEN_SPRITESET_FILE:
			BaseUtils::setString(&_spriteSetFilename, (char *)params);
			break;

		case TOKEN_SPRITESET: {
			delete _spriteSet;
			_spriteSet = new AdSpriteSet(_gameRef);
			if (!_spriteSet || DID_FAIL(_spriteSet->loadBuffer(params, false))) {
				delete _spriteSet;
				_spriteSet = nullptr;
				cmd = PARSERR_GENERIC;
			}
		}
		break;

		case TOKEN_START_TIME:
			parser.scanStr((char *)params, "%d", &_startTime);
			break;

		case TOKEN_END_TIME:
			parser.scanStr((char *)params, "%d", &_endTime);
			break;

		case TOKEN_PRECACHE:
			parser.scanStr((char *)params, "%b", &_preCache);
			break;

		case TOKEN_COMMENT:
			if (_gameRef->_editorMode) {
				BaseUtils::setString(&_comment, (char *)params);
			}
			break;

		case TOKEN_EDITOR_PROPERTY:
			parseEditorProperty(params, false);
			break;
		}
	}
	if (cmd == PARSERR_TOKENNOTFOUND) {
		_gameRef->LOG(0, "Syntax error in ACTION definition");
		return STATUS_FAILED;
	}

	if (cmd == PARSERR_GENERIC) {
		_gameRef->LOG(0, "Error loading ACTION definition");
		return STATUS_FAILED;
	}

	if (_endTime == 0) {
		_playToEnd = true;
	} else {
		_playToEnd = false;
	}

	if (_preCache && _spriteFilename) {
		delete _sprite;
		_sprite = new BaseSprite(_gameRef);
		if (!_sprite || DID_FAIL(_sprite->loadFile(_spriteFilename))) {
			return STATUS_FAILED;
		}
	}

	if (_preCache && _spriteSetFilename) {
//.........这里部分代码省略.........
开发者ID:Fyre91,项目名称:scummvm,代码行数:101,代码来源:ad_talk_node.cpp

示例13: loadBuffer

TOKEN_DEF_END
//////////////////////////////////////////////////////////////////////////
bool AdInventoryBox::loadBuffer(byte *buffer, bool complete) {
	TOKEN_TABLE_START(commands)
	TOKEN_TABLE(INVENTORY_BOX)
	TOKEN_TABLE(TEMPLATE)
	TOKEN_TABLE(WINDOW)
	TOKEN_TABLE(EXCLUSIVE)
	TOKEN_TABLE(ALWAYS_VISIBLE)
	TOKEN_TABLE(AREA)
	TOKEN_TABLE(SPACING)
	TOKEN_TABLE(ITEM_WIDTH)
	TOKEN_TABLE(ITEM_HEIGHT)
	TOKEN_TABLE(SCROLL_BY)
	TOKEN_TABLE(NAME)
	TOKEN_TABLE(CAPTION)
	TOKEN_TABLE(HIDE_SELECTED)
	TOKEN_TABLE(EDITOR_PROPERTY)
	TOKEN_TABLE_END

	byte *params;
	int cmd = 2;
	BaseParser parser;
	bool alwaysVisible = false;

	_exclusive = false;
	if (complete) {
		if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_INVENTORY_BOX) {
			_gameRef->LOG(0, "'INVENTORY_BOX' keyword expected.");
			return STATUS_FAILED;
		}
		buffer = params;
	}

	while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)&params)) > 0) {
		switch (cmd) {
		case TOKEN_TEMPLATE:
			if (DID_FAIL(loadFile((char *)params))) {
				cmd = PARSERR_GENERIC;
			}
			break;

		case TOKEN_NAME:
			setName((char *)params);
			break;

		case TOKEN_CAPTION:
			setCaption((char *)params);
			break;

		case TOKEN_WINDOW:
			delete _window;
			_window = new UIWindow(_gameRef);
			if (!_window || DID_FAIL(_window->loadBuffer(params, false))) {
				delete _window;
				_window = nullptr;
				cmd = PARSERR_GENERIC;
			} else {
				_gameRef->registerObject(_window);
			}
			break;

		case TOKEN_AREA:
			parser.scanStr((char *)params, "%d,%d,%d,%d", &_itemsArea.left, &_itemsArea.top, &_itemsArea.right, &_itemsArea.bottom);
			break;

		case TOKEN_EXCLUSIVE:
			parser.scanStr((char *)params, "%b", &_exclusive);
			break;

		case TOKEN_HIDE_SELECTED:
			parser.scanStr((char *)params, "%b", &_hideSelected);
			break;

		case TOKEN_ALWAYS_VISIBLE:
			parser.scanStr((char *)params, "%b", &alwaysVisible);
			break;

		case TOKEN_SPACING:
			parser.scanStr((char *)params, "%d", &_spacing);
			break;

		case TOKEN_ITEM_WIDTH:
			parser.scanStr((char *)params, "%d", &_itemWidth);
			break;

		case TOKEN_ITEM_HEIGHT:
			parser.scanStr((char *)params, "%d", &_itemHeight);
			break;

		case TOKEN_SCROLL_BY:
			parser.scanStr((char *)params, "%d", &_scrollBy);
			break;

		case TOKEN_EDITOR_PROPERTY:
			parseEditorProperty(params, false);
			break;
		}
	}
	if (cmd == PARSERR_TOKENNOTFOUND) {
//.........这里部分代码省略.........
开发者ID:Fyre91,项目名称:scummvm,代码行数:101,代码来源:ad_inventory_box.cpp


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