Toggleable Scoreboard

From Valve Developer Community
Revision as of 03:55, 11 April 2011 by LordNed (talk | contribs) (Formatting/Cleanup)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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.