SBSPSS/source/frontend/frontend.cpp

306 lines
6.2 KiB
C++
Raw Normal View History

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
2001-04-17 23:40:16 +02:00
#ifndef __FRONTEND_FMVTHQ_H__
#include "frontend\fmvthq.h"
#endif
#ifndef __FRONTEND_FMVINTRO_H__
#include "frontend\fmvintro.h"
#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
2001-04-25 20:15:19 +02:00
#ifndef __MAP_MAP_H__
#include "map\map.h"
2001-01-05 22:33:06 +01:00
#endif
2001-05-13 23:06:26 +02:00
#ifndef __GAME_GAMESLOT_H__
#include "game\gameslot.h"
#endif
2000-11-13 20:38:51 +01:00
/* Std Lib
------- */
/* Data
---- */
2001-04-20 16:53:35 +02:00
#ifndef __SPR_SPRITES_H__
#include <sprites.h>
2000-11-28 01:06:22 +01:00
#endif
2000-11-13 20:38:51 +01:00
/*----------------------------------------------------------------------
Tyepdefs && Defines
------------------- */
/*----------------------------------------------------------------------
Structure defintions
-------------------- */
/*----------------------------------------------------------------------
Function Prototypes
------------------- */
/*----------------------------------------------------------------------
Vars
---- */
2001-04-17 23:40:16 +02:00
static CFrontEndFMVTHQ s_frontEndFMVTHQ;
static CFrontEndFMVIntro s_frontEndFMVIntro;
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[]=
{
2001-04-17 23:40:16 +02:00
&s_frontEndFMVTHQ, // MODE__FMV_THQ
&s_frontEndFMVIntro, // MODE__FMV_INTRO
2000-11-20 16:45:17 +01:00
&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;
2001-03-07 16:50:17 +01:00
//int rsx=4096;
//int rsy=4096;
//int rsr=0;
//int rspeed=0;
2000-11-28 01:06:22 +01:00
SpriteBank *m_sprites;
FontBank *m_font;
2001-04-17 23:40:16 +02:00
static int s_runOnce=false;
2000-11-28 01:06:22 +01:00
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;
2001-03-21 21:00:22 +01:00
#if defined(__USER_art__) || defined(__USER_sbart__)
2001-02-13 23:36:06 +01:00
setMode(MODE__CHOOSE_SLOT);
#else
2001-04-17 23:40:16 +02:00
if(s_runOnce)
{
setMode(MODE__FMV_INTRO);
}
else
{
s_runOnce=true;
setMode(MODE__FMV_THQ);
}
2001-02-13 23:36:06 +01:00
#endif
2000-11-28 01:06:22 +01:00
m_sprites=new ("MainTitle Sprites") SpriteBank();
2001-04-20 16:53:35 +02:00
m_sprites->load(SPRITES_SPRITES_SPR);
2000-11-28 01:06:22 +01:00
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];
if(mode->isReadyToExit())
{
setMode(mode->getNextMode());
2001-03-01 22:50:06 +01:00
mode=s_modeCodes[m_mode];
2000-11-20 16:45:17 +01:00
}
2001-03-01 22:50:06 +01:00
mode->think(_frames);
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-03-07 16:50:17 +01:00
// m_sprites->printRotatedScaledSprite(fh,256,LOGO_CENTRE_Y,rsx,rsy,rsr,20);
2001-04-19 23:11:46 +02:00
m_sprites->printFT4(fh,256-(fh->W/2),LOGO_CENTRE_Y-(fh->H/2),0,0,FE_OT__LOGO);
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)
{
2001-03-07 16:50:17 +01:00
// rsr=(rsr+(_frames*rspeed))&4095;
2000-11-28 01:06:22 +01:00
}
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
2001-04-25 20:15:19 +02:00
if(_newMode==MODE__EXIT_TO_MAP)
2000-11-24 21:33:35 +01:00
{
m_exitToGame=true;
2001-04-25 20:15:19 +02:00
GameState::setNextScene(&MapScene);
2001-01-05 22:33:06 +01:00
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 */