diff --git a/CPreGame.cpp b/CPreGame.cpp index 586516124..d1ab0c4d1 100644 --- a/CPreGame.cpp +++ b/CPreGame.cpp @@ -35,8 +35,8 @@ void CPreGame::initMainMenu() ourMainMenu->highScores = slh->giveDef("ZMENUHS.DEF"); ourMainMenu->credits = slh->giveDef("ZMENUCR.DEF"); ourMainMenu->quit = slh->giveDef("ZMENUQT.DEF"); - ourMainMenu->ok = slh->giveDef("IOKAY.DEF"); - ourMainMenu->cancel = slh->giveDef("ICANCEL.DEF"); + ok = slh->giveDef("IOKAY.DEF"); + cancel = slh->giveDef("ICANCEL.DEF"); // new game button location ourMainMenu->lNewGame.h=ourMainMenu->newGame->ourImages[0].bitmap->h; ourMainMenu->lNewGame.w=ourMainMenu->newGame->ourImages[0].bitmap->w; @@ -128,8 +128,8 @@ void CPreGame::showAskBox (std::string data, void(*f1)(),void(*f2)()) CMessage * cmh = new CMessage(); std::vector * przyciski = new std::vector(0); std::vector * btnspos= new std::vector(0); - przyciski->push_back(ourMainMenu->ok); - przyciski->push_back(ourMainMenu->cancel); + przyciski->push_back(ok); + przyciski->push_back(cancel); SDL_Surface * infoBox = cmh->genMessage(preth->getTitle(data), preth->getDescr(data), EWindowType::yesOrNO, przyciski, btnspos); behindCurMes = SDL_CreateRGBSurface(ekran->flags,infoBox->w,infoBox->h,ekran->format->BitsPerPixel,ekran->format->Rmask,ekran->format->Gmask,ekran->format->Bmask,ekran->format->Amask); SDL_Rect pos = genRect(infoBox->h,infoBox->w, @@ -143,8 +143,8 @@ void CPreGame::showAskBox (std::string data, void(*f1)(),void(*f2)()) (*btnspos)[0].y+=pos.y; (*btnspos)[1].x+=pos.x; (*btnspos)[1].y+=pos.y; - btns.push_back(Button(1,(*btnspos)[0],&CPreGame::quit,ourMainMenu->ok)); - btns.push_back(Button(2,(*btnspos)[1],(&CPreGame::hideBox),ourMainMenu->cancel)); + btns.push_back(Button<>(1,(*btnspos)[0],&CPreGame::quit,ok)); + btns.push_back(Button<>(2,(*btnspos)[1],(&CPreGame::hideBox),cancel)); delete cmh; delete przyciski; delete btnspos; @@ -173,6 +173,7 @@ void CPreGame::runLoop() return ; else if (sEvent.type==SDL_MOUSEMOTION) { + if (currentMessage) continue; if (ourMainMenu->highlighted) { switch (ourMainMenu->highlighted) @@ -270,6 +271,7 @@ void CPreGame::runLoop() updateRect(&btns[i].pos); } } + if (currentMessage) continue; if (isItIn(&ourMainMenu->lNewGame,sEvent.motion.x,sEvent.motion.y)) { highlightButton(1,1); @@ -308,6 +310,7 @@ void CPreGame::runLoop() updateRect(&btns[i].pos); } } + if (currentMessage) continue; if (isItIn(&ourMainMenu->lNewGame,sEvent.motion.x,sEvent.motion.y)) { highlightButton(1,2); @@ -337,6 +340,7 @@ void CPreGame::runLoop() } else if ((sEvent.type==SDL_MOUSEBUTTONDOWN) && (sEvent.button.button == SDL_BUTTON_RIGHT)) { + if (currentMessage) continue; if (isItIn(&ourMainMenu->lNewGame,sEvent.motion.x,sEvent.motion.y)) { showCenBox(preth->mainNewGame); diff --git a/CPreGame.h b/CPreGame.h index 622ae297b..22d2b68b5 100644 --- a/CPreGame.h +++ b/CPreGame.h @@ -4,28 +4,30 @@ #include "CPreGameTextHandler.h" class CPreGame; extern CPreGame * CPG; -struct Button +typedef void(CPreGame::*ttt)(); +template struct Button { int type; // 1=yes; 2=no SDL_Rect pos; - (void)(CPreGame::*fun)(); + T fun; CSemiDefHandler* imgs; - Button(int Type, SDL_Rect Pos, void(CPreGame::*Fun)(),CSemiDefHandler* Imgs):imgs(Imgs),type(Type),pos(Pos),fun(Fun){}; + Button(int Type, SDL_Rect Pos, T Fun,CSemiDefHandler* Imgs):imgs(Imgs),type(Type),pos(Pos),fun(Fun){}; Button(){}; }; class CPreGame { public: - std::vector