📄 gamemsg.cpp
字号:
case _TXTATR_SYSTEM:
strcpy(szTemp, g_objGameDataSet.GetStr(STRING_PREFIX_SYSTEM));
break;
case _TXTATR_ACTION:
strcpy(szTemp, g_objGameDataSet.GetStr(STRING_PREFIX_ACTION));
break;
case _TXTATR_PRIVATE:
strcpy(szTemp, g_objGameDataSet.GetStr(STRING_PREFIX_WHISPER));
break;
case _TXTATR_TEAM:
strcpy(szTemp, g_objGameDataSet.GetStr(STRING_PREFIX_TEAM));
break;
case _TXTATR_SYNDICATE:
strcpy(szTemp, g_objGameDataSet.GetStr(STRING_PREFIX_CLAN));
break;
case _TXTATR_FAMILY:
strcpy(szTemp, g_objGameDataSet.GetStr(STRING_PREFIX_FAMILY));
break;
case _TXTATR_NORMAL:
strcpy(szTemp, g_objGameDataSet.GetStr(STRING_PREFIX_TALK));
break;
case _TXTATR_TALK:
strcpy(szTemp, g_objGameDataSet.GetStr(STRING_PREFIX_TALK));
break;
case _TXTATR_YELP:
strcpy(szTemp, g_objGameDataSet.GetStr(STRING_PREFIX_YELP));
break;
case _TXTATR_FRIEND:
strcpy(szTemp, g_objGameDataSet.GetStr(STRING_PREFIX_FRIEND));
break;
case _TXTATR_GLOBAL:
strcpy(szTemp, g_objGameDataSet.GetStr(STRING_PREFIX_GLOBAL));
break;
case _TXTATR_GM:
strcpy(szTemp, g_objGameDataSet.GetStr(STRING_PREFIX_GM));
break;
case _TXTATR_GHOST:
strcpy(szTemp, g_objGameDataSet.GetStr(STRING_PREFIX_GHOST));
break;
case _TXTATR_LEAVEWORD:
strcpy(szTemp, g_objGameDataSet.GetStr(STRING_PREFIX_LEAVEWORD));
break;
case _TXTATR_SERVE:
strcpy(szTemp, g_objGameDataSet.GetStr(STRING_PREFIX_SERVE));
break ;
default:
this->m_unTxtAttribute = _TXTATR_SYSTEM;
strcpy(szTemp, g_objGameDataSet.GetStr(STRING_PREFIX_SYSTEM));
break;
}
if(m_unTxtAttribute != _TXTATR_ACTION && m_unTxtAttribute!= _TXTATR_SYSTEM)
sprintf(szTemp, "%s%s%s%s%s",
szTemp,
this->m_szSender,
// this->m_szEmotion,
g_objGameDataSet.GetStr(STRING_TO),
this->m_szReceiver,
g_objGameDataSet.GetStr(STRING_SAY));
}
sprintf(szTemp, "%s%s", szTemp, this->m_szMsg);
szTemp[_MAX_WORDSSIZE - 1] = '\0' ;
strcpy(pszText, szTemp);
if ( bTimes )
{
GetDateTimeStr(m_dwTime, szTemp);
sprintf(pszText, "%s%s", pszText, szTemp);
}
return true;
}
//--------------------------------------------------------------------
int CGameMsgUnit::Scan(int nScreenWidth)
{
char szTemp[_MAX_WORDSSIZE * 2];
GetText(szTemp, false);
//--------------------------------------
int nLines = 1;
char* pszTemp = szTemp;
unsigned char ucSingle[2] = {'\0', '\0'};
unsigned char ucDouble[3] = {'\0', '\0', '\0'};
int nPosX = m_nStartX;
while((ucSingle[0]=*pszTemp))
{
if(ucSingle[0]<0x80)
{
nPosX += m_sizeFont.iWidth;
if((nPosX - m_nStartX) > (nScreenWidth - m_sizeFont.iWidth * 2))
{
nPosX = m_nStartX;
nLines++;
}
}
else
{
if(ucDouble[0]=='\0')
{
ucDouble[0] = ucSingle[0];
}
else if(ucDouble[1]=='\0')
{
ucDouble[1] = ucSingle[0];
nPosX = nPosX + m_sizeFont.iWidth * 2;
if((nPosX - m_nStartX) > (nScreenWidth - m_sizeFont.iWidth * 2))
{
nPosX = m_nStartX;
nLines++;
}
ucDouble[0]='\0';
ucDouble[1]='\0';
}
}
pszTemp++;
}
return nLines;
}
//--------------------------------------------------------------------
// CGameMsg Construction/Destruction
//--------------------------------------------------------------------
CGameMsg::CGameMsg()
{
m_setMsg.SetMaxMsg(2048);
m_dwTime = 0;
m_bChannelTalk = true;
m_bChannelSyndicate = true;
m_bChannelFriend = true;
m_bChannelTeam = true;
m_bChannelAction = true;
m_bChannelServe = true;
m_bChannelPrivateExceptFriend = true;
m_bChannelPrivateFriend = true;
strcpy(m_szCaptureName, "");
m_colorChannelTalk = 0xffffffff;
m_colorChannelSyndicate = 0xffffff00;
m_colorChannelFriend = 0xffffff00;
m_colorChannelTeam = 0xffffff00;
m_colorChannelPrivate = 0xffffff00;
m_colorChannelAction = 0xffffff00;
m_colorChannelServe = 0xffff0000;
m_usCurShowChannel = _TXTATR_NORMAL ;
m_nMaxMsgLine[0] = 128 ;
m_nMaxMsgLine[1] = 16 ;
m_nMaxMsgLine[2] = 128 ;
m_nMaxMsgLine[3] = 20 ;
m_nMaxMsgLine[4] = 3 ;
m_nMaxMsgLine[5] = 16 ;
m_nMaxMsgLine[6] = 128 ;
m_nMaxMsgLine[7] = 16 ;
m_nMaxMsgLine[8] = 128 ;
m_nMaxMsgLine[9] = 16 ;
m_nMaxMsgLine[10] = 1 ;
m_nMaxMsgLine[11] = 16 ;
m_nMaxMsgLine[12] = 16 ;
m_nMaxMsgLine[13] = 20 ;
m_nLastShowLineIndex[0] = LAST_SHOWLINE_INDEX ;
m_nLastShowLineIndex[1] = LAST_SHOWLINE_INDEX ;
m_nLastShowLineIndex[2] = LAST_SHOWLINE_INDEX ;
m_nLastShowLineIndex[3] = LAST_SHOWLINE_INDEX ;
m_nLastShowLineIndex[4] = LAST_SHOWLINE_INDEX ;
m_nLastShowLineIndex[5] = LAST_SHOWLINE_INDEX ;
m_nLastShowLineIndex[6] = LAST_SHOWLINE_INDEX ;
m_nLastShowLineIndex[7] = LAST_SHOWLINE_INDEX ;
m_nLastShowLineIndex[8] = LAST_SHOWLINE_INDEX ;
m_nLastShowLineIndex[9] = LAST_SHOWLINE_INDEX ;
m_nLastShowLineIndex[10] = LAST_SHOWLINE_INDEX ;
m_nLastShowLineIndex[11] = LAST_SHOWLINE_INDEX ;
m_nLastShowLineIndex[12] = LAST_SHOWLINE_INDEX ;
m_nLastShowLineIndex[13] = LAST_SHOWLINE_INDEX ;
m_nNorAreaAmount = 0 ;
m_NorAreaShowPos.x = 0;
m_NorAreaShowPos.y = 0;
m_nNorAreaWidth = 0 ;
m_nSysAreaAmount = 0 ;
m_SysAreaShowPos.x = 2;
m_SysAreaShowPos.y = MSGFONT_HEIGHT * (2+m_nMaxMsgLine[4]);
m_nSysAreaWidth = 0 ;
m_nManAreaAmount = 0 ;
m_ManAreaShowPos.x = 100;
m_ManAreaShowPos.y = (_SCR_HEIGHT - MSGFONT_HEIGHT - 130) / 2;
m_nManAreaWidth = 0 ;
}
//--------------------------------------------------------------------
CGameMsg::~CGameMsg()
{
this->ClearMsg();
this->DestroyBlackName();
this->DestroyLeaveWord();
}
void CGameMsg::ShowEx(BOOL bCapture, BOOL bSystem)
{
#ifdef _ANALYSIS_ON
DWORD dwTimeBegin = ::TimeGet();
#endif
int nScrWidth, nScrHeight;
CMyBitmap::GetScreenSize(nScrWidth, nScrHeight);
int nFontWidth, nFontHeight;
nFontHeight = MSGFONT_HEIGHT;
nFontWidth = MSGFONT_WIDTH;
int i;
CMyPos pos;
// Display normal message
int nTotalLines = 0;
int nTotalUpLines = 0;
int nTotalDownLines = 0;
bool bMsgArea = 0; // 0 down 1 up
pos.x = m_NorAreaShowPos.x;
pos.y = m_NorAreaShowPos.y;
int pos_Upy = m_NorAreaShowPos.y - (m_nMaxDownLine+1) * (nFontHeight+2) - 20;
BOOL bGetCapturename = false;
if ( m_usCurShowChannel == _TXTATR_NORMAL )
{
for ( i = m_nNorAreaAmount - 1; i >= 0; i-- )
{
CGameMsgUnit* pMsg = m_dequeMsg[m_nNorAreaShowIndex[i * 2]][m_nNorAreaShowIndex[i * 2 + 1]] ;
if ( pMsg && this->GetChannelStatus(pMsg->m_unTxtAttribute))
{
int nLines = pMsg->GetLines( m_nNorAreaWidth );
nTotalLines += nLines;
if(strstr(pMsg->m_szMsg, g_objHero.GetName()))
{
nTotalDownLines += nLines;
pos.y = pos.y - (nFontHeight+6) * nLines;
bMsgArea = 0;
}
else if(strcmp(pMsg->m_szSender, g_objHero.GetName())==0)
{
nTotalDownLines += nLines;
pos.y = pos.y - (nFontHeight+6) * nLines;
bMsgArea = 0;
}
else if(strcmp(pMsg->m_szReceiver, g_objHero.GetName())==0)
{
nTotalDownLines += nLines;
pos.y = pos.y - (nFontHeight+6) * nLines;
bMsgArea = 0;
}
else
{
nTotalUpLines += nLines;
pos_Upy = pos_Upy - (nFontHeight+6) * nLines ;
bMsgArea = 1;
}
if (nTotalUpLines > m_nMaxUpLine&&bMsgArea==1)
{
continue;
}
if (nTotalDownLines > m_nMaxDownLine&&bMsgArea==0)
{
continue;
}
int tPosy = 0;
if (bMsgArea == 1)
{
tPosy = pos_Upy;
}
else
{
tPosy = pos.y;
}
char* pszName = pMsg->Show(pos.x, tPosy, bCapture, m_nNorAreaWidth);
if(pszName)
{
strcpy(m_szCaptureName, pszName);
bGetCapturename = true;
}
}
}
if(bCapture)
{
const OBJID idStr = 100130;
CMyBitmap::ShowString(pos.x+16, pos.y-MSGFONT_HEIGHT*2-1, 0xff000000, g_objGameDataSet.GetStr(idStr),(char*)g_objGameDataSet.GetStr(FONT_NAME),MSGFONT_HEIGHT);
CMyBitmap::ShowString(pos.x+15, pos.y-MSGFONT_HEIGHT*2-2, 0xffffff00, g_objGameDataSet.GetStr(idStr),(char*)g_objGameDataSet.GetStr(FONT_NAME),MSGFONT_HEIGHT);
}
}
else
{
int nLast = ( m_nMaxLine < m_dequeMsg[m_usCurShowChannel].size() ) ? m_dequeMsg[m_usCurShowChannel].size() - m_nMaxLine : 0 ;
for ( i = m_dequeMsg[m_usCurShowChannel].size() - 1 - ( m_nLastShowLineIndex[m_usCurShowChannel] - m_nMaxLine );
i >= nLast - ( m_nLastShowLineIndex[m_usCurShowChannel] - m_nMaxLine );
i-- )
{
CGameMsgUnit* pMsg = m_dequeMsg[m_usCurShowChannel][i] ;
if ( pMsg && this->GetChannelStatus(pMsg->m_unTxtAttribute))
{
int nLines = pMsg->GetLines( m_nNorAreaWidth );
nTotalLines += nLines;
if (nTotalLines > m_nMaxLine)
{
break;
}
pos.y = pos.y - (nFontHeight+6) * nLines;
char* pszName = pMsg->Show(pos.x, pos.y, bCapture, m_nNorAreaWidth);
if(pszName)
{
strcpy(m_szCaptureName, pszName);
bGetCapturename = true;
}
}
}
if(bCapture)
{
const OBJID idStr = 100130;
CMyBitmap::ShowString(pos.x+16, pos.y-MSGFONT_HEIGHT*2-1, 0xff000000, g_objGameDataSet.GetStr(idStr),(char*)g_objGameDataSet.GetStr(FONT_NAME),MSGFONT_HEIGHT);
CMyBitmap::ShowString(pos.x+15, pos.y-MSGFONT_HEIGHT*2-2, 0xffffff00, g_objGameDataSet.GetStr(idStr),(char*)g_objGameDataSet.GetStr(FONT_NAME),MSGFONT_HEIGHT);
}
}
if(!bGetCapturename)
strcpy(m_szCaptureName, "");
m_dwTime++;
#ifdef _ANALYSIS_ON
g_dwTxtMsgTimeCost += ::TimeGet() - dwTimeBegin;
#endif
}
void CGameMsg::Show(BOOL bCapture, BOOL bSystem)
{
#ifdef _ANALYSIS_ON
DWORD dwTimeBegin = ::TimeGet();
#endif
int nScrWidth, nScrHeight;
CMyBitmap::GetScreenSize(nScrWidth, nScrHeight);
int nFontWidth, nFontHeight;
nFontHeight = MSGFONT_HEIGHT;
nFontWidth = MSGFONT_WIDTH;
int i;
CMyPos pos;
if ( bSystem )
{
// Display system area message
pos.x = m_SysAreaShowPos.x;
pos.y = m_SysAreaShowPos.y;
for ( i = m_nSysAreaAmount - 1; i >= 0; i-- )
{
CGameMsgUnit* pMsg = m_dequeMsg[m_nSysAreaShowIndex[i * 2]][m_nSysAreaShowIndex[i * 2 + 1]] ;
if( pMsg )
{
if ( ::TimeGet() > pMsg->m_dwBeginTime + 15 * 1000 )
{
m_dequeMsg[m_nSysAreaShowIndex[i * 2]].erase ( m_dequeMsg[m_nSysAreaShowIndex[i * 2]].begin() + i ) ;
SAFE_DELETE(pMsg);
m_nSysAreaAmount-- ;
for ( int j = i; j < m_nSysAreaAmount; j++ )
{
m_nSysAreaShowIndex[j * 2] = m_nSysAreaShowIndex[( j + 1 ) * 2] ;
m_nSysAreaShowIndex[j * 2 + 1] = m_nSysAreaShowIndex[( j + 1 ) * 2 + 1] ;
m_nSysAreaShowIndex[j * 2 + 1]-- ;
}
break;
}
int nLines = pMsg->GetLines();
pos.y = pos.y - (nFontHeight+2) * nLines;
pMsg->Show(pos.x, pos.y, false);
}
}
// Display manage message
pos.x = m_ManAreaShowPos.x;
pos.y = m_ManAreaShowPos.y;
for ( i = m_nManAreaAmount - 1; i >= 0; i-- )
{
CGameMsgUnit* pMsg = m_dequeMsg[m_nManAreaShowIndex[i * 2]][m_nManAreaShowIndex[i * 2 + 1]] ;
if ( pMsg )
{
if ( ::TimeGet() > pMsg->m_dwBeginTime + 15 * 1000 )
{
m_dequeMsg[m_nManAreaShowIndex[i * 2]].erase ( m_dequeMsg[m_nManAreaShowIndex[i * 2]].begin() + i ) ;
SAFE_DELETE(pMsg);
m_nManAreaAmount-- ;
for ( int j = i; j < m_nManAreaAmount; j++ )
{
m_nManAreaShowIndex[j * 2] = m_nManAreaShowIndex[( j + 1 ) * 2] ;
m_nManAreaShowIndex[j * 2 + 1] = m_nManAreaShowIndex[( j + 1 ) * 2 + 1] ;
m_nManAreaShowIndex[j * 2 + 1]-- ;
}
break;
}
int nLines = pMsg->GetLines();
pos.y = pos.y - (nFontHeight+6) * nLines;
pMsg->Show(pos.x, pos.y, false);
}
}
}
else
{
// Display normal message
int nTotalLines = 0;
pos.x = m_NorAreaShowPos.x;
pos.y = m_NorAreaShowPos.y;
BOOL bGetCapturename = false;
if ( m_usCurShowChannel == _TXTATR_NORMAL )
{
for ( i = m_nNorAreaAmount - 1; i >= 0; i-- )
{
CGameMsgUnit* pMsg = m_dequeMsg[m_nNorAreaShowIndex[i * 2]][m_nNorAreaShowIndex[i * 2 + 1]] ;
if ( pMsg && this->GetChannelStatus(pMsg->m_unTxtAttribute))
{
int nLines = pMsg->GetLines( m_nNorAreaWidth );
nTotalLines += nLines;
if (nTotalLines > m_nMaxLine)
{
break;
}
pos.y = pos.y - (nFontHeight+6) * nLines;
char* pszName = pMsg->Show(pos.x, pos.y, bCapture, m_nNorAreaWidth);
if(pszName)
{
strcpy(m_szCaptureName, pszName);
bGetCapturename = true;
}
}
}
if(bCapture)
{
const OBJID idStr = 100130;
CMyBitmap::ShowString(pos.x+4, this->GetNorAeroTop()-1 - 40, 0xff000000, g_objGameDataSet.GetStr(idStr),(char*)g_objGameDataSet.GetStr(FONT_NAME),MSGFONT_HEIGHT);
CMyBitmap::ShowString(pos.x+3, this->GetNorAeroTop()-2 - 40, 0xffffff00, g_objGameDataSet.GetStr(idStr),(char*)g_objGameDataSet.GetStr(FONT_NAME),MSGFONT_HEIGHT);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -