📄 brewhallcanvas2.cpp
字号:
// BrewHallCanvas2.cpp: implementation of the CBrewHallCanvas2 class.
//
//////////////////////////////////////////////////////////////////////
#include "BrewHallCanvas2.h"
#include "brewlogin.h"
#include "gamevv_res.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CBrewHallCanvas2::CBrewHallCanvas2()
{
m_bDisconnect = false;
m_bHideCursor = m_bBottomBar = m_bTopBar = false;
m_nTotalTables = 19;
m_nTableHeight = 60;
m_nTabsPerLine = 2;
m_nTableWidth = 60;
m_sonMenu = m_subMenu = NULL;
userinfo = NULL;
m_pGs = NULL;
m_pHelp = NULL;
m_pAbout = NULL;
m_nx = m_ny = 0;
m_nFlag = 0;
//m_bWelcome = false;
m_pWelcome = new AECHAR[80];
MEMSET(m_pWelcome,0,80*2);
m_nBGID = IDB_BG_HALL; //要画大厅背景
m_bRedraw = 2;
m_bSaveBK = true;
}
void CBrewHallCanvas2::setFrame(void *f)
{
frame = (CBrewHall*)f;
m_pShell = frame->frame->getCurrentShell();
m_offsetX = frame->frame->getScreenOffsetX();
m_offsetY = frame->frame->getScreenOffsetY();
m_pdi = frame->frame->getDeviceInfo();
m_nTotalTables = frame->m_pCurrentRoom->roomItem.tableNum;
UINT32 n32 = frame->frame->getCommonParam();
m_bWelcome = ((n32 & PERSIST_NOTSHOWDATING) == 0);
if((n32 & PERSIST_NOTSHOWHELP) == 0)
{
m_pGuide = new COpGuide;
m_pGuide->m_bFullScr = false;
m_pGuide->setFrame(frame);
}
if(m_pMouse == NULL)
{
m_pMouse = ISHELL_LoadResBitmap(m_pShell,GAMEVV_RES_FILE,IDB_MOUSE);
//m_pMouse = ISHELL_LoadBitmap(m_pShell,"res\\IDB_RECORD.png");
}
//m_bWelcome = true;
struct UserItemStruct *item = frame->m_pUList;
AECHAR tmp[sizeof(item->userItem.nickName)];
int j;
for (j = 0; j < item->userItem.nickNameLength / 2; j ++)
tmp[j] = NTOHS(*(UINT16 *)&(item->userItem.nickName[j * 2]));
tmp[j] = 0;
//char tmp3[10];
// AECHAR tmp4[10];
// MEMSET(tmp3,0,10);
// STRCPY(tmp3,"欢迎");
// for (j = 0; j < sizeof tmp3 / 2; j ++)
// tmp4[j] = NTOHS(*(UINT16 *)&(tmp3[j * 2]));
//MEMCPY(&me,item,sizeof(struct UserItemStruct));
MEMSET(m_pWelcome,0,80*2);
//WSTRCPY(m_pWelcome,tmp4);
WSTRCPY(m_pWelcome,GetDispText(IDS_HALL_WELCOME));
WSTRCAT(m_pWelcome,tmp);
WSTRCAT(m_pWelcome,GetDispText(IDS_HALL_WELCOME2));
}
CBrewHallCanvas2::~CBrewHallCanvas2()
{
RELEASEIF(m_pMouse,IBITMAP);
RELEASEIF(m_pTable,IBITMAP);
RELEASEIF(m_pFemale,IBITMAP);
RELEASEIF(m_pMale,IBITMAP);
RELEASEIF(m_subMenu,IMENUCTL);
RELEASEIF(m_sonMenu,IMENUCTL);
RELEASE(userinfo);
userinfo = NULL;
RELEASE(m_pGs);
RELEASE(m_pHelp);
RELEASE(m_pAbout);
RELEASE(m_pGuide);
if(m_pWelcome != NULL)
delete m_pWelcome;
}
void CBrewHallCanvas2::paint(IDisplay *d, IGraphics *g)
{
CBrewLoginCanvasBase* p = GetSomeCanvas();
if(p != NULL)
{
if(p == m_pGuide)
CBrewLoginCanvasBase::paint(d,g);
else
RELEASEIF(m_pBkgrd,IBITMAP);
p->paint(d,g);
IDISPLAY_Update(d);
m_bRedraw = 2;
return;
}
int nID = m_nBGID;
if(m_bRedraw)
{
RELEASEIF(m_pBkgrd,IBITMAP);
}
else
{
m_nBGID = 0; //为了不画背景
}
CBrewLoginCanvasBase::paint(d,g);
m_nBGID = nID;
if(m_bRedraw)
{
AEERect rt;
int i;
for(i = 0; i < m_nTotalTables; i++)
{
GetTextRect(i,rt);
if(rt.y+rt.dy < m_nNowTop || rt.y> m_nNowTop + m_rtMain.dy)
continue;
rt.y -= m_nNowTop-m_rtMain.y;
rt.x -= m_nNowLeft-m_rtMain.x;
int n1 = m_nTableWidth;
int n2 = m_nTableHeight;
if(rt.x+m_nTableWidth > m_cxScreen+m_rtMain.x)
n1 = m_cxScreen + m_rtMain.x - rt.x;
if(rt.y+m_nTableHeight > m_cyScreen+m_rtMain.y)
n2 = m_cyScreen + m_rtMain.y - rt.y;
int n3 = 0;
if(m_rtMain.x > rt.x)
n3 = m_rtMain.x - rt.x;
int n4 = 0;
if(m_rtMain.y > rt.y)
n4 = m_rtMain.y - rt.y;
//IDISPLAY_BitBlt(d, MAX(m_rtMain.x,rt.x) , MAX(m_rtMain.y,rt.y),
// n1,n2,(void*)m_pTable,
// n3,
// n4,AEE_RO_TRANSPARENT );
IBITMAP_BltIn(m_pBkgrd, MAX(m_rtMain.x,rt.x) , MAX(m_rtMain.y,rt.y),
n1,n2,m_pTable,
n3,
n4,AEE_RO_TRANSPARENT );
int j;
struct SeatItemStruct* cItem;
for (j = 0; j < frame->m_pCurrentRoom->roomItem.seatNumPerTable; j ++)
{
cItem = frame->findSeatItem(i + 1, j + 1);
if (cItem == NULL || cItem->seatItem.state == 0)
continue;
int8 ntmp = 0;
if(cItem->seatItem.seatId == 1)
{
ntmp = 1;
}
IBitmap* pbmp;
if(cItem->seatItem.isMale)
pbmp = m_pMale;
else
pbmp = m_pFemale;
int nowy = rt.y;
if(nowy < m_rtInfo.y)
nowy = m_rtInfo.y;
//IDISPLAY_BitBlt(d, rt.x + ntmp * m_nTableWidth / 2, nowy,
// m_nTableWidth/2, m_nTableHeight,(void*)pbmp,ntmp*m_nTableWidth/2,nowy - rt.y,AEE_RO_TRANSPARENT );
IBITMAP_BltIn(m_pBkgrd, rt.x + ntmp * m_nTableWidth / 2, nowy,
m_nTableWidth/2, m_nTableHeight,pbmp,ntmp*m_nTableWidth/2,nowy - rt.y,AEE_RO_TRANSPARENT );
}
}
/*
int nSeat,nTable;
AEERect rttable,rtseat;
GetCurTableIDandSeat(&nTable,&nSeat,&rttable,&rtseat);
rttable.x -= m_offsetX;
rttable.y -= m_offsetY;
rtseat.x -= m_offsetX;
rtseat.y -= m_offsetY;
*/
m_bRedraw = 0;
}
IDISPLAY_BitBlt(d, m_rtMain.x , m_rtMain.y,
m_rtMain.dx, m_rtMain.dy,(void*)m_pBkgrd,m_rtMain.x,m_rtMain.y,AEE_RO_COPY);
//if(m_bRedraw)
{
AEERect rt;
AECHAR buf[10];
char buf2[10];
int i;
for(i = 0; i < m_nTotalTables; i++)
{
GetTextRect(i,rt);
if(rt.y+rt.dy < m_nNowTop || rt.y> m_nNowTop + m_rtMain.dy)
continue;
rt.y -= m_nNowTop-m_rtMain.y;
rt.x -= m_nNowLeft-m_rtMain.x;
SPRINTF(buf2,"%i",i+1);
MEMSET(buf,0,sizeof(buf));
STRTOWSTR(buf2,buf,sizeof(buf));
if( MAX(m_rtMain.y,rt.y+m_nTableHeight) == rt.y+m_nTableHeight)
IDISPLAY_DrawText( d, AEE_FONT_BOLD, buf, -1,
rt.x, rt.y,
&rt, IDF_ALIGN_BOTTOM| IDF_ALIGN_CENTER | IDF_TEXT_TRANSPARENT);
}
}
if(m_pMouse != NULL && !m_bHideCursor)
{
AEEBitmapInfo bi;
IBITMAP_GetInfo(m_pMouse, &bi, sizeof(bi));
IDISPLAY_BitBlt(d, m_nx , m_ny,
m_nx+bi.cx, m_ny+bi.cy,(void*)m_pMouse,0,0,AEE_RO_TRANSPARENT );
//IBITMAP_BltIn(m_pBkgrd, m_nx , m_ny,
// m_nx+bi.cx, m_ny+bi.cy,m_pMouse,0,0,AEE_RO_TRANSPARENT );
}
if(userinfo == NULL && frame->m_nHallState == HALL_READY_QUERY)
{
m_bHideCursor = false;
frame->frame->showHint(NULL,0,HINT_BOTTOM);
struct UserItemStruct *item = frame->m_pUList;
int nt,ns;
AEERect rt1,rt2;
GetCurTableIDandSeat(&nt,&ns,&rt1,&rt2);
//while(item)
// {
// if(item->userItem.tableId == nt && item->userItem.seatId == ns)
// break;
// item = item->userNext;
// } 不能这样因为用户游戏后返回大厅,它的tableid和seatid没有清掉
if(item != NULL)
item = frame->m_pUList->userNext;//第二个总是刚查到的用户
if(item)
{
userinfo = new CUserInfoDlg(item);
if(userinfo)
{
userinfo->setFrame(this);
}
else
frame->m_nHallState = HALL_CHOOSE_SEAT; //显示对话框失败
}
else
frame->m_nHallState = HALL_CHOOSE_SEAT; //显示对话框失败
}
if(m_subMenu != NULL)
IMENUCTL_Redraw(m_subMenu);
if(m_sonMenu != NULL)
IMENUCTL_Redraw(m_sonMenu);
if(userinfo != NULL)
userinfo->paint(d,g);
if(userinfo == NULL && m_subMenu == NULL &&
m_sonMenu == NULL && !m_bHideCursor)
DrawFlag(g);
IDISPLAY_Update(d);
}
boolean CBrewHallCanvas2::key(UINT16 code, UINT32 param)
{
if(m_bHideCursor && code != AVK_CLR)
return false;
boolean b = false;
CBrewLoginCanvasBase* p = GetSomeCanvas();
if(p != NULL)
{
if(p->key(code,param))
{
p->Release();
SetNull(p);
}
return true;
}
if(userinfo != NULL)
{
if(userinfo->key(code,param))
{
userinfo->Release();
userinfo = NULL;
frame->m_nHallState = HALL_CHOOSE_SEAT;
}
return true;
}
if(m_subMenu != NULL)
{
if(code == AVK_CLR || code == AVK_SOFT1 || code == AVK_STAR)
{
RELEASEIF(m_subMenu,IMENUCTL);
}
else
{
//IMENUCTL_HandleEvent(m_subMenu,EVT_KEY,code,param);
onEvent(EVT_COMMAND,IMENUCTL_GetSel(m_subMenu),0);
}
return true;
}
if(m_sonMenu != NULL)
{
if(code == AVK_CLR)
{
RELEASEIF(m_sonMenu,IMENUCTL);
}
else
IMENUCTL_HandleEvent(m_sonMenu,EVT_KEY,code,param);
return true;
}
int npace = 10;
switch(code)
{
case AVK_SELECT:
{
if(m_bDisconnect)
{
AECHAR* p = GetDispText(IDS_MSG_DISABLE);
int i;
for (i = 0; i < WSTRLEN(p); i ++)
if(p[i] == '`')
p[i] = '\n';
frame->frame->postMessage(p,IDS_MSG_DISABLE,MESSAGE_INFO_COLOR,0
,MESSAGE_YES|MESSAGE_TEXT_CENTER);
break;
}
int nt,ns;
AEERect rt1,rt2;
GetCurTableIDandSeat(&nt,&ns,&rt1,&rt2);
if(ns != 0)
{
struct SeatItemStruct* cItem;
cItem = frame->findSeatItem(nt, ns);
if(cItem == NULL)
break;
if(cItem->seatItem.state == 0) //位置空
{
frame->m_nCurrentTableId = nt;
frame->m_nCurrentSeatId = ns;
frame->m_nHallState = HALL_TEST_SITDOWN;
m_bHideCursor = true;
frame->frame->showHint(GetDispText(IDS_MSG_SITTING),0,HINT_BOTTOM);
}
else
{
frame->m_nCurrentTableId = nt;
frame->m_nCurrentSeatId = ns;
frame->m_nHallState = HALL_TEST_QUERY;
m_IsMale = cItem->seatItem.isMale;
m_bHideCursor = true;
frame->frame->showHint(GetDispText(IDS_MSG_QUERYING),0,HINT_BOTTOM);
}
}
break;
}
case AVK_LEFT:
{
m_nx -= npace;
if(m_nx < m_rtMain.x)
{
m_nNowLeft = MAX(m_rtMain.x,m_nNowLeft-npace);
Invalidate();
}
break;
}
case AVK_RIGHT:
{
m_nx += npace;
if(m_rtMain.dx >= m_nTableWidth*m_nTabsPerLine)
break;
if(m_nx > m_rtMain.x + m_rtMain.dx)
{
m_nNowLeft += m_nx - (m_rtMain.x + m_rtMain.dx);
Invalidate();
}
EnsureMouse();
if(m_nNowLeft + m_nx - 2*m_rtMain.x > m_nTableWidth * m_nTabsPerLine)
{
m_nNowLeft = m_nTableWidth * m_nTabsPerLine - m_nx + 2*m_rtMain.x;
Invalidate();
}
break;
}
case AVK_UP:
{
m_ny -= npace;
if(m_ny < m_rtMain.y)
{
m_nNowTop = MAX(m_rtMain.y,m_nNowTop-npace);
Invalidate();
}
break;
}
case AVK_DOWN:
{
m_ny += npace;
//int n1 = m_nHeight-m_ny+m_rtMain.y;
//int n2 = m_nNowTop+npace;
if((m_ny > m_rtMain.y + m_rtMain.dy))// && (m_nNowTop + m_ny - m_rtMain.y < m_nHeight))
{
m_nNowTop += m_ny - (m_rtMain.y + m_rtMain.dy) ;//MIN(n1,n2);
Invalidate();
}
EnsureMouse();
if(m_nNowTop + m_ny - 2*m_rtMain.y > m_nHeight)
{
m_nNowTop = m_nHeight - m_ny + 2*m_rtMain.y;
Invalidate();
}
break;
}
case AVK_SOFT1:
case AVK_STAR:
{
if(m_subMenu == NULL)
CreateMenu();
break;
}
case AVK_CLR:
{
if(m_bDisconnect)
onEvent(EVT_COMMAND,IDS_MENU_EXITGAME,0);
else
onEvent(EVT_COMMAND,IDS_MENU_BACKTOLIST, 0);
b = true;
}
}
EnsureMouse();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -