From cb8f1a3ae0a8dc1c974f4e09cefd9b17cc6d5048 Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 11 Jan 2001 17:08:34 +0000 Subject: [PATCH] --- source/paul/scenesel.cpp | 218 +++++++++++++++++++++++++++++++++++++++ source/paul/scenesel.h | 87 ++++++++++++++++ 2 files changed, 305 insertions(+) create mode 100644 source/paul/scenesel.cpp create mode 100644 source/paul/scenesel.h diff --git a/source/paul/scenesel.cpp b/source/paul/scenesel.cpp new file mode 100644 index 000000000..f16a4e203 --- /dev/null +++ b/source/paul/scenesel.cpp @@ -0,0 +1,218 @@ +/*========================================================================= + + scenesel.cpp + + Author: PKG + Created: + Project: Spongebob + Purpose: + + Copyright (c) 2000 Climax Development Ltd + +===========================================================================*/ + + +/*---------------------------------------------------------------------- + Includes + -------- */ + +#include "paul\scenesel.h" + +#ifndef __GFX_FONT_H__ +#include "gfx\font.h" +#endif + +#ifndef __PAD_PADS_H__ +#include "pad\pads.h" +#endif + +#ifndef __DATA_STRUCTS_HEADER__ +#include "Dstructs.h" +#endif + +#ifndef __PRIM_HEADER__ +#include "gfx\prim.h" +#endif + +// Scenes +#ifndef __FRONTEND_FRONTEND_H__ +#include "frontend\frontend.h" +#endif + +#ifndef __GAME_GAME_H__ +#include "game\game.h" +#endif + + +/* Std Lib + ------- */ + +/* Data + ---- */ + +/*---------------------------------------------------------------------- + Tyepdefs && Defines + ------------------- */ + +/*---------------------------------------------------------------------- + Structure defintions + -------------------- */ + +/*---------------------------------------------------------------------- + Function Prototypes + ------------------- */ + +/*---------------------------------------------------------------------- + Vars + ---- */ + +CScene *CSceneSelector::s_sceneList[]= +{ + &GameScene, // First scene in the list is the default scene + &FrontEndScene, +}; +int CSceneSelector::s_sceneCount=sizeof(s_sceneList)/sizeof(CScene*); + + +CSceneSelector SceneSelector; + + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +void CSceneSelector::init() +{ + m_font=new ("scene select font") FontBank(); + m_font->initialise(&standardFont); + m_font->setJustification(FontBank::JUST_CENTRE); + m_font->setOt(10); + + m_currentSelection=0; + m_state=STATE_INIT; + m_countdown=2; // Need a couple of frames for the pad handler to wake up.. +} + + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +void CSceneSelector::shutdown() +{ + m_font->dump(); delete m_font; +} + + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +void CSceneSelector::render() +{ + if(m_state==STATE_SELECTING) + { + POLY_F4 *f4; + + f4=GetPrimF4(); + setXYWH(f4,0,0,512,256); + setRGB0(f4,10,20,30); + AddPrimToList(f4,20); + + m_font->setColour(255,255,255); + m_font->print(256,100,"Select scene:"); + m_font->setColour(100,255,100); + m_font->print(256,120,s_sceneList[m_currentSelection]->getSceneName()); + } +} + + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +void CSceneSelector::think(int _frames) +{ + switch(m_state) + { + case STATE_INIT: + { + if(--m_countdown==0) + { + int pad; + pad=PadGetHeld(0); + if(pad&(PAD_L1|PAD_L2)) + { + m_state=STATE_SELECTING; + } + else + { + m_state=STATE_SELECTED; + } + } + break; + } + + case STATE_SELECTING: + { + int pad; + pad=PadGetDown(0); + if(pad&PAD_UP) + { + if(--m_currentSelection==-1)m_currentSelection=s_sceneCount-1; + } + else if(pad&PAD_DOWN) + { + if(++m_currentSelection==s_sceneCount)m_currentSelection=0; + } + else if(pad&(PAD_CROSS|PAD_START)) + { + m_state=STATE_SELECTED; + } + break; + } + + case STATE_SELECTED: + { + selectScene(m_currentSelection); + m_state=STATE_READY_TO_EXIT; + break; + } + } +} + + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +int CSceneSelector::readyToShutdown() +{ + return m_state==STATE_READY_TO_EXIT; +} + + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +void CSceneSelector::selectScene(int _scene) +{ + GameState::setNextScene(s_sceneList[_scene]); +} + + +/*=========================================================================== + end */ \ No newline at end of file diff --git a/source/paul/scenesel.h b/source/paul/scenesel.h new file mode 100644 index 000000000..4a6192450 --- /dev/null +++ b/source/paul/scenesel.h @@ -0,0 +1,87 @@ +/*========================================================================= + + scenesel.h + + Author: PKG + Created: + Project: Spongebob + Purpose: Scene selection thingy.. + + Copyright (c) 2000 Climax Development Ltd + +===========================================================================*/ + +#ifndef __PAUL_SCENESEL_H__ +#define __PAUL_SCENESEL_H__ + +/*---------------------------------------------------------------------- + Includes + -------- */ + +#ifndef __SYSTEM_GSTATE_H__ +#include "system\gstate.h" +#endif + + +/* Std Lib + ------- */ + +/*---------------------------------------------------------------------- + Tyepdefs && Defines + ------------------- */ + +/*---------------------------------------------------------------------- + Structure defintions + -------------------- */ + +class CSceneSelector : public CScene +{ +public: + void init(); + void shutdown(); + void render(); + void think(int _frames); + int readyToShutdown(); + char *getSceneName() {return"SceneSelector";} + + +private: + enum + { + STATE_INIT, + STATE_SELECTING, + STATE_SELECTED, + STATE_READY_TO_EXIT, + }; + + static class CScene *s_sceneList[]; + static int s_sceneCount; + int m_currentSelection; + int m_state; + int m_countdown; + + class FontBank *m_font; + + + void selectScene(int _scene); + +}; + + +/*---------------------------------------------------------------------- + Globals + ------- */ + +extern CSceneSelector SceneSelector; + + +/*---------------------------------------------------------------------- + Functions + --------- */ + +/*---------------------------------------------------------------------- */ + +#endif /* __PAUL_SCENESEL_H__ */ + +/*=========================================================================== + end */