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

Reply
 
Thread Tools Display Modes
Old 07-04-2012, 05:50 PM   #1
shadow-killer
 
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 ) );
I really have NO IDEA why this keeps happening, but there you have it guys!
Thank you all in advance.
shadow-killer is offline  
Reply With Quote
Old 07-04-2012, 08:50 PM   #2
psy_commando
 
Join Date: Jul 2008
Reputation: 1
Posts: 151
Where are you drawing that ? Whats the parent panel ?
psy_commando is offline   Reply With Quote
Old 07-04-2012, 10:20 PM   #3
shadow-killer
 
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 ) );
}
shadow-killer is offline   Reply With Quote
Old 07-05-2012, 06:24 PM   #4
psy_commando
 
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.
psy_commando is offline   Reply With Quote
Old 07-06-2012, 12:57 PM   #5
shadow-killer
 
Join Date: Jul 2008
Reputation: 0
Posts: 389
Quote:
Originally Posted by psy_commando View Post
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.
Its the skeleton base for ASW, I haven't tried renaming it but I'm able to draw Images perfectly on the same HUD element

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.
shadow-killer 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 05:13 PM.


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