📄 userinfodlg.cpp
字号:
// UserInfoDlg.cpp: implementation of the CUserInfoDlg class.
//
//////////////////////////////////////////////////////////////////////
#include "UserInfoDlg.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CUserInfoDlg::CUserInfoDlg(struct UserItemStruct *item,boolean bDestroy)
{
m_bDestroy = bDestroy;
m_nforangle = 0;
m_bTopBar = m_bBottomBar = false;
m_useritem = item;
m_bMul = false;
m_nTotalLine = 1;
m_pDlg = NULL;
if(item->userNext != NULL)
{
m_bMul = true;
while(item->userNext != NULL)
{
m_nTotalLine++;
item = item->userNext;
}
m_nTotalLine++;
}
else
m_nTotalLine = 14 + 2;
}
CUserInfoDlg::~CUserInfoDlg()
{
RELEASEIF(m_pmale,IBITMAP);
RELEASEIF(m_pfemale,IBITMAP);
if(m_pDlg != NULL)
m_pDlg->Release();
if(m_bDestroy)
{
struct UserItemStruct* tmp;
while(m_useritem)
{
tmp = m_useritem->userNext;
FREEIF(m_useritem);
m_useritem = tmp;
}
}
}
void CUserInfoDlg::setFrame(void *f)
{
CBrewLoginCanvasBase* lb = (CBrewLoginCanvasBase*)f;
m_pShell = lb->m_pShell;
m_offsetX = lb->m_offsetX;
m_offsetY = lb->m_offsetY;
m_pdi = lb->m_pdi;
m_pmale = ISHELL_LoadResBitmap(m_pShell,GAMEVV_RES_FILE,IDB_MALEHEAD);
m_pfemale = ISHELL_LoadResBitmap(m_pShell,GAMEVV_RES_FILE,IDB_FEMALEHEAD);
IBitmap* bmp = ISHELL_LoadResBitmap(m_pShell,GAMEVV_RES_FILE,IDB_MAIN_BARROW);
if(bmp != NULL)
{
AEEBitmapInfo bi;
IBITMAP_GetInfo(bmp, &bi, sizeof(bi));
SETAEERECT(&m_rtArrow,0,0,bi.cx,bi.cy);
RELEASEIF(bmp,IBITMAP);
}
else
SETAEERECT(&m_rtArrow,0,0,0,0);
}
void CUserInfoDlg::paint(IDisplay *d, IGraphics *g)
{
CBrewLoginCanvasBase::paint(d,g);
if(m_pDlg != NULL)
{
m_pDlg->paint(d,g);
return;
}
if(!m_bMul)
m_nCurrent = -1;
IDISPLAY_SetColor(d ,CLR_USER_TEXT, RGB_WHITE);
IDISPLAY_SetColor(d,CLR_USER_BACKGROUND, RGB_BLACK);
DrawExtroInfo(g);
int i = 0;
AEERect rt;
AECHAR buf[100];
char buf2[10];
AECHAR buf3[10],buf4[10];
AECHAR tmp[sizeof(m_useritem->userItem.nickName)];
struct UserItemStruct* item = m_useritem;
for(i = 0; i < m_nTotalLine; i++)
{
if(GetLineRect(i,rt) != -1)
{
if(m_bMul)
{
if(i == m_nCurrent)
//IDISPLAY_FillRect(d,&rt,MAKE_RGB(255,0,255));
{
IDISPLAY_FillRect(d,&rt,MAKE_RGB(255,255,255));
IDISPLAY_SetColor(d ,CLR_USER_TEXT, RGB_BLACK);
IDISPLAY_SetColor(d,CLR_USER_BACKGROUND, RGB_WHITE);
}
if(item != NULL)
{
//WSTRCPY(buf,GetDispText(IDS_UINFO_PLAYER));
SPRINTF(buf2,"%i",i+1);
STRTOWSTR(buf2,buf3,sizeof(buf2));
WSTRCPY(buf,buf3);
WSTRCAT(buf,GetDispText(IDS_LOGIN_POINT));
STRCPY(buf2," ");
STRTOWSTR(buf2,buf3,sizeof(buf2));
WSTRCAT(buf,buf3);
int j;
for (j = 0; j < item->userItem.nickNameLength / 2; j ++)
tmp[j] = NTOHS(*(UINT16 *)&(item->userItem.nickName[j * 2]));
tmp[j] = 0;
WSTRCAT(buf,tmp);
}
else
WSTRCPY(buf,GetDispText(IDS_UINFO_BACK));
if(WSTRLEN(buf) > 0)
IDISPLAY_DrawText( d, AEE_FONT_NORMAL, buf, -1,
rt.x, rt.y,
&rt, IDF_ALIGN_MIDDLE| (item != NULL?IDF_ALIGN_LEFT:IDF_ALIGN_CENTER));
if(i == m_nCurrent)
{
IDISPLAY_SetColor(d ,CLR_USER_TEXT, RGB_WHITE);
IDISPLAY_SetColor(d,CLR_USER_BACKGROUND, RGB_BLACK);
}
if(item != NULL)
item = item->userNext;
}
else
{
SPRINTF(buf2,"%i",i+1);
MEMSET(buf3,0,sizeof(buf3));
STRTOWSTR(buf2,buf3,sizeof(buf2));
AEEBitmapInfo bi;
MEMSET(buf,0,sizeof(buf));
switch(i-2) //留两行放头像
{
case -2:
{
if(!m_bMul && m_pfemale && m_pmale)
{
NativeColor color;
IBITMAP_GetInfo(m_pfemale, &bi, sizeof(bi));
color = IBITMAP_RGBToNative(m_pmale, MAKE_RGB(255,0,255));
IBITMAP_SetTransparencyColor(m_pmale, color);
IBITMAP_SetTransparencyColor(m_pfemale, color);
rt.dy *= 2;
AEERect rtout,rtsmall;
SETAEERECT(&rtsmall,0,0,bi.cx,bi.cy);
GetFitRect(&rt,&rtsmall,&rtout,IDF_ALIGN_CENTER|IDF_ALIGN_MIDDLE);
IBitmap* p = m_pmale;
if((m_useritem->userItem.userInfo & 0x10) == 0)
p = m_pfemale;
//if(m_useritem->userItem.)
IDISPLAY_FillRect(d,&rtout,MAKE_RGB(255,255,255));
IDISPLAY_BitBlt(d, rtout.x , rtout.y,
rtout.dx, rtout.dy,(void*)p,0,0,AEE_RO_TRANSPARENT );
break;
}
}
case 0:
{
WSTRCPY(buf,GetDispText(IDS_UINFO_USER));
int j;
for (j = 0; j < m_useritem->userItem.userNameLength / 2; j ++)
tmp[j] = NTOHS(*(UINT16 *)&(m_useritem->userItem.userName[j * 2]));
tmp[j] = 0;
WSTRCAT(buf,tmp);
//WSTRCAT(buf,buf3);
break;
}
case 1:
{
WSTRCPY(buf,GetDispText(IDS_UINFO_NICK));
int j;
for (j = 0; j < m_useritem->userItem.nickNameLength / 2; j ++)
tmp[j] = NTOHS(*(UINT16 *)&(m_useritem->userItem.nickName[j * 2]));
tmp[j] = 0;
WSTRCAT(buf,tmp);
//WSTRCAT(buf,buf3);
break;
}
case 2:
{
WSTRCPY(buf,GetDispText(IDS_UINFO_LEVEL));
int j;
for (j = 0; j < m_useritem->userItem.lvNameLength / 2; j ++)
tmp[j] = NTOHS(*(UINT16 *)&(m_useritem->userItem.lvName[j * 2]));
tmp[j] = 0;
WSTRCAT(buf,tmp);
break;
}
case 3:
{
WSTRCPY(buf,GetDispText(IDS_UINFO_TITLE));
int j;
for (j = 0; j < m_useritem->userItem.rankNameLength / 2; j ++)
tmp[j] = NTOHS(*(UINT16 *)&(m_useritem->userItem.rankName[j * 2]));
tmp[j] = 0;
WSTRCAT(buf,tmp);
break;
}
case 4:
{
WSTRCPY(buf,GetDispText(IDS_UINFO_SCORE));
SPRINTF(buf2,"%i",m_useritem->userItem.totalPointHigh);
MEMSET(buf3,0,sizeof(buf3));
STRTOWSTR(buf2,buf3,sizeof(buf2));
WSTRCAT(buf,buf3);
break;
}
case 5:
{
WSTRCPY(buf,GetDispText(IDS_UINFO_MONEY));
SPRINTF(buf2,"%i",m_useritem->userItem.moneyHigh);
MEMSET(buf3,0,sizeof(buf3));
STRTOWSTR(buf2,buf3,sizeof(buf2));
WSTRCAT(buf,buf3);
break;
}
case 6:
{
WSTRCPY(buf,GetDispText(IDS_UINFO_EXP));
SPRINTF(buf2,"%i",m_useritem->userItem.exp);
MEMSET(buf3,0,sizeof(buf3));
STRTOWSTR(buf2,buf3,sizeof(buf2));
WSTRCAT(buf,buf3);
break;
}
case 7:
{
WSTRCPY(buf,GetDispText(IDS_UINFO_TOTAL));
SPRINTF(buf2,"%i",m_useritem->userItem.fleeCount+
m_useritem->userItem.winCount+m_useritem->userItem.loseCount+
m_useritem->userItem.drawCount);
MEMSET(buf3,0,sizeof(buf3));
STRTOWSTR(buf2,buf3,sizeof(buf2));
WSTRCAT(buf,buf3);
break;
}
case 8:
{
WSTRCPY(buf,GetDispText(IDS_UINFO_WIN));
SPRINTF(buf2,"%i",m_useritem->userItem.winCount);
MEMSET(buf3,0,sizeof(buf3));
STRTOWSTR(buf2,buf3,sizeof(buf2));
WSTRCAT(buf,buf3);
break;
}
case 9:
{
WSTRCPY(buf,GetDispText(IDS_UINFO_LOSE));
SPRINTF(buf2,"%i",m_useritem->userItem.loseCount);
MEMSET(buf3,0,sizeof(buf3));
STRTOWSTR(buf2,buf3,sizeof(buf2));
WSTRCAT(buf,buf3);
break;
}
case 10:
{
WSTRCPY(buf,GetDispText(IDS_UINFO_DRAW));
SPRINTF(buf2,"%i",m_useritem->userItem.drawCount);
MEMSET(buf3,0,sizeof(buf3));
STRTOWSTR(buf2,buf3,sizeof(buf2));
WSTRCAT(buf,buf3);
break;
}
case 11:
{
WSTRCPY(buf,GetDispText(IDS_UINFO_WINPER));
int n = m_useritem->userItem.fleeCount+
m_useritem->userItem.winCount+m_useritem->userItem.loseCount+
m_useritem->userItem.drawCount;
if(n != 0)
n = m_useritem->userItem.winCount * 1000 / n;
SPRINTF(buf2,"%i",n);
MEMSET(buf3,0,sizeof(buf3));
STRTOWSTR(buf2,buf3,sizeof(buf2));
int k;
int l = 0;
if(n != 0)
{ for(k = 0; k < WSTRLEN(buf3); k++)
{
if(k == WSTRLEN(buf3)-1 && k == l)
{
buf4[l++] = 46; //46是.
k--;
}
else
{
buf4[l++] = buf3[k];
}
}
buf4[l] = 0;
WSTRCAT(buf,buf4);
}
else
WSTRCAT(buf,buf3);
if(n != 0)
WSTRCAT(buf,GetDispText(IDS_UINFO_PER));
break;
}
case 12:
{
WSTRCPY(buf,GetDispText(IDS_UINFO_FLEEPER));
int n = m_useritem->userItem.fleeCount+
m_useritem->userItem.winCount+m_useritem->userItem.loseCount+
m_useritem->userItem.drawCount;
if(n != 0)
n = m_useritem->userItem.fleeCount * 1000 / n;
SPRINTF(buf2,"%i",n);
MEMSET(buf3,0,sizeof(buf3));
STRTOWSTR(buf2,buf3,sizeof(buf2));
int k;
int l = 0;
if(n != 0)
{ for(k = 0; k < WSTRLEN(buf3); k++)
{
if(k == WSTRLEN(buf3)-1 && k == l)
{
buf4[l++] = 46; //46是.
k--;
}
else
{
buf4[l++] = buf3[k];
}
}
buf4[l] = 0;
WSTRCAT(buf,buf4);
}
else
WSTRCAT(buf,buf3);
if(n != 0)
WSTRCAT(buf,GetDispText(IDS_UINFO_PER));
break;
}
case 13:
{
WSTRCPY(buf,GetDispText(IDS_UINFO_RANK));
break;
}
}
if(WSTRLEN(buf) > 0)
IDISPLAY_DrawText( d, m_nNowFont, buf, -1,
rt.x, rt.y,
&rt, IDF_ALIGN_MIDDLE| IDF_ALIGN_LEFT);
}
}
}
//DrawScrollBar();
IDISPLAY_SetColor(d ,CLR_USER_TEXT, RGB_BLACK);
IDISPLAY_SetColor(d,CLR_USER_BACKGROUND, RGB_WHITE);
}
void CUserInfoDlg::GetInfoRect()
{
AEERect rt;
GetMainRect(rt);
int k = m_bMul?1:2;
if(m_nTotalDisplayLine < m_nTotalLine)
rt.dx -= m_nVScrollBarWidth; //减去滚动条所占的区域
SETAEERECT(&m_rtInfo,rt.x,rt.y + m_nNowSize + m_nFontSpace,rt.dx,rt.dy - k*(m_nNowSize + m_nFontSpace));
}
boolean CUserInfoDlg::key(UINT16 code, UINT32 param)
{
if(m_pDlg != NULL)
{
if(m_pDlg->key(code,param))
{
m_pDlg->Release();
m_pDlg = NULL;
return false;
}
}
if(code == AVK_CLR)
return true;
if(m_bMul)
{
if(code == AVK_SELECT)
{
struct UserItemStruct* item = m_useritem;
int i = 0;
while(i++ != m_nCurrent && item != NULL)
item = item->userNext;
if(item != NULL)
{
struct UserItemStruct* newitem = (struct UserItemStruct* )MALLOC(sizeof(struct UserItemStruct));
MEMCPY(newitem,item,sizeof(struct UserItemStruct));
newitem->userNext = NULL;
m_pDlg = new CUserInfoDlg(newitem,true);
m_pDlg->setFrame(this);
}
else
return true;
}
CBrewLoginCanvasBase::key(code,param);
}
else
{
switch(code) {
case AVK_SELECT:
return true;
break;
case AVK_LEFT:
m_nFirstLine -= m_nTotalDisplayLine;
if(m_nFirstLine < 0)
m_nFirstLine = 0;
break;
case AVK_RIGHT:
if(m_nFirstLine > m_nTotalLine - 1)
m_nFirstLine = m_nTotalLine - m_nTotalDisplayLine;
else if(m_nFirstLine + m_nTotalDisplayLine < m_nTotalLine)
m_nFirstLine += m_nTotalDisplayLine;
break;
default:
break;
}
}
return false;
}
void CUserInfoDlg::SetDisplayInfo(IDisplay* d)
{
CBrewLoginCanvasBase::SetDisplayInfo(d);
}
void CUserInfoDlg::DrawExtroInfo(IGraphics* g)
{
AEERect rt,rtdraw,rtout;
GetMainRect(rt);
SETAEERECT(&rtout,rt.x-1,rt.y-1,rt.dx+2,rt.dy+2);
IDISPLAY_FillRect(m_pIDisplay,&rtout,MAKE_RGB(0,255,0));
IDISPLAY_FillRect(m_pIDisplay,&rt,MAKE_RGB(0,0,0));
SETAEERECT(&rtdraw,rt.x,rt.y,rt.dx,m_nNowSize + m_nFontSpace);
AECHAR ac[20];
MEMSET(ac,0,sizeof(ac));
WSTRCAT(ac,GetDispText(IDS_UINFO_TOP));
IDISPLAY_DrawText(m_pIDisplay,
AEE_FONT_BOLD,
ac,
-1,
0,
0,
&rtdraw,
IDF_ALIGN_CENTER | IDF_TEXT_TRANSPARENT | IDF_ALIGN_MIDDLE );
if(!m_bMul)
{
DrawSign(&rtdraw,g);
int n = m_nNowSize + m_nFontSpace;
SETAEERECT(&rtdraw,rt.x,rt.y+rt.dy - n,rt.dx,n);
IDISPLAY_DrawText(m_pIDisplay,
AEE_FONT_BOLD,
GetDispText(IDS_CMN_OKBACK),
-1,
0,
0,
&rtdraw,
IDF_ALIGN_CENTER | IDF_TEXT_TRANSPARENT | IDF_ALIGN_MIDDLE );
}
}
void CUserInfoDlg::GetMainRect(AEERect& rt)
{
CBrewLoginCanvasBase::GetMainRect(rt);
AEERect rttmp;
GetTopBarRect(rttmp); //去掉大厅消息所占区域
rt.y += rttmp.dy + 3;
rt.dy -= 2 * (rttmp.dy + 3);
rt.x += 6;
rt.dx -= 12;
}
void CUserInfoDlg::DrawSign(AEERect* prt,IGraphics* g)
{
AEERect rt1,rt2;
GetFitRect(prt,&m_rtArrow,&rt1,IDF_ALIGN_LEFT | IDF_ALIGN_MIDDLE);
GetFitRect(prt,&m_rtArrow,&rt2,IDF_ALIGN_RIGHT | IDF_ALIGN_MIDDLE);
rt1.x -= m_offsetX;
rt2.x -= m_offsetX;
rt1.y -= m_offsetY;
rt2.y -= m_offsetY;
rt1.x += 3;
rt2.x -= 3; //居中一点
boolean bb = IGRAPHICS_GetFillMode(g);
uint8 r,gg,b;
uint8 a;
IGRAPHICS_GetFillColor(g,&r,&gg,&b,&a);
AEETriangle Triangle;
int8 nn = 6;
IGRAPHICS_SetFillMode(g,true);
m_nforangle++;
m_nforangle %= nn;
if(m_nforangle < nn / 3)
IGRAPHICS_SetFillColor(g,255,0,0,255);
else if(m_nforangle < nn * 2 / 3)
IGRAPHICS_SetFillColor(g,0,255,0,255);
else if(m_nforangle < nn)
IGRAPHICS_SetFillColor(g,0,0,255,255);
//IGRAPHICS_SetFillColor(g,0,255,0,255);
IGRAPHICS_SetColor(g,255,255,255,255);
AEERect rt;
if(m_nFirstLine / m_nTotalDisplayLine > 0)
{
MEMCPY(&rt,&rt1,sizeof(AEERect));
Triangle.x0 = rt.x;
Triangle.y0 = rt.y + rt.dy / 2;
Triangle.x1 = rt.x + rt.dx;
Triangle.y1 = rt.y;
Triangle.x2 = rt.x + rt.dx;
Triangle.y2 = rt.y + rt.dy;
IGRAPHICS_DrawTriangle(g,&Triangle);
}
if(m_nFirstLine / m_nTotalDisplayLine + 1 <
m_nTotalLine / m_nTotalDisplayLine + ((m_nTotalLine % m_nTotalDisplayLine)?1:0))
{
MEMCPY(&rt,&rt2,sizeof(AEERect));
Triangle.x0 = rt.x;
Triangle.y0 = rt.y;
Triangle.x1 = rt.x + rt.dx;
Triangle.y1 = rt.y + rt.dy / 2;
Triangle.x2 = rt.x;
Triangle.y2 = rt.y + rt.dy;
IGRAPHICS_DrawTriangle(g,&Triangle);
}
IGRAPHICS_SetFillMode(g,bb);
IGRAPHICS_SetFillColor(g,r,gg,b,a);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -