📄 infopanel.cpp
字号:
//--------------------------------------------------
// Desc: information panel
// Author: artsylee/2007.6.9
//--------------------------------------------------
#include "InfoPanel.h"
#include "GameCommon.h"
#include "Common.h"
CInfoPanel::CInfoPanel()
{
m_LastTime = 0;
// 0为正常, 1为Fade
m_Mode = 0;
m_ColorWindow = 0;
for(int i=0; i<3; i++)
{
m_ColorStatic[i] = 0;
m_rcInfo[i].SetRect(0, 0, 0, 0);
}
m_AlphaWindow = 255;
m_AlphaStatic = 255;
m_ControlID = 0;
}
CInfoPanel::~CInfoPanel()
{
}
void CInfoPanel::Load(void)
{
GStatic *pInfo = (GStatic*)g_pGUIManager->GetElement(HINT_INFO1);
if(pInfo)
{
pInfo->SetLeft(true);
pInfo->SetCaption("");
m_ColorStatic[0] = pInfo->GetColor();
}
MLStatic *pMLS = (MLStatic*)g_pGUIManager->GetElement(HINT_INFO2);
if(pMLS)
{
pMLS->SetCaption("");
pMLS->GetFont()->SetLineHeight(14);
pMLS->GetFont()->SetLineCount(70);
m_ColorStatic[1] = pMLS->GetColor();
}
pInfo = (GStatic*)g_pGUIManager->GetElement(HINT_INFO3);
if(pInfo)
{
pInfo->SetLeft(true);
pInfo->SetCaption("");
m_ColorStatic[2] = pInfo->GetColor();
}
CWindow *pWin = (CWindow*)g_pGUIManager->GetElement(HINT_WINDOW);
if(pWin)
{
m_ColorWindow = pWin->GetColor();
pWin->Show(false);
}
}
void CInfoPanel::SetLineCount(int length)
{
MLStatic *pMLS = (MLStatic*)g_pGUIManager->GetElement(HINT_INFO2);
if(pMLS)
{
pMLS->GetFont()->SetLineCount(length);
}
}
void CInfoPanel::ShowTop(void)
{
g_pGUIManager->SetAsTopWindow((DWORD)HINT_WINDOW);
if(m_Mode==1 && (m_AlphaStatic>0 || m_AlphaWindow>0))
{
if(g_GlobalTime-m_LastTime>=10)
{
if(m_AlphaStatic>0) m_AlphaStatic--;
if(m_AlphaWindow>0) m_AlphaWindow--;
if(m_AlphaStatic==0)
{
m_AlphaWindow = 0;
GUIShow(HINT_WINDOW, false);
}
if(m_AlphaWindow==0)
{
m_AlphaStatic = 0;
GUIShow(HINT_WINDOW, false);
}
for(int i=0; i<3; i++)
{
GStatic *pInfoStatic = (GStatic*)g_pGUIManager->GetElement(HINT_INFO1+i);
if(pInfoStatic)
{
DWORD colorStatic = pInfoStatic->GetColor();
colorStatic = (colorStatic & 0x00FFFFFF) | m_AlphaStatic<<24;
pInfoStatic->SetColor(colorStatic);
}
}
GStatic *pInfo = (GStatic*)g_pGUIManager->GetElement(HINT_INFO1);
if(pInfo)
{
DWORD colorStatic = pInfo->GetColor();
colorStatic = (colorStatic & 0x00FFFFFF) | m_AlphaStatic<<24;
pInfo->SetColor(colorStatic);
}
MLStatic *pMLS = (MLStatic*)g_pGUIManager->GetElement(HINT_INFO2);
if(pMLS)
{
DWORD colorStatic = pMLS->GetColor();
colorStatic = (colorStatic & 0x00FFFFFF) | m_AlphaStatic<<24;
pMLS->SetColor(colorStatic);
}
pInfo = (GStatic*)g_pGUIManager->GetElement(HINT_INFO3);
if(pInfo)
{
DWORD colorStatic = pInfo->GetColor();
colorStatic = (colorStatic & 0x00FFFFFF) | m_AlphaStatic<<24;
pInfo->SetColor(colorStatic);
}
CWindow *pWin = (CWindow*)g_pGUIManager->GetElement(HINT_WINDOW);
if(pWin)
{
DWORD colorWindow = pWin->GetColor();
colorWindow = (colorWindow & 0x00FFFFFF) | m_AlphaWindow<<24;
pWin->SetColor(colorWindow);
}
m_LastTime = g_GlobalTime;
}
}
}
void CInfoPanel::ShowInfo(DWORD infoID, const char *pCaption, const char *pMain, const char *pAppend)
{
for(int i=0; i<3; i++)
{
m_rcInfo[i].SetRect(0, 0, 0, 0);
}
CWindow *pWin = (CWindow*)g_pGUIManager->GetElement(HINT_WINDOW);
if(pWin)
{
pWin->MoveTo(0, 0);
}
int num = 0;
GStatic *pInfo = (GStatic*)g_pGUIManager->GetElement(HINT_INFO1);
if(pInfo)
{
if(pCaption!=NULL && pCaption[0]!=0)
{
pInfo->SetCaption(pCaption);
pInfo->SetColor(m_ColorStatic[0]);
m_AlphaStatic = (unsigned char)(m_ColorStatic[0]>>24);
m_rcInfo[0] = pInfo->GetFontRect();
pInfo->MoveTo(10, 8);
num++;
}
else
{
pInfo->SetCaption("");
}
}
MLStatic *pMLS = (MLStatic*)g_pGUIManager->GetElement(HINT_INFO2);
if(pMLS)
{
if(pMain!=NULL && pMain[0]!=0)
{
pMLS->SetCaption(pMain);
pMLS->SetColor(m_ColorStatic[1]);
m_rcInfo[1] = pMLS->GetFontRect();
int height;
if(num==1) height = 8+m_rcInfo[0].Height()+4;
else height = 8;
pMLS->MoveTo(10, height);
num++;
}
else
{
pMLS->SetCaption("");
}
}
pInfo = (GStatic*)g_pGUIManager->GetElement(HINT_INFO3);
if(pInfo)
{
if(pAppend!=NULL && pAppend[0]!=0)
{
pInfo->SetCaption(pAppend);
pInfo->SetColor(m_ColorStatic[2]);
m_rcInfo[2] = pInfo->GetFontRect();
int height;
if(num) height = 8+m_rcInfo[0].Height()+m_rcInfo[1].Height()+4*num;
else height = 8;
pInfo->MoveTo(10, height);
num++;
}
else
{
pInfo->SetCaption("");
}
}
if(num==0) return;
m_ControlID = infoID;
int x = g_stInputInfo.point.x+10;
int y = g_stInputInfo.point.y+10;
int temp = m_rcInfo[0].Width()>m_rcInfo[1].Width()?m_rcInfo[0].Width():m_rcInfo[1].Width();
int WinWidth = temp>m_rcInfo[2].Width()?temp:m_rcInfo[2].Width();
pWin->SetWidth(WinWidth+10*2);
pWin->SetHeight(m_rcInfo[0].Height()+m_rcInfo[1].Height()+m_rcInfo[2].Height()+8*2+(num-1)*4);
if(x+pWin->GetWidth()>800)
{
x = 800-pWin->GetWidth();
}
if(y+pWin->GetHeight()>550)
{
y = 550-pWin->GetHeight();
}
if(x<0)
{
x = 0;
}
if(y<0)
{
y = 0;
}
pWin->MoveTo(x, y);
pWin->SetColor(m_ColorWindow);
m_AlphaWindow = (unsigned char)(m_ColorWindow>>24);
pWin->Show();
m_Mode = 0;
// GUI消息有点问题,暂时不处理.
}
void CInfoPanel::FadeOut(DWORD LostFocusID)
{
if(m_ControlID == LostFocusID)
m_Mode = 1;
// m_AlphaStatic = (unsigned char)(m_ColorStatic[0]>>24);
// m_AlphaWindow = (unsigned char)(m_ColorWindow>>24);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -