diff --git a/source/code/main.cpp b/source/code/main.cpp index cd4d8fc..8ae1eec 100644 --- a/source/code/main.cpp +++ b/source/code/main.cpp @@ -75,6 +75,7 @@ Copyright (C) 2008 Poul Sander //#include "ttfont.h" //To use True Type Fonts in SDL //#include "config.h" #include +#include //#include "MenuSystem.h" //if SHAREDIR is not used we look in current directory @@ -3437,7 +3438,7 @@ int main(int argc, char *argv[]) PHYSFS_addToSearchPath("blockattack.data", 1); #endif - + //Init SDL if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) { @@ -3485,6 +3486,12 @@ int main(int argc, char *argv[]) #endif cout << "-------------------------------------------" << endl; + //The menu cannot be activated the first second to prevent unexpected events + keymenu.canBeActivatedTime = SDL_GetTicks()+1000; + keymenu.activated = false; + for(int i=0;i SDL_GetTicks()) + { + keymenu.activated = true; + keymenu.x = 0; + keymenu.y = 0; + } } if ( event.key.keysym.sym == SDLK_F9 ) { writeScreenShot(); diff --git a/source/code/mainVars.hpp b/source/code/mainVars.hpp index 3418e00..6ebdee3 100644 --- a/source/code/mainVars.hpp +++ b/source/code/mainVars.hpp @@ -319,6 +319,23 @@ struct control control keySettings[3]; //array to hold the controls (default and two custom) +#define KEYMENU_MAXWITH 4 +#define KEYMENU_MAXDEPTH 7 + +//The following struct holds variables relevant to selecting menu items with +//keyboard/joypad. +struct KeyMenu_t +{ + unsigned long canBeActivatedTime; //Time that the KeyMenu can be activated by pressing a button + bool activated; //The keymenu is activated + //Here comes the coordinates to the key we are howering. + int x; + int y; + bool menumap[KEYMENU_MAXWITH][KEYMENU_MAXDEPTH]; +}; + +KeyMenu_t keymenu; + enum stageButton {SBdontShow, SBstageClear, SBpuzzleMode}; stageButton stageButtonStatus = SBdontShow;