Example #1
0
//-----------------------------------------------------------------------------
// Purpose: Constructor
//-----------------------------------------------------------------------------
CMOMSpectatorGUI::CMOMSpectatorGUI(IViewPort *pViewPort) : EditablePanel(nullptr, PANEL_SPECGUI)
{
    // 	m_bHelpShown = false;
    //	m_bInsetVisible = false;
    //	m_iDuckKey = KEY_NONE;
    SetSize(10, 10); // Quiet "parent not sized yet" spew
    m_bSpecScoreboard = false;

    m_pViewPort = pViewPort;
    g_pMOMSpectatorGUI = this;

    ListenForGameEvent("spec_target_updated");

    surface()->CreatePopup(GetVPanel(), false, false, false, false, false);

    m_flNextUpdateTime = -1.0f;

    // initialize dialog
    SetVisible(false);
    SetProportional(true);

    // load the new scheme early!!
    SetScheme("ClientScheme");
    SetMouseInputEnabled(false);
    SetKeyBoardInputEnabled(false);

    LoadControlSettings(GetResFile());

    m_pTopBar = FindControl<Panel>("topbar");
    m_pBottomBarBlank = FindControl<Panel>("bottombarblank");

    m_pPlayerLabel = FindControl<Label>("playerlabel");
    m_pPlayerLabel->SetVisible(false);

    m_pReplayLabel = FindControl<Label>("replaylabel");
    m_pTimeLabel = FindControl<Label>("timelabel");

    m_pCloseButton = FindControl<ImagePanel>("Close_Panel");
    m_pCloseButton->SetMouseInputEnabled(true);
    m_pCloseButton->InstallMouseHandler(this);

    TextImage *image = m_pPlayerLabel->GetTextImage();
    if (image)
    {
        HFont hFallbackFont = scheme()->GetIScheme(GetScheme())->GetFont("DefaultVerySmallFallBack", false);
        if (INVALID_FONT != hFallbackFont)
        {
            image->SetUseFallbackFont(true, hFallbackFont);
        }
    }

    SetPaintBorderEnabled(false);
    SetPaintBackgroundEnabled(false);

    InvalidateLayout();
}
Example #2
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void ListViewPanel::ApplyItemChanges(int itemID)
{
	if ( !m_DataItems.IsValidIndex(itemID) )
		return;
		
	KeyValues *kv = m_DataItems[itemID]->GetData();
	ListViewItem *pLabel = m_DataItems[itemID];

	pLabel->SetText(kv->GetString("text"));
	pLabel->SetTextImageIndex(1);
	pLabel->SetImagePreOffset(1, 5);

	TextImage *pTextImage = pLabel->GetTextImage();
	pTextImage->ResizeImageToContent();

	pLabel->UpdateImage();
	pLabel->SizeToContents();
	pLabel->InvalidateLayout();
}
//-----------------------------------------------------------------------------
// Purpose: Constructor
//-----------------------------------------------------------------------------
CSpectatorGUI::CSpectatorGUI(IViewPort *pViewPort) : EditablePanel( NULL, PANEL_SPECGUI )
{
// 	m_bHelpShown = false;
//	m_bInsetVisible = false;
//	m_iDuckKey = KEY_NONE;
	SetSize( 10, 10 ); // Quiet "parent not sized yet" spew
	m_bSpecScoreboard = false;

	m_pViewPort = pViewPort;
	g_pSpectatorGUI = this;

	// initialize dialog
	SetVisible(false);
	SetProportional(true);

	// load the new scheme early!!
	SetScheme("ClientScheme");
	SetMouseInputEnabled( false );
	SetKeyBoardInputEnabled( false );

	m_pTopBar = new Panel( this, "topbar" );
 	m_pBottomBarBlank = new Panel( this, "bottombarblank" );

	// m_pBannerImage = new ImagePanel( m_pTopBar, NULL );
	m_pPlayerLabel = new Label( this, "playerlabel", "" );
	m_pPlayerLabel->SetVisible( false );
	TextImage *image = m_pPlayerLabel->GetTextImage();
	if ( image )
	{
		HFont hFallbackFont = scheme()->GetIScheme( GetScheme() )->GetFont( "DefaultVerySmallFallBack", false );
		if ( INVALID_FONT != hFallbackFont )
		{
			image->SetUseFallbackFont( true, hFallbackFont );
		}
	}

	SetPaintBorderEnabled(false);
	SetPaintBackgroundEnabled(false);

	// m_pBannerImage->SetVisible(false);
	InvalidateLayout();
}
Example #4
0
	virtual void PerformLayout()
	{
		TextImage *textImage = GetTextImage();
		if (m_bSelected)
		{
			VPANEL focus = input()->GetFocus();
			// if one of the children of the SectionedListPanel has focus, then 'we have focus' if we're selected
			if (HasFocus() || (focus && ipanel()->HasParent(focus, GetVParent())))
			{
				textImage->SetColor(m_ArmedFgColor2);
			}
			else
			{
				textImage->SetColor(m_FgColor2);
			}
		}
		else
		{
			textImage->SetColor(GetFgColor());					
		}
		BaseClass::PerformLayout();
		Repaint();
	}
Example #5
0
//-----------------------------------------------------------------------------
// Purpose: sets a tooltip AND unhides it
//-----------------------------------------------------------------------------
void CHudToolTip::SetTooltip( const char* szToolTip, vgui::VPANEL _owner )
{
	//TGB: remember who set us
	m_Owner = _owner;

	//DevMsg("Called SetText!\n");
	m_Text->SetText(szToolTip);

	//TGB: got some wrapping in here

	//seems we need to do some manual scaling
	const float ratio = (float)ScreenWidth() / 640.0f;

	TextImage *tiptext = m_Text->GetTextImage();
	tiptext->SetWrap( true );
	tiptext->SetDrawWidth( DRAWWIDTH * ratio );
	tiptext->RecalculateNewLinePositions();
	tiptext->ResizeImageToContent();

	int tw, th;
	tiptext->GetSize( tw, th );			//get sizes
	//DevMsg("tooltiptext is %i by %i\n", tw, th);

	//manually resize height of it all to adjust to wrapped text
	const int newHeight = th + 8;
	m_Text->SetTall( newHeight );			//set label
	SetTall( newHeight );		//set element

	//manually resize width and position centrally
	const int newWidth = tw + 5;
	m_Text->SetWide( newWidth );
	SetWide( newWidth + PAD_HOR );

	//half of screen width minus half of element width
	//so if we're 200 wide our left corner is positioned at 220
	const int newX = (ScreenWidth() / 2) - ( GetWide() / 2 ) ;
	//TGB: also set our own height now that we don't proportionalise
	const int newY = ScreenHeight() - newHeight - 30;
	//int px, py;
	//GetPos( px, py );
	SetPos( newX, newY );

	//make sure we can be seen
	SetVisible( true );
	//DevMsg("nW = %i; nH = %i; nX = %i\n", newWidth, newHeight, newX );

	//DevMsg("Tooltip set to %s\n", szToolTip);

	//TGB: always show a tooltip we've set, as it's only logical. Special cases can do their own Hide(true)
	Hide( false );
}
//-----------------------------------------------------------------------------
// Purpose: Paint the image on screen. TextImages are not panels, you must
//  call this method explicitly for them.
//-----------------------------------------------------------------------------
void TextImageDemo::Paint()
{
   m_pTextImage->Paint();
}