Vector Graphics

kamdur

Newbie
Joined
Mar 19, 2009
Messages
6
Reaction score
0
Hello I have looked over the tutorial on authoring true type fonts to act as a hud in my mod, but i can't get it to use any font other than default. Any help or links plz?
 
Are you meant to change the the font name in some script file?
 
...was waiting for a Major Havoc or Tempest thread and got pretty excited.
 
You just have to make hud config (in resources) use font file you want. You must include *.ttf file in your resources folder too.
 
I changed to places in ClientScheme.res, and have the font file in resources. Then I have my hud window in the code and it shows up, but it's in default font.
 
In fonts of ClientScheme.res:
HUDReticleUp
{
"1"
{
"name" "HUDReticleUp"
"tall" "32"
"weight" "0"
"antialias" "1"
"additive" "1"
"custom" "3"
}
}

In Custom Font Files:
CustomFontFiles
{
"1" "resource/HALFLIFE2.ttf"
"2" "resource/HL2crosshairs.ttf"
"3" "resource/HUDReticleUp.ttf"
"4" "resource/HUDReticleRight.ttf"
"5" "resource/HUDReticleDown.ttf"
"6" "resource/HUDReticleLeft.ttf"
}

In my Hud file:
class CHUDReticleUp : public CHudElement, public CHudNumericDisplay
{
DECLARE_CLASS_SIMPLE( CHUDReticleUp, CHudNumericDisplay );
public:
CHUDReticleUp( const char *pElementName );
void Init( void );
void VidInit( void );
virtual void OnThink();

virtual void ApplySchemeSettings( IScheme *scheme );

private:
CFastTimer m_ReticleUpdateTimer;
CFastTimer m_ReticleDrawTimer;
float m_fLastUpdateSize;
float m_fLastDrawSize;
float m_fSpeed;
};

DECLARE_HUDELEMENT( CHUDReticleUp );

CHUDReticleUp::CHUDReticleUp( const char *pElementName ) :
CHudElement( pElementName ), BaseClass( NULL, "HudReticleUp" )
{
vgui::Panel *pParent = g_pClientMode->GetViewport();
SetParent( pParent );

SetHiddenBits( HIDEHUD_PLAYERDEAD | HIDEHUD_CROSSHAIR );
}

void CHUDReticleUp::ApplySchemeSettings( IScheme *scheme )
{
BaseClass::ApplySchemeSettings( scheme );
}


void CHUDReticleUp::Init( void )
{
SetDisplayValue(1);
m_ReticleUpdateTimer.Start();
m_fLastUpdateSize = 0.0f;
m_fLastDrawSize = 0.0f;
}


void CHUDReticleUp::VidInit( void )
{
Init();
}



//-----------------------------------------------------------------------------
// Purpose: Checks if the hud element needs to fade out
//-----------------------------------------------------------------------------
void CHUDReticleUp::OnThink()
{
BaseClass::OnThink();

C_BasePlayer *player = C_BasePlayer::GetLocalPlayer();
if ( player == NULL )
return;

unsigned long nTimeSinceLastDraw;

m_ReticleDrawTimer.End();
CCycleCount durDraw = m_ReticleDrawTimer.GetDuration();
nTimeSinceLastDraw = durDraw.GetMilliseconds();
m_ReticleDrawTimer.Start();

float fReticleSize = player->m_fReticleSize;
float fPos;

if (m_fLastUpdateSize != fReticleSize)
{
unsigned long nTimeSinceLastUpdate;

m_ReticleUpdateTimer.End();
CCycleCount durUpdate = m_ReticleDrawTimer.GetDuration();
nTimeSinceLastUpdate = durUpdate.GetMilliseconds();
m_ReticleUpdateTimer.Start();

m_fSpeed = (fReticleSize - m_fLastUpdateSize) / nTimeSinceLastUpdate;

m_fLastUpdateSize = fReticleSize;
m_fLastDrawSize = fReticleSize;
fPos = fReticleSize;
}
else
{
fPos = m_fLastDrawSize + m_fSpeed * nTimeSinceLastDraw;

m_fLastDrawSize = fPos;
}

float x = ScreenWidth()/2.0f;
float y = ScreenHeight()*(1.0f-fPos)/2.0f;

SetBounds(x - 92, y - 32 - 16, 100, 100);
SetPaintBackgroundEnabled(false);
}
 
Does yours replacing old one? If yes, make it "read-only".
 
right click on ClientScheme.res, hit properties and make it read only? that didn't work. Do you mean something else?
 
Back
Top