This repository has been archived by the owner on May 4, 2022. It is now read-only.
forked from FWGS/hlsdk-portable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
overview.cpp
161 lines (134 loc) · 4.5 KB
/
overview.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#include "hud.h"
#include "cl_util.h"
#include "cl_entity.h"
#include "triangleapi.h"
#include "overview.h"
// these are included for the math functions
#include "com_model.h"
#include "studio_util.h"
#pragma warning(disable: 4244)
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
int CHudOverview::Init()
{
gHUD.AddHudElem(this);
m_iFlags |= HUD_ACTIVE;
return 1;
}
//-----------------------------------------------------------------------------
// Purpose: Loads new icons
//-----------------------------------------------------------------------------
int CHudOverview::VidInit()
{
m_hsprPlayer = gEngfuncs.pfnSPR_Load( "sprites/ring.spr" );
m_hsprViewcone = gEngfuncs.pfnSPR_Load( "sprites/camera.spr" );
return 1;
}
//-----------------------------------------------------------------------------
// Purpose:
// Input : flTime -
// intermission -
//-----------------------------------------------------------------------------
int CHudOverview::Draw( float flTime )
{
#if 0
// only draw in overview mode
if( !gEngfuncs.Overview_GetOverviewState() )
return 1;
// make sure we have player info
//gViewPort->GetAllPlayersInfo();
gHUD.m_Scoreboard.GetAllPlayersInfo();
// calculate player size on the overview
int x1, y1, x2, y2;
float v0[3] = { 0.0f }, v1[3] = { 64.0f, 64.0f };
gEngfuncs.Overview_WorldToScreen( v0, &x1, &y1 );
gEngfuncs.Overview_WorldToScreen( v1, &x2, &y2 );
float scale = abs( x2 - x1 );
// loop through all the players and draw them on the map
for( int i = 1; i < MAX_PLAYERS; i++ )
{
cl_entity_t *pl = gEngfuncs.GetEntityByIndex( i );
if( pl && pl->player && pl->curstate.health > 0 && pl->curstate.solid != SOLID_NOT )
{
int x, y, z = 0;
float v[3] = { pl->origin[0], pl->origin[1], 0 };
gEngfuncs.Overview_WorldToScreen( v, &x, &y );
// hack in some team colors
float r, g, bc;
if( g_PlayerExtraInfo[i].teamnumber == 1 )
{
r = 0.0f; g = 0.0f; bc = 1.0f;
}
else if( g_PlayerExtraInfo[i].teamnumber == 2 )
{
r = 1.0f; g = 0.0f; bc = 0.0f;
}
else
{
// just use the default orange color if the team isn't set
r = 1.0f; g = 0.7f; bc = 0.0f;
}
// set the current texture
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *)gEngfuncs.GetSpritePointer( m_hsprPlayer ), 0 );
// additive render mode
gEngfuncs.pTriAPI->RenderMode( kRenderTransAdd );
// no culling
gEngfuncs.pTriAPI->CullFace( TRI_NONE );
// draw a square
gEngfuncs.pTriAPI->Begin( TRI_QUADS );
// set the color to be that of the team
gEngfuncs.pTriAPI->Color4f( r, g, bc, 1.0f );
// calculate rotational matrix
vec3_t a, b, angles;
float rmatrix[3][4]; // transformation matrix
VectorCopy( pl->angles, angles );
angles[0] = 0.0f;
angles[1] += 90.f;
angles[1] = -angles[1];
angles[2] = 0.0f;
AngleMatrix( angles, rmatrix );
a[2] = 0;
a[0] = -scale; a[1] = -scale;
VectorTransform( a, rmatrix, b );
gEngfuncs.pTriAPI->TexCoord2f( 0, 0 );
gEngfuncs.pTriAPI->Vertex3f( x + b[0], y + b[1], z );
a[0] = -scale; a[1] = scale;
VectorTransform( a, rmatrix, b );
gEngfuncs.pTriAPI->TexCoord2f( 0, 1 );
gEngfuncs.pTriAPI->Vertex3f( x + b[0], y + b[1], z );
a[0] = scale; a[1] = scale;
VectorTransform( a, rmatrix, b );
gEngfuncs.pTriAPI->TexCoord2f( 1, 1 );
gEngfuncs.pTriAPI->Vertex3f( x + b[0], y + b[1], z );
a[0] = scale; a[1] = -scale;
VectorTransform( a, rmatrix, b );
gEngfuncs.pTriAPI->TexCoord2f( 1, 0 );
gEngfuncs.pTriAPI->Vertex3f( x + b[0], y + b[1], z );
// finish up
gEngfuncs.pTriAPI->End();
gEngfuncs.pTriAPI->RenderMode( kRenderNormal );
// draw the players name and health underneath
char string[256];
sprintf( string, "%s (%i%%)", g_PlayerInfoList[i].name, pl->curstate.health );
DrawConsoleString( x, y + ( 1.1 * scale ), string );
}
}
#endif
return 1;
}
//-----------------------------------------------------------------------------
// Purpose: called every time a server is connected to
//-----------------------------------------------------------------------------
void CHudOverview::InitHUDData()
{
//this block would force the spectator view to be on
//gEngfuncs.Overview_SetDrawOverview( 1 );
//gEngfuncs.Overview_SetDrawInset( 0 );
}