From f2229b2f5ab5e9c49af27badf6cda687316c80ca Mon Sep 17 00:00:00 2001 From: gerstrong Date: Tue, 4 Aug 2009 16:53:26 +0000 Subject: [PATCH] Ordering info option has been added. This only works with Ep. 1 git-svn-id: https://clonekeenplus.svn.sourceforge.net/svnroot/clonekeenplus/cgenius/trunk@209 4df4b0f3-56ce-47cb-b001-ed939b7d65a6 --- src/CGame.cpp | 10 ++- src/keen.h | 27 ++++--- src/menu.cpp | 3 +- src/vorticon/COrderingInfo.cpp | 141 +++++++++++++++++++++++++++++++++ src/vorticon/COrderingInfo.h | 29 +++++++ 5 files changed, 195 insertions(+), 15 deletions(-) create mode 100644 src/vorticon/COrderingInfo.cpp create mode 100644 src/vorticon/COrderingInfo.h diff --git a/src/CGame.cpp b/src/CGame.cpp index aa19fbad3..2b25d69fe 100644 --- a/src/CGame.cpp +++ b/src/CGame.cpp @@ -24,6 +24,7 @@ #include "fileio/CPatcher.h" #include "sdl/sound/CSound.h" #include "sdl/CVideoDriver.h" +#include "vorticon/COrderingInfo.h" CGame::CGame() { m_Episode = 0; @@ -161,7 +162,14 @@ short CGame::runCycle(stCloneKeenPlus *pCKP) pCredit = new CCredits; pCredit->Render(pCKP); delete pCredit; - pCredit = NULL; + break; + + case MAINMNU_ORDERING_INFO: + COrderingInfo *OrderingInfo; + OrderingInfo = new COrderingInfo(pCKP->Control.levelcontrol.episode, + pCKP->GameData[pCKP->Resources.GameSelected-1].DataDirectory); + OrderingInfo->Render(pCKP); + delete OrderingInfo; break; case MAINMNU_TIMEOUT: diff --git a/src/keen.h b/src/keen.h index f7dd95c8c..a11756d3b 100644 --- a/src/keen.h +++ b/src/keen.h @@ -766,19 +766,20 @@ typedef struct stShipQueue #define BONUSLEVEL_RESPAWN_X 31812 #define BONUSLEVEL_RESPAWN_Y 18936 - #define MAINMNU_1PLAYER 0 - #define MAINMNU_2PLAYER 1 - #define MAINMNU_LOADGAME 2 - #define MAINMNU_STORY 3 - #define MAINMNU_HIGHSCORES 4 - #define MAINMNU_OPTIONS 5 - #define MAINMNU_DEMO 6 - #define MAINMNU_NEW_GAME 7 - #define MAINMNU_ABOUT 8 - #define MAINMNU_QUIT 9 - #define MAINMNU_TIMEOUT 11 // going to demo due to timeout - #define RESTART_GAME 12 - #define BACK2MAINMENU 13 + #define MAINMNU_1PLAYER 0 + #define MAINMNU_2PLAYER 1 + #define MAINMNU_LOADGAME 2 + #define MAINMNU_STORY 3 + #define MAINMNU_HIGHSCORES 4 + #define MAINMNU_OPTIONS 5 + #define MAINMNU_DEMO 6 + #define MAINMNU_NEW_GAME 7 + #define MAINMNU_ABOUT 8 + #define MAINMNU_ORDERING_INFO 9 + #define MAINMNU_QUIT 10 + #define MAINMNU_TIMEOUT 11 // going to demo due to timeout + #define RESTART_GAME 12 + #define BACK2MAINMENU 13 #define MAINMENU_NUM_OPTIONS MAINMNU_QUIT diff --git a/src/menu.cpp b/src/menu.cpp index e01865b4f..24b433de3 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -240,7 +240,7 @@ int mainmenu(stCloneKeenPlus *pCKP,int defaultopt) // Prepare the Games Menu MainMenu = new CDialog(); - MainMenu->setDimensions(11,8,18,12); + MainMenu->setDimensions(11,7,18,13); // Load the Title Bitmap bmnum = g_pGraphics->getBitmapNumberFromName("TITLE"); @@ -254,6 +254,7 @@ int mainmenu(stCloneKeenPlus *pCKP,int defaultopt) MainMenu->addOptionText("Demo"); MainMenu->addOptionText("Change Game"); MainMenu->addOptionText("About CG"); + MainMenu->addOptionText("Ordering Info"); MainMenu->addOptionText("Quit"); x = (320/2)-(bitmaps[bmnum].xsize/2); diff --git a/src/vorticon/COrderingInfo.cpp b/src/vorticon/COrderingInfo.cpp new file mode 100644 index 000000000..1697c2720 --- /dev/null +++ b/src/vorticon/COrderingInfo.cpp @@ -0,0 +1,141 @@ +/* + * COrderingInfo.cpp + * + * Created on: 04.08.2009 + * Author: gerstrong + */ + +#include "../keen.h" +#include "COrderingInfo.h" +#include "../sdl/CTimer.h" +#include "../sdl/CInput.h" +#include "../CGraphics.h" +#include "../CLogFile.h" +#include "../include/menu.h" +#include "../include/gamedo.h" +#include "../fileio/CExeFile.h" + +COrderingInfo::COrderingInfo(int episode, std::string& datadirectory) { + CExeFile *Exefile = new CExeFile(episode, datadirectory); + + // load the exe file + Exefile->readData(); + + // Get the offset where in the data the info is... + size_t offset = 0; + switch(episode) + { + case 1: + m_starty = 4; // start of y-coordinate in textheights + m_numberoflines = 21; // numberof lines to print + if(Exefile->getEXEVersion() == 131) + offset = 0x1632C; + break; + } + + // Read the strings and save them the string array of the class + if(offset) + { + char *data; + data = (char*)Exefile->getData() + offset; + std::string buf; + for(int i=0 ; itextOut(RED,"Sorry, but the ordering information text could not be read. Returning to the main menu...
"); + return; + } + + fade.mode = FADE_GO; + fade.rate = FADE_NORM; + fade.dir = FADE_IN; + fade.curamt = 0; + fade.fadetimer = 0; + + showmapatpos(90, 22<<4, 32, 0, pCKP); + + do + { + // do fades + gamedo_fades(); + + // blit the scrollbuffer to the display + gamedo_frameskipping_blitonly(); + + gamedo_AnimatedTiles(); + + if(fade.mode != FADE_COMPLETE) + continue; + + for(int i=0 ; idrawFont(m_Textline[i], m_Text_Coordinate[i], 8*(i+m_starty), true); + } + + if( g_pInput->getPressedAnyCommand() ) + { + cancel = true; + fade.dir = FADE_OUT; + fade.curamt = PAL_FADE_SHADES; + fade.fadetimer = 0; + fade.rate = FADE_NORM; + fade.mode = FADE_GO; + } + + if(g_pInput->getExitEvent()) cancel=true; + + g_pInput->pollEvents(); + g_pTimer->SpeedThrottle(); + + } while(!(cancel && fade.mode == FADE_COMPLETE)); + + +} diff --git a/src/vorticon/COrderingInfo.h b/src/vorticon/COrderingInfo.h new file mode 100644 index 000000000..4315f9c09 --- /dev/null +++ b/src/vorticon/COrderingInfo.h @@ -0,0 +1,29 @@ +/* + * COrderingInfo.h + * + * Created on: 04.08.2009 + * Author: gerstrong + */ + +#ifndef CORDERINGINFO_H_ +#define CORDERINGINFO_H_ + +#include +#include + +class COrderingInfo { +public: + COrderingInfo(int episode, std::string& datadirectory); + virtual ~COrderingInfo(); + + void Render(stCloneKeenPlus *pCKP); + +private: + std::vector m_Text_Coordinate; + std::vector m_Textline; + + int m_starty; // start of y-coordinate in textheights + int m_numberoflines; // number of lines to print +}; + +#endif /* CORDERINGINFO_H_ */