📄 gamemsg.cpp
字号:
//--------------------------------------------------------------------
char* CGameMsg::GetBlackNameByIndex(int nIndex)
{
int nAmount = this->GetBlackNameAmount();
if((nIndex < 0) && (nIndex >= nAmount))
return NULL;
return m_setBlackName[nIndex];
}
//--------------------------------------------------------------------
BOOL CGameMsg::IsBlackName(char* pszName)
{
if(!pszName)
return true;
int nAmount = this->GetBlackNameAmount();
for(int i = 0; i < nAmount; i ++)
{
char* pszMyName = m_setBlackName[i];
if(pszMyName && strcmp(pszName, pszMyName)==0)
{
return true;
}
}
return false;
}
//--------------------------------------------------------------------
void CGameMsg::GetChannelColor(unsigned short usChannel, DWORD& dwColor)
{
switch(usChannel)
{
case _TXTATR_GHOST:
dwColor = m_colorChannelTalk;
break;
case _TXTATR_NORMAL:
dwColor = m_colorChannelServe;
break;
case _TXTATR_TALK:
dwColor = m_colorChannelTalk;
break;
case _TXTATR_FRIEND:
dwColor = m_colorChannelFriend;
break;
case _TXTATR_SYNDICATE:
dwColor = m_colorChannelSyndicate;
break;
case _TXTATR_TEAM:
dwColor = m_colorChannelTeam;
break;
case _TXTATR_PRIVATE:
dwColor = m_colorChannelPrivate;
break;
case _TXTATR_ACTION:
dwColor = m_colorChannelAction;
break ;
case _TXTATR_SERVE:
dwColor = m_colorChannelServe;
break ;
default:
break;
}
}
//--------------------------------------------------------------------
void CGameMsg::SetChannelColor(unsigned short usChannel, DWORD dwColor)
{
switch(usChannel)
{
case _TXTATR_NORMAL:
case _TXTATR_GHOST:
case _TXTATR_TALK:
m_colorChannelTalk = dwColor;
break;
case _TXTATR_FRIEND:
m_colorChannelFriend = dwColor;
break;
case _TXTATR_SYNDICATE:
m_colorChannelSyndicate = dwColor;
break;
case _TXTATR_TEAM:
m_colorChannelTeam = dwColor;
break;
case _TXTATR_PRIVATE:
m_colorChannelPrivate = dwColor;
break;
case _TXTATR_ACTION:
m_colorChannelAction = dwColor;
break ;
case _TXTATR_SERVE:
m_colorChannelServe = dwColor;
break ;
default:
break;
}
}
//--------------------------------------------------------------------
void CGameMsg::SetChannelStatus(unsigned short usChannel, BOOL bOn)
{
switch(usChannel)
{
case _TXTATR_TALK:
m_bChannelTalk = bOn;
break;
case _TXTATR_FRIEND:
m_bChannelFriend = bOn;
break;
case _TXTATR_SYNDICATE:
m_bChannelSyndicate = bOn;
break;
case _TXTATR_TEAM:
m_bChannelTeam = bOn;
break;
case _TXTATR_ACTION:
m_bChannelAction = bOn;
break ;
case _TXTATR_SERVE:
m_bChannelServe = bOn;
break ;
default:
break;
}
}
//--------------------------------------------------------------------
BOOL CGameMsg::GetChannelStatus(unsigned short usChannel)
{
switch(usChannel)
{
case _TXTATR_TALK:
case _TXTATR_NORMAL:
return m_bChannelTalk;
case _TXTATR_FRIEND:
return m_bChannelFriend;
case _TXTATR_SYNDICATE:
return m_bChannelSyndicate;
case _TXTATR_TEAM:
return m_bChannelTeam;
case _TXTATR_ACTION:
return m_bChannelAction;
case _TXTATR_SERVE:
return m_bChannelServe;
case _TXTATR_PRIVATE:
return m_bChannelPrivateExceptFriend;
default:
return true;
}
return true;
}
//--------------------------------------------------------------------
void CGameMsg::SetPrivateChannelStatusExceptFriend(BOOL bOn)
{
m_bChannelPrivateExceptFriend = bOn;
}
//--------------------------------------------------------------------
void CGameMsg::SetPrivateChannelStatusFriendOnly(BOOL bOn)
{
m_bChannelPrivateFriend = bOn;
}
//--------------------------------------------------------------------
BOOL CGameMsg::TestPriveteChannel(char* pszName)
{
if(m_bChannelPrivateExceptFriend)
return true;
if(m_bChannelPrivateFriend)
{
if(!pszName)
return false;
if(g_objHero.GetFriendByName(pszName))
return true;
}
return false;
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
void CGameMsg::SetNorAreaShowStates ( const CMyPos &pos, int nWidth )
{
m_NorAreaShowPos.x = pos.x ;
m_NorAreaShowPos.y = pos.y ;
m_nNorAreaWidth = nWidth ;
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
void CGameMsg::SetSysAreaShowStates ( const CMyPos &pos, int nWidth )
{
m_SysAreaShowPos.x = pos.x ;
m_SysAreaShowPos.y = pos.y ;
m_nSysAreaWidth = nWidth ;
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
void CGameMsg::SetManAreaShowStates ( const CMyPos &pos, int nWidth )
{
m_ManAreaShowPos.x = pos.x ;
m_ManAreaShowPos.y = pos.y ;
m_nManAreaWidth = nWidth ;
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
void CGameMsg::SetCurShowChannel( unsigned short usCurChannel )
{
m_usCurShowChannel = usCurChannel ;
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
BOOL CGameMsg::SetLastShowLineIndex( int nIndex, unsigned short usChannel )
{
if ( usChannel < 0 || usChannel > 13 || m_nMaxLine >= m_dequeMsg[usChannel].size() )
{
return false ;
}
else
{
if ( nIndex == -1 )
{
if ( m_nLastShowLineIndex[usChannel] < m_dequeMsg[usChannel].size() )
{
m_nLastShowLineIndex[usChannel]++ ;
}
}
else
{
if ( m_nLastShowLineIndex[usChannel] > m_nMaxLine )
{
m_nLastShowLineIndex[usChannel]-- ;
}
}
}
return true ;
}
//--------------------------------------------------------------------
BOOL CGameMsg::GetLeaveWordByIndex(int nIndex, char *szName,char *strTxt,char *strTime)
{
int nAmount = m_dequeLeaveMsg.size();
if (nIndex > nAmount || nIndex < 0)
return false;
CGameMsgUnit* pMsg = m_dequeLeaveMsg[nIndex];
if (pMsg)
{
strcpy( strTxt, pMsg->m_szMsg ) ;
strcpy( szName, pMsg->m_szSender ) ;
int nHour, nMinute, nMonth, nDay;
strncpy(strTime,pMsg->m_szEmotion + 4,8);
int nTime=atoi(strTime);
nMonth = ( nTime / 1000000) % 100;
nDay = ( nTime / 10000 ) % 100;
nHour = ( nTime / 100 ) % 100 ;
nMinute = nTime % 100 ;
sprintf( strTime, "【%d-%d %d:%d】",nMonth, nDay, nHour, nMinute ) ;
return true ;
}
return false;
}
//--------------------------------------------------------------------
BOOL CGameMsg::GetLeaveWordByIndexName( int nIndex, char* strName, char *strTxt, char *strTime )
{
int nAmount = m_dequeLeaveMsg.size();
int nReAmount = 0;
for(int i=0;i<nAmount;i++)
{
CGameMsgUnit* pMsg = m_dequeLeaveMsg[i];
if(pMsg && 0 == strcmp(pMsg->m_szSender,strName) )
{
if (nReAmount == nIndex)
{
strcpy( strTxt, pMsg->m_szMsg ) ;
int nHour, nMinute, nMonth, nDay;
strncpy(strTime,pMsg->m_szEmotion + 4,8);
int nTime=atoi(strTime);
nMonth = ( nTime / 1000000) % 100;
nDay = ( nTime / 10000 ) % 100;
nHour = ( nTime / 100 ) % 100 ;
nMinute = nTime % 100 ;
sprintf( strTime, "【%d-%d %d:%d】",nMonth, nDay, nHour, nMinute ) ;
return true ;
}
nReAmount++;
}
}
return false;
}
//--------------------------------------------------------------------
int CGameMsg::GetLeaveWordAmountByName(const char* pszName)
{
int nAmount = m_dequeLeaveMsg.size();
int nReAmount = 0;
for(int i=0;i<nAmount;i++)
{
CGameMsgUnit* pMsg = m_dequeLeaveMsg[i];
if( 0 == strcmp(pMsg->m_szSender,pszName) )
nReAmount++;
}
return nReAmount;
}
//--------------------------------------------------------------------
int CGameMsg::GetLeaveWordAmount()
{
return m_dequeLeaveMsg.size() ;
}
//--------------------------------------------------------------------
void CGameMsg::DelLeaveWordByIndexName(int nIndex,char* strName)
{
int nAmount = this->GetLeaveWordAmount();
int nReAmount = this->GetLeaveWordAmountByName(strName);
if (nIndex <0 || nIndex > nReAmount )
return;
for(int i=nAmount-1; i>=0 ;i--)
{
CGameMsgUnit* pMsg = m_dequeLeaveMsg[i];
if(pMsg && 0 == strcmp(pMsg->m_szSender,strName))
{
nReAmount--;
if (nIndex == nReAmount)
{
m_dequeLeaveMsg.erase(m_dequeLeaveMsg.begin() + i);
return;
}
}
}
}
//--------------------------------------------------------------------
void CGameMsg::DestroyLeaveWord()
{
int nCount = m_dequeLeaveMsg.size() ;
for ( int i = 0; i < nCount; i++ )
{
SAFE_DELETE( m_dequeLeaveMsg[i] ) ;
}
m_dequeLeaveMsg.clear() ;
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
void CGameMsg::SetShowLines( UINT uMaxLines )
{
m_nMaxLine = (int)uMaxLines ;
for ( int i = 0; i < 14; i++ )
{
m_nLastShowLineIndex[i] = m_nMaxLine ;
}
}
//--------------------------------------------------------------------
void CGameMsg::GetShowLinesEx(int &nMaxUpLines, int &nMaxDownLines)
{
nMaxUpLines = m_nMaxUpLine;
nMaxDownLines = m_nMaxDownLine;
return;
}
void CGameMsg::SetShowLinesEx(UINT uMaxUpLines, UINT uMaxDownLines)
{
m_nMaxUpLine = (int)uMaxUpLines;
m_nMaxDownLine = (int)uMaxDownLines;
}
int CGameMsg::GetNorAeroTop()
{
int ntopy = m_NorAreaShowPos.y - (MSGFONT_HEIGHT +6) * m_nMaxLine;
return ntopy;
}
int CGameMsg::GetNorUpAreaTop()
{
int nTop = m_NorAreaShowPos.y - (MSGFONT_HEIGHT+4) * (m_nMaxUpLine + m_nMaxDownLine + 1) - 20;
return nTop;
}
int CGameMsg::GetNorDownAreaTop()
{
int nTop = m_NorAreaShowPos.y - (MSGFONT_HEIGHT +4 )* (m_nMaxDownLine+1);
return nTop;
}
int CGameMsg::ShowEmotionWnd (int x, int y, int nPage, int nXAmount, int nYAmount)
{
int nAmount = g_objGameDataSet.GetEmotionAmount ();
int nPageAmount = nXAmount*nYAmount;
if (nPage*nPageAmount > nAmount)
return -1;
bool bMouseIn = false;
CMyPos pMousePoint = {0,0};
CMyPos pShowPoint = {0,0};
int nMouseIndex = -1;
int nIndex = nPage*nPageAmount;
nAmount = nAmount - nIndex;
if (nAmount > nPageAmount)
nAmount = nPageAmount;
for(int i=0;i<nAmount;i++)
{
CAni* pAni = g_objGameDataSet.GetEmotionIcon (i+nIndex);
if (pAni)
{
int nFrame = ::TimeGet()/ 200 % pAni->GetFrameAmount();
pShowPoint.x = x + (i%nXAmount)*(32);
pShowPoint.y = y + (i/nXAmount)*(32);
CMyPos PointE = {pShowPoint.x + 32,pShowPoint.y + 32};
CMyPos pMousePos={0,0};
::MouseCheck(pMousePos.x, pMousePos.y);
if (pMousePos.x > pShowPoint.x -2 && pMousePos.y > pShowPoint.y - 2
&& pMousePos.x < PointE.x && pMousePos.y < PointE.y )
{
CMyBitmap::ShowRect(pShowPoint.x ,pShowPoint.y,PointE.x,PointE.y,0x4e00ff00);
bMouseIn = true;
pMousePoint = pShowPoint;
nMouseIndex = i+nIndex;
}
pAni->Show( nFrame,pShowPoint.x,pShowPoint.y); //,NULL,22,22);
}
}
if (bMouseIn)
{
char szCode[_MAX_NAMESIZE]="";
if (nMouseIndex <10)
sprintf(szCode, "#0%d",nMouseIndex);
else
sprintf(szCode, "#%d",nMouseIndex);
char szEmotionShutCut[_MAX_NAMESIZE] ="";
strcpy(szEmotionShutCut,g_objGameDataSet.GetEmotionShutCut (nMouseIndex));
int nMsgLength = max((int)strlen(szCode), (int)strlen(szEmotionShutCut));
CMyBitmap::ShowBlock(pMousePoint.x - 2 , pMousePoint.y-35, pMousePoint.x + nMsgLength*7, pMousePoint.y - 3,0xff000000);
CMyBitmap::ShowString(pMousePoint.x ,pMousePoint.y-33,0xffffffff,szCode);
if(szEmotionShutCut && strlen(szEmotionShutCut) > 0)
{
pMousePoint.y = pMousePoint.y - 19;
CMyBitmap::ShowString(pMousePoint.x , pMousePoint.y,0xffffffff,szEmotionShutCut);
}
}
return nMouseIndex;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -