//============================================================================= void AchievementListItem::ApplySchemeSettings(IScheme *pScheme) { BaseClass::ApplySchemeSettings(pScheme); #ifndef _X360 if ( !m_pAchievement ) return; if ( !g_pPreloadedAchievementListItemLayout ) { const char *pszResource = "Resource/UI/BaseModUI/AchievementListItem.res"; g_pPreloadedAchievementListItemLayout = new KeyValues( pszResource ); g_pPreloadedAchievementListItemLayout->LoadFromFile(g_pFullFileSystem, pszResource); } LoadControlSettings( "", NULL, g_pPreloadedAchievementListItemLayout ); m_iOriginalTall = GetTall(); KeyValues *pListItem = g_pPreloadedAchievementListItemLayout->FindKey( "AchievementListItem" ); if ( pListItem ) { SetBgColor( pListItem->GetColor( "BackgroundColor" ) ); } SetAchievementName( ACHIEVEMENT_LOCALIZED_NAME( m_pAchievement ) ); SetAchievementHowTo( ACHIEVEMENT_LOCALIZED_DESC( m_pAchievement ) ); SetAchievementIcon( m_pAchievement->GetIconPath() ); SetAchievementGoal( m_pAchievement->GetGoal() ); SetGamerScore( m_pAchievement->GetPointValue() ); SetAchievementProgress( m_pAchievement->IsAchieved() ? m_pAchievement->GetGoal() : m_pAchievement->GetCount() ); // TODO: /* int iNumComponents = m_pAchievement->GetNumComponents(); if ( iNumComponents > 0 ) { KeyValues *pLeftTemplate = g_pPreloadedAchievementListItemLayout->FindKey( "ComponentTemplateLeft", true ); KeyValues *pRightTemplate = g_pPreloadedAchievementListItemLayout->FindKey( "ComponentTemplateRight", true ); KeyValues *pLeftCheckmarkTemplate = g_pPreloadedAchievementListItemLayout->FindKey( "CheckmarkTemplateLeft", true ); KeyValues *pRightCheckmarkTemplate = g_pPreloadedAchievementListItemLayout->FindKey( "CheckmarkTemplateRight", true ); uint64 iComponentBits = m_pAchievement->GetComponentBits(); int iNumRows = 0; for ( int i = 0, iNumComponents = m_pAchievement->GetNumComponents(); i < iNumComponents; i++ ) { vgui::Label *pLabel = vgui::SETUP_PANEL( new vgui::Label( this, NULL, "" ) ); if ( !pLabel ) continue; pLabel->ApplySettings( (i%2) == 0 ? pLeftTemplate : pRightTemplate ); pLabel->SetName( CFmtStr( "comp%d", i ) ); pLabel->SetText( g_pVGuiLocalize->FindSafe( m_pAchievement->GetComponentDisplayString(i) ) ); pLabel->SetVisible( false ); //start out hidden pLabel->SetEnabled( ( iComponentBits & ((uint64) 1 << i) ) ); if ( iComponentBits & ((uint64) 1 << i) ) { // show a checkmark next to this component vgui::ImagePanel *pCheckmark = vgui::SETUP_PANEL( new vgui::ImagePanel( this, NULL ) ); if ( pCheckmark ) { pCheckmark->ApplySettings( (i%2) == 0 ? pLeftCheckmarkTemplate : pRightCheckmarkTemplate ); pCheckmark->SetName( CFmtStr( "check%d", i ) ); pCheckmark->SetVisible( false ); } } if ( (i%2) == 0 ) { iNumRows++; } } if ( iNumRows > 0 ) { // we have some details, make ourselves tall enough to show the details button SetTall( m_iOriginalTall + m_flDetailsExtraHeight ); } vgui::Button *pDetailsButton = dynamic_cast< vgui::Button * >( FindChildByName( "BtnDetails" ) ); if ( pDetailsButton ) { pDetailsButton->SetVisible( true ); } vgui::Label *pDetailsLabel = dynamic_cast< vgui::Label * >( FindChildByName( "LblDetails" ) ); if ( pDetailsLabel ) { pDetailsLabel ->SetVisible( true ); SetControlString( "LblDetails", "#GameUI_ShowDetails" ); } } */ #else SetBgColor(pScheme->GetColor( "Button.BgColor", Color( 32, 32, 32, 255 ) ) ); #endif }
void CHudAnimationInfo::PaintMappingInfo( int& x, int& y, Panel *element, PanelAnimationMap *map ) { if ( !map ) return; // Draw label surface()->DrawSetTextFont( m_LabelFont ); surface()->DrawSetTextColor( m_LabelColor ); surface()->DrawSetTextPos( x, y ); const char *className = ""; if ( map->pfnClassName ) { className = (*map->pfnClassName)(); } const char *p = className; while ( *p ) { surface()->DrawUnicodeChar( *p ); p++; } y += surface()->GetFontTall( m_LabelFont ) + 1; x += 10; int c = map->entries.Count(); for ( int i = 0; i < c; i++ ) { PanelAnimationMapEntry *e = &map->entries[ i ]; char sz[ 512 ]; char value[ 256 ]; Color col( 0, 0, 0, 0 ); Color *pColor = NULL; KeyValues *kv = new KeyValues( e->name() ); if ( element->RequestInfo( kv ) ) { KeyValues *dat = kv->FindKey(e->name()); if ( dat && dat->GetDataType() == KeyValues::TYPE_COLOR ) { col = dat->GetColor(); Q_snprintf( value, sizeof( value ), "%i, %i, %i, %i", col[0], col[1], col[2], col[3] ); pColor = &col; } else { Q_snprintf( value, sizeof( value ), "%s", dat->GetString() ); } } else { Q_strncpy( value, "???", sizeof( value ) ); } Q_snprintf( sz, sizeof( sz ), "%-30s %-20s (%s)", e->name(), e->type(), value ); kv->deleteThis(); PaintString( x, y, sz, pColor ); } x -= 10; if ( map->baseMap ) { PaintMappingInfo( x, y, element, map->baseMap ); } }
//----------------------------------------------------------------------------- // Purpose: Gets the specified value from a panel //----------------------------------------------------------------------------- AnimationController::Value_t AnimationController::GetValue(ActiveAnimation_t& anim, Panel *panel, UtlSymId_t var) { Value_t val = { 0, 0, 0, 0 }; if (var == m_sPosition) { int x, y; panel->GetPos(x, y); val.a = (float)(x - GetRelativeOffset( anim.align, true ) ); val.b = (float)(y - GetRelativeOffset( anim.align, false ) ); } else if (var == m_sSize) { int w, t; panel->GetSize(w, t); val.a = (float)w; val.b = (float)t; } else if (var == m_sFgColor) { Color col = panel->GetFgColor(); val.a = col[0]; val.b = col[1]; val.c = col[2]; val.d = col[3]; } else if (var == m_sBgColor) { Color col = panel->GetBgColor(); val.a = col[0]; val.b = col[1]; val.c = col[2]; val.d = col[3]; } else if ( var == m_sXPos ) { int x, y; panel->GetPos(x, y); val.a = (float)( x - GetRelativeOffset( anim.align, true ) ); } else if ( var == m_sYPos ) { int x, y; panel->GetPos(x, y); val.a = (float)( y - GetRelativeOffset( anim.align, false ) ); } else if ( var == m_sWide ) { int w, h; panel->GetSize(w, h); val.a = (float)w; } else if ( var == m_sTall ) { int w, h; panel->GetSize(w, h); val.a = (float)h; } else { KeyValues *outputData = new KeyValues(g_ScriptSymbols.String(var)); if (panel->RequestInfo(outputData)) { // find the var and lookup it's type KeyValues *kv = outputData->FindKey(g_ScriptSymbols.String(var)); if (kv && kv->GetDataType() == KeyValues::TYPE_FLOAT) { val.a = kv->GetFloat(); val.b = 0.0f; val.c = 0.0f; val.d = 0.0f; } else if (kv && kv->GetDataType() == KeyValues::TYPE_COLOR) { Color col = kv->GetColor(); val.a = col[0]; val.b = col[1]; val.c = col[2]; val.d = col[3]; } } else { // Assert(!("Unhandlable var in AnimationController::GetValue())")); } outputData->deleteThis(); } return val; }