📄 dlgskill.cpp
字号:
void CDlgSkill::UseTeamMagic(int nIndex)
{
/* if (m_TMagicIdType[nIndex])
{
CMagic* pMagic = g_objHero.GetMagic(m_TMagicIdType[nIndex]);
if (pMagic)
{
g_objHero.MagicAttack(pMagic->GetIDType(),g_objHero.GetID());
CDlgSkill::GetParent()->GetParent()->PostMessage(WM_MY_MESSAGE,ON_TEAMMAGIC_SEL,pMagic->GetIDType());
}
}*/
}
void CDlgSkill::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
LPARAM lParam ;
lParam = MAKELONG( point.x + m_Pnt.x, point.y + m_Pnt.y ) ;
CDlgSkill::GetParent()->PostMessage(WM_MOUSEMOVE,nFlags,lParam);
CDialog::OnMouseMove(nFlags, point);
}
void CDlgSkill::OnButton1()
{
// TODO: Add your control notification handler code here
DXPlaySound("Sound/Dlg_ok.wav");
CDlgSkill::OnSkillImg1();
}
void CDlgSkill::OnButton2()
{
// TODO: Add your control notification handler code here
DXPlaySound("Sound/Dlg_ok.wav");
CDlgSkill::OnSkillImg2();
}
void CDlgSkill::OnButton3()
{
// TODO: Add your control notification handler code here
DXPlaySound("Sound/Dlg_ok.wav");
CDlgSkill::OnSkillImg3();
}
void CDlgSkill::OnButton4()
{
// TODO: Add your control notification handler code here
DXPlaySound("Sound/Dlg_ok.wav");
CDlgSkill::OnSkillImg4();
}
void CDlgSkill::OnButton5()
{
// TODO: Add your control notification handler code here
DXPlaySound("Sound/Dlg_ok.wav");
CDlgSkill::OnSkillImg5();
}
void CDlgSkill::OnButton6()
{
// TODO: Add your control notification handler code here
DXPlaySound("Sound/Dlg_ok.wav");
CDlgSkill::OnSkillImg6();
}
int CDlgSkill::GetMouseInMagicIndex()
{
if (!CDlgSkill::IsWindowEnabled())
return 0;
POINT mousePnt ;
GetCursorPos ( &mousePnt ) ;
CRect BRect,ERect;
m_Img1.GetWindowRect(BRect);
m_SkillKey1Img.GetWindowRect(ERect);
m_PrgRect[0] = CRect(BRect.left,
BRect.top,ERect.right,ERect.bottom);
m_Img2.GetWindowRect(BRect);
m_SkillKey2Img.GetWindowRect(ERect);
m_PrgRect[1] = CRect(BRect.left,BRect.top,ERect.right,ERect.bottom);
m_Img3.GetWindowRect(BRect);
m_SkillKey3Img.GetWindowRect(ERect);
m_PrgRect[2] = CRect(BRect.left,BRect.top,ERect.right,ERect.bottom);
m_Img4.GetWindowRect(BRect);
m_SkillKey4Img.GetWindowRect(ERect);
m_PrgRect[3] = CRect(BRect.left,BRect.top,ERect.right,ERect.bottom);
m_Img5.GetWindowRect(BRect);
m_SkillKey5Img.GetWindowRect(ERect);
m_PrgRect[4] = CRect(BRect.left,BRect.top,ERect.right,ERect.bottom);
m_Img6.GetWindowRect(BRect);
m_SkillKey6Img.GetWindowRect(ERect);
m_PrgRect[5] = CRect(BRect.left,BRect.top,ERect.right,ERect.bottom);
int nIndex = 0;
for(int i=0;i<6;i++)
{
if (m_PrgRect[i].PtInRect(mousePnt))
{
nIndex = i+1;
break;
}
}
if (nIndex == 0)
return 0;
else
return nIndex;
}
void CDlgSkill::SetMagicHotKey(int nIndex, int HotKey)
{
CMagic *pMagic = g_objHero.GetMagicByIndex(m_nCurIndex + nIndex);
if (pMagic)
{
if (pMagic->TestTarget(MAGIC_PASSIVE))
{
g_objGameMsg.AddMsg(g_objGameDataSet.GetStr(10341));//被动技能不能绑定快捷键!
return;
}
else if (pMagic->m_infoMagicType.dwXp == TYPE_XPSKILL )
{
return;
}
m_DlgSkillHotKey.SetMouseHotKey(pMagic->GetIDType(),HotKey);
}
}
void CDlgSkill::SetTeamMagicHotKeys(int nIndex)
{
if(!g_objHero.IsTeamLeader())
return;
CMagic* pMagic = g_objHero.GetTeamMagicByIndex(nIndex);
if (pMagic)
{
if (!m_DlgSkillHotKey.m_bShow)
m_DlgSkillHotKey.EnableWindow();
if (m_DlgSkillHotKey.m_bShow)
{
m_DlgSkillHotKey.PopCurCheck(m_DlgSkillHotKey.m_iMagicHotKey);
for(int j=0;j<8;j++)
{
if (pMagic->GetIDType() == m_DlgSkillHotKey.m_HotKeyIdType[j])
{
m_DlgSkillHotKey.m_iMagicHotKey = j;
break;
}
else
m_DlgSkillHotKey.m_iMagicHotKey = 8;
}
m_DlgSkillHotKey.PopCurCheck(m_DlgSkillHotKey.m_iMagicHotKey,true);
m_DlgSkillHotKey.SetStaMagic(pMagic->GetIDType());
}
}
else
m_DlgSkillHotKey.EnableWindow(false);
}
void CDlgSkill::SetTeamMagicHotKey(int nIndex, int HotKey)
{
CMagic* pMagic = g_objHero.GetTeamMagicByIndex(m_nCurIndex + nIndex);
if (pMagic)
{
m_DlgSkillHotKey.SetMouseHotKey(pMagic->GetIDType(),HotKey);
}
}
void CDlgSkill::ShowSkillInfo(int x, int y)
{
DWORD STRCOLOR_GREEN = 0x00ff00;
DWORD STRCOLOR_BLUE = 0x0080ff;
DWORD STRCOLOR_RED = 0xff0000;
DWORD STRCOLOR_WHITE = 0xffffff;
int nIndex = CDlgSkill::GetMouseInMagicIndex();
if (nIndex != 0)
{
CMagic* pMagic = NULL;
if (m_nSkillListMode == 0)
pMagic = g_objHero.GetMagicByIndex(m_nCurIndex + nIndex-1);
else if (m_nSkillListMode == 1)
pMagic = g_objHero.GetTeamMagicByIndex(m_nTMagicIndex + nIndex-1);
if (pMagic)
{
char strText[3][64];
DWORD strColor;
CMySize FontSize;
CMyBitmap::GetFontSize(FontSize);
sprintf( strText[0], "%s", pMagic->GetName()) ;
if (pMagic->GetNeedLevel() == 0)
{
strColor = STRCOLOR_RED;
strcpy( strText[1], (char*)g_objGameDataSet.GetStr(10710)); //10710=不可继续修习
}
else if (pMagic->GetNeedLevel() >0 )
{
if (pMagic->GetNeedLevel()<=g_objHero.GetLev())
strColor = STRCOLOR_BLUE;
else
strColor = STRCOLOR_RED;
sprintf( strText[1], "%d%s",pMagic->GetNeedLevel(),(char*)g_objGameDataSet.GetStr(10711)); //10711=可以继续修习
}
strcpy(strText[2],pMagic->GetDescribe());
int nPosX = x + 50 - FontSize.iWidth*14;
int nPosY = y + 80 + 49*(nIndex-1);
int nLine = 2+ CDlgSkill::GetSkillDescLine(0,
0,
FontSize.iWidth*14,
strText[2]);
g_objGameDataSet.ShowInfoBack( nPosX - 5, nPosY - 5,
FontSize.iWidth*14 +10,(FontSize.iHeight +2)*nLine + 10) ;
CMyBitmap::ShowString ( nPosX,
nPosY ,
STRCOLOR_GREEN,
strText[0] ) ;
CMyBitmap::ShowString ( nPosX,
nPosY + FontSize.iHeight +2,
strColor,
strText[1] ) ;
CDlgSkill::ShowSkillDesc( nPosX,
nPosY + (FontSize.iHeight +2)*2,
FontSize.iWidth*14,
strText[2] ,STRCOLOR_WHITE) ;
}
}
}
void CDlgSkill::ShowSkillDesc(int nStartX, int nStartY, int nWidth,const char* szString , DWORD dwColor)
{
char Static[64] ;
strcpy(Static,szString);
if(!Static || strlen(Static)==0)
return;
CMySize psizeFont;
CMyBitmap::GetFontSize(psizeFont);
int nMaxLen = nWidth / psizeFont.iWidth;
int nDescLine = 1 ;
int nCharIndex[10];
nCharIndex[0] = 0;
int nSingle = 0;
int nLineNum = 0;
for ( int i = 0; i < strlen ( Static ); i++ )
{
if ( CMyBitmap::IsDBCSLeadByte( Static, i ) )
{
nLineNum += 2;
i++;
}
else
{
nSingle++;
nLineNum++;
}
if ( nLineNum >= nMaxLen )
{
//----------Begin the english version's process(jump line)----------//
if ( strcmp( g_objGameDataSet.GetVersionInfo(), "English" ) == 0 )
{
// Search the last word
for ( int j = i; j >= 0; j-- )
{
if (Static[j] == ' ' )
{
i -= i - j;
break;
}
}
}
//----------End the english version's process(jump line)----------//
if ( nSingle % 2 == 0 )
{
nSingle = 0;
nLineNum = 0;
nCharIndex[nDescLine] = i + 1;
nDescLine++;
}
else
{
i -= nLineNum - nMaxLen;
nCharIndex[nDescLine] = i +1 - ( nLineNum - nMaxLen );
nSingle = 0;
nLineNum = 0;
nDescLine++;
}
}
}
if ( nSingle % 2 == 0 )
{
nCharIndex[nDescLine] = i + 1 ;
}
else
{
nCharIndex[nDescLine] = i ;
}
int nPosX = nStartX;
int nPosY = nStartY;
CMyBitmap::GetFontSize(psizeFont);
char strTemp[32]="" ;
int nOffset = 0;
for (i = 0; i < nDescLine; i++ )
{
strncpy ( strTemp, Static + nCharIndex[i], nCharIndex[i + 1] - nCharIndex[i] );
strTemp[nCharIndex[i + 1] - nCharIndex[i]] = '\0';
CMyBitmap::ShowString (nPosX,
nPosY + nOffset,
dwColor,
CMyShellApp::StringChange ( strTemp, 1 ) ) ;
nOffset += psizeFont.iHeight + 2 ;
}
}
int CDlgSkill::GetSkillDescLine(int nStartX, int nStartY, int nWidth,const char* szString)
{
char Static[64] ;
strcpy(Static,szString);
if(!Static || strlen(Static)==0)
return 0;
char szTemp[64];
strcpy(szTemp, Static);
char* pszTemp = szTemp;
unsigned char ucSingle[2] = {'\0', '\0'};
unsigned char ucDouble[3] = {'\0', '\0', '\0' }; // 双字节字符
//------------------------------------------------------------
int nShowX = nStartX;
int nShowY = nStartY;
int nPosX = nStartX;
int nPosY = nStartY;
int nPos = 0;
bool bShow = false;
int nLine = 1;
char sz[64];
memset(sz, 0L, sizeof(sz));
CMySize psizeFont;
CMyBitmap::GetFontSize(psizeFont);
//------------------------------------------------------------
while((ucSingle[0]=*pszTemp))
{
sz[nPos++] = ucSingle[0];
if(ucSingle[0]<0x80) // 打印一个单字节字符
{
nPosX += psizeFont.iWidth;
if(((nPosX - nStartX) > (nWidth - psizeFont.iWidth * 2)
|| ucSingle[0] == '#')
&& *(pszTemp+1) != '\0')
{
nPosX = nStartX;
nPosY += psizeFont.iHeight+2;
bShow = true;
nLine++;
}
}
else // 打印双字节字符
{
if(ucDouble[0]=='\0')
{
ucDouble[0] = ucSingle[0];
}
else if(ucDouble[1]=='\0')
{
ucDouble[1] = ucSingle[0];
nPosX = nPosX + psizeFont.iWidth * 2;
if((nPosX - nStartX) > (nWidth - psizeFont.iWidth * 2)
&& *(pszTemp+1) != '\0')
{
nPosX = nStartX;
nPosY += psizeFont.iHeight+2;
bShow = true;
nLine++;
}
ucDouble[0] = '\0';
ucDouble[1] = '\0';
}
}
if(bShow)
{
nPos = 0;
bShow = false;
nShowX = nPosX;
nShowY = nPosY;
memset(sz, 0L, sizeof(sz));
}
pszTemp++;
}
return nLine;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -