diff --git a/source/code/main.cpp b/source/code/main.cpp index ed3bf76..90b4b0c 100644 --- a/source/code/main.cpp +++ b/source/code/main.cpp @@ -1700,205 +1700,6 @@ static string getKeyName(SDLKey key) void MakeBackground(int xsize,int ysize,BlockGame &theGame, BlockGame &theGame2); -/*int OpenControlsBox(int x, int y, int player) -{ - int mousex, mousey; - Uint8 *keys; - bool done =false; - string keyname; - MakeBackground(xsize,ysize); - while (!done && !Config::getInstance()->isShuttingDown()) - { - SDL_Delay(10); - DrawIMG(background, screen, 0, 0); - DrawIMG(changeButtonsBack,screen,x,y); - if (player == 0) - NFont_Write(screen, x+40,y+2,"Player 1 keys"); - else - NFont_Write(screen, x+40,y+2,"Player 2 keys"); - NFont_Write(screen, x+6,y+50,"Up"); - keyname = getKeyName(keySettings[player].up); - NFont_Write(screen, x+200,y+50,keyname.c_str()); - NFont_Write(screen, x+6,y+100,"Down"); - keyname = getKeyName(keySettings[player].down); - NFont_Write(screen, x+200,y+100,keyname.c_str()); - NFont_Write(screen, x+6,y+150,"Left"); - keyname = getKeyName(keySettings[player].left); - NFont_Write(screen, x+200,y+150,keyname.c_str()); - NFont_Write(screen, x+6,y+200,"Right"); - keyname = getKeyName(keySettings[player].right); - NFont_Write(screen, x+200,y+200,keyname.c_str()); - NFont_Write(screen, x+6,y+250,"Push"); - keyname = getKeyName(keySettings[player].push); - NFont_Write(screen, x+200,y+250,keyname.c_str()); - NFont_Write(screen, x+6,y+300,"Change"); - keyname = getKeyName(keySettings[player].change); - NFont_Write(screen, x+200,y+300,keyname.c_str()); - //Ask for mouse play - NFont_Write(screen, x+6,y+350,"Mouse play?"); - DrawIMG(iLevelCheckBox,screen,x+220,y+350); - if (((player==0)&&(mouseplay1))||((player==2)&&(mouseplay2))) - DrawIMG(iLevelCheck,screen,x+220,y+350); //iLevelCheck witdh is 42 - //Ask for joypad play - NFont_Write(screen, x+300,y+350,"Joypad?"); - DrawIMG(iLevelCheckBox,screen,x+460,y+350); - if (((player==0)&&(joyplay1))||((player==2)&&(joyplay2))) - DrawIMG(iLevelCheck,screen,x+460,y+350); //iLevelCheck witdh is 42 - for (int i=1; i<7; i++) - DrawIMG(bChange,screen,x+420,y+50*i); - SDL_Event event; - - while (SDL_PollEvent(&event)) - { - if ( event.type == SDL_QUIT ) { - Config::getInstance()->setShuttingDown(5); - done = true; - } - - if (event.type == SDL_KEYDOWN) - { - if (event.key.keysym.sym == SDLK_ESCAPE) - done = true; - } - } //PollEvent - - keys = SDL_GetKeyState(NULL); - - SDL_GetMouseState(&mousex,&mousey); - - // 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; - - if ((mousex>(420+x)) && (mousex<(540+x)) && (mousey>(50+y)) && (mousey<(90+y))) - { - //up - bool finnish = false; - while (!finnish) - while ( SDL_PollEvent(&event) ) - { - if (event.type == SDL_KEYDOWN) - { - if (event.key.keysym.sym != SDLK_ESCAPE) - keySettings[player].up = event.key.keysym.sym; - finnish = true; - } - } - } //up - if ((mousex>(420+x)) && (mousex<(540+x)) && (mousey>(100+y)) && (mousey<(140+y))) - { - //down - bool finnish = false; - while (!finnish) - while ( SDL_PollEvent(&event) ) - { - if (event.type == SDL_KEYDOWN) - { - if (event.key.keysym.sym != SDLK_ESCAPE) - keySettings[player].down = event.key.keysym.sym; - finnish = true; - } - } - } //down - if ((mousex>(420+x)) && (mousex<(540+x)) && (mousey>(150+y)) && (mousey<(190+y))) - { - //left - bool finnish = false; - while (!finnish) - while ( SDL_PollEvent(&event) ) - { - if (event.type == SDL_KEYDOWN) - { - if (event.key.keysym.sym != SDLK_ESCAPE) - keySettings[player].left = event.key.keysym.sym; - finnish = true; - } - } - } //left - if ((mousex>(420+x)) && (mousex<(540+x)) && (mousey>(200+y)) && (mousey<(240+y))) - { - //right - bool finnish = false; - while (!finnish) - while ( SDL_PollEvent(&event) ) - { - if (event.type == SDL_KEYDOWN) - { - if (event.key.keysym.sym != SDLK_ESCAPE) - keySettings[player].right = event.key.keysym.sym; - finnish = true; - } - } - } //right - if ((mousex>(420+x)) && (mousex<(540+x)) && (mousey>(250+y)) && (mousey<(290+y))) - { - //push - bool finnish = false; - while (!finnish) - while ( SDL_PollEvent(&event) ) - { - if (event.type == SDL_KEYDOWN) - { - if (event.key.keysym.sym != SDLK_ESCAPE) - keySettings[player].push = event.key.keysym.sym; - finnish = true; - } - } - } //push - if ((mousex>(420+x)) && (mousex<(540+x)) && (mousey>(300+y)) && (mousey<(340+y))) - { - //change - bool finnish = false; - while (!finnish) - while ( SDL_PollEvent(&event) ) - { - if (event.type == SDL_KEYDOWN) - { - if (event.key.keysym.sym != SDLK_ESCAPE) - keySettings[player].change = event.key.keysym.sym; - finnish = true; - } - } - } //change - //mouseplay: - if ((mousex>(220+x)) && (mousex<(262+x)) && (mousey>(350+y)) && (mousey<(392+y))) - { - if (player==0) - { - mouseplay1 = !mouseplay1; - } - else - { - mouseplay2 = !mouseplay2; - } - } - //Joyplay: - if ((mousex>(460+x)) && (mousex<(502+x)) && (mousey>(350+y)) && (mousey<(392+y))) - { - if (player==0) - { - joyplay1 = !joyplay1; - } - else - { - joyplay2 = !joyplay2; - } - } - } //get mouse state - - //DrawIMG(mouse,screen,mousex,mousey); - mouse.PaintTo(screen,mousex,mousey); - SDL_Flip(screen); - } //while !done - DrawIMG(background, screen, 0, 0); - return 0; -}**/ //Dialogbox @@ -2981,11 +2782,12 @@ int PuzzleLevelSelect(int Type) { int tmpSelected = -1; int j; - for (j = 0; (j(&tempBool),sizeof(bool)); - stageCleared[i]=tempBool; - } - if(!stageFile.eof()) - { - for(int i=0; i(&tempUInt32),sizeof(Uint32)); - stageScores[i]=tempUInt32; - totalScore+=tempUInt32; - } - for(int i=0; i(&tempUInt32),sizeof(Uint32)); - stageTimes[i]=tempUInt32; - totalTime += tempUInt32; - } - } - else - { - for(int i=0; i0) - scoreString = _("Best score: ")+itoa(stageScores[overLevel]); - if(stageTimes[overLevel]>0) - timeString = _("Time used: ")+itoa(stageTimes[overLevel]/1000/60)+" : "+itoa2((stageTimes[overLevel]/1000)%60); - - NFont_Write(screen, 200,200,scoreString.c_str()); - NFont_Write(screen, 200,250,timeString.c_str()); - - overLevel; - } - string totalString = (format("Total score: %1% in %2%:%3%")%totalScore%(totalTime/1000/60)%((totalTime/1000)%60)).str(); //"Total score: " +itoa(totalScore) + " in " + itoa(totalTime/1000/60) + " : " + itoa2((totalTime/1000)%60); - NFont_Write(screen, 200,600,totalString.c_str()); - - //DrawIMG(mouse,screen,mousex,mousey); - mouse.PaintTo(screen,mousex,mousey); - SDL_Flip(screen); //draws it all to the screen - - } - while (!levelSelected); - DrawIMG(background, screen, 0, 0); - return levelNr; -}*/ - -//Ask user for what AI level he will compete agains, return the number. Number must be 0..AIlevels -/*int startSingleVs() -{ - //Where to place the windows - const int xplace = 200; - const int yplace = 100; - Uint8 *keys; //To take keyboard input - int mousex, mousey; //To allow mouse - bool done = false; //When are we done? - - MakeBackground(xsize,ysize); - DrawIMG(changeButtonsBack,background,xplace,yplace); - NFont_Write(background, xplace+10,yplace+10,_("1 : Very Easy") ); - NFont_Write(background, xplace+10,yplace+40,_("2 : Easy") ); - NFont_Write(background, xplace+10,yplace+70,_("3 : Below Normal") ); - NFont_Write(background, xplace+10,yplace+100,_("4 : Normal") ); - NFont_Write(background, xplace+10,yplace+130,_("5 : Above Normal") ); - NFont_Write(background, xplace+10,yplace+160,_("6 : Hard") ); - NFont_Write(background, xplace+10,yplace+190,_("7 : Hardest") ); - DrawIMG(background, screen, 0, 0); - SDL_Flip(screen); - do - { - - SDL_Delay(10); - SDL_Event event; - while ( SDL_PollEvent(&event) ) - if ( event.type == SDL_KEYDOWN ) - { - if ( event.key.keysym.sym == SDLK_KP_ENTER || event.key.keysym.sym == SDLK_ESCAPE || event.key.keysym.sym == SDLK_RETURN ) - { - done = true; - } - if ( event.key.keysym.sym == SDLK_1 || event.key.keysym.sym == SDLK_KP1 ) - { - return 0; - } - if ( event.key.keysym.sym == SDLK_2 || event.key.keysym.sym == SDLK_KP2 ) - { - return 1; - } - if ( event.key.keysym.sym == SDLK_3 || event.key.keysym.sym == SDLK_KP3 ) - { - return 2; - } - if ( event.key.keysym.sym == SDLK_4 || event.key.keysym.sym == SDLK_KP4 ) - { - return 3; - } - if ( event.key.keysym.sym == SDLK_5 || event.key.keysym.sym == SDLK_KP5 ) - { - return 4; - } - if ( event.key.keysym.sym == SDLK_6 || event.key.keysym.sym == SDLK_KP6 ) - { - return 5; - } - if ( event.key.keysym.sym == SDLK_7 || event.key.keysym.sym == SDLK_KP7 ) - { - return 6; - } - } - - // 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; - - for (int i=0; i<7; i++) - { - if ((mousex>xplace+10)&&(mousexyplace+10+i*30)&&(mouseyisShuttingDown()); - - - return 3; //Returns normal -}*/ //The function that allows the player to choose Level number void startVsMenu() @@ -4348,85 +3904,6 @@ int runGame(int gametype, int level) */ mustsetupgame = true; } - if ( event.key.keysym.sym == SDLK_F3 ) - { -#if NETWORK - if ((!showOptions)&&(!networkActive)) - { -#else - if ((!showOptions)) - { -#endif - StartSinglePlayerTimeTrial(); - } - } - if ( event.key.keysym.sym == SDLK_F5 ) - { -#if NETWORK - if ((!showOptions)&&(!networkActive)) -#else - if ((!showOptions)) -#endif - { - int myLevel = PuzzleLevelSelect(1); - theGame.NewStageGame(myLevel,50,100,SDL_GetTicks()); - MakeBackground(xsize,ysize,&theGame,&theGame2); - DrawIMG(background, screen, 0, 0); - closeAllMenus(); - twoPlayers =false; - theGame2.SetGameOver(); - showGame = true; - vsMode = false; - strcpy(theGame.name, player1name); - strcpy(theGame2.name, player2name); - } - } - if ( event.key.keysym.sym == SDLK_F6 ) - { -#if NETWORK - if ((!showOptions)&&(!networkActive)) -#else - if ((!showOptions)) -#endif - { - StartTwoPlayerVs(); - } - } - if ( event.key.keysym.sym == SDLK_F4 ) - { -#if NETWORK - if ((!showOptions)&&(!networkActive)) -#else - if ((!showOptions)) -#endif - { - StarTwoPlayerTimeTrial(); - } - } - if ( event.key.keysym.sym == SDLK_F7 ) - { -#if NETWORK - if ((!showOptions)&&(!networkActive)) -#else - if ((!showOptions)) -#endif - { - int myLevel = PuzzleLevelSelect(0); - theGame.NewPuzzleGame(myLevel,50,100,SDL_GetTicks()); - MakeBackground(xsize,ysize,&theGame,&theGame2); - DrawIMG(background, screen, 0, 0); - closeAllMenus(); - twoPlayers = false; - theGame2.SetGameOver(); - showGame = true; - vsMode = true; - strcpy(theGame.name, player1name); - strcpy(theGame2.name, player2name); - } - } - if ( event.key.keysym.sym == SDLK_F8 ) - { - } if ( event.key.keysym.sym == SDLK_F9 ) { writeScreenShot(); @@ -4438,7 +3915,7 @@ int runGame(int gametype, int level) //theGame.CreateGreyGarbage(); //char mitNavn[30]; //SelectThemeDialogbox(300,400,mitNavn); - MainMenu(); + //MainMenu(); //OpenScoresDisplay(); } //F11 } @@ -4913,7 +4390,6 @@ int runGame(int gametype, int level) oldMousex = mousex; oldMousey = mousey; //Draw the mouse: - //DrawIMG(mouse,screen,mousex,mousey); mouse.PaintTo(screen,mousex,mousey); SDL_Flip(screen); } //game loop