📄 3duimanger.cpp
字号:
#include "3DUIManger.h"
C3DUIManger::C3DUIManger(LPDIRECT3DDEVICE9 pd3dDevice,HWND hWnd,CSkinMesh* RoleMesh):
//m_pMouse(NULL),
m_pEquip(NULL),
m_pBag(NULL)
//m_pStatus(NULL),
//m_pHp(NULL),
//m_pMp(NULL)
{
m_hWnd=hWnd;
m_pd3dDevice=pd3dDevice;
m_nScreenWidth=800;
m_nScreenHeight=600;
m_bBackBagState=false;
m_bCloseState=false;
m_bNPCLive=false;
m_nShowBag=1;
m_bShowRole=false;
m_bShowBook=false;
m_bShowBall=false;
m_bShowCup=false;
m_pRoleMesh=RoleMesh;
m_bIs=false;
corrent=NULL;
}
C3DUIManger::~C3DUIManger()
{
delete (m_pEquip);
delete (m_pBag);
//delete (m_pStatus);
//delete (m_pMouse);
//delete (m_pHp);
//delete (m_pMp);
}
void C3DUIManger::Moveto(float x,float y)
{
if(corrent==NULL)return;
corrent->MoveToMouse(x-move_x,y-move_y);
if (corrent==m_pEquip->m_pBack)
{
if (m_pEquip->m_pEnd)
{
m_pEquip->m_pEnd->MoveToMouse(x-move_x,y-move_y);
}
m_pEquip->UpdateVertices();
}
if (corrent==m_pBag->m_pBack)
{
if (m_pBag->m_pEnd)
{
m_pBag->m_pEnd->MoveToMouse(x-move_x,y-move_y);
}
m_pBag->UpdateVertices();
}
move_x=(int)x;
move_y=(int)y;
}
void C3DUIManger::UpDate()
{
bool del=true;
if(corrent==NULL)return;
if (corrent!=m_pEquip->m_pBack&&m_pEquip->m_pBack->IsPointInsidePanel(corrent->m_nX,corrent->m_nY)
||m_pEquip->m_pBack->IsPointInsidePanel(corrent->m_nX+corrent->m_nWidth,corrent->m_nY)
||m_pEquip->m_pBack->IsPointInsidePanel(corrent->m_nX+corrent->m_nWidth,corrent->m_nY+corrent->m_nHeight)
||m_pEquip->m_pBack->IsPointInsidePanel(corrent->m_nX,corrent->m_nY+corrent->m_nHeight))
{
m_pEquip->Add(corrent);
del=false;
}
if (corrent!=m_pBag->m_pBack&&m_pBag->m_pBack->IsPointInsidePanel(corrent->m_nX,corrent->m_nY)
||m_pBag->m_pBack->IsPointInsidePanel(corrent->m_nX+corrent->m_nWidth,corrent->m_nY)
||m_pBag->m_pBack->IsPointInsidePanel(corrent->m_nX+corrent->m_nWidth,corrent->m_nY+corrent->m_nHeight)
||m_pBag->m_pBack->IsPointInsidePanel(corrent->m_nX,corrent->m_nY+corrent->m_nHeight))
{
m_pBag->Add(corrent);
del=false;
}
if (corrent!=m_pEquip->m_pBack&&corrent!=m_pBag->m_pBack&&del)
{
delete (corrent);
}
corrent=NULL;
m_pBag->UpdateVertices();
m_pEquip->UpdateVertices();
}
bool C3DUIManger::IsPointIn(int x,int y)
{
if (m_pEquip->IsPointIn(x,y,&corrent))
{
m_bIs=true;
return true;
}
if (m_pBag->IsPointIn(x,y,&corrent))
{
m_bIs=true;
return true;
}
if (!m_bIs)
{
move_x=x;
move_y=y;
}
return false;
}
void C3DUIManger::Init()
{
CPanel *temp,*tempend;
temp=new CPanel(m_pd3dDevice,400,62,0,500);
temp->SetTexture(".\\UIimage\\UI_PANEL_JNL.png",D3DCOLOR_XRGB(0, 0, 0));
temp->SetButton(5);
m_pEquip=new CLinkList(temp,NULL,1,8,36,60,30);
m_pEquip->m_bVisrul=true;
temp=new CPanel(m_pd3dDevice,32,32,0,0);
temp->SetTexture(".\\UIimage\\item_magic_firelight.jpg",D3DCOLOR_XRGB(0, 0, 0));
temp->SetButton(1);
m_pEquip->Add(temp,0,0);
temp=new CPanel(m_pd3dDevice,32,32,0,0);
temp->SetTexture(".\\UIimage\\item_magic_holybolt.jpg",D3DCOLOR_XRGB(0, 0, 0));
temp->SetButton(2);
m_pEquip->Add(temp,0,1);
temp=new CPanel(m_pd3dDevice,180,232,0,0);
temp->SetTexture(".\\UIimage\\Bag.png",D3DCOLOR_XRGB(0, 0, 0));
temp->SetButton(5);
tempend=new CPanel(m_pd3dDevice,16,18,160,3);
tempend->SetTexture(".\\UIimage\\close1.bmp",D3DCOLOR_XRGB(0, 0, 0));
tempend->SetButton(5);
m_pBag=new CLinkList(temp,tempend,4,4,41,15,50);
m_pBag->m_bVisrul=false;
temp=new CPanel(m_pd3dDevice,32,32,0,0);
temp->SetTexture(".\\UIimage\\item_medicine_red.jpg",D3DCOLOR_XRGB(0, 0, 0));
temp->SetButton(3);
m_pBag->Add(temp,0,0);
temp=new CPanel(m_pd3dDevice,32,32,0,0);
temp->SetTexture(".\\UIimage\\item_medicine_red.jpg",D3DCOLOR_XRGB(0, 0, 0));
temp->SetButton(3);
m_pBag->Add(temp,0,1);
temp=new CPanel(m_pd3dDevice,32,32,0,0);
temp->SetTexture(".\\UIimage\\item_medicine_red.jpg",D3DCOLOR_XRGB(0, 0, 0));
temp->SetButton(3);
m_pBag->Add(temp,0,2);
temp=new CPanel(m_pd3dDevice,32,32,0,0);
temp->SetTexture(".\\UIimage\\item_medicine_red.jpg",D3DCOLOR_XRGB(0, 0, 0));
temp->SetButton(3);
m_pBag->Add(temp,0,3);
temp=new CPanel(m_pd3dDevice,32,32,0,0);
temp->SetTexture(".\\UIimage\\item_medicine_blue.jpg",D3DCOLOR_XRGB(0, 0, 0));
temp->SetButton(4);
m_pBag->Add(temp,1,0);
temp=new CPanel(m_pd3dDevice,32,32,0,0);
temp->SetTexture(".\\UIimage\\item_medicine_blue.jpg",D3DCOLOR_XRGB(0, 0, 0));
temp->SetButton(4);
m_pBag->Add(temp,1,1);
temp=new CPanel(m_pd3dDevice,32,32,0,0);
temp->SetTexture(".\\UIimage\\item_medicine_blue.jpg",D3DCOLOR_XRGB(0, 0, 0));
temp->SetButton(4);
m_pBag->Add(temp,1,2);
temp=new CPanel(m_pd3dDevice,32,32,0,0);
temp->SetTexture(".\\UIimage\\item_medicine_blue.jpg",D3DCOLOR_XRGB(0, 0, 0));
temp->SetButton(4);
m_pBag->Add(temp,1,3);
//m_pMouse=new CPanel(m_pd3dDevice,35,35,0,0);
//m_pMouse->SetTexture(".\\UIimage\\mouse1.tga",D3DCOLOR_XRGB(0, 0, 0));
//m_pStatus=new CPanel(m_pd3dDevice,207,104,0,0);
//m_pStatus->SetTexture(".\\UIimage\\Rolelogo.tga",D3DCOLOR_XRGB(0, 0, 0));
//m_pHp=new CPanel(m_pd3dDevice,115,6,81,26);
//m_pHp->SetTexture(".\\UIimage\\UI_PLAYER_LIFE.bmp",D3DCOLOR_XRGB(0, 0, 0));
//m_pMp=new CPanel(m_pd3dDevice,115,6,84,36);
//m_pMp->SetTexture(".\\UIimage\\UI_PLAYER_MAGIC.bmp",D3DCOLOR_XRGB(0, 0, 0));
}
void C3DUIManger::Render()
{
m_pd3dDevice->SetRenderState(D3DRS_SHADEMODE,D3DSHADE_FLAT);
m_pd3dDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
m_pEquip->Render();
m_pBag->Render();
//m_pStatus->Render();
//m_pHp->setSize(m_pRoleMesh->m_CURHP/m_pRoleMesh->m_MAXHP*115,6);
//m_pHp->Render();
//m_pMp->setSize(m_pRoleMesh->m_CURMP/m_pRoleMesh->m_MAXMP*115,6);
//m_pMp->Render();
if (corrent!=m_pBag->m_pBack&&corrent!=m_pEquip->m_pBack&&corrent!=NULL)
{
corrent->Render();
}
//POINT pt;
//GetCursorPos( &pt );
//ScreenToClient(this->m_hWnd ,&pt);
//m_pMouse->SetPro((float)pt.x,(float)pt.y);
//m_pMouse->Render();
m_pd3dDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD);
m_pd3dDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -