void QuickJoinPanel::NavigateTo() { BaseClass::NavigateTo(); SetHasMouseover( true ); BaseModHybridButton *title = dynamic_cast< BaseModHybridButton* >( FindChildByName( "LblTitle" ) ); if ( title ) { title->SetNavUp( GetNavUp() ); title->SetNavDown( GetNavDown() ); if ( m_bHasMouseover && title->IsVisible() && ( title->GetCurrentState() == BaseModHybridButton::Enabled || title->GetCurrentState() == BaseModHybridButton::Disabled ) ) { title->NavigateTo(); } } #ifdef _X360 m_GplQuickJoinList->NavigateTo(); #endif }
void GameModes::OnMousePressed( vgui::MouseCode code ) { BaseClass::OnMousePressed( code ); if ( code != MOUSE_LEFT ) return; if ( IsScrollBusy() ) return; int iPosX; int iPosY; input()->GetCursorPos( iPosX, iPosY ); ScreenToLocal( iPosX, iPosY ); if ( m_nSubPics ) { bool bRightScroll = false; bool bLeftScroll = false; int nSubPic = 0; if ( ( iPosX >= m_nPicOffsetX && iPosX <= m_nPicOffsetX + m_nPicWidth ) && ( iPosY >= 0 && iPosY <= m_nPicHeight ) ) { BaseModHybridButton *pHybridButton = GetHybridButton( m_nActive ); if ( pHybridButton && pHybridButton->GetCurrentState() != BaseModHybridButton::Open ) { // open it if ( pHybridButton->IsEnabled() ) { pHybridButton->DoClick(); } } } else if ( ( iPosX >= m_nLeftArrowX && iPosX <= m_nLeftArrowX + m_nArrowWidth ) && ( iPosY >= m_nLeftArrowY && iPosY <= m_nLeftArrowY + m_nArrowHeight ) ) { bLeftScroll = true; } else if ( ( iPosX >= m_nRightArrowX && iPosX <= m_nRightArrowX + m_nArrowWidth ) && ( iPosY >= m_nRightArrowY && iPosY <= m_nRightArrowY + m_nArrowHeight ) ) { bRightScroll = true; } else { // determine if sub pic selected if ( iPosY >= m_nSubPicY && iPosY <= m_nSubPicY + m_nSubPicHeight ) { int x = m_nSubPicX; for ( int i = 1; i <= m_nSubPics; i++ ) { if ( iPosX >= x && iPosX <= x + m_nSubPicWidth ) { nSubPic = i; break; } x += m_nSubPicWidth + m_nSubPicGap; } } } if ( bLeftScroll || bRightScroll || nSubPic ) { // close any active flyout if ( FlyoutMenu::GetActiveMenu() ) { FlyoutMenu::CloseActiveMenu( this ); } if ( bLeftScroll ) { ScrollLeft(); } else if ( bRightScroll ) { ScrollRight(); } else if ( nSubPic ) { ScrollRight( nSubPic ); } } } }
void GameModes::PaintBackground() { if ( !m_GameModeInfos.Count() ) return; BaseModHybridButton *pHybridButton = m_GameModeInfos[m_nActive].m_pHybridButton; bool bHasFocus = pHybridButton->HasFocus() || ( pHybridButton->GetCurrentState() == BaseModHybridButton::Focus ) || ( pHybridButton->GetCurrentState() == BaseModHybridButton::FocusDisabled ); bool bIsOpen = ( pHybridButton->GetCurrentState() == BaseModHybridButton::Open ); // update scroll // varies between [0..1] or [1..0] float t = 0; if ( m_startScrollTime ) { float rate = ( m_nScrollMultipleCount >= 1 ) ? 8.0f : 5.0f; t = ( Plat_FloatTime() - m_startScrollTime ) * rate; if ( t >= 1.0f ) { // finished, scroll is circular warp around t = 1.0f; m_startScrollTime = 0; int nNewActive = 0; if ( m_bLeftScroll ) { nNewActive = ( m_nActive + 1 ) % m_GameModeInfos.Count(); } else { nNewActive = ( m_nActive - 1 + m_GameModeInfos.Count() ) % m_GameModeInfos.Count(); } SetActiveGameMode( nNewActive, bHasFocus ); if ( --m_nScrollMultipleCount > 0 ) { m_startScrollTime = Plat_FloatTime(); t = 0; } } } int panelWidth, panelHeight; GetSize( panelWidth, panelHeight ); // need this to see panel bounds during debugging //vgui::surface()->DrawSetColor( Color( 255, 0, 0, 255 ) ); //vgui::surface()->DrawFilledRect( 0, 0, panelWidth, panelHeight ); // the main pic and all the subpics int nPicCount = 1 + m_nSubPics; if ( m_startScrollTime && m_bLeftScroll ) { // scrolling means one extra sub pic must be drawn at the far right edge // either coming/going nPicCount++; } int nOffscreenSubPicX = m_nPicOffsetX - m_nSubPicOffsetX - m_nSubPicWidth; int nOffscreenSubPicY = m_nSubPicY; int nOffscreenSubPicW = m_nSubPicWidth; int nOffscreenSubPicH = m_nSubPicHeight; int nActivePicX = m_nPicOffsetX; int nActivePicY = 0; int nActivePicW = m_nPicWidth; int nActivePicH = m_nPicHeight; float nActiveAngle = 0; //-3; int x, y; int w, h; int iPrevActiveMode = ( m_nActive - 1 + m_GameModeInfos.Count() ) % m_GameModeInfos.Count(); int iNextActiveMode = ( m_nActive + 1 ) % m_GameModeInfos.Count(); // center the vertical smear y = nActivePicY + nActivePicH + m_nMenuTitleY + ( m_nMenuTitleActualTall - m_nMenuTitleTall )/2; vgui::surface()->DrawSetColor( m_smearColor ); DrawSmearBackgroundFade( m_nMenuTitleX - ( 0.30f * m_nMenuTitleX ), y, m_nSubPicX + m_nSubPics * ( m_nSubPicWidth + m_nSubPicGap ), y + m_nMenuTitleTall ); // cyclical carousel // the first pic to be drawn is the active main pic, followed by all the sub pics for ( int i = 0; i < nPicCount; i++ ) { int iGameMode = ( m_nActive + i ) % m_GameModeInfos.Count(); // in between scrolling, this image transition gets handled by specialized lerp drawing bool bSkipSubPicDraw = m_startScrollTime && ( m_bLeftScroll && ( iGameMode == iNextActiveMode ) ); if ( !i ) { // active pic x = nActivePicX; y = nActivePicY; w = nActivePicW; h = nActivePicH; if ( !m_startScrollTime ) { Color picColor; picColor.SetColor( 255, 255, 255, 255 ); vgui::surface()->DrawSetColor( picColor ); vgui::surface()->DrawSetTexture( m_GameModeInfos[m_nActive].m_nImageId ); DrawTexturedRectParms_t parms; parms.x0 = x; parms.y0 = y; parms.x1 = x+w; parms.y1 = y+h; parms.angle = nActiveAngle; vgui::surface()->DrawTexturedRectEx( &parms ); if ( bHasFocus || bIsOpen ) { picColor.SetColor( 255, 255, 255, 255 ); } else { picColor.SetColor( 0, 0, 0, 255 ); } vgui::surface()->DrawSetColor( picColor ); vgui::surface()->DrawSetTexture( m_nBorderImageId ); //vgui::surface()->DrawTexturedRectEx( &parms ); } else { // draw the lerping pics // lerp active pic to sub pic on left edge int iMode = m_nActive; float tt = 1 - t; if ( !m_bLeftScroll ) { tt = t; iMode = iPrevActiveMode; } x = (float)nOffscreenSubPicX + tt * ( (float)nActivePicX - nOffscreenSubPicX ); y = (float)nOffscreenSubPicY + tt * ( (float)nActivePicY - nOffscreenSubPicY ); w = (float)nOffscreenSubPicW + tt * ( (float)nActivePicW - nOffscreenSubPicW ); h = (float)nOffscreenSubPicH + tt * ( (float)nActivePicH - nOffscreenSubPicH ); float a = tt * 255.0f; float ang = tt * nActiveAngle; Color picColor; picColor.SetColor( 255, 255, 255, a ); vgui::surface()->DrawSetColor( picColor ); vgui::surface()->DrawSetTexture( m_GameModeInfos[iMode].m_nImageId ); DrawTexturedRectParms_t parms; parms.x0 = x; parms.y0 = y; parms.x1 = x+w; parms.y1 = y+h; parms.angle = ang; vgui::surface()->DrawTexturedRectEx( &parms ); vgui::surface()->DrawSetTexture( m_nBorderImageId ); //vgui::surface()->DrawTexturedRectEx( &parms ); // lerp active pic to sub pic on right edge iMode = iNextActiveMode; tt = t; if ( !m_bLeftScroll ) { tt = 1 - t; iMode = m_nActive; } x = (float)m_nSubPicX + tt * ( (float)nActivePicX - m_nSubPicX ); y = (float)m_nSubPicY + tt * ( (float)nActivePicY - m_nSubPicY ); w = (float)m_nSubPicWidth + tt * ( (float)nActivePicW - m_nSubPicWidth ); h = (float)m_nSubPicHeight + tt * ( (float)nActivePicH - m_nSubPicHeight ); float c = 125.0f + tt * ( 255.0f - 125.0f ); ang = tt * nActiveAngle; picColor.SetColor( c, c, c, 255 ); vgui::surface()->DrawSetColor( picColor ); vgui::surface()->DrawSetTexture( m_GameModeInfos[iMode].m_nImageId ); parms.x0 = x; parms.y0 = y; parms.x1 = x+w; parms.y1 = y+h; parms.s0 = 0; parms.s1 = 1; parms.t0 = 0; parms.t1 = 1; parms.angle = ang; vgui::surface()->DrawTexturedRectEx( &parms ); } } else if ( !bSkipSubPicDraw ) { // sub pics x = m_nSubPicX + ( i - 1 ) * ( m_nSubPicWidth + m_nSubPicGap ); y = m_nSubPicY; w = m_nSubPicWidth; h = m_nSubPicHeight; int alpha = 255; int focusColor = ( bHasFocus || bIsOpen ) ? 255 : 125; if ( m_startScrollTime ) { int x1 = x; if ( m_bLeftScroll ) { x1 -= m_nSubPicWidth + m_nSubPicGap; } else { x1 += m_nSubPicWidth + m_nSubPicGap; } x = (float)x + t * (float)( x1 - x ); if ( i == nPicCount - 1 ) { if ( m_bLeftScroll ) { alpha = t * (float)alpha; } else { alpha = ( 1 - t ) * (float)alpha; } } } Color picColor; picColor.SetColor( focusColor, focusColor, focusColor, alpha ); vgui::surface()->DrawSetColor( picColor ); vgui::surface()->DrawSetTexture( m_GameModeInfos[iGameMode].m_nImageId ); vgui::surface()->DrawTexturedSubRect( x, y, x+w, y+h, 0.0f, 0.0f, 1.0f, 1.0f ); if ( !m_bHideLabels ) { // sub pics have a label on top of an inscribed rect vgui::surface()->DrawSetColor( Color( 0, 0, 0, alpha ) ); vgui::surface()->DrawFilledRect( x, y + m_nSubPicHeight - m_nNameFontHeight, x + w, y + m_nSubPicHeight ); Color textColor( focusColor, focusColor, focusColor, alpha ); int gap = vgui::surface()->GetCharacterWidth( m_hNameFont, ' ' ); DrawColoredText( m_hNameFont, x + gap, y + m_nSubPicHeight - m_nNameFontHeight/2, textColor, m_GameModeInfos[iGameMode].m_NameText ); } } } // draw arrows if ( m_nSubPics ) { // pc always shows the arrows because mouse can move over them at any time // xbox hides the arrows when the control does not have focus if ( IsPC() || ( IsX360() && bHasFocus && !bIsOpen ) ) { // xbox highlight when scroll active bool bLeftHighlight = IsX360() && m_startScrollTime && !m_bLeftScroll; bool bRightHightlight = IsX360() && m_startScrollTime && m_bLeftScroll; // pc highlights when mouse over if ( IsPC() && !m_startScrollTime ) { int iPosX; int iPosY; input()->GetCursorPos( iPosX, iPosY ); ScreenToLocal( iPosX, iPosY ); if ( ( iPosX >= m_nLeftArrowX && iPosX <= m_nLeftArrowX + m_nArrowWidth ) && ( iPosY >= m_nLeftArrowY && iPosY <= m_nLeftArrowY + m_nArrowHeight ) ) { bLeftHighlight = true; } else if ( ( iPosX >= m_nRightArrowX && iPosX <= m_nRightArrowX + m_nArrowWidth ) && ( iPosY >= m_nRightArrowY && iPosY <= m_nRightArrowY + m_nArrowHeight ) ) { bRightHightlight = true; } } Color leftArrowColor; leftArrowColor.SetColor( 125, 125, 125, 255 ); if ( bLeftHighlight ) { leftArrowColor.SetColor( 255, 255, 255, 255 ); } vgui::surface()->DrawSetColor( leftArrowColor ); vgui::surface()->DrawSetTexture( m_nLeftArrowId ); vgui::surface()->DrawTexturedRect( m_nLeftArrowX, m_nLeftArrowY, m_nLeftArrowX + m_nArrowWidth, m_nLeftArrowY + m_nArrowHeight ); Color rightArrowColor; rightArrowColor.SetColor( 125, 125, 125, 255 ); if ( bRightHightlight ) { rightArrowColor.SetColor( 255, 255, 255, 255 ); } vgui::surface()->DrawSetColor( rightArrowColor ); vgui::surface()->DrawSetTexture( m_nRightArrowId ); vgui::surface()->DrawTexturedRect( m_nRightArrowX, m_nRightArrowY, m_nRightArrowX + m_nArrowWidth, m_nRightArrowY + m_nArrowHeight ); } } }