//----------------------------------------------------------------------------- // Sets up the shader param editbox //----------------------------------------------------------------------------- void CMaterialEditorPanel::PopulateShaderParameters() { Assert( m_nShaderIndex >= 0 ); m_pEditorPanel->RemoveAll(); int nCount = g_pMaterialSystem->GetNumShaderParams(m_nShaderIndex); for (int i = 0; i < nCount; ++i) { const char *pParamName = g_pMaterialSystem->GetShaderParamName(m_nShaderIndex, i); char tempBuf[512]; Q_strncpy( tempBuf, pParamName, 512 ); Q_strnlwr( tempBuf, 512 ); // build a control & label (strip off '$' prefix) Label *pLabel = new Label( this, NULL, tempBuf + 1 ); pLabel->SetSize(128, 24); // Set up the tooltip for this puppy... pLabel->SetTooltipText( g_pMaterialSystem->GetShaderParamHelp(m_nShaderIndex, i) ); // Get at the material var bool bFound; IMaterialVar *pMaterialVar = m_pMaterial->FindVar( pParamName, &bFound ); Assert( bFound ); Panel *pEditPanel; switch( g_pMaterialSystem->GetShaderParamType(m_nShaderIndex, i) ) { case SHADER_PARAM_TYPE_TEXTURE: pEditPanel = new Label( this, NULL, "texture" ); break; case SHADER_PARAM_TYPE_INTEGER: { TextEntry *pTextEntry = new TextEntry(this, "Shader Param Integer"); Q_snprintf( tempBuf, 512, "%d", pMaterialVar->GetIntValue() ); pTextEntry->SetText( tempBuf ); pTextEntry->SetEditable( true ); pEditPanel = pTextEntry; } break; case SHADER_PARAM_TYPE_COLOR: pEditPanel = new Label( this, NULL, "color" ); break; case SHADER_PARAM_TYPE_VEC2: pEditPanel = new Label( this, NULL, "vec2" ); break; case SHADER_PARAM_TYPE_VEC3: pEditPanel = new Label( this, NULL, "vec3" ); break; case SHADER_PARAM_TYPE_FLOAT: { TextEntry *pTextEntry = new TextEntry(this, "Shader Param Float"); Q_snprintf( tempBuf, 512, "%f", pMaterialVar->GetIntValue() ); pTextEntry->SetText( tempBuf ); pTextEntry->SetEditable( true ); pEditPanel = pTextEntry; } break; default: pEditPanel = new Label( this, NULL, "other" ); break; } pEditPanel->SetSize(128, 24); // pEditPanel->SetContentAlignment( Label::a_east ); m_pEditorPanel->AddItem( pLabel, pEditPanel ); } }