本文整理汇总了C++中BaseParser::getCommand方法的典型用法代码示例。如果您正苦于以下问题:C++ BaseParser::getCommand方法的具体用法?C++ BaseParser::getCommand怎么用?C++ BaseParser::getCommand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseParser
的用法示例。
在下文中一共展示了BaseParser::getCommand方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 **)¶ms) != TOKEN_SCALE_LEVEL) {
_gameRef->LOG(0, "'SCALE_LEVEL' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
}
while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 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;
}
示例2: mergeAnims
bool AdActor::mergeAnims(const char *animsFilename) {
TOKEN_TABLE_START(commands)
TOKEN_TABLE(ANIMATION)
TOKEN_TABLE_END
byte *fileBuffer = BaseFileManager::getEngineInstance()->readWholeFile(animsFilename);
if (fileBuffer == nullptr) {
_gameRef->LOG(0, "AdActor::MergeAnims failed for file '%s'", animsFilename);
return STATUS_FAILED;
}
byte *buffer = fileBuffer;
byte *params;
int cmd;
BaseParser parser;
bool ret = STATUS_OK;
while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) {
switch (cmd) {
case TOKEN_ANIMATION: {
AdSpriteSet *anim = new AdSpriteSet(_gameRef, this);
if (!anim || DID_FAIL(anim->loadBuffer(params, false))) {
cmd = PARSERR_GENERIC;
ret = STATUS_FAILED;
} else {
_anims.add(anim);
}
}
break;
}
}
delete[] fileBuffer;
return ret;
}
示例3: 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 **)¶ms) != 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 **)¶ms)) > 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;
}
示例4: 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 **)¶ms) != TOKEN_EDIT) {
_gameRef->LOG(0, "'EDIT' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
}
while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 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;
//.........这里部分代码省略.........
示例5: 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 **)¶ms) != 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 **)¶ms)) > 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:
//.........这里部分代码省略.........
示例6: 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 **)¶ms) != 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 **)¶ms)) > 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;
//.........这里部分代码省略.........
示例7: 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 **)¶ms) != TOKEN_RESPONSE_BOX) {
_gameRef->LOG(0, "'RESPONSE_BOX' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
}
while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 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:
//.........这里部分代码省略.........
示例8: parseProperty
TOKEN_DEF_END
//////////////////////////////////////////////////////////////////////////
bool BaseScriptHolder::parseProperty(byte *buffer, bool complete) {
TOKEN_TABLE_START(commands)
TOKEN_TABLE(PROPERTY)
TOKEN_TABLE(NAME)
TOKEN_TABLE(VALUE)
TOKEN_TABLE_END
byte *params;
int cmd;
BaseParser parser;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_PROPERTY) {
_gameRef->LOG(0, "'PROPERTY' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
}
char *propName = NULL;
char *propValue = NULL;
while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) {
switch (cmd) {
case TOKEN_NAME:
delete[] propName;
propName = new char[strlen((char *)params) + 1];
if (propName) {
strcpy(propName, (char *)params);
} else {
cmd = PARSERR_GENERIC;
}
break;
case TOKEN_VALUE:
delete[] propValue;
propValue = new char[strlen((char *)params) + 1];
if (propValue) {
strcpy(propValue, (char *)params);
} else {
cmd = PARSERR_GENERIC;
}
break;
}
}
if (cmd == PARSERR_TOKENNOTFOUND) {
delete[] propName;
delete[] propValue;
propName = NULL;
propValue = NULL;
_gameRef->LOG(0, "Syntax error in PROPERTY definition");
return STATUS_FAILED;
}
if (cmd == PARSERR_GENERIC || propName == NULL || propValue == NULL) {
delete[] propName;
delete[] propValue;
propName = NULL;
propValue = NULL;
_gameRef->LOG(0, "Error loading PROPERTY definition");
return STATUS_FAILED;
}
ScValue *val = new ScValue(_gameRef);
val->setString(propValue);
scSetProperty(propName, val);
delete val;
delete[] propName;
delete[] propValue;
propName = NULL;
propValue = NULL;
return STATUS_OK;
}
示例9: 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 **)¶ms) != 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 **)¶ms)) > 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;
}
示例10: loadBuffer
TOKEN_DEF_END
//////////////////////////////////////////////////////////////////////////
bool UIText::loadBuffer(byte *buffer, bool complete) {
TOKEN_TABLE_START(commands)
TOKEN_TABLE(STATIC)
TOKEN_TABLE(TEMPLATE)
TOKEN_TABLE(DISABLED)
TOKEN_TABLE(VISIBLE)
TOKEN_TABLE(BACK)
TOKEN_TABLE(IMAGE)
TOKEN_TABLE(FONT)
TOKEN_TABLE(TEXT_ALIGN)
TOKEN_TABLE(VERTICAL_ALIGN)
TOKEN_TABLE(TEXT)
TOKEN_TABLE(X)
TOKEN_TABLE(Y)
TOKEN_TABLE(WIDTH)
TOKEN_TABLE(HEIGHT)
TOKEN_TABLE(CURSOR)
TOKEN_TABLE(NAME)
TOKEN_TABLE(SCRIPT)
TOKEN_TABLE(CAPTION)
TOKEN_TABLE(PARENT_NOTIFY)
TOKEN_TABLE(EDITOR_PROPERTY)
TOKEN_TABLE_END
byte *params;
int cmd = 2;
BaseParser parser;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_STATIC) {
_gameRef->LOG(0, "'STATIC' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
}
while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 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_BACK:
delete _back;
_back = new UITiledImage(_gameRef);
if (!_back || DID_FAIL(_back->loadFile((char *)params))) {
delete _back;
_back = nullptr;
cmd = PARSERR_GENERIC;
}
break;
case TOKEN_IMAGE:
delete _image;
_image = new BaseSprite(_gameRef);
if (!_image || DID_FAIL(_image->loadFile((char *)params))) {
delete _image;
_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:
//.........这里部分代码省略.........
示例11: 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 **)¶ms) != 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 **)¶ms)) > 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);
//.........这里部分代码省略.........
示例12: loadBuffer
TOKEN_DEF_END
//////////////////////////////////////////////////////////////////////////
bool UIButton::loadBuffer(byte *buffer, bool complete) {
TOKEN_TABLE_START(commands)
TOKEN_TABLE(BUTTON)
TOKEN_TABLE(TEMPLATE)
TOKEN_TABLE(DISABLED)
TOKEN_TABLE(VISIBLE)
TOKEN_TABLE(FOCUSABLE)
TOKEN_TABLE(BACK_HOVER)
TOKEN_TABLE(BACK_PRESS)
TOKEN_TABLE(BACK_DISABLE)
TOKEN_TABLE(BACK_FOCUS)
TOKEN_TABLE(BACK)
TOKEN_TABLE(CENTER_IMAGE)
TOKEN_TABLE(IMAGE_HOVER)
TOKEN_TABLE(IMAGE_PRESS)
TOKEN_TABLE(IMAGE_DISABLE)
TOKEN_TABLE(IMAGE_FOCUS)
TOKEN_TABLE(IMAGE)
TOKEN_TABLE(FONT_HOVER)
TOKEN_TABLE(FONT_PRESS)
TOKEN_TABLE(FONT_DISABLE)
TOKEN_TABLE(FONT_FOCUS)
TOKEN_TABLE(FONT)
TOKEN_TABLE(TEXT_ALIGN)
TOKEN_TABLE(TEXT)
TOKEN_TABLE(X)
TOKEN_TABLE(Y)
TOKEN_TABLE(WIDTH)
TOKEN_TABLE(HEIGHT)
TOKEN_TABLE(CURSOR)
TOKEN_TABLE(NAME)
TOKEN_TABLE(EVENTS)
TOKEN_TABLE(SCRIPT)
TOKEN_TABLE(CAPTION)
TOKEN_TABLE(PARENT_NOTIFY)
TOKEN_TABLE(PRESSED)
TOKEN_TABLE(PIXEL_PERFECT)
TOKEN_TABLE(EDITOR_PROPERTY)
TOKEN_TABLE_END
byte *params;
int cmd = 2;
BaseParser parser;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_BUTTON) {
_gameRef->LOG(0, "'BUTTON' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
}
while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 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_BACK:
delete _back;
_back = new UITiledImage(_gameRef);
if (!_back || DID_FAIL(_back->loadFile((char *)params))) {
delete _back;
_back = nullptr;
cmd = PARSERR_GENERIC;
}
break;
case TOKEN_BACK_HOVER:
delete _backHover;
_backHover = new UITiledImage(_gameRef);
if (!_backHover || DID_FAIL(_backHover->loadFile((char *)params))) {
delete _backHover;
_backHover = nullptr;
cmd = PARSERR_GENERIC;
}
break;
case TOKEN_BACK_PRESS:
delete _backPress;
_backPress = new UITiledImage(_gameRef);
if (!_backPress || DID_FAIL(_backPress->loadFile((char *)params))) {
delete _backPress;
_backPress = nullptr;
cmd = PARSERR_GENERIC;
}
break;
//.........这里部分代码省略.........
示例13: 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 **)¶ms) != 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 **)¶ms)) > 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;
//.........这里部分代码省略.........
示例14: 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 **)¶ms) != 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 **)¶ms)) > 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) {
//.........这里部分代码省略.........
示例15: loadBuffer
TOKEN_DEF_END
//////////////////////////////////////////////////////////////////////////
bool AdTalkDef::loadBuffer(byte *buffer, bool complete) {
TOKEN_TABLE_START(commands)
TOKEN_TABLE(TALK)
TOKEN_TABLE(TEMPLATE)
TOKEN_TABLE(ACTION)
TOKEN_TABLE(DEFAULT_SPRITESET_FILE)
TOKEN_TABLE(DEFAULT_SPRITESET)
TOKEN_TABLE(DEFAULT_SPRITE)
TOKEN_TABLE(EDITOR_PROPERTY)
TOKEN_TABLE_END
byte *params;
int cmd;
BaseParser parser;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TALK) {
_gameRef->LOG(0, "'TALK' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
}
while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) {
switch (cmd) {
case TOKEN_TEMPLATE:
if (DID_FAIL(loadFile((char *)params))) {
cmd = PARSERR_GENERIC;
}
break;
case TOKEN_ACTION: {
AdTalkNode *node = new AdTalkNode(_gameRef);
if (node && DID_SUCCEED(node->loadBuffer(params, false))) {
_nodes.add(node);
} else {
delete node;
node = nullptr;
cmd = PARSERR_GENERIC;
}
}
break;
case TOKEN_DEFAULT_SPRITE:
BaseUtils::setString(&_defaultSpriteFilename, (char *)params);
break;
case TOKEN_DEFAULT_SPRITESET_FILE:
BaseUtils::setString(&_defaultSpriteSetFilename, (char *)params);
break;
case TOKEN_DEFAULT_SPRITESET: {
delete _defaultSpriteSet;
_defaultSpriteSet = new AdSpriteSet(_gameRef);
if (!_defaultSpriteSet || DID_FAIL(_defaultSpriteSet->loadBuffer(params, false))) {
delete _defaultSpriteSet;
_defaultSpriteSet = nullptr;
cmd = PARSERR_GENERIC;
}
}
break;
case TOKEN_EDITOR_PROPERTY:
parseEditorProperty(params, false);
break;
}
}
if (cmd == PARSERR_TOKENNOTFOUND) {
_gameRef->LOG(0, "Syntax error in TALK definition");
return STATUS_FAILED;
}
if (cmd == PARSERR_GENERIC) {
_gameRef->LOG(0, "Error loading TALK definition");
return STATUS_FAILED;
}
delete _defaultSprite;
delete _defaultSpriteSet;
_defaultSprite = nullptr;
_defaultSpriteSet = nullptr;
if (_defaultSpriteFilename) {
_defaultSprite = new BaseSprite(_gameRef);
if (!_defaultSprite || DID_FAIL(_defaultSprite->loadFile(_defaultSpriteFilename))) {
return STATUS_FAILED;
}
}
if (_defaultSpriteSetFilename) {
_defaultSpriteSet = new AdSpriteSet(_gameRef);
if (!_defaultSpriteSet || DID_FAIL(_defaultSpriteSet->loadFile(_defaultSpriteSetFilename))) {
return STATUS_FAILED;
}
}
//.........这里部分代码省略.........