|
|
#1 |
|
Join Date: Jun 2009
Reputation: 0
Posts: 8
|
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; Code:
m_pLabel->SetFgColor( Color(255,255,255,255) ); m_pLabel->SetText( text ); m_pLabel->SetVisible(true); m_pLabel->SetSize(GetWide(),GetTall()); 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 ? |
|
|
|
|
|
#2 |
![]() Join Date: Jun 2009
Reputation: 34
Posts: 85
|
Did you include the label header file?
Code:
#include <vgui_controls/Label.h> |
|
|
|
|
|
#3 |
|
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());
}
|
|
|
|
|
|
#4 |
![]() 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(). |
|
|
|
![]() |
|
||||||
| Thread Tools | |
| Display Modes | |
|
|