📄 game_linklist.cpp
字号:
#include "Game_LinkList.h"
CLinkList::CLinkList(CPanel *Back,CPanel *End,int i,int j,int w,int x,int y)
{
m_pBack=Back;
m_pEnd=End;
m_ni=i;
m_nj=j;
m_nW=w;
m_nX=x;
m_nY=y;
for (i=0;i<m_ni;i++)
{
for (j=0;j<m_nj;j++)
{
m_ppbutton[i][j]=NULL;
}
}
}
void CLinkList::Add(CPanel* button)
{
int i ,j;
j=(int)(button->m_nX+button->m_nWidth/2-m_pBack->m_nX-m_nX)/m_nW;
i=(int)(button->m_nY+button->m_nHeight/2-m_pBack->m_nY-m_nY)/m_nW;
if (i<0)
{
i=0;
}
if (j<0)
{
j=0;
}
for (;i<m_ni;j++)
{
if (m_ppbutton[i][j]==NULL)
{
break;
}
if (j>=m_nj)
{
i++;
}
}
if (m_ppbutton[i][j]!=NULL)
{
for (i=0;i<m_ni;i++)
{
for (j=0;j<m_nj;j++)
{
if (m_ppbutton[i][j]==NULL)
{
break;
}
}
}
}
m_ppbutton[i][j]=button;
}
void CLinkList::Add(CPanel* button,int i,int j)
{
m_ppbutton[i][j]=button;
this->UpdateVertices();
}
void CLinkList::Render()
{
if (!m_bVisrul)return;
m_pBack->Render();
if (m_pEnd!=NULL) m_pEnd->Render();
for (int i=0;i<m_ni;i++)
{
for (int j=0;j<m_nj;j++)
{
if (m_ppbutton[i][j]!=NULL)
{
m_ppbutton[i][j]->Render();
}
}
}
}
void CLinkList::UpdateVertices()
{
for (int i =0;i<m_ni;i++)
{
for (int j=0;j<m_nj;j++)
{
if (m_ppbutton[i][j]!=NULL)
{
m_ppbutton[i][j]->m_nX=m_pBack->m_nX+m_nX+j*m_nW;
m_ppbutton[i][j]->m_nY=m_pBack->m_nY+m_nY+i*m_nW;
m_ppbutton[i][j]->UpdateVertices();
}
}
}
}
CLinkList::~CLinkList()
{
delete(m_pBack);
for (int i=0;i<m_ni;i++)
{
for (int j=0;j<m_nj;j++)
{
if (m_ppbutton[i][j]!=NULL)
{
delete (m_ppbutton[i][j]);
}
}
}
if (m_pEnd)
{
delete (m_pEnd);
}
}
bool CLinkList::IsPointIn(int x,int y,CPanel** corrent)
{
if (!m_bVisrul)
return false;
for (int i=0;i<m_ni;i++)
{
for (int j=0;j<m_nj;j++)
{
if (m_ppbutton[i][j]!=NULL&&m_ppbutton[i][j]->IsPointInsidePanel((float)x,(float)y))
{
*corrent=m_ppbutton[i][j];
m_ppbutton[i][j]=NULL;
return true;
}
}
}
if (m_pEnd!=NULL&&m_pEnd->IsPointInsidePanel((float)x,(float)y))
{
m_bVisrul=false;
return true;
}
if (m_pBack->IsPointInsidePanel((float)x,(float)y))
{
*corrent=m_pBack;
return true;
}
return false;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -