CTString CScript::GetName(CTString strLine) { int nPos = strLine.Find("="); if (nPos == -1) return ""; strLine.TrimLeft(); strLine = strLine.Mid(0,nPos); strLine.TrimLeft(); strLine.TrimRight(); return strLine; }
//导入描述文本,第一为主名称 各参数间用\分隔 参数中各项用空格分隔 bool CScript::ImportStr(CTString strDesc) { //****************替换掉\r\n************************** CTString strStreamNew ; int nLen1 = strDesc.GetLength(); BYTE *pB = (BYTE *)strStreamNew.GetBuffer(nLen1+sizeof(TCHAR)); BYTE *pDest = (BYTE *)(char*)(const char*)strDesc; int i; for (i=0;i<nLen1; i++) { if (*(pDest+i) == '\r' ||*(pDest+i) == '\n') { *pB = ' ';//替换为空格 pB++; } else { *pB = *(pDest+i); pB++; } } *pB = '\0';pB++;*pB = '\0'; strStreamNew.ReleaseBuffer(); //****************去掉\r 输出strStreamNew************************** m_strName = ""; int nLast = -1; for (i=0; i<strStreamNew.GetLength() ;i++) { if (strStreamNew.GetAt(i)=='/') { CTString str = strStreamNew.Mid(nLast+1,i-nLast-1); str.TrimLeft(); str.TrimRight(); if (nLast ==-1) m_strName = str; else m_strArray.Add(str); nLast = i; } } CTString str = strStreamNew.Mid(nLast+1,strStreamNew.GetLength() + 1 -nLast); str.TrimLeft(); str.TrimRight(); if (nLast ==-1) m_strName = str; else m_strArray.Add(str); return true; }
CTString CCurrencyField::GetAsString() { ////assert( m_pValue && *m_pValue == fvValid ); //指示字节必须为1 CTString strRetValue; CTString strFormat ; //strFormat.Format("%%%d.%df",m_nWidth,m_nDecimals); strFormat.Format("%%%d.%df",0,m_nDecimals); strRetValue.Format(strFormat,*((FieldNUM *)m_pValue)); strRetValue.TrimLeft(); /* if (m_nWidth >m_nTempBufLength)//#_修改 2002-12-12 $ 14:04:21 zlq SetTempBufLength(m_nWidth);//如果空间不够,则扩大临时缓冲区 gcvt( ((FieldCurrency *)m_pValue)->dwValue, m_nWidth, m_pTempBuf ); strRetValue = _T(m_pTempBuf); */ return strRetValue; }
// ---------------------------------------------------------------------------- // 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 }
// ---------------------------------------------------------------------------- // 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 }
// ---------------------------------------------------------------------------- // 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 ); } } }