VGUI2: Overview Display

From Valve Developer Community
Revision as of 18:44, 16 August 2005 by Holtt (talk | contribs)

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

The Source SDK includes code to create overview maps for multiplayer games. Overview maps let the player see an overview of the game map with markers showing their location and the location of other players. This is similar to the overview map available in Day of Defeat.

Enabling basic overview map display

1. In the file vgui_TeamFortressViewport.cpp, add this line to CreateDefaultPanels:

AddNewPanel( CreatePanelByName( PANEL_OVERVIEW ) );

Then rebuild your mod.

2. Create an overview map texture and configuration for your level. See Creating Level Overviews for instructions.

3. Start up your mod, and bind a key to "overview_mode". Pressing this key will toggle the overview map between off, small, and full screen modes.

Note: It's important you get your overview map created correctly so that the player locations are properly overlayed on the map!


Displaying the overview only when holding down a key

The previous section describes how to make the overview map cycle between three modes (off, mini, full screen). The following more complex modification allows you to have the overview map only display when a key is held down - much like how the scoreboard is displayed when the (default) TAB key is pressed. This takes a bit more coding to implement, but isn't that much more difficult.

What we'll do here is duplicate the code that displays the score board as we want our overview map to basically emulate it's behaviour.

Changes to cl_dll\in_main.cpp

1. Add this definition for a new key command to show/hide our overview:

static	kbutton_t	in_overview;

To know where to place it, search for the similar declaration for in_score.

2. Add the following code to define two new functions which handle showing and hiding the overview:

void IN_OverviewDown(void)
{
	KeyDown(&in_overview);

	if ( gViewPortInterface )
	{
		gViewPortInterface->ShowPanel( PANEL_OVERVIEW, true );
	}
}

void IN_OverviewUp(void)
{
	KeyUp(&in_overview);
	if ( gViewPortInterface )
	{
		gViewPortInterface->ShowPanel( PANEL_OVERVIEW, false );
		GetClientVoiceMgr()->StopSquelchMode();
	}
}

They can go just after the IN_ScoreUp function.

3. Add the following line of code with all the other CalcButtonBits calls:

CalcButtonBits( bits, IN_OVERVIEW, s_ClearInputState, &in_overview, bResetState );

4. Add the following 4 lines of code near all the other ConCommand lines:

static ConCommand startoverview("+overview", IN_OverviewDown);
static ConCommand endoverview("-overview", IN_OverviewUp);
static ConCommand startshowoverview("+showoverview", IN_OverviewDown);
static ConCommand endshowoverview("-showoverview", IN_OverviewUp);

Changes to game_shared\in_buttons.h

1. Add the following definition:

#define IN_OVERVIEW		(1 << 23)

Note: At the time of writing this, the last official IN_ defined is IN_BULLRUSH (bit shift 22). So our new define is bit shift 23. If for some reason 23 is already being used, just use some number not already being used.

See also

Creating Level Overviews