📄 mygrid.cpp
字号:
return ( lrPoint.y - 1 ) * m_GriPar.m_btGridRow + lrPoint.x - 1;
}
}
return -1 ;
}
void CMyGrid::SetGridAble(CPoint lrPoint, BOOL bAble)
{
int Index = ( lrPoint.y - 1 ) * m_GriPar.m_btGridRow + lrPoint.x ;
m_GriPar.m_bGridAble[Index - 1] = bAble ;
}
BOOL CMyGrid::LoadIcon(CPoint lrPoint, OBJID ItemTypeID, DWORD dwItemIndex, BYTE btItemType)
{
SetGridAble ( lrPoint, true ) ;
int Index = ( lrPoint.y - 1 ) * m_GriPar.m_btGridRow + lrPoint.x ;
m_GriPar.m_IconTypeID [Index-1] = ItemTypeID ;
m_GriPar.m_IconIndex[Index-1] = dwItemIndex ;
m_GriPar.m_btIconType[Index-1] = btItemType ;
if ( btItemType == ICON_TYPE_QUSE )
{
m_GriPar.m_QUseItem[Index-1].Create( Index, ItemTypeID ) ;
}
return true ;
}
int CMyGrid::GetGridIndex(CPoint lrPoint)
{
return ( lrPoint.y - 1 ) * m_GriPar.m_btGridRow + lrPoint.x ;
}
OBJID CMyGrid::GetPickUpTypeID ( )
{
return m_GriPar.m_PickUpIconTypeID ;
}
int CMyGrid::GetPickUpIndex()
{
return m_GriPar.m_dwPickUpIconIndex ;
}
DWORD CMyGrid::GetMouseMoveIndex()
{
return m_GriPar.m_dwMouseMoveIconIndex ;
}
DWORD CMyGrid::GetMouseMoveTypeID()
{
return m_GriPar.m_dwMouseMoveIconTypeID ;
}
CPoint CMyGrid::GetPickUpMousePnt()
{
return m_GriPar.m_PickUpMousePoint ;
}
void CMyGrid::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if ( !m_GriPar.m_ClientRect.PtInRect ( point ) )
return ;
CPoint LandR ;
LandR = GetLineAndRow ( point ) ;
BOOL IsAvailab = GetGridAble ( LandR ) ;
if ( IsAvailab )
{
if ( m_GriPar.m_btIconType [ GetGridIndex ( LandR ) - 1 ] == ICON_TYPE_ACTION )
return ;
if ( !m_GriPar.m_bMouseMove )
{
m_GriPar.m_bMouseMove = true ;
m_GriPar.m_MouseMoveIconLandR = LandR ;
int nPosX = m_GriPar.m_Point.x + (m_GriPar.m_btGridWidth + m_GriPar.m_iGridSpacex) * ( LandR.x - 1 ) ;
int nPosY = m_GriPar.m_Point.y + (m_GriPar.m_btGridHeight + m_GriPar.m_iGridSpacey) * ( LandR.y - 1 ) ;
m_GriPar.m_dwMouseMoveIconIndex = m_GriPar.m_IconIndex [GetGridIndex ( LandR ) - 1 ];
m_GriPar.m_dwMouseMoveIconTypeID = m_GriPar.m_IconTypeID [GetGridIndex ( LandR ) - 1 ];
m_GriPar.m_PickUpIconRealID = m_GriPar.m_IconRealID[GetGridIndex ( LandR )- 1] ;
LPARAM lParam = MAKELONG( nPosX, nPosY ) ;
if (m_GriPar.m_bScale == false)
lParam = MAKELONG( nPosX + 32, nPosY + 32 );
if ( m_GriPar.m_btIconType [ GetGridIndex ( LandR ) - 1 ] == ICON_TYPE_SKILL ||
m_GriPar.m_btIconType [ GetGridIndex ( LandR ) - 1 ] == ICON_TYPE_XP )
{
CMyGrid::GetParent ()->GetParent ()->PostMessage ( WM_MY_MESSAGE, ON_MSGDLG_POINT, lParam ) ;
CMyGrid::GetParent ()->GetParent ()->PostMessage ( WM_MY_MESSAGE, ON_MSGDLG_IMAGE, m_GriPar.m_dwMouseMoveIconTypeID ) ;
return ;
}
CMyGrid::GetParent ()->GetParent ()->PostMessage ( WM_MY_MESSAGE, ON_MSGDLG_POINT, lParam ) ;
CMyGrid::GetParent ()->GetParent ()->PostMessage ( WM_MY_MESSAGE, ON_MSGDLG_GOODS, m_GriPar.m_btOwnerID ) ;
}
else if ( m_GriPar.m_bMouseMove && m_GriPar.m_MouseMoveIconLandR != LandR )
{
m_GriPar.m_bMouseMove = true ;
m_GriPar.m_MouseMoveIconLandR = LandR ;
int nPosX = m_GriPar.m_Point.x + (m_GriPar.m_btGridWidth + m_GriPar.m_iGridSpacex) * ( LandR.x - 1 ) ;
int nPosY = m_GriPar.m_Point.y + (m_GriPar.m_btGridHeight + m_GriPar.m_iGridSpacey) * ( LandR.y - 1 ) ;
m_GriPar.m_dwMouseMoveIconIndex = m_GriPar.m_IconIndex [GetGridIndex ( LandR ) - 1 ];
m_GriPar.m_dwMouseMoveIconTypeID = m_GriPar.m_IconTypeID [GetGridIndex ( LandR ) - 1 ];
m_GriPar.m_PickUpIconRealID = m_GriPar.m_IconRealID[GetGridIndex ( LandR )- 1] ;
if ( m_GriPar.m_btIconType [ GetGridIndex ( LandR ) - 1 ] == ICON_TYPE_QUSE )
{
nPosX = m_GriPar.m_Point.x + (m_GriPar.m_btGridWidth + m_GriPar.m_iGridSpacex)* ( LandR.x - 1 );
nPosY = m_GriPar.m_Point.y + (m_GriPar.m_btGridHeight + m_GriPar.m_iGridSpacey)* ( LandR.y - 1 );
}
LPARAM lParam = MAKELONG( nPosX, nPosY ) ;
if (m_GriPar.m_bScale == false)
lParam = MAKELONG( nPosX + 32, nPosY + 32 );
if ( m_GriPar.m_btIconType [ GetGridIndex ( LandR ) - 1 ] == ICON_TYPE_SKILL ||
m_GriPar.m_btIconType [ GetGridIndex ( LandR ) - 1 ] == ICON_TYPE_XP )
{
CMyGrid::GetParent ()->GetParent ()->PostMessage ( WM_MY_MESSAGE, ON_MSGDLG_POINT, lParam ) ;
CMyGrid::GetParent ()->GetParent ()->PostMessage ( WM_MY_MESSAGE, ON_MSGDLG_IMAGE, m_GriPar.m_dwMouseMoveIconTypeID ) ;
return ;
}
CMyGrid::GetParent ()->GetParent ()->PostMessage ( WM_MY_MESSAGE, ON_MSGDLG_POINT, lParam ) ;
CMyGrid::GetParent ()->GetParent ()->PostMessage ( WM_MY_MESSAGE, ON_MSGDLG_GOODS, m_GriPar.m_btOwnerID ) ;
}
}
else
{
if ( m_GriPar.m_bMouseMove && !CMyGrid::IsWindowVisible() )
{
m_GriPar.m_bMouseMove = false ;
CMyGrid::GetParent ()->GetParent ()->PostMessage ( WM_MY_MESSAGE, ON_MSGDLG_HIDE ) ;
}
else if ( m_GriPar.m_bMouseMove && m_GriPar.m_MouseMoveIconLandR != LandR )
{
m_GriPar.m_MouseMoveIconLandR = LandR ;
CMyGrid::GetParent ()->GetParent ()->PostMessage ( WM_MY_MESSAGE, ON_MSGDLG_HIDE ) ;
}
else if ( !m_GriPar.m_bMouseMove && CMyGrid::IsWindowVisible() )
{
m_GriPar.m_bMouseMove = true ;
m_GriPar.m_MouseMoveIconLandR = LandR ;
}
}
CButton::OnMouseMove(nFlags, point);
}
void CMyGrid::MouseMoveTest()
{
POINT MousePoint ;
GetCursorPos ( &MousePoint ) ;
CRect rect ;
CMyGrid::GetWindowRect ( rect ) ;
if ( !rect.PtInRect ( MousePoint ) )
{
m_GriPar.m_bMouseMove = false ;
CMyGrid::GetParent ()->GetParent ()->PostMessage ( WM_MY_MESSAGE, ON_MSGDLG_HIDE ) ;
}
}
CPoint CMyGrid::GetInsertLandR()
{
return m_GriPar.m_InsetLandR ;
}
int CMyGrid::ChangeIcon(CPoint IconLandR, OBJID ItemTypeID, OBJID ItemRealID, DWORD dwItemIndex, BYTE btItemType)
{
int nIndex = ( IconLandR.y - 1 ) * m_GriPar.m_btGridRow + IconLandR.x ;
m_GriPar.m_PickUpIconTypeID = m_GriPar.m_IconTypeID [nIndex - 1] ;
m_GriPar.m_dwPickUpIconIndex = m_GriPar.m_IconIndex [nIndex - 1] ;
m_GriPar.m_PickUpIconRealID = m_GriPar.m_IconRealID [nIndex - 1] ;
m_GriPar.m_IconTypeID [nIndex-1] = ItemTypeID ;
m_GriPar.m_IconRealID [nIndex-1] = ItemRealID ;
m_GriPar.m_IconIndex[nIndex-1] = dwItemIndex ;
m_GriPar.m_btIconType[nIndex-1] = btItemType ;
return nIndex - 1 ;
}
void CMyGrid::RemoveIcon(int nLine, int nRow, BOOL bAll)
{
if ( bAll )
{
m_GriPar.m_nGridAbleNum = 0;
for ( int i = 0; i < 256; i++ )
{
m_GriPar.m_IconIndex[i] = 0;
m_GriPar.m_IconTypeID[i]= 0;
m_GriPar.m_IconRealID[i] = 0;
m_GriPar.m_bGridAble[i] = false ;
}
return ;
}
else
{
SetGridAble( CPoint ( nRow, nLine ), false ) ;
m_GriPar.m_nGridAbleNum-- ;
}
}
void CMyGrid::OnLButtonDblClk(UINT nFlags, CPoint point)
{
CButton::OnLButtonDblClk(nFlags, point);
}
void CMyGrid::ReSumePickUp()
{
LoadIcon( m_GriPar.m_PickUpIconLandR, m_GriPar.m_PickUpIconTypeID, m_GriPar.m_dwPickUpIconIndex, m_GriPar.m_btPickUpIconType ) ;
}
void CMyGrid::SetEnable(BOOL bEnable)
{
m_GriPar.m_bEnable = bEnable ;
}
void CMyGrid::SetPickEnable(BOOL bEnable)
{
m_GriPar.m_bPickEnable = bEnable ;
}
int CMyGrid::GetIconTypeID(int nIndex)
{
return m_GriPar.m_IconTypeID [nIndex] ;
}
void CMyGrid::SetIconNum(int nIndex, int nNum)
{
m_GriPar.m_IconNum[nIndex] = nNum ;
}
void CMyGrid::OnLButtonUp(UINT nFlags, CPoint point)
{
if ( m_GriPar.m_btPickUpIconType == ICON_TYPE_ACTION )
CMyGrid::GetParent ()->GetParent ()->PostMessage ( WM_MY_MESSAGE, ON_ICON_DROP, DLG_ACT ) ;
else if ( m_GriPar.m_btPickUpIconType == ICON_TYPE_SKILL )
CMyGrid::GetParent ()->GetParent ()->PostMessage ( WM_MY_MESSAGE, ON_ICON_DROP, DLG_MAGIC ) ;
else if ( m_GriPar.m_btPickUpIconType == ICON_TYPE_XP )
CMyGrid::GetParent ()->GetParent ()->PostMessage ( WM_MY_MESSAGE, ON_ICON_DROP, DLG_XP ) ;
CButton::OnLButtonUp(nFlags, point);
}
BYTE CMyGrid::GetPickUpType()
{
return m_GriPar.m_btPickUpIconType ;
}
BYTE CMyGrid::GetIconType(int nIndex)
{
return m_GriPar.m_btIconType [nIndex] ;
}
BYTE CMyGrid::GetPickUpActType()
{
return m_GriPar.m_btPickUpIconActType ;
}
void CMyGrid::SetIconRealID(int nIndex, OBJID rID)
{
m_GriPar.m_IconRealID [nIndex] = rID ;
}
int CMyGrid::GetPickUpRealID()
{
return m_GriPar.m_PickUpIconRealID ;
}
int CMyGrid::GetIconRealID(int nIndex)
{
return m_GriPar.m_IconRealID[nIndex] ;
}
void CMyGrid::ReSetGridSpace(int x, int y)
{
CRect rect ;
CMyGrid::GetWindowRect ( rect ) ;
m_GriPar.m_iGridSpacex = x;
m_GriPar.m_iGridSpacey = y;
m_GriPar.m_btGridWidth = ( rect.Width () - (m_GriPar.m_btGridRow - 1) *m_GriPar.m_iGridSpacex) / m_GriPar.m_btGridRow ;
m_GriPar.m_btGridHeight = ( rect.Height () - (m_GriPar.m_btGridLine - 1)*m_GriPar.m_iGridSpacey ) / m_GriPar.m_btGridLine ;
}
BOOL CMyGrid::GetGridAbleByIndex(int nIndex)
{
if ( nIndex < 0 || nIndex >= m_GriPar.m_btGridLine * m_GriPar.m_btGridRow )
return false;
else
return m_GriPar.m_bGridAble[nIndex];
}
void CMyGrid::ShowTypeItem(OBJID idType,int nX,int nY)
{
char szAni[256] = "";
sprintf(szAni, "Item%u", idType);
CAni* pAni = g_objGameDataSet.GetDataAni("ani/ItemMinIcon.Ani", szAni);
if (!pAni)
return;
CMyBitmap* pBmp = pAni->GetFrame(0);
if(!pBmp)
return;
CMySize sizeBmp;
pBmp->GetSize(sizeBmp.iWidth, sizeBmp.iHeight);
pBmp->ShowEx(nX, nY , NULL, sizeBmp.iWidth/2, sizeBmp.iHeight/2);
}
CPoint CMyGrid::GetGridPnt(int Line,int Row)
{
CPoint Pnt;
Pnt.x = m_GriPar.m_Point.x + (m_GriPar.m_btGridWidth + m_GriPar.m_iGridSpacex) * ( Row - 1 ) ;
Pnt.y = m_GriPar.m_Point.y + (m_GriPar.m_btGridHeight + m_GriPar.m_iGridSpacey) * ( Line - 1 ) ;
return Pnt;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -