//----------------------------------------------------------------------------- // initialization //----------------------------------------------------------------------------- bool CEntityTeamImagePanel::Init( KeyValues* pInitData, C_BaseEntity* pEntity ) { if (!BaseClass::Init( pInitData, pEntity)) return false; if ( pInitData->GetInt( "showinnormalmode", 0 ) ) { m_bShowInNormal = true; } // get the size... int w, h; if (!ParseCoord( pInitData, "offset", m_OffsetX, m_OffsetY )) return false; if (!ParseCoord( pInitData, "size", w, h )) return false; // Set the size... SetSize( w, h ); m_iOrgWidth = w; m_iOrgHeight = h; m_iOrgOffsetX = m_OffsetX; m_iOrgOffsetY = m_OffsetY; const char *mouseover = pInitData->GetString( "mousehint", "" ); if ( mouseover && mouseover[ 0 ] ) { Q_strncpy( m_szMouseOverText, mouseover, sizeof( m_szMouseOverText ) ); } for ( int i = 0 ; i < MAX_TEAMS; i++ ) { char teamname[ 32 ]; Q_snprintf( teamname, sizeof( teamname ), "Team%i", i ); memset( &m_Images[ i ], 0, sizeof( m_Images[ i ] ) ); // Look for team section KeyValues *pTeamKV = pInitData->FindKey( teamname ); if ( !pTeamKV ) continue; // modulation color if (!ParseRGBA( pTeamKV, "color", m_Images[i].m_r, m_Images[i].m_g, m_Images[i].m_b, m_Images[i].m_a )) return false; char const* pClassImage = pTeamKV->GetString( "material" ); if ( !pClassImage || !pClassImage[ 0 ] ) return false; // hook in the bitmap m_Images[ i ].m_pImage = new BitmapImage( GetVPanel(), pClassImage ); } // we need updating vgui::ivgui()->AddTickSignal( GetVPanel() ); return true; }
//----------------------------------------------------------------------------- // initialization //----------------------------------------------------------------------------- bool CBitmapPanel::Init(KeyValues* pInitData) { Assert(pInitData); // modulation color if (!ParseRGBA(pInitData, "color", m_r, m_g, m_b, m_a)) return false; int x, y, w, h; if (!ParseRect(pInitData, "position", x, y, w, h)) return false; const char *mouseover = pInitData->GetString("mousehint", ""); if (mouseover && mouseover[0]) { Q_strncpy(m_szMouseOverText, mouseover, sizeof(m_szMouseOverText)); } // Set the size... SetPos(x, y); SetSize(w, h); char const* pClassImage = pInitData->GetString("material"); if (!pClassImage || !pClassImage[0]) return false; // hook in the bitmap m_pImage = new BitmapImage(GetVPanel(), pClassImage); m_bOwnsImage = true; return true; }
bool ParseRGBA( KeyValues* pValues, const char* pFieldName, Color& c ) { int r, g, b, a; if (!ParseRGBA( pValues, pFieldName, r, g, b, a )) return false; c.SetColor( r, g, b, a ); return true; }
//----------------------------------------------------------------------------- // Purpose: Parse values from the file //----------------------------------------------------------------------------- bool CHealthBarPanel::Init( KeyValues* pInitData ) { if (!pInitData) return false; if (!ParseRGBA(pInitData, "okcolor", m_Ok )) return false; if (!ParseRGBA(pInitData, "badcolor", m_Bad )) return false; int x, y, w, h; if (!ParseRect(pInitData, "position", x, y, w, h )) return false; SetPos( x, y ); SetSize( w, h ); SetCursor( NULL ); return true; }
//----------------------------------------------------------------------------- // Initialization //----------------------------------------------------------------------------- bool CHudPlayerOverlaySquad::Init( KeyValues* pInitData ) { if (!pInitData) return false; SetContentAlignment( vgui::Label::a_west ); if (!ParseRGBA(pInitData, "fgcolor", m_fgColor )) return false; if (!ParseRGBA(pInitData, "bgcolor", m_bgColor)) return false; int x, y, w, h; if (!ParseRect(pInitData, "position", x, y, w, h )) return false; SetPos( x, y ); SetSize( w, h ); return true; }
bool BitmapImage::Init( vgui::VPANEL pParent, KeyValues* pInitData ) { char const* pMaterialName = pInitData->GetString( "material" ); if ( !pMaterialName || !pMaterialName[ 0 ] ) return false; // modulation color Color color; if (!ParseRGBA( pInitData, "color", color )) color.SetColor( 255, 255, 255, 255 ); Init( pParent, pMaterialName ); SetColor( color ); return true; }
bool CEntityImagePanel::Init( KeyValues* pInitData, C_BaseEntity* pEntity ) { if (!BaseClass::Init( pInitData, pEntity)) return false; // modulation color if (!ParseRGBA( pInitData, "color", m_r, m_g, m_b, m_a )) return false; // get the size... int w, h; if (!ParseCoord( pInitData, "offset", m_OffsetX, m_OffsetY )) return false; if (!ParseCoord( pInitData, "size", w, h )) return false; char const* pClassImage = pInitData->GetString( "material" ); if ( !pClassImage || !pClassImage[ 0 ] ) return false; const char *mouseover = pInitData->GetString( "mousehint", "" ); if ( mouseover && mouseover[ 0 ] ) { Q_strncpy( m_szMouseOverText, mouseover, sizeof( m_szMouseOverText ) ); } // hook in the bitmap m_pImage = new BitmapImage( GetVPanel(), pClassImage ); // Set the size... SetSize( w, h ); m_iOrgWidth = w; m_iOrgHeight = h; m_iOrgOffsetX = m_OffsetX; m_iOrgOffsetY = m_OffsetY; // we need updating vgui::ivgui()->AddTickSignal( GetVPanel() ); OnTick(); return true; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- bool CHudPlayerOverlay::Init( KeyValues* pInitData, C_BaseEntity* pEntity ) { Clear(); m_hPlayer = dynamic_cast< C_BaseTFPlayer * >( pEntity ); if (!m_hPlayer.Get()) return false; if (!BaseClass::Init( pInitData, pEntity )) return false; if (!ParseRGBA(pInitData, "fgcolor", m_fgColor )) return false; if (!ParseRGBA(pInitData, "bgcolor", m_bgColor )) return false; if (!ParseCoord(pInitData, "offset", m_OffsetX, m_OffsetY )) return false; int w, h; if (!ParseCoord(pInitData, "size", w, h )) return false; SetSize( w, h ); SetVisible( false ); m_iOrgWidth = w; m_iOrgHeight = h; m_iOrgOffsetX = m_OffsetX; m_iOrgOffsetY = m_OffsetY; const char *mouseover = pInitData->GetString( "mousehint", "" ); if ( mouseover && mouseover[ 0 ] ) { Q_strncpy( m_szMouseOverText, mouseover, sizeof( m_szMouseOverText ) ); } m_pHealth = new CHudPlayerOverlayHealth( this ); KeyValues* pHealthValue = pInitData->FindKey("HealthBar"); if (!m_pHealth->Init( pHealthValue )) return false; m_pHealth->SetVisible( false ); m_pHealth->SetParent( this ); m_pName = new CHudPlayerOverlayName( this, "" ); KeyValues* pNameValue = pInitData->FindKey("Name"); if (!m_pName->Init( pNameValue )) return false; m_pName->SetVisible( false ); m_pName->SetParent( this ); m_pClass = new CHudPlayerOverlayClass( this ); KeyValues* pClassValue = pInitData->FindKey("Class"); if (!m_pClass->Init( pClassValue )) return false; m_pClass->SetVisible( false ); m_pClass->SetParent( this ); m_pSquad = new CHudPlayerOverlaySquad( this, "" ); KeyValues* pSquadValue = pInitData->FindKey("Squad"); if (!m_pSquad->Init( pSquadValue )) return false; m_pSquad->SetVisible( false ); m_pSquad->SetParent( this ); m_pSelected = new CHudPlayerOverlaySelected( this ); KeyValues* pSelectedValue = pInitData->FindKey("Selection"); if (!m_pSelected->Init( pSelectedValue )) return false; m_pSelected->SetVisible( false ); m_pSelected->SetParent( this ); // Um, is there a better way? m_PlayerNum = GetEntity() ? GetEntity()->index : 0; if (m_PlayerNum == 0) return false; return true; }