mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
Obsługa drugiej planszy menu (nowa gra), poprawki w kodzie, naprawa crashbuga wysypującego przy okienkach bez tytułów.
Potrzebne pliki wkrótce dośle na maila.
This commit is contained in:
parent
4b67e80055
commit
dfcfda764a
21
CMessage.cpp
21
CMessage.cpp
@ -110,22 +110,29 @@ SDL_Surface * CMessage::genMessage
|
|||||||
|
|
||||||
SDL_Surface * ret = drawBox1(ww,hh);
|
SDL_Surface * ret = drawBox1(ww,hh);
|
||||||
//prepare title text
|
//prepare title text
|
||||||
SDL_Surface * titleText = TTF_RenderText_Shaded(TNRB,title.c_str(),tytulowy,tlo);
|
|
||||||
//draw title
|
if (title.length())
|
||||||
SDL_Rect tytul = genRect(titleText->h,titleText->w,((ret->w/2)-(titleText->w/2)),37);
|
{
|
||||||
SDL_BlitSurface(titleText,NULL,ret,&tytul);
|
SDL_Surface * titleText = TTF_RenderText_Shaded(TNRB,title.c_str(),tytulowy,tlo);
|
||||||
SDL_FreeSurface(titleText);
|
//draw title
|
||||||
|
SDL_Rect tytul = genRect(titleText->h,titleText->w,((ret->w/2)-(titleText->w/2)),37);
|
||||||
|
SDL_BlitSurface(titleText,NULL,ret,&tytul);
|
||||||
|
SDL_FreeSurface(titleText);
|
||||||
|
}
|
||||||
//draw text
|
//draw text
|
||||||
for (int i=0; i<tekst->size(); i++)
|
for (int i=0; i<tekst->size(); i++)
|
||||||
{
|
{
|
||||||
|
int by = 37+i*21;
|
||||||
|
if (title.length()) by+=40;
|
||||||
SDL_Surface * tresc = TTF_RenderText_Shaded(TNRB,(*tekst)[i].c_str(),zwykly,tlo);
|
SDL_Surface * tresc = TTF_RenderText_Shaded(TNRB,(*tekst)[i].c_str(),zwykly,tlo);
|
||||||
SDL_Rect trescRect = genRect(tresc->h,tresc->w,((ret->w/2)-(tresc->w/2)),77+i*21);
|
SDL_Rect trescRect = genRect(tresc->h,tresc->w,((ret->w/2)-(tresc->w/2)),by);
|
||||||
SDL_BlitSurface(tresc,NULL,ret,&trescRect);
|
SDL_BlitSurface(tresc,NULL,ret,&trescRect);
|
||||||
SDL_FreeSurface(tresc);
|
SDL_FreeSurface(tresc);
|
||||||
}
|
}
|
||||||
if (type==EWindowType::yesOrNO) // add buttons
|
if (type==EWindowType::yesOrNO) // add buttons
|
||||||
{
|
{
|
||||||
int by = 40+77+tekst->size()*21;
|
int by = 77+tekst->size()*21;
|
||||||
|
if (title.length()) by+=40;
|
||||||
int hwo = (*addPics)[0]->ourImages[0].bitmap->w, hwc=(*addPics)[0]->ourImages[0].bitmap->w;
|
int hwo = (*addPics)[0]->ourImages[0].bitmap->w, hwc=(*addPics)[0]->ourImages[0].bitmap->w;
|
||||||
//ok
|
//ok
|
||||||
SDL_Rect trescRect = genRect((*addPics)[0]->ourImages[0].bitmap->h,hwo,((ret->w/2)-hwo-10),by);
|
SDL_Rect trescRect = genRect((*addPics)[0]->ourImages[0].bitmap->h,hwo,((ret->w/2)-hwo-10),by);
|
||||||
|
283
CPreGame.cpp
283
CPreGame.cpp
@ -20,9 +20,66 @@ CPreGame::CPreGame()
|
|||||||
currentMessage=NULL;
|
currentMessage=NULL;
|
||||||
behindCurMes=NULL;
|
behindCurMes=NULL;
|
||||||
initMainMenu();
|
initMainMenu();
|
||||||
|
initNewMenu();
|
||||||
showMainMenu();
|
showMainMenu();
|
||||||
CPG=this;
|
CPG=this;
|
||||||
}
|
}
|
||||||
|
void CPreGame::initNewMenu()
|
||||||
|
{
|
||||||
|
ourNewMenu = new menuItems();
|
||||||
|
ourNewMenu->background = SDL_LoadBMP("h3bitmap.lod\\ZPIC1005.bmp");
|
||||||
|
CSemiLodHandler * slh = new CSemiLodHandler();
|
||||||
|
slh->openLod("H3sprite.lod");
|
||||||
|
//loading menu buttons
|
||||||
|
ourNewMenu->newGame = slh->giveDef("ZTSINGL.DEF");
|
||||||
|
ourNewMenu->loadGame = slh->giveDef("ZTMULTI.DEF");
|
||||||
|
ourNewMenu->highScores = slh->giveDef("ZTCAMPN.DEF");
|
||||||
|
ourNewMenu->credits = slh->giveDef("ZTTUTOR.DEF");
|
||||||
|
ourNewMenu->quit = slh->giveDef("ZTBACK.DEF");
|
||||||
|
ok = slh->giveDef("IOKAY.DEF");
|
||||||
|
cancel = slh->giveDef("ICANCEL.DEF");
|
||||||
|
// single scenario
|
||||||
|
ourNewMenu->lNewGame.h=ourNewMenu->newGame->ourImages[0].bitmap->h;
|
||||||
|
ourNewMenu->lNewGame.w=ourNewMenu->newGame->ourImages[0].bitmap->w;
|
||||||
|
ourNewMenu->lNewGame.x=545;
|
||||||
|
ourNewMenu->lNewGame.y=4;
|
||||||
|
//multiplayer
|
||||||
|
ourNewMenu->lLoadGame.h=ourNewMenu->loadGame->ourImages[0].bitmap->h;
|
||||||
|
ourNewMenu->lLoadGame.w=ourNewMenu->loadGame->ourImages[0].bitmap->w;
|
||||||
|
ourNewMenu->lLoadGame.x=568;
|
||||||
|
ourNewMenu->lLoadGame.y=120;
|
||||||
|
//campaign
|
||||||
|
ourNewMenu->lHighScores.h=ourNewMenu->highScores->ourImages[0].bitmap->h;
|
||||||
|
ourNewMenu->lHighScores.w=ourNewMenu->highScores->ourImages[0].bitmap->w;
|
||||||
|
ourNewMenu->lHighScores.x=541;
|
||||||
|
ourNewMenu->lHighScores.y=233;
|
||||||
|
//tutorial
|
||||||
|
ourNewMenu->lCredits.h=ourNewMenu->credits->ourImages[0].bitmap->h;
|
||||||
|
ourNewMenu->lCredits.w=ourNewMenu->credits->ourImages[0].bitmap->w;
|
||||||
|
ourNewMenu->lCredits.x=545;
|
||||||
|
ourNewMenu->lCredits.y=358;
|
||||||
|
//back
|
||||||
|
ourNewMenu->lQuit.h=ourNewMenu->quit->ourImages[0].bitmap->h;
|
||||||
|
ourNewMenu->lQuit.w=ourNewMenu->quit->ourImages[0].bitmap->w;
|
||||||
|
ourNewMenu->lQuit.x=582;
|
||||||
|
ourNewMenu->lQuit.y=464;
|
||||||
|
ourNewMenu->fQuit=&CPreGame::showMainMenu;
|
||||||
|
|
||||||
|
ourNewMenu->highlighted=0;
|
||||||
|
handledLods.push_back(slh);
|
||||||
|
delete slh;
|
||||||
|
}
|
||||||
|
void CPreGame::showNewMenu()
|
||||||
|
{
|
||||||
|
state = EState::newGame;
|
||||||
|
SDL_BlitSurface(ourNewMenu->background,NULL,ekran,NULL);
|
||||||
|
SDL_BlitSurface(ourNewMenu->newGame->ourImages[0].bitmap,NULL,ekran,&ourNewMenu->lNewGame);
|
||||||
|
SDL_BlitSurface(ourNewMenu->loadGame->ourImages[0].bitmap,NULL,ekran,&ourNewMenu->lLoadGame);
|
||||||
|
SDL_BlitSurface(ourNewMenu->highScores->ourImages[0].bitmap,NULL,ekran,&ourNewMenu->lHighScores);
|
||||||
|
SDL_BlitSurface(ourNewMenu->credits->ourImages[0].bitmap,NULL,ekran,&ourNewMenu->lCredits);
|
||||||
|
SDL_BlitSurface(ourNewMenu->quit->ourImages[0].bitmap,NULL,ekran,&ourNewMenu->lQuit);
|
||||||
|
SDL_Flip(ekran);
|
||||||
|
}
|
||||||
void CPreGame::initMainMenu()
|
void CPreGame::initMainMenu()
|
||||||
{
|
{
|
||||||
ourMainMenu = new menuItems();
|
ourMainMenu = new menuItems();
|
||||||
@ -42,6 +99,7 @@ void CPreGame::initMainMenu()
|
|||||||
ourMainMenu->lNewGame.w=ourMainMenu->newGame->ourImages[0].bitmap->w;
|
ourMainMenu->lNewGame.w=ourMainMenu->newGame->ourImages[0].bitmap->w;
|
||||||
ourMainMenu->lNewGame.x=540;
|
ourMainMenu->lNewGame.x=540;
|
||||||
ourMainMenu->lNewGame.y=10;
|
ourMainMenu->lNewGame.y=10;
|
||||||
|
ourMainMenu->fNewGame=&CPreGame::showNewMenu;
|
||||||
//load game location
|
//load game location
|
||||||
ourMainMenu->lLoadGame.h=ourMainMenu->loadGame->ourImages[0].bitmap->h;
|
ourMainMenu->lLoadGame.h=ourMainMenu->loadGame->ourImages[0].bitmap->h;
|
||||||
ourMainMenu->lLoadGame.w=ourMainMenu->loadGame->ourImages[0].bitmap->w;
|
ourMainMenu->lLoadGame.w=ourMainMenu->loadGame->ourImages[0].bitmap->w;
|
||||||
@ -61,7 +119,8 @@ void CPreGame::initMainMenu()
|
|||||||
ourMainMenu->lQuit.h=ourMainMenu->quit->ourImages[0].bitmap->h;
|
ourMainMenu->lQuit.h=ourMainMenu->quit->ourImages[0].bitmap->h;
|
||||||
ourMainMenu->lQuit.w=ourMainMenu->quit->ourImages[0].bitmap->w;
|
ourMainMenu->lQuit.w=ourMainMenu->quit->ourImages[0].bitmap->w;
|
||||||
ourMainMenu->lQuit.x=586;
|
ourMainMenu->lQuit.x=586;
|
||||||
ourMainMenu->lQuit.y=469;
|
ourMainMenu->lQuit.y=468;
|
||||||
|
ourMainMenu->fQuit=&CPreGame::quitAskBox;
|
||||||
|
|
||||||
ourMainMenu->highlighted=0;
|
ourMainMenu->highlighted=0;
|
||||||
handledLods.push_back(slh);
|
handledLods.push_back(slh);
|
||||||
@ -69,6 +128,7 @@ void CPreGame::initMainMenu()
|
|||||||
}
|
}
|
||||||
void CPreGame::showMainMenu()
|
void CPreGame::showMainMenu()
|
||||||
{
|
{
|
||||||
|
state = EState::mainMenu;
|
||||||
SDL_BlitSurface(ourMainMenu->background,NULL,ekran,NULL);
|
SDL_BlitSurface(ourMainMenu->background,NULL,ekran,NULL);
|
||||||
SDL_BlitSurface(ourMainMenu->newGame->ourImages[0].bitmap,NULL,ekran,&ourMainMenu->lNewGame);
|
SDL_BlitSurface(ourMainMenu->newGame->ourImages[0].bitmap,NULL,ekran,&ourMainMenu->lNewGame);
|
||||||
SDL_BlitSurface(ourMainMenu->loadGame->ourImages[0].bitmap,NULL,ekran,&ourMainMenu->lLoadGame);
|
SDL_BlitSurface(ourMainMenu->loadGame->ourImages[0].bitmap,NULL,ekran,&ourMainMenu->lLoadGame);
|
||||||
@ -79,31 +139,33 @@ void CPreGame::showMainMenu()
|
|||||||
}
|
}
|
||||||
void CPreGame::highlightButton(int which, int on)
|
void CPreGame::highlightButton(int which, int on)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
menuItems * current = currentItems();
|
||||||
switch (which)
|
switch (which)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
SDL_BlitSurface(ourMainMenu->newGame->ourImages[on].bitmap,NULL,ekran,&ourMainMenu->lNewGame);
|
SDL_BlitSurface(current->newGame->ourImages[on].bitmap,NULL,ekran,¤t->lNewGame);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2:
|
case 2:
|
||||||
{
|
{
|
||||||
SDL_BlitSurface(ourMainMenu->loadGame->ourImages[on].bitmap,NULL,ekran,&ourMainMenu->lLoadGame);
|
SDL_BlitSurface(current->loadGame->ourImages[on].bitmap,NULL,ekran,¤t->lLoadGame);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 3:
|
case 3:
|
||||||
{
|
{
|
||||||
SDL_BlitSurface(ourMainMenu->highScores->ourImages[on].bitmap,NULL,ekran,&ourMainMenu->lHighScores);
|
SDL_BlitSurface(current->highScores->ourImages[on].bitmap,NULL,ekran,¤t->lHighScores);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 4:
|
case 4:
|
||||||
{
|
{
|
||||||
SDL_BlitSurface(ourMainMenu->credits->ourImages[on].bitmap,NULL,ekran,&ourMainMenu->lCredits);
|
SDL_BlitSurface(current->credits->ourImages[on].bitmap,NULL,ekran,¤t->lCredits);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 5:
|
case 5:
|
||||||
{
|
{
|
||||||
SDL_BlitSurface(ourMainMenu->quit->ourImages[on].bitmap,NULL,ekran,&ourMainMenu->lQuit);
|
SDL_BlitSurface(current->quit->ourImages[on].bitmap,NULL,ekran,¤t->lQuit);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -160,6 +222,16 @@ void CPreGame::hideBox ()
|
|||||||
currentMessage = NULL;
|
currentMessage = NULL;
|
||||||
behindCurMes=NULL;
|
behindCurMes=NULL;
|
||||||
}
|
}
|
||||||
|
CPreGame::menuItems * CPreGame::currentItems()
|
||||||
|
{
|
||||||
|
switch (state)
|
||||||
|
{
|
||||||
|
case EState::mainMenu:
|
||||||
|
return ourMainMenu;
|
||||||
|
case EState::newGame:
|
||||||
|
return ourNewMenu;
|
||||||
|
}
|
||||||
|
}
|
||||||
void CPreGame::runLoop()
|
void CPreGame::runLoop()
|
||||||
{
|
{
|
||||||
SDL_Event sEvent;
|
SDL_Event sEvent;
|
||||||
@ -169,96 +241,134 @@ void CPreGame::runLoop()
|
|||||||
{
|
{
|
||||||
if(SDL_PollEvent(&sEvent)) //wait for event...
|
if(SDL_PollEvent(&sEvent)) //wait for event...
|
||||||
{
|
{
|
||||||
|
menuItems * current = currentItems();
|
||||||
if(sEvent.type==SDL_QUIT)
|
if(sEvent.type==SDL_QUIT)
|
||||||
return ;
|
return ;
|
||||||
|
else if (sEvent.type==SDL_KEYDOWN)
|
||||||
|
{
|
||||||
|
if (state==EState::newGame)
|
||||||
|
{
|
||||||
|
switch (sEvent.key.keysym.sym)
|
||||||
|
{
|
||||||
|
case (SDLK_q):
|
||||||
|
{
|
||||||
|
return ;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SDLK_LEFT:
|
||||||
|
{
|
||||||
|
if(currentItems()->lNewGame.x>0)
|
||||||
|
currentItems()->lNewGame.x--;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case (SDLK_RIGHT):
|
||||||
|
{
|
||||||
|
currentItems()->lNewGame.x++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case (SDLK_UP):
|
||||||
|
{
|
||||||
|
if(currentItems()->lNewGame.y>0)
|
||||||
|
currentItems()->lNewGame.y--;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case (SDLK_DOWN):
|
||||||
|
{
|
||||||
|
currentItems()->lNewGame.y++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
showNewMenu();
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (sEvent.type==SDL_MOUSEMOTION)
|
else if (sEvent.type==SDL_MOUSEMOTION)
|
||||||
{
|
{
|
||||||
if (currentMessage) continue;
|
if (currentMessage) continue;
|
||||||
if (ourMainMenu->highlighted)
|
if (current->highlighted)
|
||||||
{
|
{
|
||||||
switch (ourMainMenu->highlighted)
|
switch (current->highlighted)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
if(isItIn(&ourMainMenu->lNewGame,sEvent.motion.x,sEvent.motion.y))
|
if(isItIn(¤t->lNewGame,sEvent.motion.x,sEvent.motion.y))
|
||||||
continue;
|
continue;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ourMainMenu->highlighted=0;
|
current->highlighted=0;
|
||||||
highlightButton(1,0);
|
highlightButton(1,0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2:
|
case 2:
|
||||||
{
|
{
|
||||||
if(isItIn(&ourMainMenu->lLoadGame,sEvent.motion.x,sEvent.motion.y))
|
if(isItIn(¤t->lLoadGame,sEvent.motion.x,sEvent.motion.y))
|
||||||
continue;
|
continue;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ourMainMenu->highlighted=0;
|
current->highlighted=0;
|
||||||
highlightButton(2,0);
|
highlightButton(2,0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 3:
|
case 3:
|
||||||
{
|
{
|
||||||
if(isItIn(&ourMainMenu->lHighScores,sEvent.motion.x,sEvent.motion.y))
|
if(isItIn(¤t->lHighScores,sEvent.motion.x,sEvent.motion.y))
|
||||||
continue;
|
continue;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ourMainMenu->highlighted=0;
|
current->highlighted=0;
|
||||||
highlightButton(3,0);
|
highlightButton(3,0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 4:
|
case 4:
|
||||||
{
|
{
|
||||||
if(isItIn(&ourMainMenu->lCredits,sEvent.motion.x,sEvent.motion.y))
|
if(isItIn(¤t->lCredits,sEvent.motion.x,sEvent.motion.y))
|
||||||
continue;
|
continue;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ourMainMenu->highlighted=0;
|
current->highlighted=0;
|
||||||
highlightButton(4,0);
|
highlightButton(4,0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 5:
|
case 5:
|
||||||
{
|
{
|
||||||
if(isItIn(&ourMainMenu->lQuit,sEvent.motion.x,sEvent.motion.y))
|
if(isItIn(¤t->lQuit,sEvent.motion.x,sEvent.motion.y))
|
||||||
continue;
|
continue;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ourMainMenu->highlighted=0;
|
current->highlighted=0;
|
||||||
highlightButton(5,0);
|
highlightButton(5,0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} //switch (ourMainMenu->highlighted)
|
} //switch (current->highlighted)
|
||||||
} // if (ourMainMenu->highlighted)
|
} // if (current->highlighted)
|
||||||
if (isItIn(&ourMainMenu->lNewGame,sEvent.motion.x,sEvent.motion.y))
|
if (isItIn(¤t->lNewGame,sEvent.motion.x,sEvent.motion.y))
|
||||||
{
|
{
|
||||||
highlightButton(1,2);
|
highlightButton(1,2);
|
||||||
ourMainMenu->highlighted=1;
|
current->highlighted=1;
|
||||||
}
|
}
|
||||||
else if (isItIn(&ourMainMenu->lLoadGame,sEvent.motion.x,sEvent.motion.y))
|
else if (isItIn(¤t->lLoadGame,sEvent.motion.x,sEvent.motion.y))
|
||||||
{
|
{
|
||||||
highlightButton(2,2);
|
highlightButton(2,2);
|
||||||
ourMainMenu->highlighted=2;
|
current->highlighted=2;
|
||||||
}
|
}
|
||||||
else if (isItIn(&ourMainMenu->lHighScores,sEvent.motion.x,sEvent.motion.y))
|
else if (isItIn(¤t->lHighScores,sEvent.motion.x,sEvent.motion.y))
|
||||||
{
|
{
|
||||||
highlightButton(3,2);
|
highlightButton(3,2);
|
||||||
ourMainMenu->highlighted=3;
|
current->highlighted=3;
|
||||||
}
|
}
|
||||||
else if (isItIn(&ourMainMenu->lCredits,sEvent.motion.x,sEvent.motion.y))
|
else if (isItIn(¤t->lCredits,sEvent.motion.x,sEvent.motion.y))
|
||||||
{
|
{
|
||||||
highlightButton(4,2);
|
highlightButton(4,2);
|
||||||
ourMainMenu->highlighted=4;
|
current->highlighted=4;
|
||||||
}
|
}
|
||||||
else if (isItIn(&ourMainMenu->lQuit,sEvent.motion.x,sEvent.motion.y))
|
else if (isItIn(¤t->lQuit,sEvent.motion.x,sEvent.motion.y))
|
||||||
{
|
{
|
||||||
highlightButton(5,2);
|
highlightButton(5,2);
|
||||||
ourMainMenu->highlighted=5;
|
current->highlighted=5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((sEvent.type==SDL_MOUSEBUTTONDOWN) && (sEvent.button.button == SDL_BUTTON_LEFT))
|
else if ((sEvent.type==SDL_MOUSEBUTTONDOWN) && (sEvent.button.button == SDL_BUTTON_LEFT))
|
||||||
@ -272,30 +382,30 @@ void CPreGame::runLoop()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (currentMessage) continue;
|
if (currentMessage) continue;
|
||||||
if (isItIn(&ourMainMenu->lNewGame,sEvent.motion.x,sEvent.motion.y))
|
if (isItIn(¤t->lNewGame,sEvent.motion.x,sEvent.motion.y))
|
||||||
{
|
{
|
||||||
highlightButton(1,1);
|
highlightButton(1,1);
|
||||||
ourMainMenu->highlighted=1;
|
current->highlighted=1;
|
||||||
}
|
}
|
||||||
else if (isItIn(&ourMainMenu->lLoadGame,sEvent.motion.x,sEvent.motion.y))
|
else if (isItIn(¤t->lLoadGame,sEvent.motion.x,sEvent.motion.y))
|
||||||
{
|
{
|
||||||
highlightButton(2,1);
|
highlightButton(2,1);
|
||||||
ourMainMenu->highlighted=2;
|
current->highlighted=2;
|
||||||
}
|
}
|
||||||
else if (isItIn(&ourMainMenu->lHighScores,sEvent.motion.x,sEvent.motion.y))
|
else if (isItIn(¤t->lHighScores,sEvent.motion.x,sEvent.motion.y))
|
||||||
{
|
{
|
||||||
highlightButton(3,1);
|
highlightButton(3,1);
|
||||||
ourMainMenu->highlighted=3;
|
current->highlighted=3;
|
||||||
}
|
}
|
||||||
else if (isItIn(&ourMainMenu->lCredits,sEvent.motion.x,sEvent.motion.y))
|
else if (isItIn(¤t->lCredits,sEvent.motion.x,sEvent.motion.y))
|
||||||
{
|
{
|
||||||
highlightButton(4,1);
|
highlightButton(4,1);
|
||||||
ourMainMenu->highlighted=4;
|
current->highlighted=4;
|
||||||
}
|
}
|
||||||
else if (isItIn(&ourMainMenu->lQuit,sEvent.motion.x,sEvent.motion.y))
|
else if (isItIn(¤t->lQuit,sEvent.motion.x,sEvent.motion.y))
|
||||||
{
|
{
|
||||||
highlightButton(5,1);
|
highlightButton(5,1);
|
||||||
ourMainMenu->highlighted=5;
|
current->highlighted=5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((sEvent.type==SDL_MOUSEBUTTONUP) && (sEvent.button.button == SDL_BUTTON_LEFT))
|
else if ((sEvent.type==SDL_MOUSEBUTTONUP) && (sEvent.button.button == SDL_BUTTON_LEFT))
|
||||||
@ -311,73 +421,62 @@ void CPreGame::runLoop()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (currentMessage) continue;
|
if (currentMessage) continue;
|
||||||
if (isItIn(&ourMainMenu->lNewGame,sEvent.motion.x,sEvent.motion.y))
|
if (isItIn(¤t->lNewGame,sEvent.motion.x,sEvent.motion.y))
|
||||||
{
|
{
|
||||||
highlightButton(1,2);
|
highlightButton(1,2);
|
||||||
ourMainMenu->highlighted=1;
|
current->highlighted=1;
|
||||||
|
(this->*(current->fNewGame))();
|
||||||
}
|
}
|
||||||
else if (isItIn(&ourMainMenu->lLoadGame,sEvent.motion.x,sEvent.motion.y))
|
else if (isItIn(¤t->lLoadGame,sEvent.motion.x,sEvent.motion.y))
|
||||||
{
|
{
|
||||||
highlightButton(2,2);
|
highlightButton(2,2);
|
||||||
ourMainMenu->highlighted=2;
|
current->highlighted=2;
|
||||||
}
|
}
|
||||||
else if (isItIn(&ourMainMenu->lHighScores,sEvent.motion.x,sEvent.motion.y))
|
else if (isItIn(¤t->lHighScores,sEvent.motion.x,sEvent.motion.y))
|
||||||
{
|
{
|
||||||
highlightButton(3,2);
|
highlightButton(3,2);
|
||||||
ourMainMenu->highlighted=3;
|
current->highlighted=3;
|
||||||
}
|
}
|
||||||
else if (isItIn(&ourMainMenu->lCredits,sEvent.motion.x,sEvent.motion.y))
|
else if (isItIn(¤t->lCredits,sEvent.motion.x,sEvent.motion.y))
|
||||||
{
|
{
|
||||||
highlightButton(4,2);
|
highlightButton(4,2);
|
||||||
ourMainMenu->highlighted=4;
|
current->highlighted=4;
|
||||||
}
|
}
|
||||||
else if (isItIn(&ourMainMenu->lQuit,sEvent.motion.x,sEvent.motion.y))
|
else if (isItIn(¤t->lQuit,sEvent.motion.x,sEvent.motion.y))
|
||||||
{
|
{
|
||||||
highlightButton(5,2);
|
highlightButton(5,2);
|
||||||
ourMainMenu->highlighted=5;
|
current->highlighted=5;
|
||||||
showAskBox("\"{BBBB}BBDDDDDDDDDD\"",NULL,NULL);
|
(this->*(current->fQuit))();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((sEvent.type==SDL_MOUSEBUTTONDOWN) && (sEvent.button.button == SDL_BUTTON_RIGHT))
|
else if ((sEvent.type==SDL_MOUSEBUTTONDOWN) && (sEvent.button.button == SDL_BUTTON_RIGHT))
|
||||||
{
|
{
|
||||||
if (currentMessage) continue;
|
if (currentMessage) continue;
|
||||||
if (isItIn(&ourMainMenu->lNewGame,sEvent.motion.x,sEvent.motion.y))
|
if (isItIn(¤t->lNewGame,sEvent.motion.x,sEvent.motion.y))
|
||||||
{
|
{
|
||||||
showCenBox(preth->mainNewGame);
|
showCenBox(buttonText(0));
|
||||||
}
|
}
|
||||||
else if (isItIn(&ourMainMenu->lLoadGame,sEvent.motion.x,sEvent.motion.y))
|
else if (isItIn(¤t->lLoadGame,sEvent.motion.x,sEvent.motion.y))
|
||||||
{
|
{
|
||||||
showCenBox(preth->mainLoadGame);
|
showCenBox(buttonText(1));
|
||||||
}
|
}
|
||||||
else if (isItIn(&ourMainMenu->lHighScores,sEvent.motion.x,sEvent.motion.y))
|
else if (isItIn(¤t->lHighScores,sEvent.motion.x,sEvent.motion.y))
|
||||||
{
|
{
|
||||||
showCenBox(preth->mainHighScores);
|
showCenBox(buttonText(2));
|
||||||
}
|
}
|
||||||
else if (isItIn(&ourMainMenu->lCredits,sEvent.motion.x,sEvent.motion.y))
|
else if (isItIn(¤t->lCredits,sEvent.motion.x,sEvent.motion.y))
|
||||||
{
|
{
|
||||||
showCenBox(preth->mainCredits);
|
showCenBox(buttonText(3));
|
||||||
}
|
}
|
||||||
else if (isItIn(&ourMainMenu->lQuit,sEvent.motion.x,sEvent.motion.y))
|
else if (isItIn(&ourMainMenu->lQuit,sEvent.motion.x,sEvent.motion.y))
|
||||||
{
|
{
|
||||||
showCenBox(preth->mainQuit);
|
showCenBox(buttonText(4));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((sEvent.type==SDL_MOUSEBUTTONUP) && (sEvent.button.button == SDL_BUTTON_RIGHT) && currentMessage)
|
else if ((sEvent.type==SDL_MOUSEBUTTONUP) && (sEvent.button.button == SDL_BUTTON_RIGHT) && currentMessage)
|
||||||
{
|
{
|
||||||
hideBox();
|
hideBox();
|
||||||
}
|
}
|
||||||
else if (sEvent.type==SDL_KEYDOWN)
|
|
||||||
{
|
|
||||||
switch (sEvent.key.keysym.sym)
|
|
||||||
{
|
|
||||||
case (SDLK_q):
|
|
||||||
{
|
|
||||||
return ;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
showMainMenu();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
@ -385,5 +484,43 @@ void CPreGame::runLoop()
|
|||||||
|
|
||||||
SDL_Delay(30); //give time for other apps
|
SDL_Delay(30); //give time for other apps
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
std::string CPreGame::buttonText(int which)
|
||||||
|
{
|
||||||
|
if (state==EState::mainMenu)
|
||||||
|
{
|
||||||
|
switch (which)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
return preth->mainNewGame;
|
||||||
|
case 1:
|
||||||
|
return preth->mainLoadGame;
|
||||||
|
case 2:
|
||||||
|
return preth->mainHighScores;
|
||||||
|
case 3:
|
||||||
|
return preth->mainCredits;
|
||||||
|
case 4:
|
||||||
|
return preth->mainQuit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (state==EState::newGame)
|
||||||
|
{
|
||||||
|
switch (which)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
return preth->ngSingleScenario;
|
||||||
|
case 1:
|
||||||
|
return preth->ngMultiplayer;
|
||||||
|
case 2:
|
||||||
|
return preth->ngCampain;
|
||||||
|
case 3:
|
||||||
|
return preth->ngTutorial;
|
||||||
|
case 4:
|
||||||
|
return preth->ngBack;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void CPreGame::quitAskBox()
|
||||||
|
{
|
||||||
|
showAskBox("\"{} Are you sure you want to quit?\"",NULL,NULL);
|
||||||
}
|
}
|
@ -29,12 +29,18 @@ public:
|
|||||||
SDL_Surface * background;
|
SDL_Surface * background;
|
||||||
CSemiDefHandler *newGame, *loadGame, *highScores,*credits, *quit;
|
CSemiDefHandler *newGame, *loadGame, *highScores,*credits, *quit;
|
||||||
SDL_Rect lNewGame, lLoadGame, lHighScores, lCredits, lQuit;
|
SDL_Rect lNewGame, lLoadGame, lHighScores, lCredits, lQuit;
|
||||||
|
ttt fNewGame, fLoadGame, fHighScores, fCredits, fQuit;
|
||||||
int highlighted;//0=none; 1=new game; 2=load game; 3=high score; 4=credits; 5=quit
|
int highlighted;//0=none; 1=new game; 2=load game; 3=high score; 4=credits; 5=quit
|
||||||
} * ourMainMenu, * newGameManu;
|
} * ourMainMenu, * ourNewMenu;
|
||||||
std::string map; //selected map
|
std::string map; //selected map
|
||||||
std::vector<CSemiLodHandler *> handledLods;
|
std::vector<CSemiLodHandler *> handledLods;
|
||||||
CPreGame(); //c-tor
|
CPreGame(); //c-tor
|
||||||
|
std::string buttonText(int which);
|
||||||
|
menuItems * currentItems();
|
||||||
|
void quitAskBox();
|
||||||
void quit(){exit(0);};
|
void quit(){exit(0);};
|
||||||
|
void initNewMenu();
|
||||||
|
void showNewMenu();
|
||||||
void showMainMenu();
|
void showMainMenu();
|
||||||
void runLoop(); // runs mainloop of PreGame
|
void runLoop(); // runs mainloop of PreGame
|
||||||
void initMainMenu(); //loads components for main menu
|
void initMainMenu(); //loads components for main menu
|
||||||
|
Loading…
Reference in New Issue
Block a user