⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 popupmenu.cpp

📁 国外网游源码....除工具源码缺少之外,其余程序都全...至于,什么游戏,因为国内还没有,所以找不到测试
💻 CPP
字号:
#include "PopupMenu.h"

CPopupMenu::CPopupMenu(LPDIRECT3DDEVICE9 m_pDevice, CDrawEx *pDraw)
:m_pDraw(pDraw)
{
	m_p3DDevice = m_pDevice;

	m_iPosX = 0;
	m_iPosY = 0;
	m_iWidth = 0;
	m_iHeight = 0;

	m_bShow = false;
	
	m_dwFontColor = D3DCOLOR_ARGB(255,255,255,255);
}

CPopupMenu::~CPopupMenu()
{
	Release();
}

void CPopupMenu::Release()
{
	std::list<CButtonCtrl *>::iterator iter;

	for(iter = m_pListButton.begin(); iter != m_pListButton.end() ; iter++)
	{	
		delete (*iter);
	}
	m_pListButton.clear();
	
	m_ListMenuItem.clear();

	if(m_pFonts != NULL)
		SAFE_DELETE(m_pFonts);
}

HRESULT CPopupMenu::CreatePopupMenu(char *ButtonName,DWORD ID, int MenuNum, DWORD ButtonType)
{
	m_iMenuNum = MenuNum;

	m_pFonts = new CMcFonts();
	m_pFonts->CreateMCFont(m_p3DDevice, 12, 0, false, TEXT("奔覆眉"));

	for(int i = 0; i < MenuNum; i++)
	{
		CButtonCtrl *m_pButton = new CButtonCtrl(m_p3DDevice, m_pDraw);
		m_pButton->CreateButton(ButtonName, ID + i, ButtonType);

		m_iWidth = m_pButton->m_dwWidth;
		m_iHeight = m_pButton->m_dwHeight;

		m_pListButton.push_back(m_pButton);
	}

	return S_OK;
}

//MenuNum 父怒狼 酒捞袍阑 眠啊 矫难拎具 茄促.
void	CPopupMenu::Add_Item(char* String)
{
	MenuItem Temp;
	strcpy(Temp.Item, String);

	//x, y 蔼篮 酒流 救甸绢埃 惑怕促.
	m_ListMenuItem.push_back(Temp);
}

void	CPopupMenu::Replace_Item(DWORD Type, int x, int y, int Width, int Height, int FontSize)
{
	list <MenuItem>::iterator iter;
	for(iter = m_ListMenuItem.begin(); iter != m_ListMenuItem.end(); iter++)
	{
		MenuItem * pItem = (MenuItem *)&(*iter);
		switch(Type)
		{
		case DT_LEFT:
			{
				pItem->y = y + (Height - FontSize)/2;  //迄飘 荤捞令 12
				pItem->x = m_iPosX + (Height - FontSize)/2;  //迄飘 荤捞令 12
			}
			break;
		case DT_RIGHT:
			{
				pItem->y = y + (Height - FontSize)/2;  //迄飘 荤捞令 12
				pItem->x = m_iPosX + Width - (Height - FontSize)/2;  //迄飘 荤捞令 12
			}
			break;
		case DT_CENTER:
			{
				pItem->y = y + (Height - FontSize)/2;  //迄飘 荤捞令 12
				pItem->x = x + (Width - strlen(pItem->Item)*FontSize/2) /2;
			}
			break;
		}
	}
}
void	CPopupMenu::Draw_PopupMenu(int Alpha, int iX, int iY)
{
	if(m_bShow == false)
		return;
	if(iX != 0)
		m_iPosX = iX;
	if(iY != 0)
		m_iPosY = iY;

	m_iAlpha = Alpha;
	
	int i = 0;
	int j = 0;

	//皋春 滚瓢 弊妨林扁
	list <CButtonCtrl *>::iterator iter;
	for(iter = m_pListButton.begin(); iter != m_pListButton.end(); iter++, i++)
	{	
		CButtonCtrl *pItem = (*iter);

		pItem->DrawButton(Alpha, 0.0f, m_iPosX, m_iPosY + m_iHeight * i);
	}

	//皋春 咆胶飘 弊妨林扁.
	list <MenuItem>::iterator iter2;
	for(iter2 = m_ListMenuItem.begin(); iter2 != m_ListMenuItem.end(); iter2++, j++)
	{
		MenuItem pItem2 = (*iter2);

		//m_pFonts->DrawText(pItem2.Item, m_iPosX + pItem2.x, m_iPosY + m_iHeight * j + pItem2.y);
		m_pFonts->DrawText(pItem2.Item, pItem2.x, m_iHeight * j + pItem2.y);
	}

}

void CPopupMenu::Show_Menu(int x, int y, DWORD TextType, int FontSize)
{
	m_iPosX = x;
	m_iPosY = y;
	m_bShow = true;
	g_pApp->m_iCurrentLayer++;

	Replace_Item(TextType, m_iPosX, m_iPosY, m_iWidth, m_iHeight, FontSize);
}

void CPopupMenu::Hide_Menu()
{
	m_iPosX = 0;
	m_iPosY = 0;
	m_bShow = false;
	g_pApp->m_iCurrentLayer--;
}

char* CPopupMenu::Get_Menu_Text(int Order)
{
	int j = 0;
	list <MenuItem>::iterator iter2;
	for(iter2 = m_ListMenuItem.begin(); iter2 != m_ListMenuItem.end(); iter2++, j++)
	{
		MenuItem pItem2 = (*iter2);

		if(Order == j)
		{
			char Temp11[128];
			char Temp22[128];
			sprintf(Temp11, "\n Order : %d", Order);
			sprintf(Temp22, "\n %s", pItem2.Item);
		//	OutputDebugString(Temp11);
		//	OutputDebugString(Temp22);

			return pItem2.Item;
		}
	}
	
	return NULL;
}

void CPopupMenu::Mouse_Move(int x, int y, UINT nFlags, int iLayer)
{
	list <CButtonCtrl *>::iterator iter;

	for(iter = m_pListButton.begin() ; iter != m_pListButton.end(); iter++)
	{
		CButtonCtrl *pItem = (*iter);

		pItem->UpdateData(x, y, nFlags);

//		if((x < m_iPosX || x > m_iPosX + m_iWidth || y < m_iPosY || y > m_iPosY + m_iHeight*m_iMenuNum) && m_bShow == true)
//		{
//			Hide_Menu();
//		}
	}
}

DWORD CPopupMenu::LButtonDown(int x, int y, UINT nFlags, int iLayer)
{
	list <CButtonCtrl *>::iterator iter;

	for(iter = m_pListButton.begin() ; iter != m_pListButton.end(); iter++)
	{
		CButtonCtrl *pItem = (*iter);

		if(pItem->UpdateData(x, y, nFlags))
		{
			return pItem->GetID();	
		}
	}

	if(m_bShow == true)
		Hide_Menu();
	
	return -1;
}

void CPopupMenu::LButtonUp(int x, int y, UINT nFlags, int iLayer)
{
	list <CButtonCtrl *>::iterator iter;

	for(iter = m_pListButton.begin() ; iter != m_pListButton.end(); iter++)
	{
		CButtonCtrl *pItem = (*iter);

		pItem->UpdateData(x, y, nFlags);
	}
}

void CPopupMenu::Mouse_Wheel()
{

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -