Ejemplo n.º 1
0
Archivo: hud.cpp Proyecto: Yosam02/game
//-----------------------------------------------------------------------------
// Purpose: See if we should draw based on a hud render group
//			Return true if this group is locked, hud elem will be hidden
//-----------------------------------------------------------------------------
bool CHud::IsRenderGroupLockedFor(CHudElement *pHudElement, int iGroupIndex)
{
    // does this index exist?
    if (!DoesRenderGroupExist(iGroupIndex))
        return false;

    int i = m_RenderGroups.Find(iGroupIndex);

    Assert(m_RenderGroups.IsValidIndex(i));

    CHudRenderGroup *group = m_RenderGroups.Element(i);

    if (!group)
        return false;

    // hidden for everyone!
    if (group->bHidden)
        return true;

    if (group->m_pLockingElements.Count() == 0)
        return false;

    if (!pHudElement)
        return true;

    CHudElement *pLocker = group->m_pLockingElements.ElementAtHead();

    return (pLocker != pHudElement && pLocker->GetRenderGroupPriority() > pHudElement->GetRenderGroupPriority());
}
Ejemplo n.º 2
0
//-----------------------------------------------------------------------------
// 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;
}
Ejemplo n.º 4
0
Archivo: hud.cpp Proyecto: Yosam02/game
//-----------------------------------------------------------------------------
// Purpose: This is called every time the DLL is loaded
//-----------------------------------------------------------------------------
void CHud::Init(void)
{
    HOOK_HUD_MESSAGE(gHUD, ResetHUD);

#ifdef CSTRIKE_DLL
    HOOK_HUD_MESSAGE( gHUD, SendAudio );
#endif

    InitFonts();

    // Create all the Hud elements
    CHudElementHelper::CreateAllElements();

    gLCD.Init();

    // Initialize all created elements
    for (int i = 0; i < m_HudList.Size(); i++)
    {
        m_HudList[i]->Init();
    }

    m_bHudTexturesLoaded = false;

    KeyValues *kv = new KeyValues("layout");
    if (kv)
    {
        if (kv->LoadFromFile(filesystem, "scripts/HudLayout.res"))
        {
            int numelements = m_HudList.Size();

            for (int i = 0; i < numelements; i++)
            {
                CHudElement *element = m_HudList[i];

                vgui::Panel *pPanel = dynamic_cast<vgui::Panel*>(element);
                if (!pPanel)
                {
                    Msg("Non-vgui hud element %s\n", m_HudList[i]->GetName());
                    continue;
                }

                KeyValues *key = kv->FindKey(pPanel->GetName(), false);
                if (!key)
                {
                    Msg("Hud element '%s' doesn't have an entry '%s' in scripts/HudLayout.res\n", m_HudList[i]->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", m_HudList[i]->GetName(), pPanel->GetName());
                }
            }
        }

        kv->deleteThis();
    }

    if (m_bHudTexturesLoaded)
        return;

    m_bHudTexturesLoaded = true;
    CUtlDict< CHudTexture *, int >	textureList;

    // check to see if we have sprites for this res; if not, step down
    LoadHudTextures(textureList, "scripts/hud_textures", NULL);
    LoadHudTextures(textureList, "scripts/mod_textures", NULL);

    int c = textureList.Count();
    for (int index = 0; index < c; index++)
    {
        CHudTexture* tex = textureList[index];
        AddSearchableHudIconToList(*tex);
    }

    FreeHudTextureList(textureList);
}