@@ -99,21 +99,69 @@ int CHudSpectatorGui::VidInit()
9999 }
100100
101101 m_hTimerTexture = gRenderAPI .GL_LoadTexture (" gfx/vgui/timer.tga" , NULL , 0 , TF_NEAREST |TF_NOMIPMAP|TF_CLAMP );
102+ m_hChecked = gRenderAPI .GL_LoadTexture (" gfx/vgui/640_checked.tga" , NULL , 0 , TF_NEAREST | TF_NOMIPMAP | TF_CLAMP );
103+ m_hArrowDown = gRenderAPI .GL_LoadTexture (" gfx/vgui/1920_arrowdown.tga" , NULL , 0 , TF_NEAREST | TF_NOMIPMAP | TF_CLAMP );
104+ m_hArrowUp = gRenderAPI .GL_LoadTexture (" gfx/vgui/1920_arrowup.tga" , NULL , 0 , TF_NEAREST | TF_NOMIPMAP | TF_CLAMP );
105+ m_hArrowLeft = gRenderAPI .GL_LoadTexture (" gfx/vgui/1920_arrowleft.tga" , NULL , 0 , TF_NEAREST | TF_NOMIPMAP | TF_CLAMP );
106+ m_hArrowRight = gRenderAPI .GL_LoadTexture (" gfx/vgui/1920_arrowright.tga" , NULL , 0 , TF_NEAREST | TF_NOMIPMAP | TF_CLAMP );
102107 return 1 ;
103108}
104109
105110void CHudSpectatorGui::Shutdown ()
106111{
107112 gRenderAPI .GL_FreeTexture ( m_hTimerTexture );
113+ gRenderAPI .GL_FreeTexture ( m_hChecked );
114+ gRenderAPI .GL_FreeTexture ( m_hArrowDown );
115+ gRenderAPI .GL_FreeTexture ( m_hArrowUp );
116+ gRenderAPI .GL_FreeTexture ( m_hArrowLeft );
117+ gRenderAPI .GL_FreeTexture ( m_hArrowRight );
108118}
109119
110- inline void DrawButtonWithText ( int x1, int y1, int wide, int tall, const char *sz, int r, int g, int b )
120+ inline void DrawButtonWithText ( int x1, int y1, int wide, int tall, const char *sz, int r, int g, int b, bool highlight = false )
111121{
112122 DrawUtils::DrawRectangle (x1, y1, wide, tall);
123+
124+ if ( highlight )
125+ {
126+ FillRGBABlend (x1, y1, wide, tall, r, g, b, 48 );
127+ }
128+
113129 DrawUtils::DrawHudString (x1 + INT_XPOS (0.5 ), y1 + tall*0.5 - gHUD .GetCharHeight () * 0.5 , x1 + wide, sz,
114130 r, g, b );
115131}
116132
133+ // Unified icon drawing helper. align: -1 = left, 0 = center, 1 = right
134+ static void DrawIconOnButton ( int x1, int y1, int wide, int tall, int hTex, int align = -1 , int r = 255 , int g = 255 , int b = 255 , float alpha = 1 .0f , int pad = 15 )
135+ {
136+ if ( !hTex )
137+ return ;
138+
139+ gRenderAPI .GL_SelectTexture ( 0 );
140+ gRenderAPI .GL_Bind ( 0 , hTex );
141+ gEngfuncs .pTriAPI ->RenderMode ( kRenderTransAlpha );
142+ gEngfuncs .pTriAPI ->Color4f ( r / 255 .0f , g / 255 .0f , b / 255 .0f , alpha );
143+
144+ int uploadW = (int )gRenderAPI .RenderGetParm ( PARM_TEX_WIDTH, hTex );
145+ int uploadH = (int )gRenderAPI .RenderGetParm ( PARM_TEX_HEIGHT, hTex );
146+
147+
148+ // compute quad position in pixels
149+ float quadX = x1;
150+ float quadY = y1 + ( tall - uploadH ) / 2 .0f ;
151+
152+ if ( align == -1 ) // left
153+ quadX = x1 + pad; // small padding from left
154+ else if ( align == 0 ) // center
155+ quadX = x1 + ( wide - uploadW ) * 0 .5f ;
156+ else if ( align == 1 ) // right
157+ quadX = x1 + wide - uploadW - pad; // small padding from right
158+
159+ DrawUtils::Draw2DQuad ( quadX * gHUD .m_flScale ,
160+ quadY * gHUD .m_flScale ,
161+ (quadX + (float )uploadW) * gHUD .m_flScale ,
162+ (quadY + (float )uploadH) * gHUD .m_flScale );
163+ }
164+
117165int CHudSpectatorGui::Draw ( float flTime )
118166{
119167 if ( !g_iUser1 )
@@ -206,28 +254,89 @@ int CHudSpectatorGui::Draw( float flTime )
206254 if ( m_menuFlags & ROOT_MENU )
207255 {
208256 // draw the root menu
209- DrawButtonWithText (INT_XPOS (0.5 ), INT_YPOS (8.5 ), INT_XPOS (4 ), INT_YPOS (1 ), " Options" , r, g, b);
210- DrawButtonWithText (INT_XPOS (5 ), INT_YPOS (8.5 ), INT_XPOS (1 ), INT_YPOS (1 ), " <" , r, g, b);
257+
258+ // options
259+ {
260+ // highlight when opened
261+ if ( m_menuFlags & MENU_OPTIONS )
262+ DrawButtonWithText (INT_XPOS (0.5 ), INT_YPOS (8.5 ), INT_XPOS (4 ), INT_YPOS (1 ), " Options" , r, g, b, true );
263+ else
264+ DrawButtonWithText (INT_XPOS (0.5 ), INT_YPOS (8.5 ), INT_XPOS (4 ), INT_YPOS (1 ), " Options" , r, g, b );
265+ // arrow on right part of button: down when closed, up when open
266+ if ( m_menuFlags & MENU_OPTIONS )
267+ DrawIconOnButton ( INT_XPOS (0.5 ), INT_YPOS (8.5 ), INT_XPOS (4 ), INT_YPOS (1 ), m_hArrowUp, 1 , r, g, b );
268+ else
269+ DrawIconOnButton ( INT_XPOS (0.5 ), INT_YPOS (8.5 ), INT_XPOS (4 ), INT_YPOS (1 ), m_hArrowDown, 1 , r, g, b );
270+ }
271+
272+ DrawUtils::DrawRectangle (INT_XPOS (5 ), INT_YPOS (8.5 ), INT_XPOS (1 ), INT_YPOS (1 ));
273+ DrawIconOnButton ( INT_XPOS (5 ), INT_YPOS (8.5 ), INT_XPOS (1 ), INT_YPOS (1 ), m_hArrowLeft, 0 , r, g, b );
211274
212275 DrawUtils::DrawRectangle (INT_XPOS (6 ), INT_YPOS (8.5 ), INT_XPOS (4 ), INT_YPOS (1 ));
213276 // name will be drawn later
214277
215- DrawButtonWithText (INT_XPOS (10 ), INT_YPOS (8.5 ), INT_XPOS (1 ), INT_YPOS (1 ), " >" , r, g, b );
216- DrawButtonWithText (INT_XPOS (11.5 ), INT_YPOS (8.5 ), INT_XPOS (4 ), INT_YPOS (1 ), " Spectate Options" , r, g, b);
278+ DrawUtils::DrawRectangle (INT_XPOS (10 ), INT_YPOS (8.5 ), INT_XPOS (1 ), INT_YPOS (1 ));
279+ DrawIconOnButton ( INT_XPOS (10 ), INT_YPOS (8.5 ), INT_XPOS (1 ), INT_YPOS (1 ), m_hArrowRight, 0 , r, g, b );
280+
281+ // spectate options
282+ {
283+ // highlight when opened
284+ if ( m_menuFlags & MENU_SPEC_OPTIONS )
285+ DrawButtonWithText (INT_XPOS (11.5 ), INT_YPOS (8.5 ), INT_XPOS (4 ), INT_YPOS (1 ), " Spectate Options" , r, g, b, true );
286+ else
287+ DrawButtonWithText (INT_XPOS (11.5 ), INT_YPOS (8.5 ), INT_XPOS (4 ), INT_YPOS (1 ), " Spectate Options" , r, g, b );
288+ // arrow on right part of button: down when closed, up when open
289+ if ( m_menuFlags & MENU_SPEC_OPTIONS )
290+ DrawIconOnButton ( INT_XPOS (11.5 ), INT_YPOS (8.5 ), INT_XPOS (4 ), INT_YPOS (1 ), m_hArrowUp, 1 , r, g, b );
291+ else
292+ DrawIconOnButton ( INT_XPOS (11.5 ), INT_YPOS (8.5 ), INT_XPOS (4 ), INT_YPOS (1 ), m_hArrowDown, 1 , r, g, b );
293+ }
294+
217295 if ( m_menuFlags & MENU_OPTIONS )
218296 {
219297 DrawButtonWithText (INT_XPOS (0.5 ), INT_YPOS (2.5 ), INT_XPOS (4 ), INT_YPOS (1 ), " Close" , r, g, b );
220298 DrawButtonWithText (INT_XPOS (0.5 ), INT_YPOS (3.5 ), INT_XPOS (4 ), INT_YPOS (1 ), " Help" , r, g, b );
221- DrawButtonWithText (INT_XPOS (0.5 ), INT_YPOS (4.5 ), INT_XPOS (4 ), INT_YPOS (1 ), " Settings" , r, g, b );
299+
300+ // settings
301+ {
302+ // highlight when opened
303+ if ( m_menuFlags & MENU_OPTIONS_SETTINGS )
304+ DrawButtonWithText (INT_XPOS (0.5 ), INT_YPOS (4.5 ), INT_XPOS (4 ), INT_YPOS (1 ), " Settings" , r, g, b, true );
305+ else
306+ DrawButtonWithText (INT_XPOS (0.5 ), INT_YPOS (4.5 ), INT_XPOS (4 ), INT_YPOS (1 ), " Settings" , r, g, b );
307+
308+ DrawIconOnButton ( INT_XPOS (0.5 ), INT_YPOS (4.5 ), INT_XPOS (4 ), INT_YPOS (1 ), m_hArrowRight, 1 , r, g, b );
309+ }
310+
222311 DrawButtonWithText (INT_XPOS (0.5 ), INT_YPOS (5.5 ), INT_XPOS (4 ), INT_YPOS (1 ), " Picture-in-Picture" , r, g, b );
312+ if ( gHUD .m_Spectator .m_pip && gHUD .m_Spectator .m_pip ->value != INSET_OFF )
313+ DrawIconOnButton ( INT_XPOS (0.5 ), INT_YPOS (5.5 ), INT_XPOS (4 ), INT_YPOS (1 ), m_hChecked, -1 , r, g, b );
314+
223315 DrawButtonWithText (INT_XPOS (0.5 ), INT_YPOS (6.5 ), INT_XPOS (4 ), INT_YPOS (1 ), " Autodirector" , r, g, b );
316+ if ( gHUD .m_Spectator .m_autoDirector && gHUD .m_Spectator .m_autoDirector ->value )
317+ DrawIconOnButton ( INT_XPOS (0.5 ), INT_YPOS (6.5 ), INT_XPOS (4 ), INT_YPOS (1 ), m_hChecked, -1 , r, g, b );
318+
224319 DrawButtonWithText (INT_XPOS (0.5 ), INT_YPOS (7.5 ), INT_XPOS (4 ), INT_YPOS (1 ), " Show scores" , r, g, b );
320+ if ( gHUD .m_Scoreboard .m_bForceDraw || gHUD .m_Scoreboard .m_bShowscoresHeld )
321+ DrawIconOnButton ( INT_XPOS (0.5 ), INT_YPOS (7.5 ), INT_XPOS (4 ), INT_YPOS (1 ), m_hChecked, -1 , r, g, b );
322+
225323 if ( m_menuFlags & MENU_OPTIONS_SETTINGS )
226324 {
227325 DrawButtonWithText (INT_XPOS (4.5 ), INT_YPOS (4.5 ), INT_XPOS (4 ), INT_YPOS (1 ), " Chat messages" , r, g, b );
326+ if ( gHUD .m_Spectator .m_HUD_saytext && gHUD .m_Spectator .m_HUD_saytext ->value )
327+ DrawIconOnButton ( INT_XPOS (4.5 ), INT_YPOS (4.5 ), INT_XPOS (4 ), INT_YPOS (1 ), m_hChecked, -1 , r, g, b );
328+
228329 DrawButtonWithText (INT_XPOS (4.5 ), INT_YPOS (5.5 ), INT_XPOS (4 ), INT_YPOS (1 ), " Show status" , r, g, b );
330+ if ( gHUD .m_Spectator .m_drawstatus && gHUD .m_Spectator .m_drawstatus ->value )
331+ DrawIconOnButton ( INT_XPOS (4.5 ), INT_YPOS (5.5 ), INT_XPOS (4 ), INT_YPOS (1 ), m_hChecked, -1 , r, g, b );
332+
229333 DrawButtonWithText (INT_XPOS (4.5 ), INT_YPOS (6.5 ), INT_XPOS (4 ), INT_YPOS (1 ), " View cone" , r, g, b );
334+ if ( gHUD .m_Spectator .m_drawcone && gHUD .m_Spectator .m_drawcone ->value )
335+ DrawIconOnButton ( INT_XPOS (4.5 ), INT_YPOS (6.5 ), INT_XPOS (4 ), INT_YPOS (1 ), m_hChecked, -1 , r, g, b );
336+
230337 DrawButtonWithText (INT_XPOS (4.5 ), INT_YPOS (7.5 ), INT_XPOS (4 ), INT_YPOS (1 ), " Player names" , r, g, b );
338+ if ( gHUD .m_Spectator .m_drawnames && gHUD .m_Spectator .m_drawnames ->value )
339+ DrawIconOnButton ( INT_XPOS (4.5 ), INT_YPOS (7.5 ), INT_XPOS (4 ), INT_YPOS (1 ), m_hChecked, -1 , r, g, b );
231340 }
232341 }
233342
0 commit comments