コード例 #1
0
ファイル: UIListBox.cpp プロジェクト: AntonioModer/xray-16
CUIListBoxItem* CUIListBox::AddTextItem(LPCSTR text)
{
	CUIListBoxItem* pItem			= AddItem();

	pItem->SetWndSize				(Fvector2().set(GetDesiredChildWidth(), m_def_item_height));
	pItem->SetTextColor				(m_text_color);
	pItem->SetText					(CStringTable().translate(text).c_str());
	pItem->GetTextItem()->SetWidth	(GetDesiredChildWidth());
	return							pItem;
}
コード例 #2
0
ファイル: ServerList.cpp プロジェクト: AntonioModer/xray-16
void CServerList::FillUpDetailedServerInfo()
{	

	bool t1 = false;
	bool t2 = false;
	bool spect = false;
		
	CUIListItemServer* pItem = (CUIListItemServer*)m_list[LST_SERVER].GetSelectedItem();
	if(pItem)
	{
		ServerInfo srvInfo;
		browser().GetServerInfoByIndex(&srvInfo, pItem->GetInfo()->info.Index);
		u32 teams = srvInfo.m_aTeams.size();

		if (2 == teams)
		{
			LPSTR _buff = NULL;

			CUIListBoxItem* pItemAdv;

			// TEAM 1
			xr_vector<PlayerInfo>::iterator it;
			for (it = srvInfo.m_aPlayers.begin(); it != srvInfo.m_aPlayers.end(); ++it)
			{
				PlayerInfo pf = *it;
				if (1 != pf.Team)
					continue;
				if (pf.Spectator)
					continue;

				if (!t1)		// add header
				{
					STRCONCAT(_buff, CStringTable().translate("ui_st_team").c_str(),
						"\"", CTeamInfo::GetTeam1_name().c_str(), "\"");

					pItemAdv					= m_list[LST_PLAYERS].AddItem();
					pItemAdv->SetTextColor		(m_list[LST_PLAYERS].GetTextColor());
					pItemAdv->SetFont			(m_list[LST_PLAYERS].GetFont());
					pItemAdv->SetText			(_buff);
					pItemAdv->GetTextItem()->SetWidth(m_list[LST_PLAYERS].GetDesiredChildWidth());
					t1 = true;
				}


 				pItemAdv						= m_list[LST_PLAYERS].AddItem();

				char buf[16];
				pItemAdv->SetTextColor			(m_list[LST_PLAYERS].GetTextColor());
				pItemAdv->SetFont				(m_list[LST_PLAYERS].GetFont());
				pItemAdv->SetText	(pf.Name);
				pItemAdv->GetTextItem()->SetWidth(m_header2[1].GetWidth());

				xr_sprintf						(buf,sizeof(buf),"%d",pf.Frags);
				pItemAdv->AddTextField			(buf, m_header2[2].GetWidth());

				xr_sprintf						(buf,sizeof(buf),"%d",pf.Deaths);
				pItemAdv->AddTextField			(buf, m_header2[3].GetWidth());
			}

			
			// TEAM 2
			for (it = srvInfo.m_aPlayers.begin(); it != srvInfo.m_aPlayers.end(); it++)
			{
				PlayerInfo pf = *it;
				if (2 != pf.Team)
					continue;
				if (pf.Spectator)
					continue;

				if (!t2)
				{
					STRCONCAT(_buff, CStringTable().translate("ui_st_team").c_str(),
						"\"", CTeamInfo::GetTeam2_name().c_str(), "\"");

					m_list[LST_PLAYERS].AddTextItem	(_buff);

					t2 = true;
				}

				pItemAdv						= m_list[LST_PLAYERS].AddItem();

				char buf[16];
				pItemAdv->SetTextColor			(m_list[LST_PLAYERS].GetTextColor());
				pItemAdv->SetFont				(m_list[LST_PLAYERS].GetFont());
				pItemAdv->SetText				(pf.Name);
				pItemAdv->GetTextItem()->SetWidth(m_header2[1].GetWidth());
				
				xr_sprintf						(buf,sizeof(buf),"%d",pf.Frags);
				pItemAdv->AddTextField			(buf, m_header2[2].GetWidth());

				xr_sprintf						(buf,sizeof(buf),"%d",pf.Deaths);
				pItemAdv->AddTextField			(buf, m_header2[3].GetWidth());
			}

			// SPECTATORS
			for (it = srvInfo.m_aPlayers.begin(); it != srvInfo.m_aPlayers.end();++it)
			{
				PlayerInfo pf = *it;
				if (!pf.Spectator)
					continue;

				if (!spect)
				{
					pItemAdv					= m_list[LST_PLAYERS].AddTextItem(CStringTable().translate("mp_spectator").c_str());
					spect = true;
				}

				pItemAdv						= m_list[LST_PLAYERS].AddItem();

				char buf[16];
				pItemAdv->SetFont				(m_list[LST_PLAYERS].GetFont());
				pItemAdv->SetTextColor			(m_list[LST_PLAYERS].GetTextColor());
				pItemAdv->SetText				(pf.Name);
				pItemAdv->GetTextItem()->SetWidth(m_header2[1].GetWidth());

				xr_sprintf						(buf,sizeof(buf),"%d",pf.Frags);
				pItemAdv->AddTextField			(buf, m_header2[2].GetWidth());

				xr_sprintf						(buf,sizeof(buf),"%d",pf.Deaths);
				pItemAdv->AddTextField			(buf, m_header2[3].GetWidth());
			}

		}
		else
		{
			xr_vector<PlayerInfo>::iterator it;
			for (it = srvInfo.m_aPlayers.begin(); it != srvInfo.m_aPlayers.end(); ++it)
			{
				PlayerInfo pf = *it;
				CUIListBoxItem* pItemAdv		= m_list[LST_PLAYERS].AddItem();

				char buf[16];

				pItemAdv->SetTextColor			(m_list[LST_PLAYERS].GetTextColor());
				pItemAdv->SetFont				(m_list[LST_PLAYERS].GetFont());
				pItemAdv->SetText				(pf.Name);
				pItemAdv->GetTextItem()->SetWidth(m_header2[1].GetWidth());

				xr_sprintf						(buf,sizeof(buf),"%d",pf.Frags);
				pItemAdv->AddTextField			(buf, m_header2[2].GetWidth());

				xr_sprintf						(buf,sizeof(buf),"%d",pf.Deaths);
				pItemAdv->AddTextField			(buf, m_header2[3].GetWidth());
			}
		}

		xr_vector<GameInfo>::iterator it;
		for (it = srvInfo.m_aInfos.begin(); it != srvInfo.m_aInfos.end(); ++it)
		{
			GameInfo gi							= *it;
			CUIListBoxItem* pItemAdv			= m_list[LST_SRV_PROP].AddItem();

			pItemAdv->SetText					(gi.InfoName.c_str());
			pItemAdv->GetTextItem()->SetWidth	(m_list[LST_SRV_PROP].GetWidth()/2);

			pItemAdv->AddTextField				(gi.InfoData.c_str(), m_list[LST_SRV_PROP].GetWidth()/2);
		}
	}
	else
		ClearDetailedServerInfo		();
}