Toggleable Scoreboard

From Valve Developer Community
Jump to: navigation, search
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 links to other VDC articles. Please help improve this article by adding links 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.