//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CAvatarImagePanel::SetPlayer( C_BasePlayer *pPlayer ) { if ( GetImage() ) { ((CAvatarImage*)GetImage())->ClearAvatarSteamID(); } #ifndef NO_STEAM if ( pPlayer && SteamUtils() ) { int iIndex = pPlayer->entindex(); player_info_t pi; if ( engine->GetPlayerInfo(iIndex, &pi) ) { if ( pi.friendsID ) { CSteamID steamIDForPlayer( pi.friendsID, 1, SteamUtils()->GetConnectedUniverse(), k_EAccountTypeIndividual ); if ( !GetImage() ) { CAvatarImage *pImage = new CAvatarImage(); SetImage( pImage ); } ((CAvatarImage*)GetImage())->SetAvatarSteamID( steamIDForPlayer ); // Indent the image. These are deliberately non-resolution-scaling. int iIndent = 2; GetImage()->SetPos( iIndent, iIndent ); GetImage()->SetSize( GetWide()-(iIndent*2), GetTall()-(iIndent*2) ); } } } #endif }
void SwarmopediaPanel::PerformLayout() { BaseClass::PerformLayout(); int sw, sh; vgui::surface()->GetScreenSize( sw, sh ); float fScale = float(sh) / 768.0f; int list_wide = 200.0f * fScale; int padding = 5 * fScale; int iFooterSize = 32.0f * fScale; int html_left = list_wide + padding; int html_wide = GetWide() - (html_left + padding); if (m_pHTML) m_pHTML->SetBounds(html_left, padding, html_wide, GetTall() - (iFooterSize + padding * 3)); int text_high = fScale * 20; if (m_pTopicLabel) m_pTopicLabel->SetBounds(padding, padding, list_wide - padding * 2, text_high); Msg("SwarmopediaPanel::PerformLayout. fscale=%f list_wide=%d padding=%d footer=%d\n", fScale, list_wide, padding, iFooterSize); if (m_pList) { m_pList->SetBounds(padding, padding + text_high, list_wide - padding * 2, GetTall() - (iFooterSize + padding * 3)); m_pList->SetFirstColumnWidth(0); } }
void CASW_Medal_Collection_Frame::PerformLayout() { BaseClass::PerformLayout(); int sw, sh; vgui::surface()->GetScreenSize( sw, sh ); float fScale = float(sh) / 768.0f; int padding = 5 * fScale; int x, y, wide, tall; GetClientArea(x, y, wide, tall); m_pSheet->SetBounds(x, 5, wide, GetTall()); int iFooterSize = 32.0f * fScale; m_pCancelButton->GetTextImage()->ResizeImageToContent(); m_pCancelButton->SizeToContents(); int cancel_wide = m_pCancelButton->GetWide(); //m_pCancelButton->SetSize(cancel_wide, iFooterSize - 4); m_pCancelButton->SetPos(GetWide() - (cancel_wide + padding * 2), GetTall() - iFooterSize); m_pCollectionPanel->SetBounds(0, y, wide, tall - iFooterSize); // todo: reduce tall a bit? m_pMedalOffsetPanel->SetBounds(0, 0, wide, tall); // todo: reduce tall a bit? m_pSwarmopediaPanel->SetBounds(x, y, wide, tall - iFooterSize); // todo: reduce tall a bit? }
void CASW_Mission_Chooser_Frame::PerformLayout() { SetPos(100,10); int sw, sh; vgui::surface()->GetScreenSize( sw, sh ); SetSize(sw - 200, sh - 20); BaseClass::PerformLayout(); int x, y, wide, tall; GetClientArea(x, y, wide, tall); m_pSheet->SetBounds(x, y, wide, tall); m_pSheet->SetVisible(true); m_pSheet->InvalidateLayout(true); //m_pSheet->SetTabWidth(GetWide()/3.0f); float top_edge = 30; m_pChooserList->SetPos(0, top_edge); m_pChooserList->SetSize(wide, GetTall() - (60)); m_pChooserList->InvalidateLayout(true); if (m_pOptionsPanel) m_pOptionsPanel->SetBounds(x, top_edge, wide - x * 2, GetTall() - top_edge); }
void CASW_HUD_Health_Cross::PerformLayout() { BaseClass::PerformLayout(); m_pHealthLabel->SetBounds( health_xpos, health_ypos, GetWide(), GetTall() ); m_pHealthLabelShadow->SetBounds( health_xpos + 1, health_ypos + 1, GetWide(), GetTall() ); }
bool VideoPlayerPanel::SetVideo( const char *pVideoFile ) { ClearVideo(); // clearing the video? if ( pVideoFile == NULL || pVideoFile[0] == 0x00 ) { return true; } // create the material m_VideoMaterial = g_pVideo->CreateVideoMaterial( "VideoPlayerMaterial", pVideoFile, "GAME", VideoPlaybackFlags::DEFAULT_MATERIAL_OPTIONS, VideoSystem::DETERMINE_FROM_FILE_EXTENSION, true ); if ( m_VideoMaterial == NULL ) { return false; } // save filename int sLen = V_strlen( pVideoFile ) + 1; m_VideoFileName = new char[ sLen ]; V_strncpy( m_VideoFileName, pVideoFile, sLen ); // compute Playback dimensions int nWidth, nHeight; m_VideoMaterial->GetVideoImageSize( &nWidth, &nHeight ); m_VideoMaterial->GetVideoTexCoordRange( &m_flU, &m_flV ); float flFrameRatio = ( (float) GetWide() / (float) GetTall() ); float flVideoRatio = ( (float) nWidth / (float) nHeight ); if ( flVideoRatio > flFrameRatio ) { m_nPlaybackWidth = GetWide(); m_nPlaybackHeight = ( GetWide() / flVideoRatio ); m_letterBox = 1; } else if ( flVideoRatio < flFrameRatio ) { m_nPlaybackWidth = ( GetTall() * flVideoRatio ); m_nPlaybackHeight = GetTall(); m_letterBox = 2; } else { m_nPlaybackWidth = GetWide(); m_nPlaybackHeight = GetTall(); m_letterBox = 0; } m_pMaterial = m_VideoMaterial->GetMaterial(); m_VideoDuration = m_VideoMaterial->GetVideoDuration(); m_VideoLoaded = true; return true; }
//----------------------------------------------------------------------------- // Purpose: Begins playback of a movie // Output : Returns true on success, false on failure. //----------------------------------------------------------------------------- bool VideoPanel::BeginPlayback( const char *pFilename ) { #ifdef _X360 XVIDEO_MODE videoMode; XGetVideoMode( &videoMode ); // for 50Hz PAL, load a 25Hz version of the ep1_recap movie. if( ( videoMode.RefreshRate < 59.0f ) && ( Q_stricmp( pFilename, "media/ep1_recap.bik" ) == 0 ) ) { pFilename = "media/ep1_recap_25fps.bik"; } #endif // Destroy any previously allocated video if ( m_BIKHandle != BIKHANDLE_INVALID ) { bik->DestroyMaterial( m_BIKHandle ); m_BIKHandle = BIKHANDLE_INVALID; } // Load and create our BINK video m_BIKHandle = bik->CreateMaterial( "VideoBIKMaterial", pFilename, "GAME" ); if ( m_BIKHandle == BIKHANDLE_INVALID ) return false; // We want to be the sole audio source // FIXME: This may not always be true! enginesound->NotifyBeginMoviePlayback(); int nWidth, nHeight; bik->GetFrameSize( m_BIKHandle, &nWidth, &nHeight ); bik->GetTexCoordRange( m_BIKHandle, &m_flU, &m_flV ); m_pMaterial = bik->GetMaterial( m_BIKHandle ); float flFrameRatio = ( (float) GetWide() / (float) GetTall() ); float flVideoRatio = ( (float) nWidth / (float) nHeight ); if ( flVideoRatio > flFrameRatio ) { m_nPlaybackWidth = GetWide(); m_nPlaybackHeight = ( GetWide() / flVideoRatio ); } else if ( flVideoRatio < flFrameRatio ) { m_nPlaybackWidth = ( GetTall() * flVideoRatio ); m_nPlaybackHeight = GetTall(); } else { m_nPlaybackWidth = GetWide(); m_nPlaybackHeight = GetTall(); } return true; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CControlPointProgressBar::PerformLayout( void ) { BaseClass::PerformLayout(); if ( m_pAttachedToIcon && m_pTeardrop && m_pTeardropSide ) { int iIconX, iIconY; ipanel()->GetAbsPos(m_pAttachedToIcon->GetVPanel(), iIconX, iIconY ); int iDir = m_pAttachedToIcon->GetCapProgressDir(); int iXPos = 0; int iYPos = 0; int iEdgeSpace = (GetWide() - m_pTeardrop->GetWide()) * 0.5; // Line up our middle with the middle of the icon switch ( iDir ) { default: case CP_DIR_N: SetSize( GetWide(), m_iOrgHeight ); m_pTeardrop->SetVisible( true ); m_pTeardropSide->SetVisible( false ); iXPos = iIconX - ((GetWide() - m_pAttachedToIcon->GetWide()) * 0.5); iYPos = iIconY - GetTall(); break; case CP_DIR_NE: SetSize( GetWide(), YRES(53) ); m_pTeardropSide->SetIcon( "cappoint_progressbar_teardrop_right" ); m_pTeardrop->SetVisible( false ); m_pTeardropSide->SetVisible( true ); iXPos = iIconX + m_pAttachedToIcon->GetWide() - iEdgeSpace; iYPos = iIconY - GetTall(); break; case CP_DIR_NW: SetSize( GetWide(), YRES(53) ); m_pTeardropSide->SetIcon( "cappoint_progressbar_teardrop_left" ); m_pTeardrop->SetVisible( false ); m_pTeardropSide->SetVisible( true ); iXPos = iIconX - GetWide() + iEdgeSpace; iYPos = iIconY - GetTall(); break; } SetPos( iXPos, iYPos ); } }
void CASWSelectOverlayPulse::Initialize() { vgui::HScheme scheme = vgui::scheme()->LoadSchemeFromFile("resource/swarm/SwarmSchemeNew.res", "SwarmSchemeNew"); SetScheme(scheme); m_pOverlayLabel = new vgui::ImagePanel( this, "SelectOverlayImage" ); m_fStartTime = gpGlobals->curtime; int x, y; m_pParent->GetPos( x, y ); int w, h; m_pParent->GetSize( w, h ); SetSize( w * m_fScale, h * m_fScale ); SetPos( x - ( GetWide() - w ) / 2, y - ( GetTall() - h ) / 2 ); SetZPos( 100 ); if ( m_pOverlayLabel ) { m_pOverlayLabel->SetImage( "inventory/item_select_glow" ); m_pOverlayLabel->SetShouldScaleImage( true ); m_pOverlayLabel->SetAlpha( 255 ); m_pOverlayLabel->SetPos( 0, 0 ); m_pOverlayLabel->SetSize( w * m_fScale, h * m_fScale ); m_bStarted = true; } }
void CASW_VGUI_Message_Log::PerformLayout() { BaseClass::PerformLayout(); // sizes uses by baseclass int w = GetWide(); int t = GetTall(); m_fScale = ScreenWidth() / 1024.0f; float panel_y = ScreenHeight() * TEXT_BORDER_Y; int button_high = 40 * m_fScale; // how much space do we have for message buttons? int message_y_space = ( (t - button_high * 1.7f) - (ScreenHeight() * TEXT_BORDER_Y) ) - panel_y; int padding = 5 * m_fScale; int message_y_per_button = (message_y_space / float(ASW_MAX_LOGGED_MESSAGES)); int pos_x = ScreenWidth() * TEXT_BORDER_X; // position message buttons for (int i=0;i<ASW_MAX_LOGGED_MESSAGES;i++) { if (!m_pMessageButton[i]) continue; m_pMessageButton[i]->SetBounds(pos_x, panel_y, w - (pos_x * 2), message_y_per_button - padding); panel_y += message_y_per_button; } }
void CNB_Mission_Summary::PerformLayout() { BaseClass::PerformLayout(); //m_pObjectivesLabel->GetTextImage()->ResizeImageToContent(); int nLabelWidth = YRES( 168 ); m_pObjectivesLabel->SetSize( nLabelWidth, 400 ); m_pObjectivesLabel->GetTextImage()->SetDrawWidth( nLabelWidth ); m_pObjectivesLabel->InvalidateLayout( true ); int texwide, texttall; m_pObjectivesLabel->GetTextImage()->ResizeImageToContentMaxWidth( nLabelWidth ); m_pObjectivesLabel->GetTextImage()->GetContentSize( texwide, texttall ); m_pObjectivesLabel->InvalidateLayout( true ); int x, y, w, h; m_pObjectivesLabel->GetBounds( x, y, w, h ); h = texttall; int dw, dh; m_pDetailsButton->GetSize( dw, dh ); h += dh; int border = YRES( 10 ); SetTall( y + h + border ); m_pBackground->SetTall( y + h + border ); int bx, by; m_pBackgroundInner->GetPos( bx, by ); m_pBackgroundInner->SetTall( y + h + border - ( by * 2 ) ); m_pDetailsButton->SetPos( GetWide() - ( dw + border ), GetTall() - ( dh + border ) ); }
void ServerOptionsPanel::PerformLayout() { BaseClass::PerformLayout(); int sw, sh; vgui::surface()->GetScreenSize( sw, sh ); float fScale = float(sh) / 768.0f; int w = GetParent()->GetWide(); int padding = 8 * fScale; int option_spacing = 24 * fScale; int left_edge = padding * 3; int choice_left_edge = padding * 3; int option_width = w * 0.25f; int option_height = 20 * fScale; int ypos = option_spacing; m_HostNameLabel->SetBounds(left_edge, ypos, option_width, option_height); ypos+=option_height + padding; m_pHostNameEntry->SetBounds(choice_left_edge, ypos, option_width, option_height); ypos+=option_height + option_spacing; m_pPasswordLabel->SetBounds(left_edge, ypos, option_width, option_height); ypos+=option_height + padding; m_pServerPasswordEntry->SetBounds(choice_left_edge, ypos, option_width, option_height); ypos+=option_height + option_spacing; m_pMaxPlayersLabel->SetBounds(left_edge, ypos, option_width, option_height); ypos+=option_height + padding; m_pMaxPlayersCombo->SetBounds(choice_left_edge, ypos, option_width, option_height); ypos+=option_height + option_spacing; m_pLANCheck->SetBounds(left_edge, ypos, option_width, option_height); ypos+=option_height + padding; m_pCancelButton->SetTextInset(6.0f * fScale, 0); m_pCancelButton->GetTextImage()->ResizeImageToContent(); m_pCancelButton->SizeToContents(); int cancel_wide = m_pCancelButton->GetWide(); int iFooterSize = 32 * fScale; m_pCancelButton->SetSize(cancel_wide, iFooterSize - 4 * fScale); m_pCancelButton->SetPos(GetWide() - cancel_wide, GetTall() - iFooterSize); }
void CNB_Weapon_Unlocked::PaintBackground() { // fill background float flAlpha = 200.0f / 255.0f; vgui::surface()->DrawSetColor( Color( 16, 32, 46, 230 * flAlpha ) ); vgui::surface()->DrawFilledRect( 0, 0, GetWide(), GetTall() ); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CAvatarImagePanel::SetPlayer( C_BasePlayer *pPlayer ) { if ( GetImage() ) { ((CAvatarImage*)GetImage())->ClearAvatarSteamID(); } if ( pPlayer && steamapicontext->SteamUtils() ) { int iIndex = pPlayer->entindex(); player_info_t pi; if ( engine->GetPlayerInfo(iIndex, &pi) ) { if ( pi.friendsID ) { CSteamID steamIDForPlayer( pi.friendsID, 1, steamapicontext->SteamUtils()->GetConnectedUniverse(), k_EAccountTypeIndividual ); if ( !GetImage() ) { CAvatarImage *pImage = new CAvatarImage(); SetImage( pImage ); } CAvatarImage *pAvImage = ((CAvatarImage*)GetImage()); pAvImage->SetAvatarSteamID( steamIDForPlayer ); // Indent the image. These are deliberately non-resolution-scaling. pAvImage->SetAvatarSize( 32, 32 ); // Deliberately non scaling SetSize( pAvImage->GetWide(), GetTall() ); } } } }
void CASW_VGUI_Queen_Health_Panel::UpdateBars() { if (GetQueen() && GetQueen()->GetHealth() > 0 && !GetQueen()->IsDormant()) { int w = GetWide(); int h = GetTall(); m_pBackdrop->SetBounds(0, 0, w, h); int padding = ScreenWidth() * 0.005f; int bar_width = (w - padding) / ASW_QUEEN_HEALTH_BARS; float health_per_bar = float(GetQueen()->GetMaxHealth()) / ASW_QUEEN_HEALTH_BARS; float queen_health = GetQueen()->GetHealth(); static float flasthealth = 0; if (flasthealth != queen_health) { //Msg("Queen health changed. health=%f / %d\n", queen_health, GetQueen()->GetMaxHealth()); flasthealth = queen_health; } for (int i=0;i<ASW_QUEEN_HEALTH_BARS;i++) { float f = (queen_health > (health_per_bar * (i+1)) ) ? 1.0f : // queen's health is more than this bar section, so full bar (queen_health - (health_per_bar * i)) / health_per_bar; // find the health remainder into this bar and divide by the health per bar to get how full this bar should be m_pHealthBar[i]->SetBounds((bar_width * i + padding), padding, f * (bar_width - padding), h - (padding * 2)); } } }
void CASW_Difficulty_Entry::PerformLayout() { BaseClass::PerformLayout(); int image_tall = GetTall() * 0.9f; int image_wide = image_tall * 1.3333f; m_pImagePanel->SetBounds(GetTall() * 0.05f, GetTall() * 0.05f, image_wide, image_tall); int font_tall = vgui::surface()->GetFontTall(m_hDefaultFont); m_pDifficultyLabel->SetBounds(image_wide * 1.2f, 0, GetWide() - (image_wide * 1.2f), font_tall); m_pDifficultyLabel->InvalidateLayout(true); m_pDifficultyLabel->GetTextImage()->RecalculateNewLinePositions(); m_pDifficultyDescriptionLabel->SetBounds(image_wide * 1.2f, font_tall, GetWide() - (image_wide * 1.2f), GetTall() - font_tall); m_pDifficultyDescriptionLabel->InvalidateLayout(true); m_pDifficultyDescriptionLabel->GetTextImage()->RecalculateNewLinePositions(); }
//----------------------------------------------------------------------------- // Purpose: Begins playback of a movie // Output : Returns true on success, false on failure. //----------------------------------------------------------------------------- bool VideoPanel::Play( const char *pFilename ) { if ( m_bPlaying ) { Stop(); } // Load and create our BINK video m_BIKHandle = bik->CreateMaterial( "VideoBIKMaterial", pFilename, "GAME" ); if ( m_BIKHandle == BIKHANDLE_INVALID ) { m_bPlaying = false; return false; } int nWidth, nHeight; bik->GetFrameSize( m_BIKHandle, &nWidth, &nHeight ); bik->GetTexCoordRange( m_BIKHandle, &m_flU, &m_flV ); m_pMaterial = bik->GetMaterial( m_BIKHandle ); float flFrameRatio = ( (float) GetWide() / (float) GetTall() ); float flVideoRatio = ( (float) nWidth / (float) nHeight ); if ( flVideoRatio > flFrameRatio ) { m_nPlaybackWidth = GetWide(); m_nPlaybackHeight = ( GetWide() / flVideoRatio ); } else if ( flVideoRatio < flFrameRatio ) { m_nPlaybackWidth = ( GetTall() * flVideoRatio ); m_nPlaybackHeight = GetTall(); } else { m_nPlaybackWidth = GetWide(); m_nPlaybackHeight = GetTall(); } m_bPlaying = true; Q_strncpy( m_czLastFile, pFilename, sizeof( m_czLastFile ) ); return true; }
void CHudLessonPanel::ApplySchemeSettings( vgui::IScheme *pScheme ) { BaseClass::ApplySchemeSettings( pScheme ); SetFgColor( GetFgColor() ); m_hFont = pScheme->GetFont( "HudHintTextLarge", true ); m_pLabel->SetBgColor( Color( 0, 0, 0, 150 ) ); m_pLabel->SetPaintBackgroundType( 2 ); m_pLabel->SetSize( 0, GetTall() ); // Start tiny, it'll grow. }
void CReplayListPanel::ApplySchemeSettings( vgui::IScheme *pScheme ) { BaseClass::ApplySchemeSettings( pScheme ); LoadControlSettings( "resource/ui/replaybrowser/replaylistpanel.res", "GAME" ); #if !defined( TF_CLIENT_DLL ) SetPaintBorderEnabled( false ); #endif MoveScrollBarToTop(); vgui::ScrollBar *pScrollBar = dynamic_cast< vgui::ScrollBar * >( FindChildByName( "PanelListPanelVScroll" ) ); pScrollBar->SetScrollbarButtonsVisible( false ); Color clrButtonColor = GetSchemeColor( "Yellow", Color( 255, 255, 255, 255 ), pScheme ); Color clrBgColor = GetSchemeColor( "TanDark", Color( 255, 255, 255, 255 ), pScheme ); const int nWidth = XRES( 5 ); pScrollBar->SetSize( nWidth, GetTall() ); pScrollBar->GetSlider()->SetSize( nWidth, GetTall() ); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CAvatarImagePanel::PaintBackground( void ) { // Paint the outline vgui::surface()->DrawSetColor( m_clrOutline ); vgui::surface()->DrawFilledRect( 0, 0, GetWide(), GetTall() ); if ( GetImage() ) { GetImage()->Paint(); } }
HapticsGraph::HapticsGraph(vgui::VPANEL parent) : BaseClass( NULL, 50, -3, 3) { // if created by VPanel, well need to put a frame behind us. vgui::Frame *frame = new vgui::Frame(NULL,"hdebug"); frame->SetPos(24,24); SetWide(150); SetTall(75); frame->SetWide(GetWide()); frame->SetTall(GetTall()+24); SetParent(frame); }
void CHudChapterTitle::Paint() { return; if (!m_wChapterName) return; int textWidth, textHeight; vgui::surface()->GetTextSize(m_ChapterTitleFont, m_wChapterName, textWidth, textHeight); vgui::surface()->DrawSetTextColor(Color(255, 255, 255, 255)); vgui::surface()->DrawSetTextFont(m_ChapterTitleFont); vgui::surface()->DrawSetTextPos(0, GetTall() / 2 - textHeight / 2); vgui::surface()->DrawPrintText(m_wChapterName, wcslen(m_wChapterName), vgui::FONT_DRAW_NONADDITIVE); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CControlPointProgressBar::ApplySchemeSettings( IScheme *pScheme ) { BaseClass::ApplySchemeSettings( pScheme ); LoadControlSettings( "resource/UI/ControlPointProgressBar.res" ); m_pBar = dynamic_cast<vgui::CircularProgressBar *>( FindChildByName("ProgressBar") ); m_pBarText = dynamic_cast<vgui::Label *>( FindChildByName("ProgressText") ); m_pTeardrop = dynamic_cast<CIconPanel *>( FindChildByName("Teardrop") ); m_pTeardropSide = dynamic_cast<CIconPanel *>( FindChildByName("TeardropSide") ); m_pBlocked = dynamic_cast<CIconPanel *>( FindChildByName("Blocked") ); m_iOrgHeight = GetTall(); m_iMidGroupIndex = gHUD.LookupRenderGroupIndexByName( "mid" ); }
void CASW_Hotbar_Entry::ShowTooltip() { if ( !m_hMarine.Get() ) return; C_ASW_Weapon *pWeapon = m_hMarine->GetASWWeapon( m_iInventoryIndex ); if ( !pWeapon ) return; const CASW_WeaponInfo* pInfo = pWeapon->GetWeaponInfo(); if ( !pInfo || !pInfo->m_bOffhandActivate ) // TODO: Fix for sentry guns return; int x = GetWide() * 0.8f; int y = GetTall() * 0.02f; LocalToScreen( x, y ); g_hBriefingTooltip->SetTooltip( this, pInfo->szPrintName, " ", x, y, true ); }
void CAvatarImagePanel::SetAvatarBySteamID( CSteamID *friendsID ) { if ( !GetImage() ) { CAvatarImage *pImage = new CAvatarImage(); SetImage( pImage ); } // Indent the image. These are deliberately non-resolution-scaling. int iIndent = 2; GetImage()->SetPos( iIndent, iIndent ); int wide = GetWide() - (iIndent*2); ((CAvatarImage*)GetImage())->SetAvatarSize( ( wide > 32 ) ? k_EAvatarSize64x64 : k_EAvatarSize32x32 ); ((CAvatarImage*)GetImage())->SetAvatarSteamID( *friendsID ); GetImage()->SetSize( wide, GetTall()-(iIndent*2) ); }
void CIOSUpdatePanel::ApplySchemeSettings( IScheme *pScheme ) { m_pScheme = pScheme; BaseClass::ApplySchemeSettings( pScheme ); SetTitle("IOS Updater", false); SetProportional(false); SetSizeable(false); SetBounds(0, 0, PANEL_WIDTH, PANEL_HEIGHT); //SetBgColor(Color(0, 0, 0, 255)); SetPaintBackgroundEnabled(true); SetCloseButtonVisible(false); MoveToCenterOfScreen(); m_pContent->SetBounds(PADDING, PADDING + TOP_PADDING, GetWide() - 2 * PADDING, GetTall() - 2 * PADDING - TOP_PADDING); m_pUpdateButton->SetBounds(m_pContent->GetWide() / 2 - UPDATE_BUTTON_WIDTH / 2, m_pContent->GetTall() - UPDATE_BUTTON_HEIGHT - BUTTON_MARGIN - BUTTON_HEIGHT, UPDATE_BUTTON_WIDTH, UPDATE_BUTTON_HEIGHT); m_pUpdateButton->SetContentAlignment(Label::a_center); m_pCloseButton->SetBounds(m_pContent->GetWide() / 2 - BUTTON_WIDTH / 2, m_pContent->GetTall() - BUTTON_HEIGHT, BUTTON_WIDTH, BUTTON_HEIGHT); m_pCloseButton->SetContentAlignment(Label::a_center); m_pInfoText->SetBounds(PADDING, 3 * PADDING, m_pContent->GetWide() - 2 * PADDING, INFO_HEIGHT); m_pInfoText->SetFont(pScheme->GetFont("DefaultBig")); m_pInfoText->SetContentAlignment(Label::a_center); m_pInfoText->SetFgColor(Color(255, 255, 255, 255)); m_pExtraInfoText->SetBounds(PADDING, 3 * PADDING + INFO_HEIGHT + PADDING, m_pContent->GetWide() - 2 * PADDING, INFO_HEIGHT); m_pExtraInfoText->SetFont(pScheme->GetFont("DefaultBig")); m_pExtraInfoText->SetContentAlignment(Label::a_center); m_pExtraInfoText->SetFgColor(Color(255, 255, 255, 255)); m_pExtraInfoText2->SetBounds(PADDING, 3 * PADDING + 2 * (INFO_HEIGHT + PADDING), m_pContent->GetWide() - 2 * PADDING, INFO_HEIGHT); m_pExtraInfoText2->SetFont(pScheme->GetFont("DefaultBig")); m_pExtraInfoText2->SetContentAlignment(Label::a_center); m_pExtraInfoText2->SetFgColor(Color(255, 255, 255, 255)); m_pProgressBar->SetBounds(m_pContent->GetWide() / 2 - PROGRESSBAR_WIDTH / 2, 3 * PADDING + 3 * (INFO_HEIGHT + PADDING), PROGRESSBAR_WIDTH, PROGRESSBAR_HEIGHT); m_pChangelog->SetBounds(m_pContent->GetWide() / 2 - CHANGELOG_WIDTH / 2, 4 * PADDING + 3 * (INFO_HEIGHT + PADDING) + PROGRESSBAR_HEIGHT, CHANGELOG_WIDTH, CHANGELOG_HEIGHT); }
void CASW_Difficulty_Chooser::PerformLayout() { int sw, sh; vgui::surface()->GetScreenSize( sw, sh ); int wide = sw * 0.5f; int tall = sh * 0.5f; SetSize(wide, tall); SetPos((sw * 0.5f) - (wide * 0.5f), (sh * 0.5f) - (tall * 0.5f)); BaseClass::PerformLayout(); int x, y, cwide, ctall; GetClientArea(x, y, cwide, ctall); float fScale = float(sh) / 768.0f; int iFooterSize = 32 * fScale; int iEntryHeight = (ctall - iFooterSize * 2) / ASW_NUM_DIFFICULTIES; m_pCancelButton->SetTextInset(6.0f * fScale, 0); for (int i=0;i<ASW_NUM_DIFFICULTIES;i++) { if (!m_pDifficulty[i]) continue; int inset = 0; m_pDifficulty[i]->SetBounds(x + inset, y + (iEntryHeight*i) + (iFooterSize * 0.5f), cwide - (inset * 2), iEntryHeight); m_pDifficulty[i]->InvalidateLayout(); } m_pCancelButton->GetTextImage()->ResizeImageToContent(); m_pCancelButton->SizeToContents(); int cancel_wide = m_pCancelButton->GetWide(); m_pCancelButton->SetSize(cancel_wide, iFooterSize - 5 * fScale); m_pCancelButton->SetPos(GetWide() - (cancel_wide + 5 * fScale), GetTall() - iFooterSize); }
CASW_Medal_Collection_Frame::CASW_Medal_Collection_Frame( vgui::Panel *pParent, const char *pElementName) : Frame(pParent, pElementName) { vgui::HScheme scheme = vgui::scheme()->LoadSchemeFromFileEx(0, "resource/SwarmFrameScheme.res", "SwarmFrameScheme"); SetScheme(scheme); // create a propertysheet m_pSheet = new vgui::PropertySheet(this, "IAFDatabaseSheet"); m_pSheet->SetPos(0,0); m_pSheet->SetSize(GetWide(), GetTall() - 30); m_pSheet->SetVisible(true); m_pMedalOffsetPanel = new vgui::Panel(m_pSheet, "MedalOffset"); m_pCollectionPanel = new MedalCollectionPanel(m_pMedalOffsetPanel, "MedalCollection"); m_pSheet->AddPage(m_pMedalOffsetPanel, "#asw_medals_tab"); m_pSwarmopediaPanel = new SwarmopediaPanel(m_pSheet, "SwarmopediaPanel"); m_pSheet->AddPage(m_pSwarmopediaPanel, "#asw_swarmopedia"); m_pCancelButton = new vgui::Button(this, "CancelButton", "#asw_chooser_close", this, "Cancel"); m_pCancelButton->SetContentAlignment(vgui::Label::a_west); m_pSheet->SetActivePage(m_pCollectionPanel); //m_pSwarmopediaPanel); }
void CASW_HUD_Health_Cross::Paint() { if ( !m_hPortrait.Get() ) return; if ( !m_hPortrait->m_hMarineResource.Get() ) return; C_ASW_Marine *pMarine = m_hPortrait->m_hMarineResource->GetMarineEntity(); if ( !pMarine ) return; float fHealth = m_hPortrait->m_hMarineResource->GetHealthPercent(); fHealth = clamp( fHealth, 0.0f, 1.0f ); int r, g, b, a; r = g = b = a = 0; r = a = 255; float diffr = (128.0f - r) * pMarine->m_fRedNamePulse; float diffg = (0.0f - g) * pMarine->m_fRedNamePulse; float diffb = (0.0f - b) * pMarine->m_fRedNamePulse; r += diffr; g += diffg; b += diffb; /* if ( fHealth < 1.0f && fHealth >= 0.5f ) { float fOrangeFade = ( ( fHealth - 0.5f ) / 0.5f ); g = fOrangeFade * 128.0f + 128.0f; b = fOrangeFade * 255.0f; } else if ( fHealth < 0.5f ) { float fRedFade = fHealth / 0.5f; g = fRedFade * 128.0f; b = 0; }*/ // remap onto 18 px to 128-18px range of the health texture fHealth *= 0.71875f; fHealth += 0.140625f; fHealth = clamp( fHealth, 0.0f, 1.0f ); if ( m_nFullHealthTexture == -1 || m_nNoHealthTexture == -1 ) return; int empty_height = GetTall() * ( 1.0f - fHealth ); int w = GetWide(); int t = GetTall(); vgui::surface()->DrawSetColor(Color(r,g,b,a)); vgui::surface()->DrawSetTexture(m_nNoHealthTexture); vgui::Vertex_t nopoints[4] = { vgui::Vertex_t( Vector2D(0, 0), Vector2D(0, 0) ), vgui::Vertex_t( Vector2D(w, 0), Vector2D(1, 0) ), vgui::Vertex_t( Vector2D(w, empty_height), Vector2D(1, 1.0f - fHealth) ), vgui::Vertex_t( Vector2D(0, empty_height), Vector2D(0, 1.0f - fHealth) ) }; vgui::surface()->DrawTexturedPolygon( 4, nopoints ); vgui::surface()->DrawSetColor(Color(r,g,b,a)); vgui::surface()->DrawSetTexture(m_nFullHealthTexture); vgui::Vertex_t fullpoints[4] = { vgui::Vertex_t( Vector2D(0, empty_height), Vector2D(0, 1.0f - fHealth) ), vgui::Vertex_t( Vector2D(w, empty_height), Vector2D(1, 1.0f - fHealth) ), vgui::Vertex_t( Vector2D(w, t), Vector2D(1,1) ), vgui::Vertex_t( Vector2D(0, t), Vector2D(0,1) ) }; vgui::surface()->DrawTexturedPolygon( 4, fullpoints ); }
//----------------------------------------------------------------------------- // Purpose: Create and arrange the panel button labels according to the dialog type //----------------------------------------------------------------------------- void CMessageDialog::ApplySchemeSettings( vgui::IScheme *pScheme ) { BaseClass::ApplySchemeSettings( pScheme ); LoadControlSettings( "resource/ui/MessageDialog.res", "GAME", m_pControlSettings ); m_hButtonFont = pScheme->GetFont( "GameUIButtons" ); m_hTextFont = pScheme->GetFont( "MenuLarge" ); if ( m_nType & MD_OK ) { CreateButtonLabel( &m_Buttons[BTN_A], "#GameUI_Icons_A_BUTTON", "#GameUI_OK" ); } else if ( m_nType & MD_CANCEL ) { CreateButtonLabel( &m_Buttons[BTN_B], "#GameUI_Icons_B_BUTTON", "#GameUI_Cancel" ); } else if ( m_nType & MD_OKCANCEL ) { CreateButtonLabel( &m_Buttons[BTN_A], "#GameUI_Icons_A_BUTTON", "#GameUI_OK" ); CreateButtonLabel( &m_Buttons[BTN_B], "#GameUI_Icons_B_BUTTON", "#GameUI_Cancel" ); } else if ( m_nType & MD_YESNO ) { CreateButtonLabel( &m_Buttons[BTN_A], "#GameUI_Icons_A_BUTTON", "#GameUI_Yes" ); CreateButtonLabel( &m_Buttons[BTN_B], "#GameUI_Icons_B_BUTTON", "#GameUI_No" ); } // count the buttons and add up their widths int cButtons = 0; int nTotalWide = 0; for ( int i = 0; i < MAX_BUTTONS; ++i ) { if ( m_Buttons[i].bCreated ) { ++cButtons; nTotalWide += m_Buttons[i].nWide; } } // make sure text and icons are center-aligned vertically with each other int nButtonTall = vgui::surface()->GetFontTall( m_hButtonFont ); int nTextTall = vgui::surface()->GetFontTall( m_hTextFont ); int nVerticalAdjust = ( nButtonTall - nTextTall ) / 2; // position the buttons with even horizontal spacing int xpos = 0; int ypos = GetTall() - max( nButtonTall, nTextTall ) - m_ButtonMargin; int nSpacing = ( GetWide() - nTotalWide ) / ( cButtons + 1 ); for ( int i = 0; i < MAX_BUTTONS; ++i ) { if ( m_Buttons[i].bCreated ) { xpos += nSpacing; m_Buttons[i].pIcon->SetPos( xpos, ypos ); xpos += m_Buttons[i].pIcon->GetWide() + m_ButtonIconLabelSpace; m_Buttons[i].pText->SetPos( xpos, ypos + nVerticalAdjust ); xpos += m_Buttons[i].pText->GetWide(); } } m_clrNotSimpleBG = pScheme->GetColor( "MessageDialog.MatchmakingBG", Color( 200, 184, 151, 255 ) ); m_clrNotSimpleBGBlack = pScheme->GetColor( "MessageDialog.MatchmakingBGBlack", Color( 52, 48, 55, 255 ) ); if ( !m_bShowActivity ) { if ( m_pAnimatingPanel ) { if ( m_pAnimatingPanel->IsVisible() ) { m_pAnimatingPanel->SetVisible( false ); } m_pAnimatingPanel->StopAnimation(); } } else { if ( m_pAnimatingPanel ) { if ( !m_pAnimatingPanel->IsVisible() ) { m_pAnimatingPanel->SetVisible( true ); } m_pAnimatingPanel->StartAnimation(); } } MoveToCenterOfScreen(); if ( m_bShowActivity && m_ActivityIndent ) { // If we're animating, we push our text label in, and reduce its width int iX,iY,iW,iH; m_pMsg->GetBounds( iX, iY, iW, iH ); m_pMsg->SetBounds( iX + m_ActivityIndent, iY, max(0,iW-m_ActivityIndent), iH ); } // Invalidate the scheme on our message label so that it recalculates // its line breaks in case it was resized when we loaded our .res file. m_pMsg->InvalidateLayout( false, true ); }