2000-11-13 20:38:51 +01:00
|
|
|
/*=========================================================================
|
|
|
|
|
|
|
|
frontend.cpp
|
|
|
|
|
|
|
|
Author: PKG
|
|
|
|
Created:
|
|
|
|
Project: Spongebob
|
|
|
|
Purpose:
|
|
|
|
|
|
|
|
Copyright (c) 2000 Climax Development Ltd
|
|
|
|
|
|
|
|
===========================================================================*/
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Includes
|
|
|
|
-------- */
|
|
|
|
|
|
|
|
#include "frontend\frontend.h"
|
|
|
|
|
|
|
|
#ifndef __MEMORY_HEADER__
|
|
|
|
#include "mem\memory.h"
|
|
|
|
#endif
|
|
|
|
|
2000-11-15 16:37:12 +01:00
|
|
|
#ifndef __FRONTEND_MAINTITL_H__
|
|
|
|
#include "frontend\maintitl.h"
|
2000-11-13 20:38:51 +01:00
|
|
|
#endif
|
|
|
|
|
2000-11-22 18:02:04 +01:00
|
|
|
#ifndef __FRONTEND_OPTIONS_H__
|
|
|
|
#include "frontend\options.h"
|
|
|
|
#endif
|
|
|
|
|
2000-11-24 18:30:49 +01:00
|
|
|
#ifndef __FRONTEND_START_H__
|
|
|
|
#include "frontend\start.h"
|
|
|
|
#endif
|
|
|
|
|
2000-11-24 01:00:10 +01:00
|
|
|
#ifndef __FRONTEND_DEMOMODE_H__
|
|
|
|
#include "frontend\demomode.h"
|
|
|
|
#endif
|
|
|
|
|
2000-11-24 18:30:49 +01:00
|
|
|
#ifndef __FRONTEND_CREDITS_H__
|
|
|
|
#include "frontend\credits.h"
|
|
|
|
#endif
|
|
|
|
|
2000-11-28 01:06:22 +01:00
|
|
|
#ifndef __GFX_SPRBANK_H__
|
|
|
|
#include "gfx\sprbank.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __GFX_FONT_H__
|
|
|
|
#include "gfx\font.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __LOCALE_TEXTDBASE_H__
|
|
|
|
#include "locale\textdbase.h"
|
|
|
|
#endif
|
|
|
|
|
2001-01-05 22:33:06 +01:00
|
|
|
#ifndef __DATA_STRUCTS_HEADER__
|
|
|
|
#include "Dstructs.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __GAME_GAME_H__
|
|
|
|
#include "game\game.h"
|
|
|
|
#endif
|
|
|
|
|
2000-11-13 20:38:51 +01:00
|
|
|
|
|
|
|
/* Std Lib
|
|
|
|
------- */
|
|
|
|
|
|
|
|
/* Data
|
|
|
|
---- */
|
|
|
|
|
2000-11-28 01:06:22 +01:00
|
|
|
#ifndef __SPR_FRONTEND_H__
|
|
|
|
#include <frontend.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2000-11-13 20:38:51 +01:00
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Tyepdefs && Defines
|
|
|
|
------------------- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Structure defintions
|
|
|
|
-------------------- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function Prototypes
|
|
|
|
------------------- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Vars
|
|
|
|
---- */
|
|
|
|
|
2000-11-20 16:45:17 +01:00
|
|
|
static CFrontEndMainTitles s_frontEndModeMainTitles;
|
2000-11-22 18:02:04 +01:00
|
|
|
static CFrontEndOptions s_frontEndModeOptions;
|
2000-11-24 18:30:49 +01:00
|
|
|
static CFrontEndStart s_frontEndStart;
|
2000-11-24 01:00:10 +01:00
|
|
|
static CFrontEndDemoMode s_frontEndDemoMode;
|
2000-11-24 18:30:49 +01:00
|
|
|
static CFrontEndCredits s_frontEndCredits;
|
2000-11-20 16:45:17 +01:00
|
|
|
|
|
|
|
CFrontEndMode *CFrontEndScene::s_modeCodes[]=
|
|
|
|
{
|
|
|
|
&s_frontEndModeMainTitles, // MODE__MAIN_TITLES
|
2000-11-22 18:02:04 +01:00
|
|
|
&s_frontEndModeOptions, // MODE__GAME_OPTIONS
|
2000-11-24 18:30:49 +01:00
|
|
|
&s_frontEndStart, // MODE__CHOOSE_SLOT
|
2000-11-24 01:00:10 +01:00
|
|
|
&s_frontEndDemoMode, // MODE__DEMO
|
2000-11-24 18:30:49 +01:00
|
|
|
&s_frontEndCredits, // MODE__CREDITS
|
2000-11-20 16:45:17 +01:00
|
|
|
|
2000-11-24 21:33:35 +01:00
|
|
|
// NULL, // MODE__NONE
|
|
|
|
// NULL, // MODE__EXIT_TO_GAME
|
2000-11-20 16:45:17 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2000-11-13 20:38:51 +01:00
|
|
|
CFrontEndScene FrontEndScene;
|
|
|
|
|
|
|
|
|
2000-11-28 01:06:22 +01:00
|
|
|
int rsx=4096;
|
|
|
|
int rsy=4096;
|
|
|
|
int rsr=0;
|
|
|
|
int rspeed=0;
|
|
|
|
SpriteBank *m_sprites;
|
|
|
|
FontBank *m_font;
|
|
|
|
|
|
|
|
|
2000-11-13 20:38:51 +01:00
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CFrontEndScene::init()
|
|
|
|
{
|
2000-11-22 18:02:04 +01:00
|
|
|
for(int i=0;i<MODE__NONE;i++)
|
|
|
|
{
|
|
|
|
s_modeCodes[i]->init();
|
|
|
|
}
|
|
|
|
|
2000-11-24 21:33:35 +01:00
|
|
|
m_exitToGame=false;
|
2000-11-20 16:45:17 +01:00
|
|
|
m_mode=MODE__NONE;
|
|
|
|
setMode(MODE__MAIN_TITLES);
|
2000-11-28 01:06:22 +01:00
|
|
|
|
|
|
|
m_sprites=new ("MainTitle Sprites") SpriteBank();
|
|
|
|
m_sprites->load(FRONTEND_FRONTEND_SPR);
|
|
|
|
|
|
|
|
m_font=new ("frontendfont") FontBank();
|
|
|
|
m_font->initialise(&standardFont);
|
|
|
|
m_font->setJustification(FontBank::JUST_CENTRE);
|
2000-11-13 20:38:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CFrontEndScene::shutdown()
|
|
|
|
{
|
2000-11-28 01:06:22 +01:00
|
|
|
m_font->dump(); delete m_font;
|
|
|
|
m_sprites->dump(); delete m_sprites;
|
|
|
|
|
2000-11-22 18:02:04 +01:00
|
|
|
for(int i=0;i<MODE__NONE;i++)
|
|
|
|
{
|
|
|
|
s_modeCodes[i]->shutdown();
|
|
|
|
}
|
2000-11-13 20:38:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CFrontEndScene::render()
|
|
|
|
{
|
2000-11-20 16:45:17 +01:00
|
|
|
s_modeCodes[m_mode]->render();
|
2000-11-13 20:38:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CFrontEndScene::think(int _frames)
|
|
|
|
{
|
2000-11-20 16:45:17 +01:00
|
|
|
CFrontEndMode *mode;
|
|
|
|
|
2000-11-28 01:06:22 +01:00
|
|
|
thinkLogo(_frames);
|
|
|
|
|
2000-11-20 16:45:17 +01:00
|
|
|
mode=s_modeCodes[m_mode];
|
|
|
|
mode->think(_frames);
|
|
|
|
if(mode->isReadyToExit())
|
|
|
|
{
|
|
|
|
setMode(mode->getNextMode());
|
|
|
|
}
|
2000-11-13 20:38:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
int CFrontEndScene::readyToShutdown()
|
|
|
|
{
|
2000-11-24 21:33:35 +01:00
|
|
|
return m_exitToGame;
|
2000-11-13 20:38:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-11-28 01:06:22 +01:00
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CFrontEndScene::renderLogo()
|
|
|
|
{
|
|
|
|
sFrameHdr *fh;
|
|
|
|
|
|
|
|
fh=m_sprites->getFrameHeader(FRM__SBLOGO);
|
2001-02-09 17:46:47 +01:00
|
|
|
m_sprites->printRotatedScaledSprite(fh,256,LOGO_CENTRE_Y,rsx,rsy,rsr,20);
|
2000-11-28 01:06:22 +01:00
|
|
|
m_font->setColour(GAME_TITLE_TEXT_R,GAME_TITLE_TEXT_G,GAME_TITLE_TEXT_B);
|
|
|
|
m_font->print(256,GAME_TITLE_TEXT_CENTRE_Y,STR__FRONTEND__GAME_TITLE);
|
|
|
|
m_font->setColour(0,0,0);
|
|
|
|
m_font->print(256+1,GAME_TITLE_TEXT_CENTRE_Y+1,STR__FRONTEND__GAME_TITLE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CFrontEndScene::thinkLogo(int _frames)
|
|
|
|
{
|
|
|
|
rsr=(rsr+(_frames*rspeed))&4095;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-11-20 16:45:17 +01:00
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CFrontEndScene::setMode(FrontEndMode _newMode)
|
|
|
|
{
|
|
|
|
// Close old mode
|
2000-11-24 21:33:35 +01:00
|
|
|
if(m_mode!=MODE__NONE)
|
2000-11-20 16:45:17 +01:00
|
|
|
{
|
2000-11-22 18:02:04 +01:00
|
|
|
s_modeCodes[m_mode]->unselect();
|
2000-11-20 16:45:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Open new mode
|
2000-11-24 21:33:35 +01:00
|
|
|
if(_newMode==MODE__EXIT_TO_GAME)
|
|
|
|
{
|
|
|
|
m_exitToGame=true;
|
2001-01-05 22:33:06 +01:00
|
|
|
GameState::setNextScene(&GameScene);
|
|
|
|
|
2000-11-24 21:33:35 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_mode=_newMode;
|
|
|
|
s_modeCodes[m_mode]->select();
|
|
|
|
}
|
2000-11-20 16:45:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-11-13 20:38:51 +01:00
|
|
|
/*===========================================================================
|
|
|
|
end */
|