Beispiel #1
0
// get first next word or quoted string
CTString GetNextParam(void)
{
    // strip leading spaces/tabs
    _strCmd.TrimSpacesLeft();
    // if nothing left
    if (_strCmd=="") {
        // no word to return
        return "";
    }

    // if the first char is quote
    if (_strCmd[0]=='"') {
        // find first next quote
        const char* pCmd = _strCmd;
        char *pchClosingQuote = strchr((char*)pCmd+1, '"');
        // if not found
        if (pchClosingQuote==NULL) {
            // error in command line
            cmd_strOutput+=CTString(0, TRANS("Command line error!\n"));
            // finish parsing
            _strCmd = "";
            return "";
        }
        INDEX iQuote = pchClosingQuote-_strCmd;

        // get the quoted string
        CTString strWord;
        CTString strRest;
        _strCmd.Split(iQuote, strWord, strRest);
        // remove the quotes
        strWord.DeleteChar(0);
        strRest.DeleteChar(0);
        // get the word
        _strCmd = strRest;
        return strWord;

        // if the first char is not quote
    } else {
        // find first next space
        INDEX iSpace;
        INDEX ctChars = strlen(_strCmd);
        for(iSpace=0; iSpace<ctChars; iSpace++) {
            if (isspace(_strCmd[iSpace])) {
                break;
            }
        }
        // get the word string
        CTString strWord;
        CTString strRest;
        _strCmd.Split(iSpace, strWord, strRest);
        // remove the space
        strRest.DeleteChar(0);
        // get the word
        _strCmd = strRest;
        return strWord;
    }
}
CTString CUIQuestBook::MakeTitleString(CTString strTitle, int iSplitPos)
{
	if( strTitle.Length() <= iSplitPos )
		return strTitle;

	BOOL b2ByteChar = FALSE;

	for( int iPos = 0; iPos < iSplitPos; ++iPos )
	{
		if( strTitle[iPos] & 0x80 )
			b2ByteChar = !b2ByteChar;
		else
			b2ByteChar = FALSE;
	}

	if( b2ByteChar )
		iSplitPos--;

	CTString	strTemp, strTemp2;
	strTitle.Split( iSplitPos, strTemp, strTemp2 );

	strTemp += _s("...");

	return strTemp;
}
// ----------------------------------------------------------------------------
// Name : AddString()
// Desc : 
// ----------------------------------------------------------------------------
void CUIPetItemMix::AddString ( CTString& strText, COLOR colText )
{
	int nLength =  strText.Length();

	if( nLength >= _iMaxMsgStringChar )
	{
		nLength -= nLength - _iMaxMsgStringChar;
		
		do
		{
			if ( strText[nLength] == ' ' )
			{
				break;
			}

		} while ( nLength-- );

		CTString strTemp2, strTemp;

		strText.Split( nLength, strTemp2, strTemp );
		m_lbPreconditionDesc.AddString ( 0, strTemp2, colText );

		strTemp2.PrintF ( "%s", strTemp );
		
		m_lbPreconditionDesc.AddString ( 0, strTemp2, colText );

	}
	else 
	{
		m_lbPreconditionDesc.AddString ( 0, strText, colText );
	}

}
Beispiel #4
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);
}
Beispiel #5
0
// parse command line parameters and set results to static variables
void ParseCommandLine(CTString strCmd)
{
  cmd_strOutput = "";
  cmd_strOutput+=CTString(0, TRANS("Command line: '%s'\n"), strCmd);
  // if no command line
  if (strlen(strCmd) == 0) {
    // do nothing
    return;
  }
  _strCmd = strCmd;

  FOREVER {
    CTString strWord = GetNextParam();
    if (strWord=="") {
      cmd_strOutput+="\n";
      return;
    } else if (strWord=="+level") {
      cmd_strWorld = GetNextParam();
    } else if (strWord=="+server") {
      cmd_bServer = TRUE;
    } else if (strWord=="+quickjoin") {
      cmd_bQuickJoin = TRUE;
    } else if (strWord=="+game") {
      CTString strMod = GetNextParam();
      if (strMod!="SeriousSam") { // (we ignore default mod - always use base dir in that case)
        _fnmMod = "Mods\\"+strMod+"\\";
      }
    } else if (strWord=="+cdpath") {
      _fnmCDPath = GetNextParam();
    } else if (strWord=="+password") {
      cmd_strPassword = GetNextParam();
    } else if (strWord=="+connect") {
      cmd_strServer = GetNextParam();
      const char *pcColon = strchr(cmd_strServer, ':');
      if (pcColon!=NULL) {
        CTString strServer;
        CTString strPort;
        cmd_strServer.Split(pcColon-cmd_strServer, strServer, strPort);
        cmd_strServer = strServer;
        strPort.ScanF(":%d", &cmd_iPort);
      }
    } else if (strWord=="+script") {
      cmd_strScript = GetNextParam();
    } else if (strWord=="+goto") {
      GetNextParam().ScanF("%d", &cmd_iGoToMarker);
    } else if (strWord=="+logfile") {
      _strLogFile = GetNextParam();
    } else {
      cmd_strOutput+=CTString(0, TRANS("  Unknown option: '%s'\n"), strWord);
    }
  }
}
Beispiel #6
0
// ----------------------------------------------------------------------------
// Name : AddString()
// Desc :
// ----------------------------------------------------------------------------
void CUICompound::AddString( CTString &strDesc )
{
	if( m_nStringCount >= MAX_COMPOUND_STRING )
		return;

	// Get length of string
	INDEX	nLength = strDesc.Length();
	if( nLength == 0 )
		return;
	// wooss 051002
#if defined(G_THAI)
	{
		int		iPos;
		// Get length of string
		INDEX	nThaiLen = FindThaiLen(strDesc);
		INDEX	nChatMax= (_iMaxMsgStringChar-1)*(_pUIFontTexMgr->GetFontWidth()+_pUIFontTexMgr->GetFontSpacing());
		if( nLength == 0 )
			return;
		// If length of string is less than max char
		if( nThaiLen <= nChatMax )
		{
		// Check line character
			for( iPos = 0; iPos < nLength; iPos++ )
			{
				if( strDesc[iPos] == '\n' || strDesc[iPos] == '\r' )
					break;
			}

			// Not exist
			if( iPos == nLength )
				m_strDesc[m_nStringCount++] = strDesc;
			else
			{
				// Split string
				CTString	strTemp;
				strDesc.Split( iPos, m_strDesc[m_nStringCount++], strTemp );

				// Trim line character
				if( strTemp[0] == '\r' && strTemp[1] == '\n' )
					strTemp.TrimLeft( strTemp.Length() - 2 );
				else
					strTemp.TrimLeft( strTemp.Length() - 1 );

				AddString( strTemp );
			}
		}
		// Need multi-line
		else
		{
			// Check splitting position for 2 byte characters
			int		nSplitPos = _iMaxMsgStringChar;
			BOOL	b2ByteChar = FALSE;
			for( iPos = 0; iPos < nLength; iPos++ )
			{
				if(nChatMax < FindThaiLen(strDesc,0,iPos))
					break;
			}
			nSplitPos = iPos;

			// Check line character
			for( iPos = 0; iPos < nSplitPos; iPos++ )
			{
				if( strDesc[iPos] == '\n' || strDesc[iPos] == '\r' )
					break;
			}

			// Not exist
			if( iPos == nSplitPos )
			{
				// Split string
				CTString	strTemp;
				strDesc.Split( nSplitPos, m_strDesc[m_nStringCount++], strTemp );

				// Trim space
				if( strTemp[0] == ' ' )
				{
					int	nTempLength = strTemp.Length();
					for( iPos = 1; iPos < nTempLength; iPos++ )
					{
						if( strTemp[iPos] != ' ' )
							break;
					}

					strTemp.TrimLeft( strTemp.Length() - iPos );
				}

				AddString( strTemp );
			}
			else
			{
				// Split string
				CTString	strTemp;
				strDesc.Split( iPos, m_strDesc[m_nStringCount++], strTemp );

				// Trim line character
				if( strTemp[0] == '\r' && strTemp[1] == '\n' )
					strTemp.TrimLeft( strTemp.Length() - 2 );
				else
					strTemp.TrimLeft( strTemp.Length() - 1 );

				AddString( strTemp );
			}

		}
		
	}
#else
	{	
		// If length of string is less than max char
		if( nLength <= _iMaxMsgStringChar )
		{
			// Check line character
			int iPos;
			for( iPos = 0; iPos < nLength; iPos++ )
			{
				if( strDesc[iPos] == '\n' || strDesc[iPos] == '\r' )
					break;
			}

			// Not exist
			if( iPos == nLength )
				m_strDesc[m_nStringCount++] = strDesc;
			else
			{
				// Split string
				CTString	strTemp;
				strDesc.Split( iPos, m_strDesc[m_nStringCount++], strTemp );

				// Trim line character
				if( strTemp[0] == '\r' && strTemp[1] == '\n' )
					strTemp.TrimLeft( strTemp.Length() - 2 );
				else
					strTemp.TrimLeft( strTemp.Length() - 1 );

				AddString( strTemp );
			}
		}
		// Need multi-line
		else
		{
			// Check splitting position for 2 byte characters
			int		nSplitPos = _iMaxMsgStringChar;
			BOOL	b2ByteChar = FALSE;
			int		iPos;
			for( iPos = 0; iPos < nSplitPos; iPos++ )
			{
				if( strDesc[iPos] & 0x80 )
					b2ByteChar = !b2ByteChar;
				else
					b2ByteChar = FALSE;
			}

			if( b2ByteChar )
				nSplitPos--;

			// Check line character
			for( iPos = 0; iPos < nSplitPos; iPos++ )
			{
				if( strDesc[iPos] == '\n' || strDesc[iPos] == '\r' )
					break;
			}

			// Not exist
			if( iPos == nSplitPos )
			{
				// Split string
				CTString	strTemp;
				strDesc.Split( nSplitPos, m_strDesc[m_nStringCount++], strTemp );

				// Trim space
				if( strTemp[0] == ' ' )
				{
					int	nTempLength = strTemp.Length();
					for( iPos = 1; iPos < nTempLength; iPos++ )
					{
						if( strTemp[iPos] != ' ' )
							break;
					}

					strTemp.TrimLeft( strTemp.Length() - iPos );
				}

				AddString( strTemp );
			}
			else
			{
				// Split string
				CTString	strTemp;
				strDesc.Split( iPos, m_strDesc[m_nStringCount++], strTemp );

				// Trim line character
				if( strTemp[0] == '\r' && strTemp[1] == '\n' )
					strTemp.TrimLeft( strTemp.Length() - 2 );
				else
					strTemp.TrimLeft( strTemp.Length() - 1 );

				AddString( strTemp );
			}
		}
	}
#endif
}
Beispiel #7
0
// ----------------------------------------------------------------------------
// Name : AddString()
// Desc :
// ----------------------------------------------------------------------------
void CUIGWMix::AddString( CTString &strDesc )
{
    if( m_nStringCount >= MAX_GW_MIX_STRING )
        return;

    // Get length of string
    INDEX	nLength = strDesc.Length();
    if( nLength == 0 )
        return;

    // If length of string is less than max char
    if( nLength <= _iMaxMsgStringChar )
    {
        // Check line character
        int iPos;
        for( iPos = 0; iPos < nLength; iPos++ )
        {
            if( strDesc[iPos] == '\n' || strDesc[iPos] == '\r' )
                break;
        }

        // Not exist
        if( iPos == nLength )
            m_strMixDesc[m_nStringCount++] = strDesc;
        else
        {
            // Split string
            CTString	strTemp;
            strDesc.Split( iPos, m_strMixDesc[m_nStringCount++], strTemp );

            // Trim line character
            if( strTemp[0] == '\r' && strTemp[1] == '\n' )
                strTemp.TrimLeft( strTemp.Length() - 2 );
            else
                strTemp.TrimLeft( strTemp.Length() - 1 );

            AddString( strTemp );
        }
    }
    // Need multi-line
    else
    {
        // Check splitting position for 2 byte characters
        int		nSplitPos = _iMaxMsgStringChar;
        BOOL	b2ByteChar = FALSE;
        int		iPos;
        for( iPos = 0; iPos < nSplitPos; iPos++ )
        {
            if( strDesc[iPos] & 0x80 )
                b2ByteChar = !b2ByteChar;
            else
                b2ByteChar = FALSE;
        }

        if( b2ByteChar )
            nSplitPos--;

        // Check line character
        for( iPos = 0; iPos < nSplitPos; iPos++ )
        {
            if( strDesc[iPos] == '\n' || strDesc[iPos] == '\r' )
                break;
        }

        // Not exist
        if( iPos == nSplitPos )
        {
            // Split string
            CTString	strTemp;
            strDesc.Split( nSplitPos, m_strMixDesc[m_nStringCount++], strTemp );

            // Trim space
            if( strTemp[0] == ' ' )
            {
                int	nTempLength = strTemp.Length();
                for( iPos = 1; iPos < nTempLength; iPos++ )
                {
                    if( strTemp[iPos] != ' ' )
                        break;
                }

                strTemp.TrimLeft( strTemp.Length() - iPos );
            }

            AddString( strTemp );
        }
        else
        {
            // Split string
            CTString	strTemp;
            strDesc.Split( iPos, m_strMixDesc[m_nStringCount++], strTemp );

            // Trim line character
            if( strTemp[0] == '\r' && strTemp[1] == '\n' )
                strTemp.TrimLeft( strTemp.Length() - 2 );
            else
                strTemp.TrimLeft( strTemp.Length() - 1 );

            AddString( strTemp );
        }
    }
}
//-----------------------------------------------------------------------------
// Purpose: 캐릭터의 설명을 설정함.
// Input  : &strItemInfo - 
//			colItemInfo - 
//-----------------------------------------------------------------------------
void CUICreateChar::AddCharInfoString( CTString &strCharInfo, COLOR colCharInfo )
{
	if( m_nCurInfoLines >= MAX_CHARINFO_LINE )
		return;

	// Get length of string
	INDEX	nLength = strCharInfo.Length();
	if( nLength == 0 )
		return;

	// wooss 051002
#if defined(G_THAI)
	{
		int		iPos;
		// Get length of string
		INDEX	nThaiLen = FindThaiLen(strCharInfo);
		INDEX	nChatMax= (_iMaxCharInfoChar-1)*(_pUIFontTexMgr->GetFontWidth()+_pUIFontTexMgr->GetFontSpacing());
		if( nLength == 0 )
			return;
		// If length of string is less than max char
		if( nThaiLen <= nChatMax )
		{
			// Check line character
			for( iPos = 0; iPos < nLength; iPos++ )
			{
				if( strCharInfo[iPos] == '\n' || strCharInfo[iPos] == '\r' )
					break;	
			}

			// Not exist
			if( iPos == nLength )
			{
				m_strCharInfo[m_nCurInfoLines] = strCharInfo;
				m_colCharInfo[m_nCurInfoLines++] = colCharInfo;
			}
			else
			{
				// Split string
				CTString	strTemp;
				strCharInfo.Split( iPos, m_strCharInfo[m_nCurInfoLines], strTemp );
				m_colCharInfo[m_nCurInfoLines++] = colCharInfo;

				// Trim line character
				if( strTemp[0] == '\r' && strTemp[1] == '\n' )
					strTemp.TrimLeft( strTemp.Length() - 2 );
				else
					strTemp.TrimLeft( strTemp.Length() - 1 );

				AddCharInfoString( strTemp, colCharInfo );
			}
		}
		// Need multi-line
		else
		{
			// Check splitting position for 2 byte characters
			int		nSplitPos = _iMaxCharInfoChar;
			BOOL	b2ByteChar = FALSE;
			for( iPos = 0; iPos < nLength; iPos++ )
			{
				if(nChatMax < FindThaiLen(strCharInfo,0,iPos))
					break;
			}
			nSplitPos = iPos;

			// Check line character
			for( iPos = 0; iPos < nSplitPos; iPos++ )
			{
				if( strCharInfo[iPos] == '\n' || strCharInfo[iPos] == '\r' )
					break;
			}

			// Not exist
			if( iPos == nSplitPos )
			{
				// Split string
				CTString	strTemp;
				strCharInfo.Split( nSplitPos, m_strCharInfo[m_nCurInfoLines], strTemp );
				m_colCharInfo[m_nCurInfoLines++] = colCharInfo;

				// Trim space
				if( strTemp[0] == ' ' )
				{
					int	nTempLength = strTemp.Length();
					for( iPos = 1; iPos < nTempLength; iPos++ )
					{
						if( strTemp[iPos] != ' ' )
							break;
					}

					strTemp.TrimLeft( strTemp.Length() - iPos );
				}

				AddCharInfoString( strTemp, colCharInfo );
			}
			else
			{
				// Split string
				CTString	strTemp;
				strCharInfo.Split( iPos, m_strCharInfo[m_nCurInfoLines], strTemp );
				m_colCharInfo[m_nCurInfoLines++] = colCharInfo;

				// Trim line character
				if( strTemp[0] == '\r' && strTemp[1] == '\n' )
					strTemp.TrimLeft( strTemp.Length() - 2 );
				else
					strTemp.TrimLeft( strTemp.Length() - 1 );

				AddCharInfoString( strTemp, colCharInfo );
			}

		}
		
	} 
#else
 {
		// If length of string is less than max char
		if( nLength < _iMaxCharInfoChar )
		{
			// Check line character
			int iPos;
			for( iPos = 0; iPos < nLength; iPos++ )
			{
				if( strCharInfo[iPos] == '\n' || strCharInfo[iPos] == '\r' )
					break;	
			}

			// Not exist
			if( iPos == nLength )
			{
				m_strCharInfo[m_nCurInfoLines] = strCharInfo;
				m_colCharInfo[m_nCurInfoLines++] = colCharInfo;
			}
			else
			{
				// Split string
				CTString	strTemp;
				strCharInfo.Split( iPos, m_strCharInfo[m_nCurInfoLines], strTemp );
				m_colCharInfo[m_nCurInfoLines++] = colCharInfo;

				// Trim line character
				if( strTemp[0] == '\r' && strTemp[1] == '\n' )
					strTemp.TrimLeft( strTemp.Length() - 2 );
				else
					strTemp.TrimLeft( strTemp.Length() - 1 );

				AddCharInfoString( strTemp, colCharInfo );
			}
		}
		// Need multi-line
		else
		{
			// Check splitting position for 2 byte characters
			int		nSplitPos = _iMaxCharInfoChar;
			BOOL	b2ByteChar = FALSE;
			int		iPos;
			for( iPos = 0; iPos < nSplitPos; iPos++ )
			{
				if( strCharInfo[iPos] & 0x80 )
					b2ByteChar = !b2ByteChar;
				else
					b2ByteChar = FALSE;
			}

			if( b2ByteChar )
				nSplitPos--;

			// Check line character			
			for( iPos = 0; iPos < nSplitPos; iPos++ )
			{
				if( strCharInfo[iPos] == '\n' || strCharInfo[iPos] == '\r' )
					break;
			}

			// Not exist
			if( iPos == nSplitPos )
			{
				// Split string
				CTString	strTemp;
				strCharInfo.Split( nSplitPos, m_strCharInfo[m_nCurInfoLines], strTemp );
				m_colCharInfo[m_nCurInfoLines++] = colCharInfo;

				// Trim space
				if( strTemp[0] == ' ' )
				{
					int	nTempLength = strTemp.Length();
					for( iPos = 1; iPos < nTempLength; iPos++ )
					{
						if( strTemp[iPos] != ' ' )
							break;
					}

					strTemp.TrimLeft( strTemp.Length() - iPos );
				}

				AddCharInfoString( strTemp, colCharInfo );
			}
			else
			{
				// Split string
				CTString	strTemp;
				strCharInfo.Split( iPos, m_strCharInfo[m_nCurInfoLines], strTemp );
				m_colCharInfo[m_nCurInfoLines++] = colCharInfo;

				// Trim line character
				if( strTemp[0] == '\r' && strTemp[1] == '\n' )
					strTemp.TrimLeft( strTemp.Length() - 2 );
				else
					strTemp.TrimLeft( strTemp.Length() - 1 );

				AddCharInfoString( strTemp, colCharInfo );
			}
		}
	}
#endif
}
Beispiel #9
0
// parse command line parameters and set results to static variables
void ParseCommandLine(CTString strCmd)
{
    cmd_strOutput = "";
    cmd_strOutput+=CTString(0, TRANS("Command line: '%s'\n"), strCmd);
    // if no command line
    if (strlen(strCmd) == 0) {
        // do nothing
        return;
    }
    _strCmd = strCmd;

    FOREVER {
        CTString strWord = GetNextParam();
        if (strWord=="") {
            cmd_strOutput+="\n";
            return;
        } else if (strWord=="+level") {
            cmd_strWorld = GetNextParam();
        } else if (strWord=="+server") {
            cmd_bServer = TRUE;
        } else if (strWord=="+player") {
            cmd_strPlayer = GetNextParam();
        } else if (strWord=="+quickjoin") {
            cmd_bQuickJoin = TRUE;
        } else if (strWord=="+game") {
            CTString strMod = GetNextParam();
#if _SE_DEMO
            if (strMod!="SeriousSam" && strMod!="Warped") {
                FatalError(TRANS("This MOD is not allowed in demo version!"));
                return;
            }
#endif
            if (strMod!="SeriousSam") { // (we ignore default mod - always use base dir in that case)
                _fnmMod = "Mods\\"+strMod+"\\";
            }
        } else if (strWord=="+cdpath") {
            _fnmCDPath = GetNextParam();
        } else if (strWord=="+password") {
            cmd_strPassword = GetNextParam();
        } else if (strWord=="+connect") {
            cmd_strServer = GetNextParam();
            const char *pcColon = strchr(cmd_strServer, ':');
            if (pcColon!=NULL) {
                CTString strServer;
                CTString strPort;
                cmd_strServer.Split(pcColon-cmd_strServer, strServer, strPort);
                cmd_strServer = strServer;
                strPort.ScanF(":%d", &cmd_iPort);
            }
        } else if (strWord=="+windowpos") {
            CTString strWinPos = GetNextParam();
            const char *pcColon = strchr(strWinPos, ':');
            if (pcColon!=NULL) {
                CTString strLeft;
                CTString strTop;
                strWinPos.Split(pcColon-strWinPos, strLeft, strTop);
                strLeft.ScanF("%d", &cmd_iWindowLeft);
                strTop.ScanF(":%d", &cmd_iWindowTop);
            }
        } else if (strWord=="+script") {
            cmd_strScript = GetNextParam();
        } else if (strWord=="+goto") {
            GetNextParam().ScanF("%d", &cmd_iGoToMarker);
        } else if (strWord=="+logfile") {
            _strLogFile = GetNextParam();
        } else {
            cmd_strOutput+=CTString(0, TRANS("  Unknown option: '%s'\n"), strWord);
        }
    }
}
Beispiel #10
0
// ----------------------------------------------------------------------------
// Name : AddReadingString()
// Desc :
// ----------------------------------------------------------------------------
void CUIHelp::AddReadingString( CUIListBox& lbList, CTString &strContent, COLOR colContent, int iMaxChar )
{
	// Get length of string
	INDEX	nLength = strContent.Length();
	if( nLength == 0 )
		return;

	// wooss 051002
#if defined (THAI)
	// Get length of string
	INDEX	nThaiLen = FindThaiLen(strContent);
	INDEX	nChatMax= (iMaxChar-1)*(_pUIFontTexMgr->GetFontWidth()+_pUIFontTexMgr->GetFontSpacing());
	if( nLength == 0 )
		return;
	// If length of string is less than max char
	if( nThaiLen <= nChatMax )
	{
		// Check line character
		for( int iPos = 0; iPos < nLength; iPos++ )
		{
			if( strContent[iPos] == '\n' || strContent[iPos] == '\r' )
				break;	
		}

		// Not exist
		if( iPos == nLength )
		{
			lbList.AddString( 0, strContent, colContent );
		}
		else
		{
			// Split string
			CTString	strTemp, strTemp2;
			strContent.Split( iPos, strTemp2, strTemp );
			lbList.AddString( 0, strTemp2, colContent );

			// Trim line character
			if( strTemp[0] == '\r' && strTemp[1] == '\n' )
				strTemp.TrimLeft( strTemp.Length() - 2 );
			else
				strTemp.TrimLeft( strTemp.Length() - 1 );

			AddReadingString( lbList, strTemp, colContent );
		}
	}
	// Need multi-line
	else
	{
		// Check splitting position for 2 byte characters
		int		nSplitPos = iMaxChar;
		BOOL	b2ByteChar = FALSE;
		for( int iPos = 0; iPos < nLength; iPos++ )
		{
			if(nChatMax < FindThaiLen(strContent,0,iPos))
				break;
		}
		nSplitPos = iPos;

		// Check line character
		for( iPos = 0; iPos < nSplitPos; iPos++ )
		{
			if( strContent[iPos] == '\n' || strContent[iPos] == '\r' )
				break;
		}

		// Not exist
		if( iPos == nSplitPos )
		{
			// Split string
			CTString	strTemp, strTemp2;
			strContent.Split( nSplitPos, strTemp2, strTemp );
			lbList.AddString( 0, strTemp2, colContent );

			// Trim space
			if( strTemp[0] == ' ' )
			{
				int	nTempLength = strTemp.Length();
				for( iPos = 1; iPos < nTempLength; iPos++ )
				{
					if( strTemp[iPos] != ' ' )
						break;
				}

				strTemp.TrimLeft( strTemp.Length() - iPos );
			}

			AddReadingString( lbList, strTemp, colContent );
		}
		else
		{
			// Split string
			CTString	strTemp, strTemp2;
			strContent.Split( iPos, strTemp2, strTemp );
			lbList.AddString( 0, strTemp2, colContent );

			// Trim line character
			if( strTemp[0] == '\r' && strTemp[1] == '\n' )
				strTemp.TrimLeft( strTemp.Length() - 2 );
			else
				strTemp.TrimLeft( strTemp.Length() - 1 );

			AddReadingString( lbList, strTemp, colContent );
		}

	}
#else
	// If length of string is less than max char
	if( nLength <= iMaxChar )
	{
		// Check line character
		int iPos;
		for( iPos = 0; iPos < nLength; iPos++ )
		{
			if( strContent[iPos] == '\n' || strContent[iPos] == '\r' )
				break;	
		}

		// Not exist
		if( iPos == nLength )
		{
			lbList.AddString( 0, strContent, colContent );
		}
		else
		{
			// Split string
			CTString	strTemp, strTemp2;
			strContent.Split( iPos, strTemp2, strTemp );
			lbList.AddString( 0, strTemp2, colContent );

			// Trim line character
			if( strTemp[0] == '\r' && strTemp[1] == '\n' )
				strTemp.TrimLeft( strTemp.Length() - 2 );
			else
				strTemp.TrimLeft( strTemp.Length() - 1 );

			AddReadingString( lbList, strTemp, colContent );
		}
	}
	// Need multi-line
	else
	{
		// Check splitting position for 2 byte characters
		int		nSplitPos = iMaxChar;
		BOOL	b2ByteChar = FALSE;
		int		iPos;
		for( iPos = 0; iPos < nSplitPos; iPos++ )
		{
			if( strContent[iPos] & 0x80 )
				b2ByteChar = !b2ByteChar;
			else
				b2ByteChar = FALSE;
		}

		if( b2ByteChar )
			nSplitPos--;

		// Check line character		
		for( iPos = 0; iPos < nSplitPos; iPos++ )
		{
			if( strContent[iPos] == '\n' || strContent[iPos] == '\r' )
				break;
		}

		// Not exist
		if( iPos == nSplitPos )
		{
			// Split string
			CTString	strTemp, strTemp2;
			strContent.Split( nSplitPos, strTemp2, strTemp );
			lbList.AddString( 0, strTemp2, colContent );

			// Trim space
			if( strTemp[0] == ' ' )
			{
				int	nTempLength = strTemp.Length();
				for( iPos = 1; iPos < nTempLength; iPos++ )
				{
					if( strTemp[iPos] != ' ' )
						break;
				}

				strTemp.TrimLeft( strTemp.Length() - iPos );
			}

			AddReadingString( lbList, strTemp, colContent );
		}
		else
		{
			// Split string
			CTString	strTemp, strTemp2;
			strContent.Split( iPos, strTemp2, strTemp );
			lbList.AddString( 0, strTemp2, colContent );

			// Trim line character
			if( strTemp[0] == '\r' && strTemp[1] == '\n' )
				strTemp.TrimLeft( strTemp.Length() - 2 );
			else
				strTemp.TrimLeft( strTemp.Length() - 1 );

			AddReadingString( lbList, strTemp, colContent );
		}
	}
#endif
}
Beispiel #11
0
// ----------------------------------------------------------------------------
// Name : AddReadingString()
// Desc :
// ----------------------------------------------------------------------------
void CUIHelp3::AddHelpString( CTString &strContent, COLOR colContent, int iMaxChar )
{
	// Get length of string
	INDEX	nLength = strContent.Length();
	if( nLength == 0 )
		return;

	// wooss 051002
#if defined (G_THAI)
	int		iPos;
	// Get length of string
	INDEX	nThaiLen = FindThaiLen(strContent);
	// [2011/08/24 : Sora]
	INDEX	nChatMax= m_lbContent.GetWidth() - 15;

	if( nLength == 0 )
		return;
	// If length of string is less than max char
	if( nThaiLen <= nChatMax )
	{
		// Check line character
		for( iPos = 0; iPos < nLength; iPos++ )
		{
			if( strContent[iPos] == '\n' || strContent[iPos] == '\r' )
				break;	
		}

		// Not exist
		if( iPos == nLength )
		{
			m_lbContent.AddString( 0, strContent, colContent );
		}
		else
		{
			// Split string
			CTString	strTemp, strTemp2;
			strContent.Split( iPos, strTemp2, strTemp );
			m_lbContent.AddString( 0, strTemp2, colContent );

			// Trim line character
			if( strTemp[0] == '\r' && strTemp[1] == '\n' )
				strTemp.TrimLeft( strTemp.Length() - 2 );
			else
				strTemp.TrimLeft( strTemp.Length() - 1 );

			AddHelpString( strTemp, colContent );
		}
	}
	// Need multi-line
	else
	{
		// Check splitting position for 2 byte characters
		int		nSplitPos = iMaxChar;
		BOOL	b2ByteChar = FALSE;
		for( iPos = 0; iPos < nLength; iPos++ )
		{
			if(nChatMax < FindThaiLen(strContent,0,iPos))
				break;
		}
		nSplitPos = iPos;

		// Check line character
		for( iPos = 0; iPos < nSplitPos; iPos++ )
		{
			if( strContent[iPos] == '\n' || strContent[iPos] == '\r' )
				break;
		}

		// Not exist
		if( iPos == nSplitPos )
		{
			// Split string
			CTString	strTemp, strTemp2;
			strContent.Split( nSplitPos, strTemp2, strTemp );
			m_lbContent.AddString( 0, strTemp2, colContent );

			// Trim space
			if( strTemp[0] == ' ' )
			{
				int	nTempLength = strTemp.Length();
				for( iPos = 1; iPos < nTempLength; iPos++ )
				{
					if( strTemp[iPos] != ' ' )
						break;
				}

				strTemp.TrimLeft( strTemp.Length() - iPos );
			}

			AddHelpString( strTemp, colContent );
		}
		else
		{
			// Split string
			CTString	strTemp, strTemp2;
			strContent.Split( iPos, strTemp2, strTemp );
			m_lbContent.AddString( 0, strTemp2, colContent );

			// Trim line character
			if( strTemp[0] == '\r' && strTemp[1] == '\n' )
				strTemp.TrimLeft( strTemp.Length() - 2 );
			else
				strTemp.TrimLeft( strTemp.Length() - 1 );

			AddHelpString( strTemp, colContent );
		}

	}
#else
	// If length of string is less than max char
	if( nLength <= iMaxChar )
	{
		// Check line character
		int iPos;
		for( iPos = 0; iPos < nLength; iPos++ )
		{
			if( strContent[iPos] == '\n' || strContent[iPos] == '\r' )
				break;	
		}

		// Not exist
		if( iPos == nLength )
		{
			m_lbContent.AddString( 0, strContent, colContent );
		}
		else
		{
			// Split string
			CTString	strTemp, strTemp2;
			strContent.Split( iPos, strTemp2, strTemp );
			m_lbContent.AddString( 0, strTemp2, colContent );

			// Trim line character
			if( strTemp[0] == '\r' && strTemp[1] == '\n' )
				strTemp.TrimLeft( strTemp.Length() - 2 );
			else
				strTemp.TrimLeft( strTemp.Length() - 1 );

			AddHelpString( strTemp, colContent );
		}
	}
	// Need multi-line
	else
	{
		// Check splitting position for 2 byte characters
		int		nSplitPos = iMaxChar;
		BOOL	b2ByteChar = FALSE;
		int		iPos;
		for( iPos = 0; iPos < nSplitPos; iPos++ )
		{
			if( strContent[iPos] & 0x80 )
				b2ByteChar = !b2ByteChar;
			else
				b2ByteChar = FALSE;
		}

		if( b2ByteChar )
			nSplitPos--;

		// Check line character		
		for( iPos = 0; iPos < nSplitPos; iPos++ )
		{
			if( strContent[iPos] == '\n' || strContent[iPos] == '\r' )
				break;
		}

		// Not exist
		if( iPos == nSplitPos )
		{
			// Split string
			CTString	strTemp, strTemp2;
						// Split string
#ifdef LINE_CHANGE_BY_WORD
			if( strContent[nSplitPos] != ' ' )
			{
				for(int i = iPos; i>=0; --i)
				{
					if( strContent[i] == ' ' )
					{
						iPos = i;
						break;
					}
				}
			}
#endif
			strContent.Split( iPos, strTemp2, strTemp );
			m_lbContent.AddString( 0, strTemp2, colContent );

			// Trim space
			if( strTemp[0] == ' ' )
			{
				int	nTempLength = strTemp.Length();
				for( iPos = 1; iPos < nTempLength; iPos++ )
				{
					if( strTemp[iPos] != ' ' )
						break;
				}

				strTemp.TrimLeft( strTemp.Length() - iPos );
			}

			AddHelpString( strTemp, colContent );
		}
		else
		{
			// Split string
			CTString	strTemp, strTemp2;
			strContent.Split( iPos, strTemp2, strTemp );
			m_lbContent.AddString( 0, strTemp2, colContent );

			// Trim line character
			if( strTemp[0] == '\r' && strTemp[1] == '\n' )
				strTemp.TrimLeft( strTemp.Length() - 2 );
			else
				strTemp.TrimLeft( strTemp.Length() - 1 );

			AddHelpString( strTemp, colContent );
		}
	}
#endif
}
Beispiel #12
0
// ----------------------------------------------------------------------------
// Name : AddString()
// Desc :
// ----------------------------------------------------------------------------
void CUIMixNew::AddString( CTString &strDesc )
{
	if( m_nStringCount >= MAX_MIXNEW_STRING )
		return;
	
	// Get length of string
	INDEX	nLength = strDesc.Length();
	INDEX	limitstrpos = _iMaxMsgStringChar;
	if( nLength == 0 )
		return;
#if defined(G_THAI)
	nLength = FindThaiLen(strDesc);
	limitstrpos = (_iMaxMsgStringChar-1)*(_pUIFontTexMgr->GetFontWidth()+_pUIFontTexMgr->GetFontSpacing());
#else
	nLength = strDesc.Length();
	limitstrpos = _iMaxMsgStringChar;
#endif

	int iPos;
	// If length of string is less than max char
	if( nLength <= limitstrpos )
	{
		// Check line character		
		for( iPos = 0; iPos < strDesc.Length(); iPos++ )
		{
			if( strDesc[iPos] == '\n' || strDesc[iPos] == '\r' )
				break;
		}
		
		// Not exist
		if( iPos == nLength )
			m_strMixDesc[m_nStringCount++] = strDesc;
		else
		{
			// Split string
			CTString	strTemp;
			strDesc.Split( iPos, m_strMixDesc[m_nStringCount++], strTemp );
			
			// Trim line character
			if( strTemp[0] == '\r' && strTemp[1] == '\n' )
				strTemp.TrimLeft( strTemp.Length() - 2 );
			else
				strTemp.TrimLeft( strTemp.Length() - 1 );
			
			AddString( strTemp );
		}
	}
	// Need multi-line
	else
	{
		// Check splitting position for 2 byte characters
		int		nSplitPos = limitstrpos;
		BOOL	b2ByteChar = FALSE;
#if defined(G_THAI)
		for( iPos = 0; iPos < strDesc.Length(); iPos++ )
		{
			if(nSplitPos < FindThaiLen(strDesc,0,iPos))
				break;
		}
		nSplitPos = iPos;
#else
		for( iPos = 0; iPos < nSplitPos; iPos++ )
		{
			if( strDesc[iPos] & 0x80 )
				b2ByteChar = !b2ByteChar;
			else
				b2ByteChar = FALSE;
		}
		
		if( b2ByteChar )
			nSplitPos--;
#endif
		// Check line character
		for( iPos = 0; iPos < nSplitPos; iPos++ )
		{
			if( strDesc[iPos] == '\n' || strDesc[iPos] == '\r' )
				break;
		}
		
		// Not exist
		if( iPos == nSplitPos )
		{
			// Split string
			CTString	strTemp;
#ifdef LINE_CHANGE_BY_WORD
			if( strDesc[nSplitPos] != ' ' )
			{
				for(int i = iPos; i>=0; --i)
				{
					if( strDesc[i] == ' ' )
					{
						iPos = i;
						break;
					}
				}
			}
#endif
			strDesc.Split( nSplitPos, m_strMixDesc[m_nStringCount++], strTemp );
			
			// Trim space
			if( strTemp[0] == ' ' )
			{
				int	nTempLength = strTemp.Length();
				for( iPos = 1; iPos < nTempLength; iPos++ )
				{
					if( strTemp[iPos] != ' ' )
						break;
				}
				
				strTemp.TrimLeft( strTemp.Length() - iPos );
			}
			
			AddString( strTemp );
		}
		else
		{
			// Split string
			CTString	strTemp;
			strDesc.Split( iPos, m_strMixDesc[m_nStringCount++], strTemp );
			
			// Trim line character
			if( strTemp[0] == '\r' && strTemp[1] == '\n' )
				strTemp.TrimLeft( strTemp.Length() - 2 );
			else
				strTemp.TrimLeft( strTemp.Length() - 1 );
			
			AddString( strTemp );
		}
	}
}