|
|
#1 |
![]() Join Date: Jul 2008
Reputation: 0
Posts: 389
|
ASW: Draw Text
Hey guys, I have been having this problem for a while now, where I can't draw text to the HUD, and it never really seems to make any sense to me. There are two different scenarios for this when I try to draw text to the screen.
1. It doesn't draw 2. It draws only when the in-game menu is drawn Here's how I draw the text: Code:
wchar_t unicode[6]; g_pVGuiLocalize->ConstructString( unicode, sizeof( unicode ), L"%d", 1, wpn->Clip1() ); surface()->DrawSetTextFont(m_ammoFont); surface()->DrawSetTextPos(xAbsPos, yAbsPos); surface()->DrawPrintText( unicode, wcslen( unicode ) ); Thank you all in advance. |
|
|
|
|
|
#2 |
![]() Join Date: Jul 2008
Reputation: 1
Posts: 151
|
Where are you drawing that ? Whats the parent panel ?
|
|
|
|
|
|
#3 |
![]() Join Date: Jul 2008
Reputation: 0
Posts: 389
|
My Bad
Code:
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose: HUD Target ID element
//
// $NoKeywords: $
//=============================================================================//
#include "cbase.h"
#include "hud.h"
#include "hudelement.h"
#include "hud_macros.h"
#include "vgui_EntityPanel.h"
#include "iclientmode.h"
#include "beamdraw.h"
#include "vgui/ILocalize.h"
#include "vgui_controls/controls.h"
#include "vgui/ISurface.h"
#include <vgui/IVGui.h>
#include <vgui/IScheme.h>
// Player
#include "basenetworkedplayer_cl.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
class CHudAmmo : public CHudElement, public vgui::Panel
{
DECLARE_CLASS_SIMPLE( CHudAmmo, vgui::Panel );
public:
CHudAmmo( const char *pElementName );
void Init( void );
void ApplySchemeSettings( vgui::IScheme *scheme );
void Paint( void );
void VidInit( void );
private:
CPanelAnimationVar( vgui::HFont, m_ammoFont, "TextFont", "WeaponSwapText" );
CPanelAnimationVar( Color, m_TextColor, "TextColor", "HudOrange" );
};
DECLARE_HUDELEMENT( CHudAmmo );
using namespace vgui;
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
CHudAmmo::CHudAmmo( const char *pElementName ) : CHudElement( pElementName ), BaseClass( NULL, "HudAmmo" )
{
SetParent( GetClientMode()->GetViewport() );
}
//-----------------------------------------------------------------------------
// Purpose: Setup
//-----------------------------------------------------------------------------
void CHudAmmo::Init( void )
{
}
void CHudAmmo::ApplySchemeSettings( vgui::IScheme *scheme )
{
BaseClass::ApplySchemeSettings( scheme );
SetPaintBackgroundEnabled( false );
SetPos(0,0);
int xsize;
int ysize;
engine->GetScreenSize(xsize,ysize);
SetSize(xsize,ysize);
}
//-----------------------------------------------------------------------------
// Purpose: clear out string etc between levels
//-----------------------------------------------------------------------------
void CHudAmmo::VidInit()
{
CHudElement::VidInit();
}
//-----------------------------------------------------------------------------
// Purpose: Draw function for the element
//-----------------------------------------------------------------------------
void CHudAmmo::Paint()
{
C_BaseNetworkedPlayer *pLocal = C_BaseNetworkedPlayer::GetLocalNetworkPlayer();
if ( !pLocal && !pLocal->IsAlive() )
return;
wchar_t unicode[6];
g_pVGuiLocalize->ConstructString( unicode, sizeof( unicode ), L"%d", 1, wpn->Clip1() );
surface()->DrawSetTextFont(m_ammoFont);
surface()->DrawSetTextPos(500, 500);
surface()->DrawPrintText( unicode, wcslen( unicode ) );
}
|
|
|
|
|
|
#4 |
![]() Join Date: Jul 2008
Reputation: 1
Posts: 151
|
Thats pretty weird. I'm not sure what could be the problem. Do you still have the ASW hud showing up ? And did you use a template sdk base, or the skeleton base?
Maybe try naming the class to something else,so we're sure it won't load the settings from the default hudammo. |
|
|
|
|
|
#5 | |
![]() Join Date: Jul 2008
Reputation: 0
Posts: 389
|
Quote:
EDIT: So I tried renaming the class and nothing has changed, I'm currently using the ASW Skeleton base so there's no other HUD to display EDIT: SOLVED! The .vpk file wasn't being compiled properly so HudLayout.res wasn't being loaded Last edited by shadow-killer: 07-07-2012 at 09:26 AM. |
|
|
|
|
![]() |
|
||||||
| Thread Tools | |
| Display Modes | |
|
|