2
0
mirror of https://github.com/FWGS/hlsdk-xash3d synced 2024-11-11 04:39:03 +01:00
hlsdk-xash3d/cl_dll/train.cpp

83 lines
1.6 KiB
C++
Raw Normal View History

2017-12-18 00:39:44 +01:00
/***
*
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC.
*
****/
//
// Train.cpp
//
// implementation of CHudAmmo class
//
#include "hud.h"
#include "cl_util.h"
#include <string.h>
#include <stdio.h>
#include "parsemsg.h"
2016-07-03 15:39:55 +02:00
DECLARE_MESSAGE( m_Train, Train )
2017-12-18 00:39:44 +01:00
2016-07-03 15:39:55 +02:00
int CHudTrain::Init( void )
2017-12-18 00:39:44 +01:00
{
HOOK_MESSAGE( Train );
m_iPos = 0;
m_iFlags = 0;
2016-07-03 15:39:55 +02:00
gHUD.AddHudElem( this );
2017-12-18 00:39:44 +01:00
return 1;
2016-06-25 20:21:01 +02:00
}
2017-12-18 00:39:44 +01:00
2016-07-03 15:39:55 +02:00
int CHudTrain::VidInit( void )
2017-12-18 00:39:44 +01:00
{
m_hSprite = 0;
return 1;
2016-06-25 20:21:01 +02:00
}
2017-12-18 00:39:44 +01:00
2016-07-03 15:39:55 +02:00
int CHudTrain::Draw( float fTime )
2017-12-18 00:39:44 +01:00
{
2016-07-03 15:39:55 +02:00
if( !m_hSprite )
m_hSprite = LoadSprite( "sprites/%d_train.spr" );
2017-12-18 00:39:44 +01:00
2016-07-03 15:39:55 +02:00
if( m_iPos )
2017-12-18 00:39:44 +01:00
{
int r, g, b, x, y;
UnpackRGB(r,g,b, gHUD.m_iHUDColor);
2016-07-03 15:39:55 +02:00
SPR_Set( m_hSprite, r, g, b );
2017-12-18 00:39:44 +01:00
// This should show up to the right and part way up the armor number
2016-07-03 15:39:55 +02:00
y = ScreenHeight - SPR_Height( m_hSprite, 0 ) - gHUD.m_iFontHeight;
x = ScreenWidth / 3 + SPR_Width( m_hSprite, 0 ) / 4;
2017-12-18 00:39:44 +01:00
2016-07-03 15:39:55 +02:00
SPR_DrawAdditive( m_iPos - 1, x, y, NULL );
2017-12-18 00:39:44 +01:00
}
return 1;
}
2016-07-03 15:39:55 +02:00
int CHudTrain::MsgFunc_Train( const char *pszName, int iSize, void *pbuf )
2017-12-18 00:39:44 +01:00
{
BEGIN_READ( pbuf, iSize );
// update Train data
m_iPos = READ_BYTE();
2016-07-03 15:39:55 +02:00
if( m_iPos )
2017-12-18 00:39:44 +01:00
m_iFlags |= HUD_ACTIVE;
else
m_iFlags &= ~HUD_ACTIVE;
return 1;
}