// MenuGroup.cpp: implementation of the CMenuGroup class. // ////////////////////////////////////////////////////////////////////// #include "MenuGroup.h" ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CMenuGroup::CMenuGroup(){ /*ix=x; iy=y; icols=cols; irows=rows; uiImages=uiImgs; uiContent=uiCont; iLastClicked=1; (GameEngine::GetEngine()->GetMenuOpen())?bClosed=false:bClosed=true; bMouseDown=false; pElementMenus=new CElementMenu*[cols*rows+1]; pElementMenus[0]=new CElementMenu(uiImgs); pElementMenus[0]->SetPosition(x,y); pElementMenus[0]->SetContent(0); int nextX=x; int nextY=y+pElementMenus[0]->GetHeight(); for(int i=0;iSetPosition(nextX,nextY); nextY+=pElementMenus[i*rows+j+1]->GetHeight(); pElementMenus[i*rows+j+1]->SetContent(uiContent+i*rows+j); } nextX+=pElementMenus[i*rows+rows]->GetWidth(); nextY=y+pElementMenus[0]->GetHeight(); }*/ } CMenuGroup::~CMenuGroup() { delete[] pElementMenus; } void CMenuGroup::MouseButtonDown(int x, int y, BOOL bLeft){ //pElementMenus[0]->MouseButtonDown BOOL bDownInside=false; if(!bClosed){ for(int i=1;i<=icols*irows;i++){ pElementMenus[i]->MouseButtonDown(x,y,bLeft); if(!bDownInside){ bDownInside=pElementMenus[i]->JustDown(); } } bMouseDown=true; GameEngine::GetEngine()->SetManuMouseDown(true); } if(!bMouseDown){ pElementMenus[0]->MouseButtonDown(x,y,bLeft); if(pElementMenus[0]->JustDown()){ if(bClosed){ bClosed=false; GameEngine::GetEngine()->SetManuOpen(true); GameEngine::GetEngine()->WhoOpenedMenu(uiImages); } else{ bClosed=true; bMouseDown=false; GameEngine::GetEngine()->SetManuOpen(false); GameEngine::GetEngine()->SetManuMouseDown(false); MouseMove(x,y); } bDownInside=true; bMouseDown=true; GameEngine::GetEngine()->SetManuMouseDown(true); } } /* CHAR szText[64]; wsprintf(szText, "Time 2 show %d",GameEngine::GetEngine()->GetMenuMouseDown()); MessageBox(GameEngine::GetEngine()->GetWindow(), szText, TEXT("Brainiac"),MB_OK);*/ if(!bClosed &&!bDownInside) GameEngine::GetEngine()->SetManuOpen(false); if(!bDownInside){ bMouseDown=false; //GameEngine::GetEngine()->SetManuMouseDown(false); bClosed=true; MouseMove(x,y); } if(GameEngine::GetEngine()->WhoOpenedMenu()!=uiImages){ bClosed=true; MouseMove(x,y); bMouseDown=false; } } void CMenuGroup::MouseButtonUp(int x, int y, BOOL bLeft){ if(GameEngine::GetEngine()->WhoOpenedMenu()!=uiImages){ bClosed=true; bMouseDown=false; MouseMove(x,y); return; } if(!bClosed){ for(int i=1;i<=icols*irows;i++){ pElementMenus[i]->MouseButtonUp(x,y,bLeft); if(pElementMenus[i]->JustClicked()){ bMouseDown=false; GameEngine::GetEngine()->SetManuMouseDown(false); bClosed=true; MouseMove(x,y); //to update GameEngine::GetEngine()->SetManuOpen(false); pElementMenus[i]->NotNowClicked(); iLastClicked=i; } } bMouseDown=false; GameEngine::GetEngine()->SetManuMouseDown(false); } } void CMenuGroup::MouseMove(int x, int y){ if(bClosed){ pElementMenus[0]->MouseMove(x,y); if(GameEngine::GetEngine()->GetMenuOpen() && pElementMenus[0]->JustTouched()){ bClosed=false; GameEngine::GetEngine()->WhoOpenedMenu(uiImages); pElementMenus[0]->MouseButtonDown(x,y,true); if(GameEngine::GetEngine()->GetMenuMouseDown()){ /*TCHAR szText[64]; wsprintf(szText, "Time 2 show"); MessageBox(GameEngine::GetEngine()->GetWindow(), szText, TEXT("Brainiac"),MB_OK); */ bMouseDown=true; } } } else{ for(int i=1;i<=icols*irows;i++){ if(bMouseDown){ pElementMenus[i]->MouseButtonDown(x,y,true); } else pElementMenus[i]->MouseMove(x,y); } } if(GameEngine::GetEngine()->WhoOpenedMenu()!=uiImages){ bClosed=true; bMouseDown=false; return; } } void CMenuGroup::DrawScreen(HDC hDC){ pElementMenus[0]->DrawScreen(hDC); if(!bClosed){ for(int i=1;i<=icols*irows;i++){ pElementMenus[i]->DrawScreen(hDC); } } } void CMenuGroup::SetMenuGroup(int iRows, int iCols, int *szContent) { }