Go Back   Steam Users' Forums > Steam Tool Discussions > Source Coding

Reply
 
Thread Tools Display Modes
Old 07-26-2012, 01:37 AM   #1
kacper344
 
Join Date: Jun 2009
Reputation: 0
Posts: 8
Question VGUI::LABEL - what's the problem?

Hello I'm trying to make my own HUD element with labels (display current level, experience etc.) and I have some problem with:

Code:
vgui::label *m_pLabel;
When I use it later as this:

Code:
  m_pLabel->SetFgColor( Color(255,255,255,255) );    
   m_pLabel->SetText( text );    
   m_pLabel->SetVisible(true);    
   m_pLabel->SetSize(GetWide(),GetTall());
It gives me error:

error C2027: use of undefined type 'vgui::Label'



I don't know what is wrong. I have one more problem with this line:
Code:
m_pLabel = vgui::SETUP_PANEL(new vgui::Label(this,"Label",""));

Here I'm getting:

error C2514: 'vgui::Label' : class has no constructors


What I'm doing bad ? Can you help me ?
kacper344 is offline  
Reply With Quote
Old 07-26-2012, 01:45 AM   #2
Sandern
 
 
 
Join Date: Jun 2009
Reputation: 34
Posts: 85
Did you include the label header file?

Code:
#include <vgui_controls/Label.h>
Sandern is offline   Reply With Quote
Old 07-26-2012, 05:02 AM   #3
kacper344
 
Join Date: Jun 2009
Reputation: 0
Posts: 8
Ok thanks, but why instead of text I have white filled rectangle?

Code:
void CHudLevel::Paint()
{
   SetPaintBorderEnabled(false);
   // surface()->DrawSetTexture( m_nImport );
  // surface()->DrawTexturedRect( 2, 2, 128, 128 );

   //surface()->DrawFilledRect(2,2,128,128);

   char text[256];

   Q_snprintf( text, sizeof(text), "XP: %d\nLevel: %d\n", m_Exp, m_Level ); 
   m_pLabel = vgui::SETUP_PANEL(new vgui::Label(this,"Label","")); 
   m_pLabel->SetFgColor( Color(255,255,255,255) );    
   m_pLabel->SetText( text );    
   m_pLabel->SetVisible(true);    
  // m_pLabel->SetSize(GetWide(),GetTall());   

}
What is wrong here?
kacper344 is offline   Reply With Quote
Old 07-26-2012, 06:48 AM   #4
Sandern
 
 
 
Join Date: Jun 2009
Reputation: 34
Posts: 85
You should first move everything from the Paint function to the constructor of CHudLevel. You are now creating a new label every frame. SetFgColor should be called in CHudLevel::ApplySchemeSettings (otherwise the default scheme file overrides it again).

The white filled rectangle might be shown due the default background color of the label. You can change it with SetBgColor().
Sandern is offline   Reply With Quote
Reply

Go Back   Steam Users' Forums > Steam Tool Discussions > Source Coding


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT -7. The time now is 04:01 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
Site Content Copyright Valve Corporation 1998-2012, All Rights Reserved.