git repos / blockattack-game

commit 7ca669ac

sago007 · 2008-12-09 16:30
7ca669acb2799c73205f5327c34bb4121080484f patch · browse files
parent 9050a50ac75989a6265a39cdd3a5bde9f0596069

Buttons on Score/Stats screen


git-svn-id: https://blockattack.svn.sourceforge.net/svnroot/blockattack/trunk@57 9d7177f8-192b-0410-8f35-a16a89829b06

Changed files

M source/code/main.cpp before
M source/code/mainVars.hpp before
diff --git a/source/code/main.cpp b/source/code/main.cpp index 65186dc..a5d57ee 100644 --- a/source/code/main.cpp +++ b/source/code/main.cpp
@@ -1271,6 +1271,7 @@ textManeger theTextManeger;
//Here comes the Block Game object
#include "BlockGame.hpp"
+#include "SFont.h"
//writeScreenShot saves the screen as a bmp file, it uses the time to get a unique filename
void writeScreenShot()
@@ -1957,7 +1958,15 @@ void OpenScoresDisplay()
int mousex,mousey;
bool done = false; //We are done!
int page = 0;
+ const int ysize = 768;
const int numberOfPages = 3;
+ //button coodinates:
+ const int scoreX = buttonXsize*2;
+ const int scoreY = 0;
+ const int backX = 20;
+ const int backY = ysize-buttonYsize-20;
+ const int nextX = xsize-buttonXsize-20;
+ const int nextY = backY;
while (!done)
{
switch(page)
@@ -1974,8 +1983,15 @@ void OpenScoresDisplay()
default:
DrawStats();
};
-
+ //Draw buttons:
+ DrawIMG(bHighScore,screen,scoreX,scoreY);
+ DrawIMG(bBack,screen,backX,backY);
+ DrawIMG(bNext,screen,nextX,nextY);
+
+ //Draw page number
+ string pageXofY = ((string)"Page ")+itoa(page+1)+((string)" of ")+itoa(numberOfPages);
+ SFont_Write(screen,fBlueFont,xsize/2-SFont_TextWidth(fBlueFont,pageXofY.c_str())/2,ysize-60,pageXofY.c_str());
SDL_Delay(10);
SDL_Event event;
@@ -1998,13 +2014,15 @@ void OpenScoresDisplay()
if(page>=numberOfPages)
page = 0;
}
-
+ else
if( (event.key.keysym.sym == SDLK_LEFT))
{
page--;
if(page<0)
page = numberOfPages-1;
}
+ else
+ done = true;
if ( (event.key.keysym.sym == SDLK_RETURN)||(event.key.keysym.sym == SDLK_KP_ENTER) ) {
done = true;
@@ -2016,6 +2034,38 @@ void OpenScoresDisplay()
}
} //while(event)
+
+ // If the mouse button is released, make bMouseUp equal true
+ if (!SDL_GetMouseState(NULL, NULL)&SDL_BUTTON(1))
+ {
+ bMouseUp=true;
+ }
+
+ if (SDL_GetMouseState(NULL,NULL)&SDL_BUTTON(1) && bMouseUp)
+ {
+ bMouseUp = false;
+
+ //The Score button:
+ if((mousex>scoreX) && (mousex<scoreX+buttonXsize) && (mousey>scoreY) && (mousey<scoreY+buttonYsize))
+ done =true;
+
+ //The back button:
+ if((mousex>backX) && (mousex<backX+buttonXsize) && (mousey>backY) && (mousey<backY+buttonYsize))
+ {
+ page--;
+ if(page<0)
+ page = numberOfPages-1;
+ }
+
+ //The next button:
+ if((mousex>nextX) && (mousex<nextX+buttonXsize) && (mousey>nextY) && (mousey<nextY+buttonYsize))
+ {
+ page++;
+ if(page>=numberOfPages)
+ page = 0;
+ }
+ }
+
DrawIMG(mouse,screen,mousex,mousey);
SDL_Flip(screen); //Update screen
}
diff --git a/source/code/mainVars.hpp b/source/code/mainVars.hpp index 4dfa66a..f8f5271 100644 --- a/source/code/mainVars.hpp +++ b/source/code/mainVars.hpp
@@ -256,7 +256,7 @@ Uint8 player2handicap=0;
unsigned long int currentTime; //contains the current time, so we don't call SDL_GetTickets() too often...
-int xsize;
+int xsize = 1024;
//Stores the players names (way to long, but at least no buffer overflows (max length is 16 for display reasons))
char player1name[30];