This commit is contained in:
parent
5c9ba0bed4
commit
cb8f1a3ae0
2 changed files with 305 additions and 0 deletions
218
source/paul/scenesel.cpp
Normal file
218
source/paul/scenesel.cpp
Normal file
|
@ -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 */
|
87
source/paul/scenesel.h
Normal file
87
source/paul/scenesel.h
Normal file
|
@ -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 */
|
Loading…
Add table
Reference in a new issue