GameUI
- Not to be confused with the game_ui entity.
GameUI is the code which provides the VGUI 'frontend': broadly speaking, the main menu and loading screens.
GameUI panels are children of their own dedicated panel ("GameUI Panel"). The client's RootPanel is used only for in-game HUD elements.
Source 2009

In Source 2009 (and earlier), GameUI is a closed engine library manipulable to a limited extent by editing .res script files. These define properties like width, height, element location, and so on. You can add new non-interactive elements, and with a bit of effort hide existing ones.
It is possible to create new VGUI panels that behave in exactly the same way as GameUI ones.
Left 4 Dead

The Alien Swarm SDK contains the complete source for the newer L4D-style GameUI, which has been moved into the client library. It has been redesigned for consoles' lack of a pointing device: everything is integrated into the same navigable menu system, and you can't be in more than area at once. It's also far, far easier to program.

Creating a new window
- Create a new class, inheriting from
CBaseModFrame
. - Create an accompanying "<class name>.res" script in
game\resource\ui\basemodui\
. - Add a new entry to the
WINDOW_TYPE
enum. - Edit the enormous switch in
CBaseModPanel::OpenWindow()
to include your new enum and class.
The ugly enum/switch indirection is presumably designed to allow a single "window type" value to open slightly different window objects depending on the UI's state. Too bad Valve haven't found any excuse to do that yet!
Opening windows
Use CBaseModFrame* CBaseModPanel::OpenWindow()
:
#include "gameui\swarm\basemodpanel.h"
using namespace BaseModUI;
void openwindow()
{
CBaseModFrame* mainMenu = CBaseModPanel::GetSingleton().GetWindow( WT_MAINMENU );
CBaseModPanel::GetSingleton().OpenWindow( WT_GAMESETTINGS, mainMenu );
}
The arguments are:
WINDOW_TYPE &wt
- An enum value that defines which precise window to open.
CBaseModFrame* caller
- The window which requested this one to open. Among other things, this becomes the target of 'back' buttons on the new window.
bool hidePrevious
- Hides
caller
if true. KeyValues* pParameters
- Passed on to the new window.
OnOpen()
is called on the opened window.
Startup
The initialization sequence is:
CGameUI::Initialize()
CBaseModPanel::RunFrame()
CBaseModPanel::OnGameUIActivated()
CBaseModPanel::OpenFrontScreen()
CBaseModPanel::OpenWindow()
CBaseModPanel
is a singleton; CBaseModFrame
is the base class of all windows.