diff --git a/src/cinematics/CommonEnding.cpp b/src/cinematics/CommonEnding.cpp index 4714b81f3..a5fe019d0 100644 --- a/src/cinematics/CommonEnding.cpp +++ b/src/cinematics/CommonEnding.cpp @@ -12,6 +12,8 @@ #include "../sdl/CInput.h" #include "../sdl/CTimer.h" +#include "../include/game.h" + #define LETTER_SHOW_SPD 30 #define HEADFOREARTH_WAIT_TIME 600 @@ -37,6 +39,11 @@ int endsequence(stCloneKeenPlus *pCKP) if (eseq3_AwardBigV(pCKP)) return 0; } + pCKP->Control.levelcontrol.gameovermode = true; + // Remove all the items. + + start_gameover(pCKP); + return 0; } diff --git a/src/game.cpp b/src/game.cpp index 8de428cc9..e96af6dfd 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -183,55 +183,7 @@ void gameloop(stCloneKeenPlus *pCKP) if (pCKP->Control.levelcontrol.gameovermode) { if (enter) - { - int cities=0; - CHighScores *HighScoreTable; - - if (pCKP->Control.levelcontrol.levels_completed[4]) cities++; - if (pCKP->Control.levelcontrol.levels_completed[6]) cities++; - if (pCKP->Control.levelcontrol.levels_completed[7]) cities++; - if (pCKP->Control.levelcontrol.levels_completed[13]) cities++; - if (pCKP->Control.levelcontrol.levels_completed[11]) cities++; - if (pCKP->Control.levelcontrol.levels_completed[9]) cities++; - if (pCKP->Control.levelcontrol.levels_completed[15]) cities++; - if (pCKP->Control.levelcontrol.levels_completed[16]) cities++; - - HighScoreTable = new CHighScores(pCKP); - - bool extras[4] = {false,false,false,false}; - - // check inventory or saved cities - if(pCKP->Control.levelcontrol.episode == 1) - { - if(player[0].inventory.HasJoystick) - extras[0] = true; - if(player[0].inventory.HasBattery) - extras[1] = true; - if(player[0].inventory.HasVacuum) - extras[2] = true; - if(player[0].inventory.HasWiskey) - extras[3] = true; - } - - HighScoreTable->writeHighScore((int)player[0].inventory.score,extras,cities); - - HighScoreTable->showHighScore(); - - delete HighScoreTable; - - - if (fade.mode!=FADE_GO && fade.dir!=FADE_OUT) - { - fade.dir = FADE_OUT; - fade.curamt = PAL_FADE_SHADES; - fade.fadetimer = 0; - fade.rate = FADE_NORM; - fade.mode = FADE_GO; - } - - pCKP->Control.levelcontrol.command = LVLC_GAME_OVER; - - } + start_gameover( pCKP ); if (fade.mode==FADE_COMPLETE && fade.dir==FADE_OUT) { @@ -271,6 +223,57 @@ void gameloop(stCloneKeenPlus *pCKP) } +void start_gameover(stCloneKeenPlus *pCKP) +{ + int cities=0; + CHighScores *HighScoreTable = new CHighScores(pCKP); + + bool extras[4] = {false,false,false,false}; + + stLevelControl *p_levelcontrol = &(pCKP->Control.levelcontrol); + + // check inventory or saved cities + if(p_levelcontrol->episode == 1) + { + if(player[0].inventory.HasJoystick) + extras[0] = true; + if(player[0].inventory.HasBattery) + extras[1] = true; + if(player[0].inventory.HasVacuum) + extras[2] = true; + if(player[0].inventory.HasWiskey) + extras[3] = true; + } + else if(p_levelcontrol->episode == 2) + { + if (p_levelcontrol->levels_completed[4]) cities++; + if (p_levelcontrol->levels_completed[6]) cities++; + if (p_levelcontrol->levels_completed[7]) cities++; + if (p_levelcontrol->levels_completed[13]) cities++; + if (p_levelcontrol->levels_completed[11]) cities++; + if (p_levelcontrol->levels_completed[9]) cities++; + if (p_levelcontrol->levels_completed[15]) cities++; + if (p_levelcontrol->levels_completed[16]) cities++; + } + + HighScoreTable->writeHighScore((int)player[0].inventory.score,extras,cities); + + HighScoreTable->showHighScore(); + + delete HighScoreTable; + + if (fade.mode!=FADE_GO && fade.dir!=FADE_OUT) + { + fade.dir = FADE_OUT; + fade.curamt = PAL_FADE_SHADES; + fade.fadetimer = 0; + fade.rate = FADE_NORM; + fade.mode = FADE_GO; + } + + p_levelcontrol->command = LVLC_GAME_OVER; +} + // gives keycard for door doortile to player p void give_keycard(int doortile, int p) { diff --git a/src/include/game.h b/src/include/game.h index 961e165c3..097ae1946 100644 --- a/src/include/game.h +++ b/src/include/game.h @@ -271,3 +271,4 @@ void gamedo_enemyai(stLevelControl *p_levelcontrol); // Referenzed from cinematics/EndingSequenceEp3.cpp void eseq3_Mortimer(); +void start_gameover(stCloneKeenPlus *pCKP); diff --git a/src/vorticon/CHighScores.cpp b/src/vorticon/CHighScores.cpp index 0db1da906..6f768c6b4 100644 --- a/src/vorticon/CHighScores.cpp +++ b/src/vorticon/CHighScores.cpp @@ -293,13 +293,13 @@ char CHighScores::writeHighScore(int points, bool *extras, int cities) g_pGraphics->drawBitmap(x4, y2, bExtra); memset(buf,0,256); - *buf= '_'; // This cycle will wait for the input of name and hit of enter + bool blink = true; + int blinkctr = 0; do { // Blit all the text and images - for(i=KA ; igetPressedKey(i)) @@ -308,7 +308,6 @@ char CHighScores::writeHighScore(int points, bool *extras, int cities) WrittenName.append(buf); copy(WrittenName.data(),WrittenName.data()+WrittenName.length(),Name[place]); WrittenName.copy(buf,WrittenName.length(),0); - strcat(buf,"_"); } } if(g_pInput->getPressedKey(KBCKSPCE) && (WrittenName.length() > 0)) @@ -319,7 +318,6 @@ char CHighScores::writeHighScore(int points, bool *extras, int cities) WrittenName.copy(buf,WrittenName.length(),0); memset(Name[place],0,16); WrittenName.copy(Name[place],WrittenName.length(),0); - strcat(buf,"_"); } @@ -328,13 +326,18 @@ char CHighScores::writeHighScore(int points, bool *extras, int cities) // Here it must be split up in Episodes 1, 2 and 3. // Print the labels - for( i=0 ; i<7 ; i++ ) { if(i != place) g_pGraphics->sb_color_font_draw(Name[i],40,64+(i<<4),4,7); else + { g_pGraphics->sb_color_font_draw(buf,40,64+(i<<4),4,7); + if(blink) + g_pGraphics->sb_color_font_draw("_",40+(strlen(buf)<<3),64+(i<<4),4,7); + else + g_pGraphics->sb_color_font_draw(" ",40+(strlen(buf)<<3),64+(i<<4),4,7); + } g_pGraphics->sb_color_font_draw(Score[i],200-(strlen(Score[i])<<3),64+(i<<4),4,7); if(pCKP->Control.levelcontrol.episode == 1) @@ -357,6 +360,13 @@ char CHighScores::writeHighScore(int points, bool *extras, int cities) g_pInput->pollEvents(); g_pTimer->SpeedThrottle(); + blinkctr++; // The blinking cursor + if(blinkctr > 100) + { + blink = !blink; + blinkctr = 0; + } + }while(!g_pInput->getPressedKey(KENTER)); saveHighScoreTable();