//----------------------------------------------------------------------------- // Purpose: This is called every time the DLL is loaded //----------------------------------------------------------------------------- void CHud::Init( void ) { ASSERT_LOCAL_PLAYER_RESOLVABLE(); m_nSplitScreenSlot = GET_ACTIVE_SPLITSCREEN_SLOT(); g_HudHelper.Init(); InitFonts(); // Create all the Hud elements CHudElementHelper::CreateAllElements(); gLCD.Init(); // Initialize all created elements for ( int i = 0; i < GetHudList().Count(); i++ ) { GetHudList()[ i ]->Init(); } KeyValues *kv = new KeyValues( "layout" ); if ( kv ) { if ( kv->LoadFromFile( filesystem, "scripts/HudLayout.res" ) ) { int numelements = GetHudList().Count(); for ( int i = 0; i < numelements; i++ ) { CHudElement *element = GetHudList()[i]; vgui::Panel *pPanel = GetHudPanelList()[i]; KeyValues *key = kv->FindKey( pPanel->GetName(), false ); if ( !key ) { Msg( "Hud element '%s' doesn't have an entry '%s' in scripts/HudLayout.res\n", element->GetName(), pPanel->GetName() ); } // Note: When a panel is parented to the module root, it's "parent" is returned as NULL. if ( !element->IsParentedToClientDLLRootPanel() && !pPanel->GetParent() ) { DevMsg( "Hud element '%s'/'%s' doesn't have a parent\n", element->GetName(), pPanel->GetName() ); } } } kv->deleteThis(); } if ( GET_ACTIVE_SPLITSCREEN_SLOT() == 0 ) { HudIcons().Init(); } }
static int HudElementCompletion( const char *partial, char commands[ COMMAND_COMPLETION_MAXITEMS ][ COMMAND_COMPLETION_ITEM_LENGTH ] ) { const char *cmdname = "cl_animationinfo"; char *substring = (char *)partial; if ( Q_strstr( partial, cmdname ) ) { substring = (char *)partial + strlen( cmdname ) + 1; } int current = 0; int c = gHUD.m_HudList.Count(); int i; for ( i = 0; i < c; i++ ) { CHudElement *e = gHUD.m_HudList[ i ]; if ( !e ) continue; bool add = false; // Insert into lookup if ( substring[0] ) { if ( !Q_strncasecmp( e->GetName(), substring, strlen( substring ) ) ) { add = true; } } else { add = true; } if ( add ) { Q_snprintf( commands[ current ], sizeof( commands[ current ] ), "%s %s", cmdname, e->GetName() ); current++; } } return current; }