SBSPSS/source/frontend/frontend.cpp
2001-05-17 18:42:59 +00:00

306 lines
6.2 KiB
C++

/*=========================================================================
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
#ifndef __FRONTEND_MAINTITL_H__
#include "frontend\maintitl.h"
#endif
#ifndef __FRONTEND_FMVTHQ_H__
#include "frontend\fmvthq.h"
#endif
#ifndef __FRONTEND_FMVINTRO_H__
#include "frontend\fmvintro.h"
#endif
#ifndef __FRONTEND_OPTIONS_H__
#include "frontend\options.h"
#endif
#ifndef __FRONTEND_START_H__
#include "frontend\start.h"
#endif
#ifndef __FRONTEND_DEMOMODE_H__
#include "frontend\demomode.h"
#endif
#ifndef __FRONTEND_CREDITS_H__
#include "frontend\credits.h"
#endif
#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
#ifndef __DATA_STRUCTS_HEADER__
#include "Dstructs.h"
#endif
#ifndef __MAP_MAP_H__
#include "map\map.h"
#endif
#ifndef __GAME_GAMESLOT_H__
#include "game\gameslot.h"
#endif
/* Std Lib
------- */
/* Data
---- */
#ifndef __SPR_SPRITES_H__
#include <sprites.h>
#endif
/*----------------------------------------------------------------------
Tyepdefs && Defines
------------------- */
/*----------------------------------------------------------------------
Structure defintions
-------------------- */
/*----------------------------------------------------------------------
Function Prototypes
------------------- */
/*----------------------------------------------------------------------
Vars
---- */
static CFrontEndFMVTHQ s_frontEndFMVTHQ;
static CFrontEndFMVIntro s_frontEndFMVIntro;
static CFrontEndMainTitles s_frontEndModeMainTitles;
static CFrontEndOptions s_frontEndModeOptions;
static CFrontEndStart s_frontEndStart;
static CFrontEndDemoMode s_frontEndDemoMode;
static CFrontEndCredits s_frontEndCredits;
CFrontEndMode *CFrontEndScene::s_modeCodes[]=
{
&s_frontEndFMVTHQ, // MODE__FMV_THQ
&s_frontEndFMVIntro, // MODE__FMV_INTRO
&s_frontEndModeMainTitles, // MODE__MAIN_TITLES
&s_frontEndModeOptions, // MODE__GAME_OPTIONS
&s_frontEndStart, // MODE__CHOOSE_SLOT
&s_frontEndDemoMode, // MODE__DEMO
&s_frontEndCredits, // MODE__CREDITS
// NULL, // MODE__NONE
// NULL, // MODE__EXIT_TO_GAME
};
CFrontEndScene FrontEndScene;
//int rsx=4096;
//int rsy=4096;
//int rsr=0;
//int rspeed=0;
SpriteBank *m_sprites;
FontBank *m_font;
static int s_runOnce=false;
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CFrontEndScene::init()
{
for(int i=0;i<MODE__NONE;i++)
{
s_modeCodes[i]->init();
}
m_exitToGame=false;
m_mode=MODE__NONE;
#if defined(__USER_art__) || defined(__USER_sbart__)
setMode(MODE__CHOOSE_SLOT);
#else
if(s_runOnce)
{
setMode(MODE__FMV_INTRO);
}
else
{
s_runOnce=true;
setMode(MODE__FMV_THQ);
}
#endif
m_sprites=new ("MainTitle Sprites") SpriteBank();
m_sprites->load(SPRITES_SPRITES_SPR);
m_font=new ("frontendfont") FontBank();
m_font->initialise(&standardFont);
m_font->setJustification(FontBank::JUST_CENTRE);
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CFrontEndScene::shutdown()
{
m_font->dump(); delete m_font;
m_sprites->dump(); delete m_sprites;
for(int i=0;i<MODE__NONE;i++)
{
s_modeCodes[i]->shutdown();
}
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CFrontEndScene::render()
{
s_modeCodes[m_mode]->render();
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CFrontEndScene::think(int _frames)
{
CFrontEndMode *mode;
thinkLogo(_frames);
mode=s_modeCodes[m_mode];
if(mode->isReadyToExit())
{
setMode(mode->getNextMode());
mode=s_modeCodes[m_mode];
}
mode->think(_frames);
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
int CFrontEndScene::readyToShutdown()
{
return m_exitToGame;
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CFrontEndScene::renderLogo()
{
sFrameHdr *fh;
fh=m_sprites->getFrameHeader(FRM__SBLOGO);
// m_sprites->printRotatedScaledSprite(fh,256,LOGO_CENTRE_Y,rsx,rsy,rsr,20);
m_sprites->printFT4(fh,256-(fh->W/2),LOGO_CENTRE_Y-(fh->H/2),0,0,FE_OT__LOGO);
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;
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CFrontEndScene::setMode(FrontEndMode _newMode)
{
// Close old mode
if(m_mode!=MODE__NONE)
{
s_modeCodes[m_mode]->unselect();
}
// Open new mode
if(_newMode==MODE__EXIT_TO_MAP)
{
m_exitToGame=true;
GameState::setNextScene(&MapScene);
}
else
{
m_mode=_newMode;
s_modeCodes[m_mode]->select();
}
}
/*===========================================================================
end */