2001-01-11 18:08:34 +01:00
|
|
|
/*=========================================================================
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2001-06-04 18:10:06 +02:00
|
|
|
#ifndef __FMA_FMA_H__
|
|
|
|
#include "fma\fma.h"
|
|
|
|
#endif
|
|
|
|
|
2001-06-05 21:26:14 +02:00
|
|
|
#ifndef __SHOP_SHOP_H__
|
|
|
|
#include "shop\shop.h"
|
|
|
|
#endif
|
|
|
|
|
2001-01-11 23:06:59 +01:00
|
|
|
#ifndef __BACKEND_GAMEOVER_H__
|
|
|
|
#include "backend\gameover.h"
|
|
|
|
#endif
|
|
|
|
|
2001-04-24 21:37:12 +02:00
|
|
|
#ifndef __MAP_MAP_H__
|
|
|
|
#include "map\map.h"
|
|
|
|
#endif
|
|
|
|
|
2001-06-19 23:26:50 +02:00
|
|
|
#ifndef __BACKEND_CREDITS_H__
|
|
|
|
#include "backend\credits.h"
|
|
|
|
#endif
|
|
|
|
|
2001-06-25 22:25:28 +02:00
|
|
|
#ifndef __PAUL_ANIMTEST_H__
|
|
|
|
#include "paul\animtest.h"
|
|
|
|
#endif
|
|
|
|
|
2001-07-02 17:46:34 +02:00
|
|
|
#ifndef __SAVE_SAVE_H__
|
|
|
|
#include "save\save.h"
|
|
|
|
#endif
|
|
|
|
|
2001-06-19 23:26:50 +02:00
|
|
|
|
2001-01-11 18:08:34 +01:00
|
|
|
|
|
|
|
/* Std Lib
|
|
|
|
------- */
|
|
|
|
|
|
|
|
/* Data
|
|
|
|
---- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Tyepdefs && Defines
|
|
|
|
------------------- */
|
|
|
|
|
2001-01-12 18:31:33 +01:00
|
|
|
// Uncomment this to make the selector automatically choose the default ( first ) scene
|
|
|
|
// You can still use L1&L2 to force the selection menu to appear
|
|
|
|
//#define AUTOMATICALLY_CHOOSE_DEFAULT
|
|
|
|
|
2001-01-11 18:08:34 +01:00
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Structure defintions
|
|
|
|
-------------------- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function Prototypes
|
|
|
|
------------------- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Vars
|
|
|
|
---- */
|
|
|
|
|
|
|
|
CScene *CSceneSelector::s_sceneList[]=
|
|
|
|
{
|
2001-01-11 23:06:59 +01:00
|
|
|
&GameScene, // First scene in the list is the default scene
|
2001-01-11 18:08:34 +01:00
|
|
|
&FrontEndScene,
|
2001-01-11 23:06:59 +01:00
|
|
|
&GameOverScene,
|
2001-06-04 18:10:06 +02:00
|
|
|
&FmaScene,
|
2001-04-24 21:37:12 +02:00
|
|
|
&MapScene,
|
2001-06-05 21:26:14 +02:00
|
|
|
&ShopScene,
|
2001-06-19 23:26:50 +02:00
|
|
|
&CreditsScene,
|
2001-06-25 22:25:28 +02:00
|
|
|
&AnimTestScene,
|
2001-07-02 17:46:34 +02:00
|
|
|
&SaveScene,
|
2001-01-11 18:08:34 +01:00
|
|
|
};
|
|
|
|
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;
|
2001-01-11 23:06:59 +01:00
|
|
|
int i;
|
2001-01-11 18:08:34 +01:00
|
|
|
|
|
|
|
f4=GetPrimF4();
|
|
|
|
setXYWH(f4,0,0,512,256);
|
|
|
|
setRGB0(f4,10,20,30);
|
2001-04-19 22:19:58 +02:00
|
|
|
AddPrimToList(f4,15);
|
2001-01-11 18:08:34 +01:00
|
|
|
|
|
|
|
m_font->setColour(255,255,255);
|
2001-06-19 23:26:50 +02:00
|
|
|
m_font->print(256,50,"Select scene:");
|
2001-01-11 23:06:59 +01:00
|
|
|
for(i=0;i<s_sceneCount;i++)
|
|
|
|
{
|
|
|
|
if(i==m_currentSelection)
|
|
|
|
{
|
|
|
|
m_font->setColour(100,255,100);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_font->setColour(255,100,100);
|
|
|
|
}
|
2001-06-19 23:26:50 +02:00
|
|
|
m_font->print(256,80+(i*m_font->getCharHeight()),s_sceneList[i]->getSceneName());
|
2001-01-11 23:06:59 +01:00
|
|
|
}
|
2001-01-11 18:08:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
2001-06-28 21:14:44 +02:00
|
|
|
#include "pad\vibe.h"
|
|
|
|
|
2001-01-11 18:08:34 +01:00
|
|
|
void CSceneSelector::think(int _frames)
|
|
|
|
{
|
2001-06-28 21:14:44 +02:00
|
|
|
if(PadGetDown(0)&PAD_L1) CPadVibrationManager::setVibration(0,CPadVibrationManager::VIBE_LONG_STROBEY);
|
|
|
|
if(PadGetDown(0)&PAD_L2) CPadVibrationManager::setVibration(0,CPadVibrationManager::VIBE_LONG_STROBEY,127);
|
|
|
|
|
2001-01-11 18:08:34 +01:00
|
|
|
switch(m_state)
|
|
|
|
{
|
|
|
|
case STATE_INIT:
|
|
|
|
{
|
|
|
|
if(--m_countdown==0)
|
|
|
|
{
|
2001-01-12 18:31:33 +01:00
|
|
|
#ifdef AUTOMATICALLY_CHOOSE_DEFAULT
|
2001-01-11 18:08:34 +01:00
|
|
|
int pad;
|
|
|
|
pad=PadGetHeld(0);
|
|
|
|
if(pad&(PAD_L1|PAD_L2))
|
|
|
|
{
|
|
|
|
m_state=STATE_SELECTING;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_state=STATE_SELECTED;
|
|
|
|
}
|
2001-01-12 18:31:33 +01:00
|
|
|
#else
|
|
|
|
m_state=STATE_SELECTING;
|
|
|
|
#endif
|
2001-01-11 18:08:34 +01:00
|
|
|
}
|
|
|
|
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 */
|