Skip to content

Commit c1df894

Browse files
committed
client: allow toggling hud_saytext in the spectator GUI
1 parent 8e77e47 commit c1df894

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

cl_dll/hud/spectator_gui.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ void CHudSpectatorGui::UserCmd_ToggleSpectatorMenuOptionsSettings()
438438
if( !(m_menuFlags & MENU_OPTIONS_SETTINGS) )
439439
{
440440
m_menuFlags |= MENU_OPTIONS_SETTINGS;
441-
gMobileAPI.pfnTouchAddClientButton( "_spec_opt_chat_msgs", "*white", "messagemode; _spec_toggle_menu_options_settings",
441+
gMobileAPI.pfnTouchAddClientButton( "_spec_opt_chat_msgs", "*white", "hud_saytext t; _spec_toggle_menu_options_settings",
442442
PLACE_DEFAULT_SIZE_BUTTON_AT_X_Y( 4.5f, 4.5f ), color, 0, 1.0f, 0 );
443443
gMobileAPI.pfnTouchAddClientButton( "_spec_opt_set_status", "*white", "spec_drawstatus t; _spec_toggle_menu_options_settings",
444444
PLACE_DEFAULT_SIZE_BUTTON_AT_X_Y( 4.5f, 5.5f ), color, 0, 1.0f, 0 );

cl_dll/hud_spectator.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,23 @@ void SpecPip( void )
188188
gEngfuncs.Cvar_Set( name, gEngfuncs.Cmd_Argv(1) );
189189
}
190190

191+
void HudSayText( void )
192+
{
193+
if ( gEngfuncs.Cmd_Argc() <= 1 )
194+
{
195+
gEngfuncs.Con_Printf( "usage: hud_saytext <0|1>\n" );
196+
return;
197+
}
198+
199+
const char *name = "hud_saytext_internal";
200+
char *arg = gEngfuncs.Cmd_Argv(1);
201+
202+
if( arg[0] == 't' && arg[1] == '\0' )
203+
gEngfuncs.Cvar_SetValue( name, !gEngfuncs.pfnGetCvarFloat(name) );
204+
else
205+
gEngfuncs.Cvar_Set( name, gEngfuncs.Cmd_Argv(1) );
206+
}
207+
191208
//-----------------------------------------------------------------------------
192209
// Purpose:
193210
//-----------------------------------------------------------------------------
@@ -213,6 +230,7 @@ int CHudSpectator::Init()
213230
gEngfuncs.pfnAddCommand ("spec_drawnames", SpecDrawNames );
214231
gEngfuncs.pfnAddCommand ("spec_drawcone", SpecDrawCone );
215232
gEngfuncs.pfnAddCommand ("spec_drawstatus", SpecDrawStatus );
233+
gEngfuncs.pfnAddCommand ("hud_saytext", HudSayText );
216234
gEngfuncs.pfnAddCommand ("spec_autodirector", SpecAutoDirector );
217235
gEngfuncs.pfnAddCommand ("spec_pip", SpecPip );
218236

cl_dll/hud_spectator.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ class CHudSpectator : public CHudBase
9999
cvar_t * m_drawnames;
100100
cvar_t * m_drawcone;
101101
cvar_t * m_drawstatus;
102+
cvar_t * m_HUD_saytext;
102103
cvar_t * m_autoDirector;
103104
float m_lastAutoDirector;
104105
cvar_t * m_pip;

cl_dll/saytext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ int CHudSayText :: Init( void )
5555

5656
InitHUDData();
5757

58-
m_HUD_saytext = gEngfuncs.pfnRegisterVariable( "hud_saytext", "1", 0 );
58+
m_HUD_saytext = gEngfuncs.pfnRegisterVariable( "hud_saytext_internal", "1", 0 );
5959
m_HUD_saytext_time = gEngfuncs.pfnRegisterVariable( "hud_saytext_time", "5", 0 );
6060

6161
m_iFlags |= HUD_INTERMISSION; // is always drawn during an intermission

0 commit comments

Comments
 (0)