From b69724ad38ea55634045ebbef66ec4d6f024038c Mon Sep 17 00:00:00 2001 From: albertzeyer Date: Wed, 22 Jul 2009 21:58:45 +0000 Subject: [PATCH] reverted commit 98 (was also wrongly removing my previous work) git-svn-id: https://clonekeenplus.svn.sourceforge.net/svnroot/clonekeenplus/cgenius/trunk@109 4df4b0f3-56ce-47cb-b001-ed939b7d65a6 --- src/menu.cpp | 859 +++++++++++++++++++++++++-------------------------- 1 file changed, 427 insertions(+), 432 deletions(-) diff --git a/src/menu.cpp b/src/menu.cpp index 547d3645d..c3a35ce15 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -1,6 +1,6 @@ -/* MENU.C - The main menu, intro, and other such stuff. - */ + /* MENU.C + The main menu, intro, and other such stuff. +*/ #include "keen.h" #include "pressf10.h" @@ -26,7 +26,8 @@ #include #include #include -using namespace std; +#include "StringUtils.h" + #define SELMOVE_SPD 3 @@ -35,14 +36,13 @@ short openDlgStruct(stDlgStruct *pDlgStruct, stCloneKeenPlus *pCKP); void showmapatpos(int level, int xoff, int yoff, int wm, stCloneKeenPlus *pCKP) { int i; - char levelname[MAX_STRING_LENGTH]; + std::string levelname; g_pLogFile->ftextOut("showmapatpos(%d, %d, %d, %d);
",level,xoff,yoff,wm); pCKP->Control.levelcontrol.dark = 0; g_pGraphics->initPalette(pCKP->Control.levelcontrol.dark); initgame(pCKP); // reset scroll - memset(levelname,0,MAX_STRING_LENGTH*sizeof(char)); - sprintf(levelname, "level%02d.ck%d", level, pCKP->Control.levelcontrol.episode); + levelname = "level" + FixedWidthStr_LeftFill(itoa(level), 2, '0') + ".ck" + itoa(pCKP->Control.levelcontrol.episode); short numsel; if(pCKP->Resources.GameSelected == 0 ) // First time startup. No game has been chosen @@ -62,83 +62,83 @@ void showmapatpos(int level, int xoff, int yoff, int wm, stCloneKeenPlus *pCKP) short loadResourcesforStartMenu(stCloneKeenPlus *pCKP, CGame *Game) { - string line; - - ifstream gamescfg("data/games.cfg"); - + std::string line; + + std::ifstream gamescfg("data/games.cfg"); + if (gamescfg.is_open()) { - while ( !gamescfg.eof() && pCKP->numGames < 20 ) - { - getline (gamescfg,line); - - if(strncmp(line.data(),"[",strlen("[")) == 0) - { - stGameData *NewGameData; - - pCKP->numGames++; - NewGameData = new stGameData[pCKP->numGames]; - memset(NewGameData,0,pCKP->numGames*sizeof(stGameData)); - memcpy(NewGameData,pCKP->GameData,(pCKP->numGames-1)*sizeof(stGameData)); - - delete[] pCKP->GameData; - - pCKP->GameData = NewGameData; - } - if(strncmp(line.data(),"Name=",strlen("Name=")) == 0) - { - line.copy(pCKP->GameData[pCKP->numGames-1].Name,line.length()-strlen("Name="),strlen("Name=")); - } - if(strncmp(line.data(),"Episode=",strlen("Episode=")) == 0) - { - sscanf(line.data(),"Episode=%hd", &(pCKP->GameData[pCKP->numGames-1].Episode)); - } - if(strncmp(line.data(),"Path=",strlen("Path=")) == 0) - { - unsigned short l = strlen("Path="); - line.copy(pCKP->GameData[pCKP->numGames-1].DataDirectory,line.length()-l,l); - } - } - gamescfg.close(); + while ( !gamescfg.eof() && pCKP->numGames < 20 ) + { + getline (gamescfg,line); + + if(strncmp(line.data(),"[",strlen("[")) == 0) + { + stGameData *NewGameData; + + pCKP->numGames++; + NewGameData = new stGameData[pCKP->numGames]; + for(int i = 0; i < pCKP->numGames-1; ++i) + NewGameData[i] = pCKP->GameData[i]; + + delete[] pCKP->GameData; + + pCKP->GameData = NewGameData; + } + if(strncmp(line.data(),"Name=",strlen("Name=")) == 0) + { + pCKP->GameData[pCKP->numGames-1].Name = line.substr(strlen("Name=")); + } + if(strncmp(line.data(),"Episode=",strlen("Episode=")) == 0) + { + sscanf(line.data(),"Episode=%hd", &(pCKP->GameData[pCKP->numGames-1].Episode)); + } + if(strncmp(line.data(),"Path=",strlen("Path=")) == 0) + { + unsigned short l = strlen("Path="); + pCKP->GameData[pCKP->numGames-1].DataDirectory = line.substr(l); + } + } + gamescfg.close(); } else { g_pLogFile->ftextOut(RED,"loadResourcesforStartMenu(): \"data/games.cfg\" could not be read! Assure, that the directory can be accessed."); return -1; } - + if( pCKP->numGames >= 20 ) g_pLogFile->ftextOut(PURPLE,"parseTheGames(): Warning! Number of games limit in \"data/games.cfg\" reached."); - + if(pCKP->numGames == 0) { g_pLogFile->ftextOut(PURPLE,"parseTheGames(): In the file \"data/games.cfg\" no games were found."); return -1; } - + unsigned short c=0; for(c=0 ; c < pCKP->numGames ; c++) { checkConsistencyofGameData(&(pCKP->GameData[c])); } - + // /* Load the graphics of the first game for displaying the menu */ /* Graphics of the first Episode are taken*/ if(!pCKP->Control.skipstarting) pCKP->Control.levelcontrol.episode = 1; else pCKP->Control.levelcontrol.episode = pCKP->GameData[pCKP->Resources.GameSelected-1].Episode; - + //if (latch_loadgraphics(pCKP->Control.levelcontrol.episode, pCKP->GameData[0].DataDirectory)) return abortCKP(pCKP); //if (Game->getLatch()->loadGraphics(pCKP->Control.levelcontrol.episode, pCKP->GameData[0].DataDirectory)) return abortCKP(pCKP); Game->loadResources(pCKP->Control.levelcontrol.episode, pCKP->GameData[0].DataDirectory); - + player[0].x = player[0].y = 0; if(initgamefirsttime(pCKP, 0) != 0) { return 1; } initgame(pCKP); - + return 0; } @@ -150,45 +150,45 @@ short loadStartMenu(stCloneKeenPlus *pCKP) { CDialog *GamesMenu; int i; - + fade.mode = FADE_GO; fade.rate = FADE_NORM; fade.dir = FADE_IN; fade.curamt = 0; fade.fadetimer = 0; showmapatpos(90, (104 << 2)+256+256+80, 32-4, 0, pCKP); - + // Prepare the Games Menu GamesMenu = new CDialog(); - + GamesMenu->setDimensions(2,2,36,15); - + // Show me the games you detected! for( i=0 ; i < pCKP->numGames ; i++ ) { GamesMenu->addOptionText(pCKP->GameData[i].Name); } - + GamesMenu->animateDialogBox(true); - + do { g_pInput->pollEvents(); g_pTimer->SpeedThrottle(); - + // do fades gamedo_fades(); if(fade.mode == FADE_COMPLETE) GamesMenu->setVisible(true); - + gamedo_AnimatedTiles(); - + // Check the Input if(g_pInput->getPulsedCommand(IC_DOWN, 80)) GamesMenu->setNextSelection(); if(g_pInput->getPulsedCommand(IC_UP, 80)) GamesMenu->setPrevSelection(); - + if(g_pInput->getPressedCommand(0, IC_STATUS)) { fade.dir = FADE_OUT; @@ -200,48 +200,48 @@ short loadStartMenu(stCloneKeenPlus *pCKP) pCKP->Control.levelcontrol.episode = pCKP->GameData[pCKP->Resources.GameSelected-1].Episode; break; } - + // Render the Games-Menu GamesMenu->renderDialog(); - + // blit the scrollbuffer to the display gamedo_frameskipping_blitonly(); } while(!g_pInput->getExitEvent()); - + delete GamesMenu; - + return 0; } int mainmenu(stCloneKeenPlus *pCKP,int defaultopt) { - + CDialog *MainMenu; int bmnum; int x; int selection; - + for(unsigned int cp=0 ; cpsetDimensions(11,8,18,12); - + // Load the Title Bitmap bmnum = g_pGraphics->getBitmapNumberFromName("TITLE"); - + MainMenu->addOptionText("1-Player Game"); MainMenu->addOptionText("2-Player Game"); MainMenu->addOptionText("Load Game"); @@ -252,53 +252,53 @@ int mainmenu(stCloneKeenPlus *pCKP,int defaultopt) MainMenu->addOptionText("Change Game"); MainMenu->addOptionText("About CG"); MainMenu->addOptionText("Quit"); - + x = (320/2)-(bitmaps[bmnum].xsize/2); - + g_pGraphics->drawBitmap(x, 0, bmnum); - + MainMenu->animateDialogBox(true); - + do { - + g_pInput->pollEvents(); g_pTimer->SpeedThrottle(); - + // do fades gamedo_fades(); if(fade.mode == FADE_COMPLETE) MainMenu->setVisible(true); - + gamedo_AnimatedTiles(); - + // Check the Input if(g_pInput->getPulsedCommand(IC_DOWN, 80)) MainMenu->setNextSelection(); if(g_pInput->getPulsedCommand(IC_UP, 80)) MainMenu->setPrevSelection(); - + if(g_pInput->getPressedCommand(IC_STATUS)) { selection = MainMenu->getSelection(); break; } - - + + // Render the Games-Menu MainMenu->renderDialog(); - + // blit the scrollbuffer to the display gamedo_frameskipping_blitonly(); - + if(g_pInput->getExitEvent()) { delete MainMenu; return MAINMNU_QUIT; } - + } while(1); - + if (selection==MAINMNU_LOADGAME) { int diff; @@ -307,37 +307,37 @@ int mainmenu(stCloneKeenPlus *pCKP,int defaultopt) { return BACK2MAINMENU; } - + pCKP->Control.levelcontrol.hardmode = (diff == 1) ? true : false; - - loadslot = save_slot_box(0, pCKP); - if (loadslot) - { - fade.dir = FADE_OUT; - fade.curamt = PAL_FADE_SHADES; - fade.fadetimer = 0; - fade.rate = FADE_NORM; - fade.mode = FADE_GO; - } - bmnum = g_pGraphics->getBitmapNumberFromName("TITLE"); - x = (320/2)-(bitmaps[bmnum].xsize/2); - g_pGraphics->drawBitmap(x, 0, bmnum); + + loadslot = save_slot_box(0, pCKP); + if (loadslot) + { + fade.dir = FADE_OUT; + fade.curamt = PAL_FADE_SHADES; + fade.fadetimer = 0; + fade.rate = FADE_NORM; + fade.mode = FADE_GO; + } + bmnum = g_pGraphics->getBitmapNumberFromName("TITLE"); + x = (320/2)-(bitmaps[bmnum].xsize/2); + g_pGraphics->drawBitmap(x, 0, bmnum); } else if (selection==MAINMNU_OPTIONS) { - if (configmenu(pCKP)) - { // need to restart game - return RESTART_GAME; - } + if (configmenu(pCKP)) + { // need to restart game + return RESTART_GAME; + } } else { if(selection==MAINMNU_1PLAYER || selection==MAINMNU_2PLAYER) { - + int diff; diff = getDifficulty(pCKP); - + if(diff>2) { delete MainMenu; @@ -345,16 +345,16 @@ int mainmenu(stCloneKeenPlus *pCKP,int defaultopt) } pCKP->Control.levelcontrol.hardmode = (diff == 1) ? true : false; } - + fade.dir = FADE_OUT; fade.curamt = PAL_FADE_SHADES; fade.fadetimer = 0; fade.rate = FADE_NORM; fade.mode = FADE_GO; } - + delete MainMenu; - + return selection; } @@ -372,49 +372,49 @@ int getDifficulty(stCloneKeenPlus *pCKP) int bmnum; int selection; int x; - + fade.mode = FADE_GO; fade.rate = FADE_NORM; fade.dir = FADE_IN; fade.curamt = 0; fade.fadetimer = 0; - + showmapatpos(90, MAINMENU_X, MENUS_Y, 0, pCKP); - + // Load the Title Bitmap bmnum = g_pGraphics->getBitmapNumberFromName("TITLE"); - + x = (320/2)-(bitmaps[bmnum].xsize/2); - + g_pGraphics->drawBitmap(x, 0, bmnum); - + // Prepare the Games Menu DifficultyMenu = new CDialog(); - + DifficultyMenu->setDimensions(15,4,14,6); - + DifficultyMenu->addOptionText("Normal"); DifficultyMenu->addOptionText("Hard"); DifficultyMenu->addSeparator(); DifficultyMenu->addOptionText("Cancel"); - + DifficultyMenu->animateDialogBox(true); - + do { // do fades gamedo_fades(); if(fade.mode == FADE_COMPLETE) DifficultyMenu->setVisible(true); - + gamedo_AnimatedTiles(); - + // Check the Input if(g_pInput->getPulsedCommand(IC_DOWN, 80)) DifficultyMenu->setNextSelection(); if(g_pInput->getPulsedCommand(IC_UP, 80)) DifficultyMenu->setPrevSelection(); - + if(g_pInput->getPressedCommand(IC_STATUS)) { selection = DifficultyMenu->getSelection(); @@ -422,17 +422,17 @@ int getDifficulty(stCloneKeenPlus *pCKP) } // Render the Games-Menu DifficultyMenu->renderDialog(); - + // blit the scrollbuffer to the display gamedo_frameskipping_blitonly(); - + g_pInput->pollEvents(); g_pTimer->SpeedThrottle(); - + } while(1); - + delete DifficultyMenu; - + return selection; } @@ -443,21 +443,21 @@ int AudioDlg(stCloneKeenPlus *pCKP) int selection; int x; int ok=0; - + int rate=0; short mode=0; - + showmapatpos(90, MAINMENU_X, MENUS_Y, 0, pCKP); - + // Load the Title Bitmap bmnum = g_pGraphics->getBitmapNumberFromName("TITLE"); x = (320/2)-(bitmaps[bmnum].xsize/2); g_pGraphics->drawBitmap(x, 0, bmnum); - + // Prepare the Games Menu AudioMenu = new CDialog(); AudioMenu->setDimensions(4,4,32,7); - + char buf[256]; rate = g_pSound->getAudioSpec().freq; sprintf(buf,"Rate: %d kHz",rate); @@ -470,9 +470,9 @@ int AudioDlg(stCloneKeenPlus *pCKP) AudioMenu->addSeparator(); AudioMenu->addOptionText("Save and go back"); AudioMenu->addOptionText("Cancel"); - + AudioMenu->animateDialogBox(true); - + do { // do fades @@ -480,31 +480,31 @@ int AudioDlg(stCloneKeenPlus *pCKP) if(fade.mode == FADE_COMPLETE) AudioMenu->setVisible(true); gamedo_AnimatedTiles(); - + // Check the Input if(g_pInput->getPulsedCommand(IC_DOWN, 80)) AudioMenu->setNextSelection(); if(g_pInput->getPulsedCommand(IC_UP, 80)) AudioMenu->setPrevSelection(); - + if(g_pInput->getPressedCommand(IC_STATUS)) { selection = AudioMenu->getSelection(); - + if(selection == 0) { switch(rate) { - case 44100: rate = 48000; break; - case 22050: rate = 44100; break; - case 11000: rate = 22050; break; - default: rate = 11000; break; + case 44100: rate = 48000; break; + case 22050: rate = 44100; break; + case 11000: rate = 22050; break; + default: rate = 11000; break; } - + sprintf(buf,"Rate: %d kHz",rate); AudioMenu->setOptionText(0,buf); } - + if(selection == 1) { mode = !mode; @@ -513,7 +513,7 @@ int AudioDlg(stCloneKeenPlus *pCKP) else AudioMenu->setOptionText(1,"Mode: Stereo"); } - + if(selection == 3) { g_pSound->destroy(); @@ -524,25 +524,25 @@ int AudioDlg(stCloneKeenPlus *pCKP) delete Settings; Settings = NULL; g_pSound->init(); ok = g_pSound->loadSoundData(pCKP->Control.levelcontrol.episode, - pCKP->GameData[pCKP->Resources.GameSelected-1].DataDirectory); - + pCKP->GameData[pCKP->Resources.GameSelected-1].DataDirectory); + break; } if(selection == 4) break; - + } // Render the Games-Menu AudioMenu->renderDialog(); - + // blit the scrollbuffer to the display gamedo_frameskipping_blitonly(); - + g_pInput->pollEvents(); g_pTimer->SpeedThrottle(); - + } while(1); - + delete AudioMenu; return ok; } @@ -553,20 +553,20 @@ void OptionsDlg(stCloneKeenPlus *pCKP) int bmnum; int selection; int x,i; - + char buf[256]; - + showmapatpos(90, MAINMENU_X, MENUS_Y, 0, pCKP); - + // Load the Title Bitmap bmnum = g_pGraphics->getBitmapNumberFromName("TITLE"); x = (320/2)-(bitmaps[bmnum].xsize/2); g_pGraphics->drawBitmap(x, 0, bmnum); - + // Prepare the Games Menu OptionsMenu = new CDialog(); OptionsMenu->setDimensions(3,3,34,12); - + for( i = 0 ; i < NUM_OPTIONS ; i++ ) { sprintf(buf,"%s: ",options[i].name); @@ -574,15 +574,15 @@ void OptionsDlg(stCloneKeenPlus *pCKP) strcat(buf,"Enabled"); else strcat(buf,"Disabled"); - + OptionsMenu->addOptionText(buf); } - + OptionsMenu->addSeparator(); OptionsMenu->addOptionText("Return"); - + OptionsMenu->animateDialogBox(true); - + do { // do fades @@ -590,21 +590,21 @@ void OptionsDlg(stCloneKeenPlus *pCKP) if(fade.mode == FADE_COMPLETE) OptionsMenu->setVisible(true); gamedo_AnimatedTiles(); - + // Check the Input if(g_pInput->getPulsedCommand(IC_DOWN, 80)) OptionsMenu->setNextSelection(); if(g_pInput->getPulsedCommand(IC_UP, 80)) OptionsMenu->setPrevSelection(); - + if(g_pInput->getPressedCommand(IC_STATUS)) { selection = OptionsMenu->getSelection(); - + if(selection < NUM_OPTIONS) { sprintf(buf,"%s: ",options[selection].name); - + if(options[selection].value) { options[selection].value = 0; @@ -615,7 +615,7 @@ void OptionsDlg(stCloneKeenPlus *pCKP) options[selection].value = 1; strcat(buf,"Enabled"); } - + OptionsMenu->setOptionText(selection,buf); } else @@ -627,15 +627,15 @@ void OptionsDlg(stCloneKeenPlus *pCKP) } // Render the Games-Menu OptionsMenu->renderDialog(); - + // blit the scrollbuffer to the display gamedo_frameskipping_blitonly(); - + g_pInput->pollEvents(); g_pTimer->SpeedThrottle(); - + } while(1); - + delete OptionsMenu; } @@ -658,27 +658,27 @@ short GraphicsDlg(stCloneKeenPlus *pCKP) short retval = 0; unsigned char autoframeskip = 0; bool aspect; - + showmapatpos(90, MAINMENU_X, MENUS_Y, 0, pCKP); - + // Load the Title Bitmap bmnum = g_pGraphics->getBitmapNumberFromName("TITLE"); x = (320/2)-(bitmaps[bmnum].xsize/2); g_pGraphics->drawBitmap(x, 0, bmnum); - + // Prepare the Games Menu DisplayMenu = new CDialog(); DisplayMenu->setDimensions(4,3,32,13); - + width = g_pVideoDriver->getWidth(); height = g_pVideoDriver->getHeight(); depth = g_pVideoDriver->getDepth(); sprintf(buf,"Resolution: %dx%dx%d",width,height,depth); - + zoom = g_pVideoDriver->getZoomValue(); filter = g_pVideoDriver->getFiltermode(); frameskip = g_pVideoDriver->getFrameskip(); - + DisplayMenu->addOptionText(buf); if(g_pVideoDriver->getFullscreen()) { @@ -690,12 +690,12 @@ short GraphicsDlg(stCloneKeenPlus *pCKP) DisplayMenu->addOptionText("Windowed mode"); fsmode = false; } - + opengl = g_pVideoDriver->isOpenGL(); if(!opengl) { zoom = g_pVideoDriver->getZoomValue(); - + if(zoom == 1) sprintf(buf,"No scale"); else @@ -705,14 +705,14 @@ short GraphicsDlg(stCloneKeenPlus *pCKP) else { gl_filter = g_pVideoDriver->getOGLFilter(); - + if(gl_filter == 1) sprintf(buf,"OGL Filter: Linear"); else sprintf(buf,"OGL Filter: Nearest"); DisplayMenu->addOptionText(buf); } - + filter = g_pVideoDriver->getFiltermode(); if(filter == 0) DisplayMenu->addOptionText("No Filter"); @@ -724,36 +724,36 @@ short GraphicsDlg(stCloneKeenPlus *pCKP) DisplayMenu->addOptionText("Scale4x Filter"); else DisplayMenu->addOptionText("Unknown Filter"); - + sprintf(buf,"Frameskip: %d", frameskip); DisplayMenu->addOptionText(buf); - + if(opengl) DisplayMenu->addOptionText("OpenGL Acceleration"); else DisplayMenu->addOptionText("Software Rendering"); - + autoframeskip = g_pVideoDriver->getTargetFPS(); - + if(autoframeskip) sprintf(buf,"Auto-Frameskip : %d fps",autoframeskip); else sprintf(buf,"Auto-Frameskip disabled"); - + DisplayMenu->addOptionText(buf); - + aspect = g_pVideoDriver->getAspectCorrection(); - + if(aspect) DisplayMenu->addOptionText("OGL Aspect Ratio Enabled"); else DisplayMenu->addOptionText("OGL Aspect Ratio Disabled"); - + DisplayMenu->addSeparator(); DisplayMenu->addOptionText("Save and return"); DisplayMenu->addOptionText("Cancel"); DisplayMenu->animateDialogBox(true); - + do { // do fades @@ -761,23 +761,23 @@ short GraphicsDlg(stCloneKeenPlus *pCKP) if(fade.mode == FADE_COMPLETE) DisplayMenu->setVisible(true); gamedo_AnimatedTiles(); - + // Check the Input if(g_pInput->getPulsedCommand(IC_DOWN, 80)) DisplayMenu->setNextSelection(); if(g_pInput->getPulsedCommand(IC_UP, 80)) DisplayMenu->setPrevSelection(); - + if(g_pInput->getPressedCommand(IC_STATUS)) { selection = DisplayMenu->getSelection(); - + if(selection == 0) { // Now the part of the resolution list st_resolution Resolution; Resolution = g_pVideoDriver->setNextResolution(); - + sprintf(buf,"Resolution: %dx%dx%d", Resolution.width, Resolution.height, Resolution.depth); DisplayMenu->setOptionText(selection,buf); } @@ -794,12 +794,12 @@ short GraphicsDlg(stCloneKeenPlus *pCKP) if(opengl) { gl_filter = (gl_filter==1) ? 0 : 1; - + if(gl_filter == 1) sprintf(buf,"OGL Filter: Linear"); else sprintf(buf,"OGL Filter: Nearest"); - + DisplayMenu->setOptionText(2,buf); } else @@ -808,23 +808,23 @@ short GraphicsDlg(stCloneKeenPlus *pCKP) zoom = 1; else zoom++; - + if(zoom == 1) sprintf(buf,"No scale"); else sprintf(buf,"Scale: %d", zoom); } - + DisplayMenu->setOptionText(2,buf); } - + else if(selection == 3) { if(filter >= 3) filter = 0; else filter++; - + if(filter == 0) DisplayMenu->setOptionText(3,"No Filter"); else if(filter == 1) @@ -837,17 +837,17 @@ short GraphicsDlg(stCloneKeenPlus *pCKP) else if(selection == 4) { frameskip++; - + if(frameskip > 20) frameskip = 0; - + sprintf(buf,"Frameskip: %d",frameskip); DisplayMenu->setOptionText(4,buf); } else if(selection == 5) { opengl = opengl ? false : true; // switch the mode!! - + if(opengl) DisplayMenu->setOptionText(5,"OpenGL Acceleration"); else @@ -865,28 +865,28 @@ short GraphicsDlg(stCloneKeenPlus *pCKP) autoframeskip = 0; sprintf(buf,"Auto-Frameskip disabled"); } - + DisplayMenu->setOptionText(6, buf); } else if(selection == 7) { aspect = !aspect; - + if(aspect) DisplayMenu->setOptionText(7,"OGL Aspect Ratio Enabled"); else DisplayMenu->setOptionText(7,"OGL Aspect Ratio Disabled"); - + } else if(selection == 9) { g_pVideoDriver->stop(); - + if(fsmode) g_pVideoDriver->isFullscreen(true); else g_pVideoDriver->isFullscreen(false); - + g_pVideoDriver->enableOpenGL(opengl); g_pVideoDriver->setOGLFilter(gl_filter); g_pVideoDriver->setZoom(zoom); @@ -894,20 +894,20 @@ short GraphicsDlg(stCloneKeenPlus *pCKP) g_pVideoDriver->setFrameskip(frameskip); g_pVideoDriver->setTargetFPS(autoframeskip); g_pVideoDriver->setAspectCorrection(aspect); - + // initialize/activate all drivers g_pLogFile->ftextOut("Restarting graphics driver... (Menu)
"); if (g_pVideoDriver->start()) retval = 1; - + CSettings *Settings; Settings = new CSettings(); - + Settings->saveDrvCfg(); delete Settings; Settings = NULL; - + showmapatpos(90, MAINMENU_X, MENUS_Y, 0, pCKP); - + fade.mode = FADE_GO; fade.dir = FADE_IN; fade.curamt = 0; @@ -921,17 +921,17 @@ short GraphicsDlg(stCloneKeenPlus *pCKP) } // Render the Games-Menu DisplayMenu->renderDialog(); - + // blit the scrollbuffer to the display gamedo_frameskipping_blitonly(); - + g_pInput->pollEvents(); g_pTimer->SpeedThrottle(); - + } while(1); - + delete DisplayMenu; - + return retval; } @@ -946,41 +946,41 @@ void showPage(char *text, stCloneKeenPlus *pCKP, int textsize) unsigned int dlgX,dlgY,dlgW,dlgH; unsigned int scroll, maxscroll; char buffer[200][40]; - + showmapatpos(90, STORYBOARD_X, STORYBOARD_Y, 0, pCKP); - + fade.mode = FADE_GO; fade.rate = FADE_NORM; fade.dir = FADE_IN; fade.curamt = 0; fade.fadetimer = 0; - + scroll=0; maxscroll=0; - + j=0; k=0; - + AllPlayersInvisible(); - - dlgX = 0; - dlgY = 0; - dlgW = 39; - dlgH = 15; - - textpos=0; - memset(buffer,0,200*40*sizeof(char)); - // Prepare the buffer - - char sbuf[256]; - unsigned int totnumline=0; - - for(i=0;i<200;i++) - { + + dlgX = 0; + dlgY = 0; + dlgW = 39; + dlgH = 15; + + textpos=0; + memset(buffer,0,200*40*sizeof(char)); + // Prepare the buffer + + char sbuf[256]; + unsigned int totnumline=0; + + for(i=0;i<200;i++) + { for(j=0;j dlgW-2)) { if(text[textpos] == ' ') @@ -989,20 +989,20 @@ void showPage(char *text, stCloneKeenPlus *pCKP, int textsize) break; } } - + if(text[textpos]=='\n' ) { textpos++; break; } - + if(text[textpos]==31 ) // I don't know, what they do, - //but original version seems to ignore them! + //but original version seems to ignore them! { text[textpos]=' '; } - - + + buffer[i][j]=text[textpos]; textpos++; if(textpos >= textsize) @@ -1013,44 +1013,42 @@ void showPage(char *text, stCloneKeenPlus *pCKP, int textsize) totnumline+=3; break; } - + totnumline++; - } - buffer[i][j] = ' '; // Last character is empty! - - char coverline[39]; - memset(coverline,2,38*sizeof(char)); // for the upper and lower edges - coverline[38]=0; - - do - { + } + buffer[i][j] = ' '; // Last character is empty! + + char coverline[39]; + memset(coverline,2,38*sizeof(char)); // for the upper and lower edges + coverline[38]=0; + + do + { gamedo_fades(); - + gamedo_AnimatedTiles(); - + sb_dialogbox(dlgX, dlgY, dlgW, dlgH); - + k=0; - + // Draw the text for(i=0;i>3)][0]=='~') // Special Background Colour { - char temp[39]; - memset(temp,' ',38*sizeof(char)); - temp[38]=0; - g_pGraphics->sb_color_font_draw((unsigned char*) temp, (dlgX+1)<<3, (((dlgY+i+1)<<3) -(scroll%8)),COLOUR_DARKRED,COLOUR_GREY); - g_pGraphics->sb_color_font_draw((unsigned char*) buffer[i+(scroll>>3)]+1, (dlgX+1)<<3, (((dlgY+i+1)<<3) -(scroll%8)),COLOUR_DARKRED,COLOUR_GREY); + std::string temp(38, ' '); + g_pGraphics->sb_color_font_draw(temp, (dlgX+1)<<3, (((dlgY+i+1)<<3) -(scroll%8)),COLOUR_DARKRED,COLOUR_GREY); + g_pGraphics->sb_color_font_draw(buffer[i+(scroll>>3)]+1, (dlgX+1)<<3, (((dlgY+i+1)<<3) -(scroll%8)),COLOUR_DARKRED,COLOUR_GREY); } else { - g_pGraphics->sb_font_draw((unsigned char*) buffer[i+(scroll>>3)], (dlgX+1)<<3, (((dlgY+i+1)<<3) -(scroll%8))); + g_pGraphics->sb_font_draw(buffer[i+(scroll>>3)], (dlgX+1)<<3, (((dlgY+i+1)<<3) -(scroll%8))); } } - g_pGraphics->sb_font_draw((unsigned char*) coverline, (dlgX+1)<<3, dlgY); // Upper and lower edge Update - g_pGraphics->sb_font_draw((unsigned char*) coverline, (dlgX+1)<<3, (dlgY+dlgH-1)<<3); - + g_pGraphics->sb_font_draw(coverline, (dlgX+1)<<3, dlgY); // Upper and lower edge Update + g_pGraphics->sb_font_draw(coverline, (dlgX+1)<<3, (dlgY+dlgH-1)<<3); + // If user presses up or down if (g_pInput->getHoldedCommand(0,IC_DOWN) || g_pInput->getHoldedCommand(1,IC_DOWN)) { @@ -1064,7 +1062,7 @@ void showPage(char *text, stCloneKeenPlus *pCKP, int textsize) scroll--; SDL_Delay(2); } - + enter = (g_pInput->getPressedCommand(0,IC_STATUS) || g_pInput->getPressedCommand(1,IC_STATUS)); if (enter) { @@ -1075,19 +1073,19 @@ void showPage(char *text, stCloneKeenPlus *pCKP, int textsize) fade.rate = FADE_NORM; fade.mode = FADE_GO; } - + gamedo_frameskipping(pCKP); - + g_pInput->pollEvents(); g_pTimer->SpeedThrottle(); - - + + if(exit==1 && fade.mode==FADE_COMPLETE) break; - + if (g_pInput->getPressedCommand(KQUIT)) break; - } while(!crashflag); - return; + } while(!crashflag); + return; } char configmenu(stCloneKeenPlus *pCKP) @@ -1096,45 +1094,45 @@ char configmenu(stCloneKeenPlus *pCKP) int bmnum; int selection; int x; - + showmapatpos(90, MAINMENU_X, MENUS_Y, 0, pCKP); - + // Load the Title Bitmap bmnum = g_pGraphics->getBitmapNumberFromName("TITLE"); - + x = (320/2)-(bitmaps[bmnum].xsize/2); - + g_pGraphics->drawBitmap(x, 0, bmnum); - + // Prepare the Games Menu OptionsMenu = new CDialog(); - + OptionsMenu->setDimensions(15,4,14,8); - + OptionsMenu->addOptionText("Graphics"); OptionsMenu->addOptionText("Audio"); OptionsMenu->addOptionText("Game"); OptionsMenu->addOptionText("Controls"); OptionsMenu->addSeparator(); OptionsMenu->addOptionText("Back"); - + OptionsMenu->animateDialogBox(true); - + do { // do fades gamedo_fades(); if(fade.mode == FADE_COMPLETE) OptionsMenu->setVisible(true); - + gamedo_AnimatedTiles(); - + // Check the Input if(g_pInput->getPulsedCommand(IC_DOWN, 80)) OptionsMenu->setNextSelection(); if(g_pInput->getPulsedCommand(IC_UP, 80)) OptionsMenu->setPrevSelection(); - + if(g_pInput->getPressedCommand(IC_STATUS)) { selection = OptionsMenu->getSelection(); @@ -1142,39 +1140,39 @@ char configmenu(stCloneKeenPlus *pCKP) } // Render the Games-Menu OptionsMenu->renderDialog(); - + // blit the scrollbuffer to the display gamedo_frameskipping_blitonly(); - + g_pInput->pollEvents(); g_pTimer->SpeedThrottle(); - + } while(1); - + switch(selection) { - case 0: - GraphicsDlg(pCKP); - break; - - case 1: - AudioDlg(pCKP); - break; - - case 2: - OptionsDlg(pCKP); - break; - - case 3: - controlsmenu(pCKP); - break; - - default: - break; + case 0: + GraphicsDlg(pCKP); + break; + + case 1: + AudioDlg(pCKP); + break; + + case 2: + OptionsDlg(pCKP); + break; + + case 3: + controlsmenu(pCKP); + break; + + default: + break; } - + delete OptionsMenu; - + return 0; } @@ -1186,21 +1184,21 @@ char controlsmenu(stCloneKeenPlus *pCKP) int x; char buf[256]; char buf2[256]; - + showmapatpos(90, MAINMENU_X, MENUS_Y, 0, pCKP); - + // Load the Title Bitmap bmnum = g_pGraphics->getBitmapNumberFromName("TITLE"); - + x = (320/2)-(bitmaps[bmnum].xsize/2); - + g_pGraphics->drawBitmap(x, 0, bmnum); - + // Prepare the Games Menu ControlsMenu = new CDialog(); - + ControlsMenu->setDimensions(1,2,38,21); - + g_pInput->getEventName(IC_LEFT, 0, buf2); sprintf(buf,"P1 Left: %s",buf2); ControlsMenu->addOptionText(buf); @@ -1225,7 +1223,7 @@ char controlsmenu(stCloneKeenPlus *pCKP) g_pInput->getEventName(IC_STATUS, 0, buf2); sprintf(buf,"P1 Status: %s",buf2); ControlsMenu->addOptionText(buf); - + g_pInput->getEventName(IC_LEFT, 1, buf2); sprintf(buf,"P2 Left: %s",buf2); ControlsMenu->addOptionText(buf); @@ -1253,9 +1251,9 @@ char controlsmenu(stCloneKeenPlus *pCKP) ControlsMenu->addSeparator(); ControlsMenu->addOptionText("Reset Controls"); ControlsMenu->addOptionText("Return"); - + ControlsMenu->animateDialogBox(true); - + do { // do fades @@ -1263,17 +1261,17 @@ char controlsmenu(stCloneKeenPlus *pCKP) if(fade.mode == FADE_COMPLETE) ControlsMenu->setVisible(true); gamedo_AnimatedTiles(); - + // Check the Input if(g_pInput->getPulsedCommand(IC_DOWN, 80)) ControlsMenu->setNextSelection(); if(g_pInput->getPulsedCommand(IC_UP, 80)) ControlsMenu->setPrevSelection(); - + if(g_pInput->getPressedCommand(IC_STATUS)) { selection = ControlsMenu->getSelection(); - + if(selection < MAX_COMMANDS) { int item=0; @@ -1281,29 +1279,29 @@ char controlsmenu(stCloneKeenPlus *pCKP) item = selection + 4; else item = selection - 4; - + switch(selection) { - case 0: sprintf(buf,"P1 Left: "); break; - case 1: sprintf(buf,"P1 Up: "); break; - case 2: sprintf(buf,"P1 Right: "); break; - case 3: sprintf(buf,"P1 Down: "); break; - case 4: sprintf(buf,"P1 Jump: "); break; - case 5: sprintf(buf,"P1 Pogo: "); break; - case 6: sprintf(buf,"P1 Fire: "); break; - case 7: sprintf(buf,"P1 Status: "); break; + case 0: sprintf(buf,"P1 Left: "); break; + case 1: sprintf(buf,"P1 Up: "); break; + case 2: sprintf(buf,"P1 Right: "); break; + case 3: sprintf(buf,"P1 Down: "); break; + case 4: sprintf(buf,"P1 Jump: "); break; + case 5: sprintf(buf,"P1 Pogo: "); break; + case 6: sprintf(buf,"P1 Fire: "); break; + case 7: sprintf(buf,"P1 Status: "); break; } - + strcpy(buf2,buf); strcat(buf2,"*Waiting for Input*"); ControlsMenu->setOptionText(selection,buf2); - + while(!g_pInput->readNewEvent(0,item)) { ControlsMenu->renderDialog(); gamedo_frameskipping_blitonly(); } - + g_pInput->getEventName(item, 0, buf2); strcat(buf,buf2); ControlsMenu->setOptionText(selection,buf); @@ -1315,29 +1313,29 @@ char controlsmenu(stCloneKeenPlus *pCKP) item = selection + 4 - MAX_COMMANDS; else item = selection - 4 - MAX_COMMANDS; - + switch(selection) { - case 0+ MAX_COMMANDS: sprintf(buf,"P2 Left: "); break; - case 1+ MAX_COMMANDS: sprintf(buf,"P2 Up: "); break; - case 2+ MAX_COMMANDS: sprintf(buf,"P2 Right: "); break; - case 3+ MAX_COMMANDS: sprintf(buf,"P2 Down: "); break; - case 4+ MAX_COMMANDS: sprintf(buf,"P2 Jump: "); break; - case 5+ MAX_COMMANDS: sprintf(buf,"P2 Pogo: "); break; - case 6+ MAX_COMMANDS: sprintf(buf,"P2 Fire: "); break; - case 7+ MAX_COMMANDS: sprintf(buf,"P2 Status: "); break; + case 0+ MAX_COMMANDS: sprintf(buf,"P2 Left: "); break; + case 1+ MAX_COMMANDS: sprintf(buf,"P2 Up: "); break; + case 2+ MAX_COMMANDS: sprintf(buf,"P2 Right: "); break; + case 3+ MAX_COMMANDS: sprintf(buf,"P2 Down: "); break; + case 4+ MAX_COMMANDS: sprintf(buf,"P2 Jump: "); break; + case 5+ MAX_COMMANDS: sprintf(buf,"P2 Pogo: "); break; + case 6+ MAX_COMMANDS: sprintf(buf,"P2 Fire: "); break; + case 7+ MAX_COMMANDS: sprintf(buf,"P2 Status: "); break; } - + strcpy(buf2,buf); strcat(buf2,"*Waiting for Input*"); ControlsMenu->setOptionText(selection,buf2); - + while(!g_pInput->readNewEvent(1,item)) { ControlsMenu->renderDialog(); gamedo_frameskipping_blitonly(); } - + g_pInput->getEventName(item, 1, buf2); strcat(buf,buf2); ControlsMenu->setOptionText(selection,buf); @@ -1357,101 +1355,98 @@ char controlsmenu(stCloneKeenPlus *pCKP) } // Render the Menu ControlsMenu->renderDialog(); - + // blit the scrollbuffer to the display gamedo_frameskipping_blitonly(); - + g_pInput->pollEvents(); g_pTimer->SpeedThrottle(); - + } while(1); - + delete ControlsMenu; return 0; } void keensleft(stCloneKeenPlus *pCKP) { - int enter, lastenterstate; - unsigned int p; - int x,y,i; - int boxY, boxH; - int boxtimer; - int ep3; - - stLevelControl *p_levelcontrol; - - p_levelcontrol = &(pCKP->Control.levelcontrol); - - // on episode 3 we have to subtract one from the map tiles - // because the tiles start at 31, not 32 like on the other eps - ep3 = 0; - if (p_levelcontrol->episode==3) ep3 = 1; - -#define KEENSLEFT_TIME 400 - - for(i=0;idrawFont( (unsigned char*) getstring("LIVES_LEFT_BACKGROUND"),(KEENSLEFT_X+1)*8,(boxY+1)*8,0); - g_pGraphics->drawFont( (unsigned char*) getstring("LIVES_LEFT"),((KEENSLEFT_X+7)*8)+4,(boxY+1)*8,0); - y = ((boxY+2)*8)+4; - if (numplayers>1) y--; - for(p=0;pdrawSprite_direct(x, y, PMAPDOWNFRAME+playerbaseframes[p]-ep3); - x+=16; - } - y+=18; - } - g_pVideoDriver->update_screen(); - - g_pSound->playSound(SOUND_KEENSLEFT, PLAY_NOW); - - boxtimer = 0; - do - { - - gamedo_fades(); - - if (boxtimer > KEENSLEFT_TIME) - { - break; - } else boxtimer++; - - enter = g_pInput->getPressedCommand(IC_STATUS)||g_pInput->getPressedCommand(IC_FIRE)|| - g_pInput->getPressedCommand(IC_JUMP)||g_pInput->getPressedCommand(IC_POGO); - if (enter) - { - break; - } - if (g_pInput->getPressedCommand(KQUIT)) - { - return; - } - - lastenterstate = enter; - g_pInput->pollEvents(); - g_pTimer->SpeedThrottle(); - } while(!crashflag); - +int enter, lastenterstate; +unsigned int p; +int x,y,i; +int boxY, boxH; +int boxtimer; + +stLevelControl *p_levelcontrol = &pCKP->Control.levelcontrol; + + // on episode 3 we have to subtract one from the map tiles + // because the tiles start at 31, not 32 like on the other eps + int ep3 = 0; + if (p_levelcontrol->episode==3) ep3 = 1; + + #define KEENSLEFT_TIME 400 + + for(i=0;idrawFont( getstring("LIVES_LEFT_BACKGROUND"),(KEENSLEFT_X+1)*8,(boxY+1)*8,0); + g_pGraphics->drawFont( getstring("LIVES_LEFT"),((KEENSLEFT_X+7)*8)+4,(boxY+1)*8,0); + y = ((boxY+2)*8)+4; + if (numplayers>1) y--; + for(p=0;pdrawSprite_direct(x, y, PMAPDOWNFRAME+playerbaseframes[p]-ep3); + x+=16; + } + y+=18; + } + g_pVideoDriver->update_screen(); + + g_pSound->playSound(SOUND_KEENSLEFT, PLAY_NOW); + + boxtimer = 0; + do + { + + gamedo_fades(); + + if (boxtimer > KEENSLEFT_TIME) + { + break; + } else boxtimer++; + + enter = g_pInput->getPressedCommand(IC_STATUS)||g_pInput->getPressedCommand(IC_FIRE)|| + g_pInput->getPressedCommand(IC_JUMP)||g_pInput->getPressedCommand(IC_POGO); + if (enter) + { + break; + } + if (g_pInput->getPressedCommand(KQUIT)) + { + return; + } + + lastenterstate = enter; + g_pInput->pollEvents(); + g_pTimer->SpeedThrottle(); + } while(!crashflag); + }