//------------------------------------------------------------------------- bool ScriptTranslator::passValidateProperty(Ogre::ScriptCompiler* compiler, Ogre::PropertyAbstractNode* prop, const Ogre::String& token, ValidationType validationType) { if (!passValidatePropertyNoValues(compiler, prop, token)) { return false; } bool ret = true; switch(validationType) { case VAL_BOOL: { ret = passValidatePropertyNumberOfValues(compiler, prop, token, 1) && passValidatePropertyValidBool(compiler, prop); } break; case VAL_COLOURVALUE: { ret = passValidatePropertyNumberOfValuesRange(compiler, prop, token, 3, 4); } break; case VAL_INT: { ret = passValidatePropertyNumberOfValues(compiler, prop, token, 1) && passValidatePropertyValidInt(compiler, prop); } break; case VAL_QUATERNION: { ret = passValidatePropertyNumberOfValues(compiler, prop, token, 4) && passValidatePropertyValidQuaternion(compiler, prop); } break; case VAL_REAL: { ret = passValidatePropertyNumberOfValues(compiler, prop, token, 1) && passValidatePropertyValidReal(compiler, prop); } break; case VAL_STRING: { ret = passValidatePropertyNumberOfValues(compiler, prop, token, 1); } break; case VAL_UINT: { ret = passValidatePropertyNumberOfValues(compiler, prop, token, 1) && passValidatePropertyValidUint(compiler, prop); } break; case VAL_VECTOR2: { ret = passValidatePropertyNumberOfValues(compiler, prop, token, 2) && passValidatePropertyValidVector2(compiler, prop); } break; case VAL_VECTOR3: { ret = passValidatePropertyNumberOfValues(compiler, prop, token, 3) && passValidatePropertyValidVector3(compiler, prop); } break; case VAL_VECTOR4: { ret = passValidatePropertyNumberOfValues(compiler, prop, token, 4) && passValidatePropertyValidVector4(compiler, prop); } break; } return ret; }
//------------------------------------------------------------------------- bool PUColorAffectorTranslator::translateChildProperty( PUScriptCompiler* compiler, PUAbstractNode *node ) { PUPropertyAbstractNode* prop = reinterpret_cast<PUPropertyAbstractNode*>(node); PUAffector* af = static_cast<PUAffector*>(prop->parent->context); PUColorAffector* affector = static_cast<PUColorAffector*>(af); if (prop->name == token[TOKEN_TIME_COLOUR] || prop->name == token[TOKEN_COLOUR_TIME_COLOUR]) { if (passValidatePropertyNumberOfValuesRange(compiler, prop, token[TOKEN_TIME_COLOUR], 4, 5)) { int n = 0; float time; Vec4 colour; PUAbstractNodeList::const_iterator i = prop->values.begin(); PUAbstractNodeList::const_iterator end = prop->values.end(); while(i != end) { float v = 0; if(getFloat(**i, &v)) { switch(n) { case 0: time = v; break; case 1: colour.x = v; break; case 2: colour.y = v; break; case 3: colour.z = v; break; case 4: colour.w = v; break; } } ++n; ++i; } affector->addColor(time, colour); return true; } } else if (prop->name == token[TOKEN_COLOUR_OPERATION]) { if (passValidateProperty(compiler, prop, token[TOKEN_COLOUR_OPERATION], VAL_STRING)) { std::string val; if(getString(*prop->values.front(), &val)) { if (val == token[TOKEN_COLOUR_SET]) { affector->setColorOperation(PUColorAffector::CAO_SET); return true; } else if (val == token[TOKEN_COLOUR_MULTIPLY]) { affector->setColorOperation(PUColorAffector::CAO_MULTIPLY); return true; } } } } return false; }