void CEffectCreator::InitPainterParameters (CCreatePainterCtx &Ctx, IEffectPainter *pPainter) // InitPainterParameters // // Initialize painter parameters { SEventHandlerDesc Event; if (FindEventHandlerEffectType(evtGetParameters, &Event)) { CCodeChainCtx CCCtx; CCCtx.SaveAndDefineDataVar(Ctx.GetData()); ICCItem *pResult = CCCtx.Run(Event); if (pResult->IsError()) ::kernelDebugLogMessage(CONSTLIT("EffectType %x GetParameters: %s"), GetUNID(), (LPSTR)pResult->GetStringValue()); else if (pResult->IsSymbolTable()) { int i; CCSymbolTable *pTable = (CCSymbolTable *)pResult; for (i = 0; i < pTable->GetCount(); i++) { CString sParam = pTable->GetKey(i); ICCItem *pValue = pTable->GetElement(i); CEffectParamDesc Value; if (pValue->IsNil()) Value.InitNull(); else if (pValue->IsInteger()) Value.InitInteger(pValue->GetIntegerValue()); else if (pValue->IsIdentifier()) { CString sValue = pValue->GetStringValue(); char *pPos = sValue.GetASCIIZPointer(); // If this is a color, parse it if (*pPos == '#') Value.InitColor(::LoadRGBColor(sValue)); // Otherwise, a string else Value.InitString(sValue); } pPainter->SetParam(Ctx, sParam, Value); } } else ::kernelDebugLogMessage(CONSTLIT("EffectType %x GetParameters: Expected struct result."), GetUNID()); CCCtx.Discard(pResult); } }
void COrbEffectPainter::SetParam (CCreatePainterCtx &Ctx, const CString &sParam, const CEffectParamDesc &Value) // SetParam // // Sets parameters { if (strEquals(sParam, ANIMATE_ATTRIB)) m_iAnimation = (EAnimationTypes)Value.EvalIntegerBounded(Ctx, 0, -1, animateNone); else if (strEquals(sParam, INTENSITY_ATTRIB)) m_iIntensity = Value.EvalIntegerBounded(Ctx, 0, 100, 50); else if (strEquals(sParam, LIFETIME_ATTRIB)) m_iLifetime = Value.EvalIntegerBounded(Ctx, 0, -1, 0); else if (strEquals(sParam, PRIMARY_COLOR_ATTRIB)) m_wPrimaryColor = Value.EvalColor(Ctx); else if (strEquals(sParam, RADIUS_ATTRIB)) m_iRadius = Value.EvalIntegerBounded(Ctx, 1, -1, (int)(STD_SECONDS_PER_UPDATE * LIGHT_SECOND / KLICKS_PER_PIXEL)); else if (strEquals(sParam, SECONDARY_COLOR_ATTRIB)) m_wSecondaryColor = Value.EvalColor(Ctx); else if (strEquals(sParam, STYLE_ATTRIB)) m_iStyle = (EOrbStyles)Value.EvalIdentifier(Ctx, STYLE_TABLE, styleMax, styleSmooth); }
void IEffectPainter::OnWriteToStream (IWriteStream *pStream) // OnWriteToStream // // Writes list of parameters from the painter. { int i; TArray<CString> Params; if (!m_bSingleton && GetParamList(&Params)) { // Write the count of parameters DWORD dwSave = Params.GetCount(); pStream->Write((char *)&dwSave, sizeof(DWORD)); // Write each parameter (name and value) for (i = 0; i < Params.GetCount(); i++) { // Write the parameter value Params[i].WriteToStream(pStream); // Write the value CEffectParamDesc Value; GetParam(Params[i], &Value); Value.WriteToStream(pStream); } } else { DWORD dwSave = 0; pStream->Write((char *)&dwSave, sizeof(DWORD)); } }
void CRayEffectPainter::SetParam (CCreatePainterCtx &Ctx, const CString &sParam, const CEffectParamDesc &Value) // SetParam // // Sets parameters { if (strEquals(sParam, ANIMATE_OPACITY_ATTRIB)) m_iOpacityAnimation = (EAnimationTypes)Value.EvalIntegerBounded(Ctx, 0, -1, animateNone); else if (strEquals(sParam, INTENSITY_ATTRIB)) m_iIntensity = Value.EvalIntegerBounded(Ctx, 0, 100, 50); else if (strEquals(sParam, LENGTH_ATTRIB)) m_iLength = Value.EvalIntegerBounded(Ctx, 1, -1, (int)(STD_SECONDS_PER_UPDATE * LIGHT_SECOND / KLICKS_PER_PIXEL)); else if (strEquals(sParam, LIFETIME_ATTRIB)) m_iLifetime = Value.EvalIntegerBounded(Ctx, 0, -1, 0); else if (strEquals(sParam, PRIMARY_COLOR_ATTRIB)) m_wPrimaryColor = Value.EvalColor(Ctx); else if (strEquals(sParam, SECONDARY_COLOR_ATTRIB)) m_wSecondaryColor = Value.EvalColor(Ctx); else if (strEquals(sParam, SHAPE_ATTRIB)) m_iShape = (ERayShapes)Value.EvalIdentifier(Ctx, SHAPE_TABLE, shapeMax, shapeStraight); else if (strEquals(sParam, STYLE_ATTRIB)) m_iStyle = (ERayStyles)Value.EvalIdentifier(Ctx, STYLE_TABLE, styleMax, styleGlow); else if (strEquals(sParam, WIDTH_ATTRIB)) m_iWidth = Value.EvalIntegerBounded(Ctx, 1, -1, 10); else if (strEquals(sParam, XFORM_ROTATION_ATTRIB)) m_iXformRotation = Value.EvalIntegerBounded(Ctx, -359, 359, 0); }
void IEffectPainter::OnReadFromStream (SLoadCtx &Ctx) // OnReadFromStream // // This is the default for reading painter parameters. We ask the painter for // a list of its parameters and read those. { int i; // Read parameters if (Ctx.dwVersion >= 90) { // Read the number of parameters DWORD dwCount; Ctx.pStream->Read((char *)&dwCount, sizeof(DWORD)); for (i = 0; i < (int)dwCount; i++) { // Read the parameter name CString sParam; sParam.ReadFromStream(Ctx.pStream); // Read the value CEffectParamDesc Value; Value.ReadFromStream(Ctx); // Set it SetParam(CCreatePainterCtx(), sParam, Value); } } }
void CParticleJetEffectPainter::SetParam (CCreatePainterCtx &Ctx, const CString &sParam, const CEffectParamDesc &Value) // SetParam // // Sets parameters { if (strEquals(sParam, CUR_DIRECTION_ATTRIB)) m_iCurDirection = Value.EvalIntegerBounded(Ctx, 0, -1, -1); else if (strEquals(sParam, EMIT_RATE_ATTRIB)) m_EmitRate = Value.EvalDiceRange(Ctx, 10); else if (strEquals(sParam, EMIT_SPEED_ATTRIB)) m_EmitSpeed = Value.EvalDiceRange(Ctx, 50); else if (strEquals(sParam, FIXED_POS_ATTRIB)) m_bUseObjectMotion = Value.EvalBool(Ctx); else if (strEquals(sParam, IS_TRACKING_OBJECT_ATTRIB)) m_bTrackingObject = Value.EvalBool(Ctx); else if (strEquals(sParam, PARTICLE_LIFETIME_ATTRIB)) m_ParticleLifetime = Value.EvalDiceRange(Ctx, 10); else if (strEquals(sParam, LAST_DIRECTION_ATTRIB)) m_iLastDirection = Value.EvalIntegerBounded(Ctx, 0, -1, -1); else if (strEquals(sParam, LAST_EMIT_POS_ATTRIB)) m_vLastEmitPos = Value.EvalVector(Ctx); else if (strEquals(sParam, LIFETIME_ATTRIB)) m_iLifetime = Value.EvalIntegerBounded(Ctx, 0, -1, 0); else if (strEquals(sParam, SPREAD_ANGLE_ATTRIB)) m_SpreadAngle = Value.EvalDiceRange(Ctx, 5); else if (strEquals(sParam, TANGENT_SPEED_ATTRIB)) m_TangentSpeed = Value.EvalDiceRange(Ctx, 0); else if (strEquals(sParam, USE_OBJECT_CENTER_ATTRIB)) m_bUseObjectCenter = Value.EvalBool(Ctx); else if (strEquals(sParam, XFORM_ROTATION_ATTRIB)) m_iXformRotation = Value.EvalIntegerBounded(Ctx, -359, 359, 0); else if (strEquals(sParam, XFORM_TIME_ATTRIB)) m_rXformTime = Value.EvalIntegerBounded(Ctx, 0, -1, 100) / 100.0; }