//-----------------------------------------------------------------------------
// Purpose: 
// Input  : playerIndex - 
//			hintID - 
//			priority - 
//			entityIndex - 
//-----------------------------------------------------------------------------
C_TFBaseHint *C_TFHintManager::AddHint( int hintID, const char *subsection, int entityIndex, int maxduplicates )
{
	if ( !tf2_hintsystem.GetBool() )
		return NULL;

	// Don't add the same hint more than once unless maxduplicates >= 1 has been specifically requested
	int count = CountInstancesOfHintID( hintID );
	if ( count > maxduplicates )
	{
		return NULL;
	}

	C_TFBaseHint *hint = C_TFBaseHint::CreateHint( hintID, subsection, entityIndex );
	if ( hint )
	{
		// Force it to compute it's exact size
		hint->PerformLayout();

		PositionPanel( hint );

		m_aHints.AddToTail( hint );
	}

	return hint;
}
Beispiel #2
0
void Hotlist::OnReadPanels(PrefsSection *section)
{
	OP_PROFILE_METHOD("Created panels");

	//remember which panels exist right now, so we know what to remove
	OpVector<HotlistPanel> removed_panels;

	for (INT32 i=0; i < GetPanelCount(); ++i)
	{
		HotlistPanel* old_panel = GetPanel(i);
		if (old_panel->GetType() != PANEL_TYPE_WEB)	//web panels are maintained by the bookmarks events
			removed_panels.Add(old_panel);
	}

	//read panel setup and apply to current setup
	if (section)
	{
		for (const PrefsEntry *entry = section->Entries(); entry; entry = (const PrefsEntry *) entry->Suc())
		{
			OpLineParser line(entry->Key());

			OpString item_type;
			INT32 pos = -1;

			if (OpStatus::IsError(line.GetNextToken(item_type)))
				continue;

			line.GetNextValue(pos);

			//get the new panel type;
			Type new_panel_type = GetPanelTypeByName(item_type.CStr());

			//move or create it if needed
			HotlistPanel* positioned_panel = PositionPanel(new_panel_type, pos);

			//this panel (if already existed) should not be removed
			OpStatus::Ignore(removed_panels.RemoveByItem(positioned_panel));
		}
	}

	//all panels in this list have not been reread, so they must have been removed
	while (removed_panels.GetCount() > 0)
	{
		INT32 pos;
		GetPanelByType(removed_panels.Get(0)->GetType(), &pos);
		OP_ASSERT(pos >= 0);	//panels in the removed_panels list should exist
		//delete panel and remove from the removal list
		RemovePanel(pos);
		removed_panels.Remove(0);
	}

	//update panels from bookmarks (webpanels)
	OnTreeChanged(g_hotlist_manager->GetBookmarksModel());

	INT32 active = ReadActiveTab();

	Collapse collapse = GetCollapse();
	if (collapse == COLLAPSE_SMALL)
		active = -1;

	m_selector->SetSelected(active, TRUE, TRUE);
}