void FieldRenderer::RenderAll(std::ostream &reply, Context &context, const ROAnything &config) { StartTrace(FieldRenderer.Render); TraceAny(config, "config"); if (config.IsDefined("Name")) { reply << "<INPUT TYPE=\"" ; RenderType(reply, context, config); reply << "\" NAME=\""; RenderName(reply, context, config); reply << "\""; RenderOptions(reply, context, config); reply << ">"; } else { SystemLog::Error("FieldRenderer::RenderAll: mandatory 'Name' slot is missing in configuration!"); } }
void ViewerClientAttributes::SetFromNode(DataNode *parentNode) { if(parentNode == 0) return; DataNode *searchNode = parentNode->GetNode("ViewerClientAttributes"); if(searchNode == 0) return; DataNode *node; if((node = searchNode->GetNode("renderingType")) != 0) { // Allow enums to be int or string in the config file if(node->GetNodeType() == INT_NODE) { int ival = node->AsInt(); if(ival >= 0 && ival < 3) SetRenderingType(RenderType(ival)); } else if(node->GetNodeType() == STRING_NODE) { RenderType value; if(RenderType_FromString(node->AsString(), value)) SetRenderingType(value); } } if((node = searchNode->GetNode("id")) != 0) SetId(node->AsInt()); if((node = searchNode->GetNode("title")) != 0) SetTitle(node->AsString()); if((node = searchNode->GetNode("windowIds")) != 0) SetWindowIds(node->AsIntVector()); if((node = searchNode->GetNode("imageWidth")) != 0) SetImageWidth(node->AsInt()); if((node = searchNode->GetNode("imageHeight")) != 0) SetImageHeight(node->AsInt()); if((node = searchNode->GetNode("imageResolutionPcnt")) != 0) SetImageResolutionPcnt(node->AsDouble()); if((node = searchNode->GetNode("externalClient")) != 0) SetExternalClient(node->AsBool()); if((node = searchNode->GetNode("renderingTypes")) != 0) SetRenderingTypes(node->AsIntVector()); }
int CParticle::Create (CFixVector *vPos, CFixVector *vDir, CFixMatrix *mOrient, short nSegment, int nLife, int nSpeed, char nParticleSystemType, char nClass, float nScale, tRgbaColorf *colorP, int nCurTime, int bBlowUp, char nFadeType, float fBrightness, CFixVector *vEmittingFace) { tRgbaColorf color; int nType = particleImageManager.GetType (nParticleSystemType); m_bChecked = 0; m_bBlowUp = bBlowUp && gameOpts->render.particles.bDisperse; if (nScale < 0) m_nRad = float (-nScale); else if (gameOpts->render.particles.bSyncSizes) m_nRad = float (PARTICLE_SIZE (gameOpts->render.particles.nSize [0], nScale, m_bBlowUp)); else m_nRad = float (nScale); if (!m_nRad) m_nRad = 1.0f; m_nType = nType; m_bEmissive = (nParticleSystemType == LIGHT_PARTICLES) ? 1 : (nParticleSystemType == FIRE_PARTICLES) ? 2 : 0; m_nClass = nClass; m_nFadeType = nFadeType; m_nSegment = nSegment; m_nBounce = ((m_nType == BUBBLE_PARTICLES) || (m_nType == WATERFALL_PARTICLES)) ? 1 : 2; m_bReversed = 0; m_nMoved = nCurTime; if (nLife < 0) nLife = -nLife; m_nLife = nLife; m_nDelay = 0; //bStart ? randN (nLife) : 0; m_color [0] = m_color [1] = color = (colorP && (m_bEmissive < 2)) ? *colorP : defaultParticleColor; if ((nType == BULLET_PARTICLES) || (nType == BUBBLE_PARTICLES)) { m_bBright = 0; m_nFadeState = -1; } else { m_bBright = (nType <= SMOKE_PARTICLES) ? (rand () % 50) == 0 : 0; if (colorP) { if (!m_bEmissive) { m_color [0].red *= RANDOM_FADE; m_color [0].green *= RANDOM_FADE; m_color [0].blue *= RANDOM_FADE; } m_nFadeState = 0; } else { m_color [0].red = 1.0f; m_color [0].green = 0.5f; m_color [0].blue = 0.0f; m_nFadeState = 2; } if (m_bEmissive) m_color [0].alpha = float (SMOKE_START_ALPHA + 64) / 255.0f; else if (nParticleSystemType != GATLING_PARTICLES) { if (!colorP) m_color [0].alpha = float (3 * SMOKE_START_ALPHA / 4 + randN (SMOKE_START_ALPHA / 2)) / 255.0f; else { if (colorP->alpha < 0) { ubyte a = ubyte (-colorP->alpha * 255.0f * 0.25f + 0.5f); m_color [0].alpha = float (3 * a + randN (2 * a)) / 255.0f; } else { if (2 == (m_nFadeState = char (colorP->alpha))) { m_color [0].red = 1.0f; m_color [0].green = 0.5f; m_color [0].blue = 0.0f; } m_color [0].alpha = float (3 * SMOKE_START_ALPHA / 4 + randN (SMOKE_START_ALPHA / 2)) / 255.0f; } } if (m_bBlowUp && !m_bBright) { fBrightness = 1.0f - fBrightness; m_color [0].alpha += fBrightness * fBrightness / 8.0f; } } } #if 0 if (nType == FIRE_PARTICLES) nSpeed = int (sqrt (double (nSpeed)) * float (I2X (1))); else #endif nSpeed *= I2X (1); if (!vDir) { m_vDrift [X] = nSpeed - randN (2 * nSpeed); m_vDrift [Y] = nSpeed - randN (2 * nSpeed); m_vDrift [Z] = nSpeed - randN (2 * nSpeed); m_vDir.SetZero (); m_bHaveDir = 1; } else { m_vDir = *vDir; CAngleVector a; CFixMatrix m; a [PA] = randN (I2X (1) / 4) - I2X (1) / 8; a [BA] = randN (I2X (1) / 4) - I2X (1) / 8; a [HA] = randN (I2X (1) / 4) - I2X (1) / 8; m = CFixMatrix::Create (a); if (nType == WATERFALL_PARTICLES) CFixVector::Normalize (m_vDir); m_vDrift = m * m_vDir; CFixVector::Normalize (m_vDrift); if (nType == WATERFALL_PARTICLES) { fix dot = CFixVector::Dot (m_vDir, m_vDrift); if (dot < I2X (1) / 2) return 0; } float d = float (CFixVector::DeltaAngle (m_vDrift, m_vDir, NULL)); if (d) { d = (float) exp ((I2X (1) / 8) / d); nSpeed = (fix) ((float) nSpeed / d); } m_vDrift *= nSpeed; if (nType <= FIRE_PARTICLES) m_vDir *= (I2X (3) / 4 + I2X (randN (16)) / 64); #if DBG if (CFixVector::Dot (m_vDrift, m_vDir) < 0) d = 0; #endif m_bHaveDir = 1; } if (vEmittingFace) m_vPos = *RandomPointOnQuad (vEmittingFace, vPos); else if (nType != BUBBLE_PARTICLES) m_vPos = *vPos + m_vDrift * (I2X (1) / 64); else { //m_vPos = *vPos + vDrift * (I2X (1) / 32); nSpeed = m_vDrift.Mag () / 16; CFixVector v = CFixVector::Avg ((*mOrient).RVec () * (nSpeed - randN (2 * nSpeed)), (*mOrient).UVec () * (nSpeed - randN (2 * nSpeed))); m_vPos = *vPos + v + (*mOrient).FVec () * (I2X (1) / 2 - randN (I2X (1))); } if ((nType != BUBBLE_PARTICLES) && mOrient) { CAngleVector vRot; CFixMatrix mRot; vRot [BA] = 0; vRot [PA] = 2048 - ((d_rand () % 9) * 512); vRot [HA] = 2048 - ((d_rand () % 9) * 512); mRot = CFixMatrix::Create (vRot); m_mOrient = *mOrient * mRot; } if (nType <= SMOKE_PARTICLES) { if (m_bBlowUp) m_nLife = 2 * m_nLife / 3; m_nLife = 4 * m_nLife / 5 + randN (2 * m_nLife / 5); m_nRad += float (randN (int (m_nRad))); } else if (nType == FIRE_PARTICLES) { m_nLife = 3 * m_nLife / 4 + randN (m_nLife / 4); m_nRad += float (randN (int (m_nRad))); } else if (nType == BUBBLE_PARTICLES) m_nRad = m_nRad / 10 + float (randN (int (9 * m_nRad / 10))); else m_nRad *= 2; //m_nRad *= 0.5f; m_vStartPos = m_vPos; if (m_bBlowUp) { m_nWidth = (nType == WATERFALL_PARTICLES) ? m_nRad * 0.6666667f : m_nRad; m_nHeight = m_nRad; } else { m_nWidth = (nType == WATERFALL_PARTICLES) ? m_nRad * 0.3333333f : m_nRad * 2; m_nHeight = m_nRad * 2; } m_nWidth /= 65536.0f; m_nHeight /= 65536.0f; m_nRad /= 65536.0f; m_nFrames = ParticleImageInfo (nType).nFrames; m_deltaUV = 1.0f / float (m_nFrames); if (nType == BULLET_PARTICLES) { m_iFrame = 0; m_nRotFrame = 0; m_nOrient = 3; } else if (nType == BUBBLE_PARTICLES) { m_iFrame = rand () % (m_nFrames * m_nFrames); m_nRotFrame = 0; m_nOrient = 0; } else if ((nType == LIGHT_PARTICLES) /*|| (nType == WATERFALL_PARTICLES)*/) { m_iFrame = 0; m_nRotFrame = 0; m_nOrient = 0; } else if (nType == FIRE_PARTICLES) { m_iFrame = (rand () % 10 < 6) ? 0 : 2; // more fire than smoke (60:40) if (m_iFrame < 2) m_nLife = 9 * m_nLife / 10; else m_nLife = 10 * m_nLife / 9; m_nRotFrame = rand () % PARTICLE_POSITIONS; m_nOrient = rand () % 4; } else { m_iFrame = rand () % (m_nFrames * m_nFrames); m_nRotFrame = rand () % PARTICLE_POSITIONS; m_nOrient = rand () % 4; #if 1 #endif } m_nTTL = m_nLife; m_nRenderType = RenderType (); m_bAnimate = (nType != FIRE_PARTICLES) && (gameOpts->render.particles.nQuality > 1) && (m_nFrames > 1); m_bRotate = (m_nRenderType <= SMOKE_PARTICLES) ? 1 : (m_nRenderType == FIRE_PARTICLES + PARTICLE_TYPES) ? -1 : 0; UpdateDecay (); UpdateTexCoord (); #if 0 if (colorP && (colorP->alpha < 0)) m_color [0].alpha /= 2.0f; else #endif { if (m_bEmissive) m_color [0].alpha = 1.0f; else if (nParticleSystemType == SIMPLE_SMOKE_PARTICLES) m_color [0].alpha /= 3.5f - float (gameOpts->render.particles.nQuality) / 2.0f; //colorP ? 2.0f + (color.red + color.green + color.blue) / 3.0f : 2.0f; else if (nParticleSystemType == SMOKE_PARTICLES) m_color [0].alpha /= colorP ? 3.0f - (color.red + color.green + color.blue) / 3.0f : 2.5f; else if (nParticleSystemType == BUBBLE_PARTICLES) m_color [0].alpha /= 2.0f; else if (nParticleSystemType == GATLING_PARTICLES) m_color [0].alpha /= 4.0f; # if 0 else if (nParticleSystemType == GATLING_PARTICLES) ;//m_color [0].alpha /= 6; # endif } SetupColor (fBrightness); return 1; }
ViewerClientAttributes::RenderType ViewerClientAttributes::GetRenderingType() const { return RenderType(renderingType); }
RenderType CameraComponent::getPipeline() const { return RenderType(_data.pipeline); }
// // hwndGV - handle to GridView control // hRoot - root item-handle // type - node in the type-chain // dwOffset - current offset // // returns: size of type // size_w RecurseType(HWND hwndGV, HGRIDITEM hRoot, Type *type, size_w dwOffset, TypeDecl *typeDecl) { GVITEM gvitem = { 0 }; Structure *sptr; size_t i; TCHAR buf[200]; if(type == 0) return 0; size_w dwLength = 0; INUMTYPE switchVal = 0;//1; HWND hwndHV = GetActiveHexView(g_hwndMain); switch(type->ty) { case typeDOSTIME: case typeDOSDATE: case typeFILETIME: case typeTIMET: dwLength = FmtData(hwndGV, hRoot, type, dwOffset, typeDecl); break; case typeCHAR: case typeWCHAR: case typeBYTE: case typeWORD: case typeDWORD: case typeQWORD: case typeFLOAT: case typeDOUBLE: case typeENUM: dwLength = FmtData(hwndGV, hRoot, type, dwOffset, typeDecl); break; case typeUNION: // evaluate the switch_is() ExprNode *switchExpr; if(FindTag(typeDecl->tagList, TOK_SWITCHIS, &switchExpr)) { switchVal = Evaluate(switchExpr); } sptr = type->sptr; for(i = 0; i < sptr->typeDeclList.size(); i++) { TypeDecl *typeDecl = sptr->typeDeclList[i]; ExprNode *caseExpr; size_w tmpLen = 0; if(FindTag(typeDecl->tagList, TOK_CASE, &caseExpr)) { if(Evaluate(caseExpr) == switchVal) tmpLen = InsertTypeGV(hwndGV, hRoot, typeDecl, dwOffset); } else { tmpLen = InsertTypeGV(hwndGV, hRoot, typeDecl, dwOffset); } dwLength = max(dwLength, tmpLen); } break; case typeSTRUCT: sptr = type->sptr; for(i = 0; i < sptr->typeDeclList.size(); i++) { TypeDecl *typeDecl = sptr->typeDeclList[i]; dwLength += InsertTypeGV(hwndGV, hRoot, typeDecl, dwOffset + dwLength); } break; case typeIDENTIFIER: hRoot = InsertIdentifier(hwndGV, hRoot, type, dwOffset, typeDecl); dwLength = RecurseType(hwndGV, hRoot, type->link, dwOffset, typeDecl); break; #if 0 if(fShowFullType) { RenderType(buf, 200, type); gvitem.pszText = buf; } else { _stprintf(buf, TEXT("%hs"), type->sym->name); gvitem.pszText = buf;//type->sym->name; } gvitem.state = 0; if(type->link && type->link->ty != typeARRAY) gvitem.state |= GVIS_EXPANDED; gvitem.iImage = IsStruct(type) ? 1 : 0; if(typeDecl->tagList) gvitem.iImage+=2; gvitem.param = (ULONG_PTR)type;//typeDecl; gvitem.mask = GVIF_PARAM | GVIF_TEXT | GVIF_STATE | GVIF_IMAGE; GridView2_SetItem(hwndGV, hRoot, &gvitem); if(type->link && type->link->ty == typeARRAY) { FormatDataItem(hwndGV, hRoot, type, dwOffset); } if(IsStruct(type)) { gvitem.iSubItem = COLIDX_DATA; gvitem.state = GVIS_READONLY; gvitem.pszText = TEXT("{...}"); gvitem.param = 0; gvitem.mask = GVIF_PARAM | GVIF_TEXT | GVIF_STATE; GridView2_SetItem(hwndGV, hRoot, &gvitem); } if(!fShowFullType) { RenderType(buf, 200, type->link); //_stprintf(buf, TEXT("%hs"), type->sym->name); gvitem.iSubItem = 0;//COLIDX_TYPE; gvitem.state = GVIS_READONLY; gvitem.pszText = buf; gvitem.param = (UINT64)type; gvitem.mask = GVIF_PARAM | GVIF_TEXT | GVIF_STATE; GridView2_SetItem(hwndGV, hRoot, &gvitem); } dwLength = RecurseType(hwndGV, hRoot, type->link, dwOffset, typeDecl); break; #endif case typeTYPEDEF: case typeSIGNED: case typeUNSIGNED: case typeCONST: // return 0; case typePOINTER: dwLength = RecurseType(hwndGV, hRoot, type->link, dwOffset, typeDecl); break; case typeARRAY: Symbol *sym; ExprNode *nameExpr; if(FindTag(typeDecl->tagList, TOK_NAME, &nameExpr)) { if((sym = LookupSymbol(globalTagSymbolList, nameExpr->str)) != 0) { if(sym->type && sym->type->ty == typeENUM) ; else sym = 0; } } else { sym = 0; } UINT64 count; count = 0; Evaluate(GridView_GetParent(hwndGV, hRoot), type->elements, &count, dwOffset, hwndHV, hwndGV); count &= 0xffff; count = min(count,100); for(i = 0; i < count; i++) { HGRIDITEM hItem; TCHAR buf[164]; int len = _stprintf(buf, TEXT("[%d] "), (int)i); if(sym) { Enum *eptr = sym->type->eptr; char *s = 0; for(size_t x = 0; x < eptr->fieldList.size(); x++) { if(i == eptr->fieldList[x]->val) { s = eptr->fieldList[i]->name->name; } } _stprintf(buf + 5, TEXT("- %hs"), s); } gvitem.pszText = buf; gvitem.state = GVIS_READONLY; gvitem.iImage = 0;//rand() % 2; gvitem.param = (ULONG_PTR)type->link; gvitem.iSubItem = COLIDX_NAME; gvitem.mask = GVIF_STATE|GVIF_PARAM|GVIF_TEXT; hItem = GridView2_InsertUniqueChild(hwndGV, hRoot, &gvitem); // used to pass '0' as typeDecl??? why?? because this is an array element we // are recursing through!!!! dwLength += RecurseType(hwndGV, hItem, type->link, dwOffset + dwLength, 0);//typeDecl); } break; default: break; } // add the 'offset' column to all items if(hRoot) { _stprintf(buf, TEXT("%08x"), (DWORD)dwOffset); gvitem.pszText = buf; gvitem.iSubItem = COLIDX_OFFSET; gvitem.state = 0; gvitem.param = dwOffset; gvitem.mask = GVIF_TEXT | GVIF_STATE | GVIF_PARAM; GridView2_SetItem(hwndGV, hRoot, &gvitem); // add the 'comment' column item - only do this for items that aren't array elements if(typeDecl)// && type->ty != typeARRAY) { FILEREF *ref; ref = &typeDecl->postRef; buf[0] = '\0'; FormatWhitespace(ref, buf); gvitem.pszText = buf; gvitem.iSubItem = COLIDX_COMMENT; gvitem.state = 0; gvitem.mask = GVIF_TEXT | GVIF_STATE; GridView2_SetItem(hwndGV, hRoot, &gvitem); } } return dwLength; }
HGRIDITEM InsertIdentifier(HWND hwndGV, HGRIDITEM hRoot, Type *type, size_w dwOffset, TypeDecl *typeDecl) { TCHAR buf[200]; GVITEM gvitem = { 0 }; HGRIDITEM hItem; if(fShowFullType) { RenderType(buf, 200, type); gvitem.pszText = buf; } else { _stprintf(buf, TEXT("%hs"), type->sym->name); RenderType(buf, 200, type->link); gvitem.pszText = buf;//type->sym->name; } gvitem.state = 0; if(type->link && type->link->ty != typeARRAY) gvitem.state |= GVIS_EXPANDED; gvitem.iImage = IsStruct(type) ? 1 : 0; //gvitem.iImage = isstruct ? 3 : 2; if(typeDecl && typeDecl->tagList) gvitem.iImage+=2; gvitem.param = (ULONG_PTR)type;//typeDecl; gvitem.mask = GVIF_TEXT|GVIF_PARAM |GVIF_STATE | GVIF_IMAGE; hItem = GridView2_InsertUniqueChild(hwndGV, hRoot, &gvitem); if(type->link && type->link->ty == typeARRAY) { FormatDataItem(hwndGV, hItem, type, dwOffset); } if(IsStruct(type)) { gvitem.iSubItem = COLIDX_DATA; gvitem.state = GVIS_READONLY; gvitem.pszText = TEXT("{...}"); gvitem.param = 0; gvitem.mask = GVIF_PARAM | GVIF_TEXT | GVIF_STATE; GridView2_SetItem(hwndGV, hItem, &gvitem); } /*if(!fShowFullType) { RenderType(buf, 200, type->link); //_stprintf(buf, TEXT("%hs"), type->sym->name); gvitem.iSubItem = 0;//COLIDX_TYPE; gvitem.state = GVIS_READONLY; gvitem.pszText = buf; gvitem.param = (UINT64)type; gvitem.mask = GVIF_PARAM | GVIF_TEXT | GVIF_STATE; GridView2_SetItem(hwndGV, hItem, &gvitem); }*/ return hItem; }