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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: MiniMap.h: interface for the CMiniMap class.
//
// $NoKeywords: $
//=============================================================================//
#if !defined HLTVPANEL_H
#define HLTVPANEL_H
#ifdef _WIN32
#pragma once
#endif
#include <vgui_controls/Panel.h>
#include <game/client/iviewport.h>
#include "mathlib/vector.h"
#include <igameevents.h>
#include <shareddefs.h>
#include <const.h>
#include "hudelement.h"
class IMapOverviewPanel
{
public:
virtual void SetMode( int mode ) = 0;
virtual int GetMode( void ) = 0;
virtual void FlashEntity( int entityID ) = 0;
virtual void SetPlayerPositions(int index, const Vector &position, const QAngle &angle) = 0;
virtual void SetVisible(bool state) = 0;
virtual float GetZoom( void ) = 0;
virtual vgui::Panel *GetAsPanel() = 0;
virtual bool AllowConCommandsWhileAlive() = 0;
virtual void SetPlayerPreferredMode( int mode ) = 0;
virtual void SetPlayerPreferredViewSize( float viewSize ) = 0;
virtual bool IsVisible() = 0;
virtual void GetBounds(int &x, int &y, int &wide, int &tall) = 0;
virtual float GetFullZoom( void ) = 0;
virtual float GetMapScale( void ) = 0;
};
#define MAX_TRAIL_LENGTH 30
#define OVERVIEW_MAP_SIZE 1024 // an overview map is 1024x1024 pixels
typedef bool ( *FnCustomMapOverviewObjectPaint )( int textureID, Vector pos, float scale, float angle, const char *text, Color *textColor, float status, Color *statusColor );
class CMapOverview : public CHudElement, public vgui::Panel, public IMapOverviewPanel
{
DECLARE_CLASS_SIMPLE( CMapOverview, vgui::Panel );
public:
enum
{
MAP_MODE_OFF = 0, // Totally off
MAP_MODE_INSET, // A little map up in a corner
MAP_MODE_FULL, // Full screen, full map
MAP_MODE_RADAR // In game radar, extra functionality
};
CMapOverview( const char *pElementName );
virtual ~CMapOverview();
virtual bool ShouldDraw( void );
vgui::Panel *GetAsPanel(){ return this; }
virtual bool AllowConCommandsWhileAlive(){return true;}
virtual void SetPlayerPreferredMode( int mode ){}
virtual void SetPlayerPreferredViewSize( float viewSize ){};
protected: // private structures & types
float GetViewAngle( void ); // The angle that determines the viewport twist from map texture to panel drawing.
// list of game events the hLTV takes care of
typedef struct {
int xpos;
int ypos;
} FootStep_t;
typedef struct MapPlayer_s {
int index; // player's index
int userid; // user ID on server
int icon; // players texture icon ID
Color color; // players team color
char name[MAX_PLAYER_NAME_LENGTH];
int team; // N,T,CT
int health; // 0..100, 7 bit
Vector position; // current x,y pos
QAngle angle; // view origin 0..360
Vector2D trail[MAX_TRAIL_LENGTH]; // save 1 footstep each second for 1 minute
} MapPlayer_t;
typedef struct MapObject_s {
int objectID; // unique object ID
int index; // entity index if any
int icon; // players texture icon ID
Color color; // players team color
char name[MAX_PLAYER_NAME_LENGTH]; // show text under icon
Vector position; // current x,y pos
QAngle angle; // view origin 0..360
float endtime; // time stop showing object
float size; // object size
float status; // green status bar [0..1], -1 = disabled
Color statusColor; // color of status bar
int flags; // MAB_OBJECT_*
const char *text; // text to draw underneath the icon
} MapObject_t;
#define MAP_OBJECT_ALIGN_TO_MAP (1<<0)
public: // IViewPortPanel interface:
virtual const char *GetName( void ) { return PANEL_OVERVIEW; }
virtual void SetData(KeyValues *data);
virtual void Reset();
virtual void OnThink();
virtual void Update();
virtual bool NeedsUpdate( void );
virtual bool HasInputElements( void ) { return false; }
virtual void ShowPanel( bool bShow );
virtual void Init( void );
// both vgui::Frame and IViewPortPanel define these, so explicitly define them here as passthroughs to vgui
vgui::VPANEL GetVPanel( void ) { return BaseClass::GetVPanel(); }
virtual bool IsVisible() { return BaseClass::IsVisible(); }
virtual void GetBounds(int &x, int &y, int &wide, int &tall) { BaseClass::GetBounds(x, y, wide, tall); }
virtual void SetParent(vgui::VPANEL parent) { BaseClass::SetParent(parent); }
public: // IGameEventListener
virtual void FireGameEvent( IGameEvent *event);
public: // VGUI overrides
virtual void Paint();
virtual void OnMousePressed( vgui::MouseCode code );
virtual void ApplySchemeSettings(vgui::IScheme *scheme);
virtual void SetVisible(bool state){BaseClass::SetVisible(state);}
public:
virtual float GetZoom( void );
virtual int GetMode( void );
virtual float GetFullZoom( void ){ return m_fFullZoom; }
virtual float GetMapScale( void ){ return m_fMapScale; }
// Player settings:
virtual void ShowPlayerNames(bool state);
virtual void ShowPlayerHealth(bool state);
virtual void ShowPlayerTracks(float seconds);
virtual void SetPlayerPositions(int index, const Vector &position, const QAngle &angle);
// general settings:
virtual void SetMap(const char * map);
virtual void SetTime( float time );
virtual void SetMode( int mode );
virtual bool SetTeamColor(int team, Color color);
virtual void SetFollowAngle(bool state);
virtual void SetFollowEntity(int entindex); // 0 = off
virtual void SetCenter( const Vector2D &mappos);
virtual void SetAngle( float angle);
virtual Vector2D WorldToMap( const Vector &worldpos );
// Object settings
virtual int AddObject( const char *icon, int entity, float timeToLive ); // returns object ID, 0 = no entity, -1 = forever
virtual void SetObjectIcon( int objectID, const char *icon, float size ); // icon world size
virtual void SetObjectText( int objectID, const char *text, Color color ); // text under icon
virtual void SetObjectStatus( int objectID, float value, Color statusColor ); // status bar under icon
virtual void SetObjectPosition( int objectID, const Vector &position, const QAngle &angle ); // world pos/angles
virtual void AddObjectFlags( int objectID, int flags );
virtual void SetObjectFlags( int objectID, int flags );
virtual void RemoveObject( int objectID );
virtual void RemoveObjectByIndex( int index );
virtual void FlashEntity( int entityID ){}
// rules that define if you can see a player on the overview or not
virtual bool CanPlayerBeSeen(MapPlayer_t *player);
/// allows mods to restrict health
virtual bool CanPlayerHealthBeSeen(MapPlayer_t *player);
/// allows mods to restrict names (e.g. CS when mp_playerid is non-zero)
virtual bool CanPlayerNameBeSeen(MapPlayer_t *player);
virtual int GetIconNumberFromTeamNumber( int teamNumber ){return teamNumber;}
protected:
virtual void DrawCamera();
virtual void DrawObjects();
virtual void DrawMapTexture();
virtual void DrawMapPlayers();
virtual void DrawMapPlayerTrails();
virtual void UpdatePlayerTrails();
virtual void ResetRound();
virtual void InitTeamColorsAndIcons();
virtual void UpdateSizeAndPosition();
virtual bool RunHudAnimations(){ return true; }
bool IsInPanel(Vector2D &pos);
MapPlayer_t* GetPlayerByUserID( int userID );
int AddIconTexture(const char *filename);
Vector2D MapToPanel( const Vector2D &mappos );
int GetPixelOffset( float height );
void UpdateFollowEntity();
virtual void UpdatePlayers();
void UpdateObjects(); // objects bound to entities
MapObject_t* FindObjectByID(int objectID);
virtual bool IsRadarLocked() {return false;}
virtual bool DrawIcon( MapObject_t *obj );
/*virtual bool DrawIcon( int textureID,
int offscreenTextureID,
Vector pos,
float scale,
float angle,
int alpha = 255,
const char *text = NULL,
Color *textColor = NULL,
float status = -1,
Color *statusColor = NULL,
int objectType = OBJECT_TYPE_NORMAL );*/
int m_nMode;
Vector2D m_vPosition;
Vector2D m_vSize;
float m_flChangeSpeed;
float m_flIconSize;
IViewPort * m_pViewPort;
MapPlayer_t m_Players[MAX_PLAYERS];
CUtlDict< int, int> m_TextureIDs;
CUtlVector<MapObject_t> m_Objects;
Color m_TeamColors[MAX_TEAMS];
int m_TeamIcons[MAX_TEAMS];
int m_ObjectIcons[64];
int m_ObjectCounterID;
vgui::HFont m_hIconFont;
bool m_bShowNames;
bool m_bShowTrails;
bool m_bShowHealth;
int m_nMapTextureID; // texture id for current overview image
KeyValues * m_MapKeyValues; // keyvalues describing overview parameters
Vector m_MapOrigin; // read from KeyValues files
float m_fMapScale; // origin and scale used when screenshot was made
bool m_bRotateMap; // if true roatate map around 90 degress, so it fits better to 4:3 screen ratio
int m_nFollowEntity;// entity number to follow, 0 = off
CPanelAnimationVar( float, m_fZoom, "zoom", "1.0" ); // current zoom n = overview panel shows 1/n^2 of whole map'
float m_fFullZoom; // best zoom factor for full map view (1.0 is map is a square)
Vector2D m_ViewOrigin; // map coordinates that are in the center of the pverview panel
Vector2D m_MapCenter; // map coordinates that are in the center of the pverview panel
float m_fNextUpdateTime;
float m_fViewAngle; // rotation of overview map
float m_fWorldTime; // current world time
float m_fNextTrailUpdate; // next time to update player trails
float m_fTrailUpdateInterval; // if -1 don't show trails
bool m_bFollowAngle; // if true, map rotates with view angle
};
extern IMapOverviewPanel *g_pMapOverview;
#endif //
|