Example #1
0
void StringSplit(std::vector<CTString>& vecOutput, CTString strInput, ULONG ulColumnWidth)
{
	CDrawPort* pDrawPort = CUIManager::getSingleton()->GetDrawPort();

	ULONG ulWidth = 0;
#if defined(G_RUSSIA)
	ulWidth = UTIL_HELP()->GetNoFixedWidth(_pfdDefaultFont, strInput.str_String);
#else	//	defined(G_RUSSIA)
	ulWidth = pDrawPort->GetTextWidth2(strInput);
#endif	//	defined(G_RUSSIA)
	
	if (ulWidth <= ulColumnWidth)
	{
		strInput.TrimSpacesLeft();
		strInput.TrimSpacesRight();
		vecOutput.push_back(strInput);
		return;
	}
	
	char szTemp[4];
	int len = strInput.Length(), pos = 0;
	ulWidth = 0;
	for (int i = 0, j = 0; i < len; j = 0)
	{
		if (IsDBCSLeadByte(strInput[i]))
			szTemp[j++] = strInput[i++];
		szTemp[j++] = strInput[i++];
		szTemp[j] = 0;
		ULONG ulTempWidth = 0;
#if defined(G_RUSSIA)
		ulTempWidth = UTIL_HELP()->GetNoFixedWidth(_pfdDefaultFont, szTemp);
#else	//	defined(G_RUSSIA)
		ulTempWidth = pDrawPort->GetTextWidth2(szTemp);
#endif	//	defined(G_RUSSIA)
		if (ulWidth + ulTempWidth > ulColumnWidth &&
			!(j == 1 && (szTemp[0] == '.' || szTemp[0] == ',' || szTemp[0] == ' ')))
			break;

		pos = i;
		ulWidth += ulTempWidth;
		if( strInput[pos] == '\n' || strInput[pos] == '\r' )
		{
			pos++;
			break;
		}	
	}
	CTString strLeft, strRight;
	strInput.Split(pos, strLeft, strRight);
	strLeft.TrimSpacesLeft();
	strLeft.TrimSpacesRight();
	vecOutput.push_back(strLeft);

	if (strRight.Length() > 0)
		StringSplit(vecOutput, strRight, ulColumnWidth);
}
Example #2
0
void CUIPortal::updateUI()
{
	if (m_pList == NULL)
		return;

	m_pList->DeleteAllListItem();

	int nMax = m_vectorListInfo.size();

	if (nMax <= 0)
		return;

	CUIListItem* pTemp = m_pList->GetListItemTemplate();

	if (pTemp == NULL)
		return;

	CUIListItem* pItem = NULL;
	CUIText*	 pText = NULL;
	CTString	 strTemp;
	CDrawPort*  pDrawPort = CUIManager::getSingleton()->GetDrawPort();
		
	for( int i = 0; i < nMax; i++ )
	{
		m_pList->AddListItem(pTemp->Clone());

		pItem = (CUIListItem*)m_pList->GetListItem(i);

		if (pItem == NULL)
			return;

		{
			CmdPortalMouseEvent* pCmd = new CmdPortalMouseEvent;
			pCmd->setData(this, pItem, 0xF8E1B5FF);
			pItem->SetCommandEnter(pCmd);
		}

		{
			CmdPortalMouseEvent* pCmd = new CmdPortalMouseEvent;
			pCmd->setData(this, pItem, 0xC0C0C0FF);
			pItem->SetCommandLeave(pCmd);
		}

		pText = (CUIText*)pItem->findUI("txt_zone");

		if (pText != NULL)
		{
			strTemp.PrintF("%s", CZoneInfo::getSingleton()->GetZoneName( m_vectorListInfo[i].zone ) );

			ULONG nStringWidth = pDrawPort->GetTextWidth2(strTemp);
			if (nStringWidth > pText->GetWidth())
			{
				pText->setTooltip(strTemp);
				strTemp = UtilHelp::getSingleton()->GetCalcStringEllipsis(strTemp, pText->GetWidth(), CTString("..."));
			}			
			pText->SetText(strTemp);
		}

		pText = (CUIText*)pItem->findUI("txt_pos");

		if (pText != NULL)
		{
			strTemp.PrintF("%s", CZoneInfo::getSingleton()->GetExtraName( m_vectorListInfo[i].zone, m_vectorListInfo[i].extra ) );

			ULONG nStringWidth = pDrawPort->GetTextWidth2(strTemp);
			if (nStringWidth > pText->GetWidth())
			{
				pText->setTooltip(strTemp);
				strTemp = UtilHelp::getSingleton()->GetCalcStringEllipsis(strTemp, pText->GetWidth(), CTString("..."));
			}			
			pText->SetText(strTemp);
		}
	}

	m_pList->UpdateList();
}