Toggleable Scoreboard: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Created page with 'To replace the default behaviour of scoreboards (where one would need to hold down a button to make the scoreboard appear), the following change would make it so the scoreboard b…')
 
m (clean up, added orphan, deadend tags)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
To replace the default behaviour of scoreboards (where one would need to hold down a button to make the scoreboard appear), the following change would make it so the scoreboard becomes Toggleable.  
{{Multiple issues|
{{Dead end|date=January 2024}}
{{Orphan|date=January 2024}}
}}
 
== Overview ==
This article will show you how to modify the default behavior of the scoreboard. Instead of requiring the player to hold down the scoreboard key (+showscores) to show the scoreboard, we'll modify it so that it toggles on and off.
 
'''This has been tested on SDK Template technology and may or may not work on other engine branches!'''
 
== Code ==
 
Open '''in_main.cpp''', and modify the '''IN_ScoreDown''' (Lines 503-510), and the '''IN_ScoreUp''' (Lines 512-520) functions.


Open the file in_main.cpp and modify the IN_ScoreDown and IN_ScoreUp functions to the following:
<source lang=cpp>
<source lang=cpp>
//Replace the old function entirely with this
void IN_ScoreDown( const CCommand &args )
void IN_ScoreDown( const CCommand &args )
{
{
Line 20: Line 32:
}
}


//Replace the old function entirely with this
void IN_ScoreUp( const CCommand &args )
void IN_ScoreUp( const CCommand &args )
{
{
Line 25: Line 38:
}
}
</source>
</source>
[[Category:VGUI]] [[Category:Programming]]
 
== Conclusion ==
With this simple change, the scoreboard will go from the button having to be held down, to having the scoreboard be toggled on or off each time the button is pressed.
 
[[Category:VGUI]]
[[Category:Programming]]

Latest revision as of 10:17, 21 January 2024

Wikipedia - Letter.png
This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these template messages)
Dead End - Icon.png
This article has no Wikipedia icon links to other VDC articles. Please help improve this article by adding links Wikipedia icon that are relevant to the context within the existing text.
January 2024

Overview

This article will show you how to modify the default behavior of the scoreboard. Instead of requiring the player to hold down the scoreboard key (+showscores) to show the scoreboard, we'll modify it so that it toggles on and off.

This has been tested on SDK Template technology and may or may not work on other engine branches!

Code

Open in_main.cpp, and modify the IN_ScoreDown (Lines 503-510), and the IN_ScoreUp (Lines 512-520) functions.

//Replace the old function entirely with this
void IN_ScoreDown( const CCommand &args )
{
	KeyDown( &in_score, args[1] );

	if(gViewPortInterface)
	{
		if ((gViewPortInterface->FindPanelByName( PANEL_SCOREBOARD ))->IsVisible())
		{
			gViewPortInterface->ShowPanel( PANEL_SCOREBOARD, false );
		}
		else 
		{
			gViewPortInterface->ShowPanel( PANEL_SCOREBOARD, true );
		}
	}
}

//Replace the old function entirely with this
void IN_ScoreUp( const CCommand &args )
{

}

Conclusion

With this simple change, the scoreboard will go from the button having to be held down, to having the scoreboard be toggled on or off each time the button is pressed.