SBSPSS/source/game/pause.cpp

520 lines
13 KiB
C++
Raw Normal View History

2001-02-09 18:48:35 +01:00
/*=========================================================================
pause.cpp
Author: PKG
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
/*----------------------------------------------------------------------
Includes
-------- */
2001-06-21 21:19:15 +02:00
#include "system\vid.h"
2001-02-09 18:48:35 +01:00
#include "game\pause.h"
2001-06-27 20:06:59 +02:00
#ifndef __GFX_FONT_H__
#include "gfx\font.h"
#endif
#ifndef __GFX_SPRBANK_H__
#include "gfx\sprbank.h"
#endif
2001-02-09 18:48:35 +01:00
#ifndef __GUI_GFRAME_H__
#include "gui\gframe.h"
#endif
2001-02-09 22:41:55 +01:00
#ifndef __GUI_GFACTORY_H__
#include "gui\gfactory.h"
2001-02-09 18:48:35 +01:00
#endif
2001-06-27 20:06:59 +02:00
#ifndef __GUI_GTEXTBOX_H__
#include "gui\gtextbox.h"
#endif
2001-07-26 18:12:32 +02:00
#ifndef __GUI_GBUTTON_H__
#include "gui\gbutton.h"
#endif
2001-02-09 22:41:55 +01:00
#ifndef __MEMORY_HEADER__
#include "mem\memory.h"
2001-02-09 18:48:35 +01:00
#endif
2001-02-12 22:54:44 +01:00
#ifndef __PLAYER_PLAYER_H__
#include "player\player.h"
#endif
2001-05-13 23:06:26 +02:00
#ifndef __GAME_GAME_H__
#include "game\game.h"
#endif
2001-06-28 16:14:07 +02:00
#ifndef __GAME_GAMESLOT_H__
#include "game\gameslot.h"
#endif
2001-07-10 21:43:13 +02:00
#ifndef __PAD_PADS_H__
#include "pad/pads.h"
#endif
2001-07-26 18:12:32 +02:00
#ifndef __PAD_VIBE_H__
#include "pad\vibe.h"
#endif
2001-02-09 18:48:35 +01:00
/* Std Lib
------- */
/* Data
---- */
#ifndef __STRING_ENUMS__
#include <trans.h>
#endif
2001-06-27 20:06:59 +02:00
#ifndef __SPR_SPRITES_H__
#include <sprites.h>
#endif
2001-02-09 18:48:35 +01:00
/*----------------------------------------------------------------------
Tyepdefs && Defines
------------------- */
/*----------------------------------------------------------------------
Structure defintions
-------------------- */
/*----------------------------------------------------------------------
Function Prototypes
------------------- */
/*----------------------------------------------------------------------
Vars
---- */
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
2001-03-09 20:57:10 +01:00
static const int FRAME_WIDTH =352;
2001-06-27 20:06:59 +02:00
static const int FRAME_HEIGHT =160-64;
2001-07-26 18:12:32 +02:00
static const int TEXT_BOX_WIDTH =200;
2001-03-09 20:57:10 +01:00
static const int TEXT_BOX_HEIGHT =20;
2001-07-26 18:12:32 +02:00
static const int TEXT_SPACING =16;
2001-02-09 22:41:55 +01:00
extern int newmode;
2001-04-25 20:38:00 +02:00
extern int invincibleSponge;
int inv_data[]={0,1,-1};
2001-07-26 18:12:32 +02:00
static CGUITextReadout::TextReadoutData s_yesNoReadoutData[2]={{0,STR__OFF},{1,STR__ON}};
static CGUIGroupFrame *s_vibFrame;
2001-04-25 20:38:00 +02:00
2001-02-09 22:41:55 +01:00
void CPauseMenu::init()
2001-02-09 18:48:35 +01:00
{
2001-07-26 18:12:32 +02:00
int ypos;
2001-06-27 20:06:59 +02:00
CGUITextBox *tb;
2001-02-09 22:41:55 +01:00
2001-05-11 23:35:08 +02:00
2001-06-27 20:06:59 +02:00
// MAIN MENU
m_pauseGuiFrame=new ("Conversation GUI") CGUIControlFrame();
m_pauseGuiFrame->init(0);
m_pauseGuiFrame->setObjectXYWH((INGAME_SCREENW-FRAME_WIDTH)/2,(INGAME_SCREENH-FRAME_HEIGHT)/2,FRAME_WIDTH,FRAME_HEIGHT);
m_pauseGuiFrame->setFlags(CGUIObject::FLAG_DRAWBORDER);
2001-07-26 18:12:32 +02:00
ypos=TEXT_SPACING/3;
2001-06-27 20:06:59 +02:00
tb=new ("textbox") CGUITextBox();
tb->init(m_pauseGuiFrame);
2001-07-26 18:12:32 +02:00
tb->setObjectXYWH((FRAME_WIDTH-TEXT_BOX_WIDTH)/2,ypos,TEXT_BOX_WIDTH,TEXT_BOX_HEIGHT);
2001-06-27 20:06:59 +02:00
tb->setText(STR__PAUSE_MENU__GAME_PAUSED);
2001-07-26 18:12:32 +02:00
ypos+=TEXT_SPACING*2;
2001-06-27 20:06:59 +02:00
CGUIFactory::createValueButtonFrame(m_pauseGuiFrame,
2001-07-26 18:12:32 +02:00
(FRAME_WIDTH-TEXT_BOX_WIDTH)/2,ypos,TEXT_BOX_WIDTH,TEXT_BOX_HEIGHT,
2001-02-09 22:41:55 +01:00
STR__PAUSE_MENU__CONTINUE,
2001-06-27 20:06:59 +02:00
&m_responseFlag,RESPONSE__CONTINUE);
2001-07-26 18:12:32 +02:00
ypos+=TEXT_SPACING;
{
// Vibration toggle
CGUIGroupFrame *fr;
CGUITextBox *tb;
CGUIValueButton *vb;
CGUITextReadout *tr;
fr=new ("frame") CGUIGroupFrame();
2001-07-31 18:01:36 +02:00
m_vibGUIOption=fr;
2001-07-26 18:12:32 +02:00
fr->init(m_pauseGuiFrame);
fr->setObjectXYWH((FRAME_WIDTH-TEXT_BOX_WIDTH)/2,ypos,TEXT_BOX_WIDTH,TEXT_BOX_HEIGHT);
tb=new ("textbox") CGUITextBox();
tb->init(fr);
tb->setObjectXYWH(0,0,(TEXT_BOX_WIDTH/3)*2,TEXT_BOX_HEIGHT);
tb->setText(STR__PAUSE_MENU__VIBRATION);
vb=new ("valuebutton") CGUIValueButton();
vb->init(fr);
vb->setButtonTarget(&m_vibrationChangeFlag);
vb->setButtonValue(true);
tr=new ("textreadout") CGUITextReadout();
tr->init(fr);
tr->setObjectXYWH((TEXT_BOX_WIDTH/3)*2,0,(TEXT_BOX_WIDTH/3)*1,TEXT_BOX_HEIGHT);
tr->setReadoutTarget(&m_vibrationState);
tr->setReadoutData(s_yesNoReadoutData);
s_vibFrame=fr;
}
ypos+=TEXT_SPACING;
2001-06-27 20:06:59 +02:00
CGUIFactory::createValueButtonFrame(m_pauseGuiFrame,
2001-07-26 18:12:32 +02:00
(FRAME_WIDTH-TEXT_BOX_WIDTH)/2,ypos,TEXT_BOX_WIDTH,TEXT_BOX_HEIGHT,
2001-02-12 18:18:17 +01:00
STR__PAUSE_MENU__QUIT,
2001-06-27 20:06:59 +02:00
&m_responseFlag,RESPONSE__QUIT);
2001-03-31 20:22:38 +02:00
2001-07-27 23:48:35 +02:00
#ifdef __VERSION_DEBUG__
2001-07-26 18:12:32 +02:00
ypos+=8;
2001-06-27 20:06:59 +02:00
CGUIFactory::createCycleButtonFrame(m_pauseGuiFrame,
2001-07-26 18:12:32 +02:00
(FRAME_WIDTH-TEXT_BOX_WIDTH)/2,ypos,TEXT_BOX_WIDTH,TEXT_BOX_HEIGHT,
2001-04-25 20:38:00 +02:00
STR__INVINCIBILE_SPONGEBOB,
2001-07-26 18:12:32 +02:00
&invincibleSponge,inv_data,s_yesNoReadoutData);
ypos+=TEXT_SPACING;
2001-06-27 20:06:59 +02:00
#if defined (__USER_paul__) || defined (__USER_charles__)
CGUIFactory::createValueButtonFrame(m_pauseGuiFrame,
2001-07-26 18:12:32 +02:00
(FRAME_WIDTH-TEXT_BOX_WIDTH)/2,ypos,TEXT_BOX_WIDTH,TEXT_BOX_HEIGHT,
2001-02-12 22:54:44 +01:00
STR__DEBUG__BASICUNARMED_MODE,
&newmode,PLAYER_MODE_BASICUNARMED);
2001-07-26 18:12:32 +02:00
ypos+=8;
2001-06-27 20:06:59 +02:00
CGUIFactory::createValueButtonFrame(m_pauseGuiFrame,
2001-07-26 18:12:32 +02:00
(FRAME_WIDTH-TEXT_BOX_WIDTH)/2,ypos,TEXT_BOX_WIDTH,TEXT_BOX_HEIGHT,
2001-03-25 23:33:20 +02:00
STR__DEBUG__FULLUNARMED_MODE,
&newmode,PLAYER_MODE_FULLUNARMED);
2001-07-26 18:12:32 +02:00
ypos+=8;
2001-06-27 20:06:59 +02:00
CGUIFactory::createValueButtonFrame(m_pauseGuiFrame,
2001-07-26 18:12:32 +02:00
(FRAME_WIDTH-TEXT_BOX_WIDTH)/2,ypos,TEXT_BOX_WIDTH,TEXT_BOX_HEIGHT,
2001-02-28 20:37:01 +01:00
STR__DEBUG__BALLOON_MODE,
&newmode,PLAYER_MODE_BALLOON);
2001-07-26 18:12:32 +02:00
ypos+=8;
2001-06-27 20:06:59 +02:00
CGUIFactory::createValueButtonFrame(m_pauseGuiFrame,
2001-07-26 18:12:32 +02:00
(FRAME_WIDTH-TEXT_BOX_WIDTH)/2,ypos,TEXT_BOX_WIDTH,TEXT_BOX_HEIGHT,
2001-03-30 19:47:00 +02:00
STR__DEBUG__BUBBLEMIXTURE_MODE,
&newmode,PLAYER_MODE_BUBBLE_MIXTURE);
2001-07-26 18:12:32 +02:00
ypos+=8;
2001-06-27 20:06:59 +02:00
CGUIFactory::createValueButtonFrame(m_pauseGuiFrame,
2001-07-26 18:12:32 +02:00
(FRAME_WIDTH-TEXT_BOX_WIDTH)/2,ypos,TEXT_BOX_WIDTH,TEXT_BOX_HEIGHT,
2001-03-31 20:22:38 +02:00
STR__DEBUG__NET_MODE,
&newmode,PLAYER_MODE_NET);
2001-07-26 18:12:32 +02:00
ypos+=8;
2001-06-27 20:06:59 +02:00
CGUIFactory::createValueButtonFrame(m_pauseGuiFrame,
2001-07-26 18:12:32 +02:00
(FRAME_WIDTH-TEXT_BOX_WIDTH)/2,ypos,TEXT_BOX_WIDTH,TEXT_BOX_HEIGHT,
2001-03-30 19:47:00 +02:00
STR__DEBUG__CORALBLOWER_MODE,
&newmode,PLAYER_MODE_CORALBLOWER);
2001-07-26 18:12:32 +02:00
ypos+=8;
2001-06-27 20:06:59 +02:00
CGUIFactory::createValueButtonFrame(m_pauseGuiFrame,
2001-07-26 18:12:32 +02:00
(FRAME_WIDTH-TEXT_BOX_WIDTH)/2,ypos,TEXT_BOX_WIDTH,TEXT_BOX_HEIGHT,
2001-04-03 23:36:35 +02:00
STR__DEBUG__JELLYLAUNCHER_MODE,
&newmode,PLAYER_MODE_JELLY_LAUNCHER);
2001-07-26 18:12:32 +02:00
ypos+=8;
2001-06-27 20:06:59 +02:00
CGUIFactory::createValueButtonFrame(m_pauseGuiFrame,
2001-07-26 18:12:32 +02:00
(FRAME_WIDTH-TEXT_BOX_WIDTH)/2,ypos,TEXT_BOX_WIDTH,TEXT_BOX_HEIGHT,
2001-03-25 23:33:20 +02:00
STR__DEBUG__DEAD_MODE,
&newmode,PLAYER_MODE_DEAD);
2001-06-27 20:06:59 +02:00
#endif
#endif
// CONFIRM QUIT MENU
m_confirmQuitGuiFrame=new ("Conversation GUI") CGUIControlFrame();
m_confirmQuitGuiFrame->init(0);
m_confirmQuitGuiFrame->setObjectXYWH((INGAME_SCREENW-FRAME_WIDTH)/2,(INGAME_SCREENH-FRAME_HEIGHT)/2,FRAME_WIDTH,FRAME_HEIGHT);
m_confirmQuitGuiFrame->setFlags(CGUIObject::FLAG_DRAWBORDER);
2001-07-26 18:12:32 +02:00
ypos=TEXT_SPACING/3;
2001-06-27 20:06:59 +02:00
tb=new ("textbox") CGUITextBox();
tb->init(m_confirmQuitGuiFrame);
2001-07-26 18:12:32 +02:00
tb->setObjectXYWH((FRAME_WIDTH-TEXT_BOX_WIDTH)/2,ypos,TEXT_BOX_WIDTH,TEXT_BOX_HEIGHT);
2001-06-27 20:06:59 +02:00
tb->setText(STR__PAUSE_MENU__CONFIRM_QUIT);
2001-07-26 18:12:32 +02:00
ypos+=TEXT_SPACING*2;
2001-06-27 20:06:59 +02:00
CGUIFactory::createValueButtonFrame(m_confirmQuitGuiFrame,
2001-07-26 18:12:32 +02:00
(FRAME_WIDTH-TEXT_BOX_WIDTH)/2,ypos,TEXT_BOX_WIDTH,TEXT_BOX_HEIGHT,
2001-06-27 20:06:59 +02:00
STR__NO,
&m_responseFlag,RESPONSE__CONFIRM_QUIT_NO);
2001-07-26 18:12:32 +02:00
ypos+=TEXT_SPACING;
2001-06-27 20:06:59 +02:00
CGUIFactory::createValueButtonFrame(m_confirmQuitGuiFrame,
2001-07-26 18:12:32 +02:00
(FRAME_WIDTH-TEXT_BOX_WIDTH)/2,ypos,TEXT_BOX_WIDTH,TEXT_BOX_HEIGHT,
2001-06-27 20:06:59 +02:00
STR__YES,
&m_responseFlag,RESPONSE__CONFIRM_QUIT_YES);
2001-02-09 18:48:35 +01:00
2001-06-27 20:06:59 +02:00
m_fontBank=new ("PauseMenuFont") FontBank();
m_fontBank->initialise(&standardFont);
2001-05-13 23:06:26 +02:00
2001-02-09 18:48:35 +01:00
m_active=false;
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
2001-02-09 22:41:55 +01:00
void CPauseMenu::shutdown()
2001-02-09 18:48:35 +01:00
{
2001-06-27 20:06:59 +02:00
m_fontBank->dump(); delete m_fontBank;
m_confirmQuitGuiFrame->shutdown();
m_pauseGuiFrame->shutdown();
2001-02-09 18:48:35 +01:00
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
2001-02-09 22:41:55 +01:00
void CPauseMenu::select()
2001-02-09 18:48:35 +01:00
{
2001-05-13 23:06:26 +02:00
int chapter,level;
2001-02-09 18:48:35 +01:00
m_active=true;
2001-07-10 21:43:13 +02:00
m_padDebounce=true;
2001-06-27 20:06:59 +02:00
m_currentState=STATE__MAIN_MENU;
m_responseFlag=RESPONSE__WAITING;
2001-07-26 18:12:32 +02:00
m_vibrationChangeFlag=false;
m_vibrationState=PadGetVibrationIsTurnedOn(0);
2001-06-27 20:06:59 +02:00
m_pauseGuiFrame->select();
2001-07-26 18:12:32 +02:00
s_vibFrame->think(1); // This just makes sure that the readout reads correctly on the first frame
2001-05-13 23:06:26 +02:00
2001-05-31 23:17:33 +02:00
chapter=GameScene.getChapterNumber()-1;
level=GameScene.getLevelNumber()-1;
2001-07-18 22:39:48 +02:00
m_SpeechPlaying=false;
if (CXAStream::IsPlaying())
{
m_SpeechPlaying=true;
CXAStream::Pause();
}
2001-02-09 18:48:35 +01:00
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
2001-02-09 22:41:55 +01:00
void CPauseMenu::unselect()
2001-02-09 18:48:35 +01:00
{
2001-02-09 22:41:55 +01:00
m_active=false;
2001-07-18 22:39:48 +02:00
if (m_SpeechPlaying)
{
CXAStream::Resume();
m_SpeechPlaying=false;
}
2001-02-09 22:41:55 +01:00
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CPauseMenu::think(int _frames)
{
if(m_active)
{
2001-07-31 18:01:36 +02:00
if(m_pauseGuiFrame->isSelected())
{
// Hide the VIBRATION option if vibration not available
if(PadCanVibrate(0))
{
m_vibGUIOption->unhide();
}
else
{
if(m_vibGUIOption->isSelected())
{
m_pauseGuiFrame->selectPreviousItem();
}
m_vibGUIOption->hide();
}
}
2001-07-10 21:43:13 +02:00
if(PadGetDown(0)&PAD_START)
2001-02-09 22:41:55 +01:00
{
2001-07-10 21:43:13 +02:00
if(!m_padDebounce)
{
if(m_pauseGuiFrame->isSelected())m_pauseGuiFrame->unselect();
if(m_confirmQuitGuiFrame->isSelected())m_confirmQuitGuiFrame->unselect();
unselect();
}
}
else
{
switch(m_currentState)
{
// Main menu
case STATE__MAIN_MENU:
m_pauseGuiFrame->think(_frames);
switch(m_responseFlag)
{
case RESPONSE__WAITING:
2001-07-26 18:12:32 +02:00
if(m_vibrationChangeFlag)
{
m_vibrationState=PadGetVibrationIsTurnedOn(0)==true?false:true;
PadSetVibrationIsTurnedOn(0,m_vibrationState);
if(m_vibrationState)
{
CPadVibrationManager::setVibration(0,CPadVibrationManager::VIBE_MEDIUM);
}
else
{
CPadVibrationManager::stopAllVibration();
}
m_vibrationChangeFlag=false;
}
2001-07-10 21:43:13 +02:00
break;
case RESPONSE__CONTINUE:
m_pauseGuiFrame->unselect();
unselect();
break;
case RESPONSE__QUIT:
m_pauseGuiFrame->unselect();
m_confirmQuitGuiFrame->select();
m_currentState=STATE__CONFIRM_QUIT;
m_responseFlag=RESPONSE__WAITING;
break;
case RESPONSE__CONFIRM_QUIT_YES:
case RESPONSE__CONFIRM_QUIT_NO:
ASSERT(0);
break;
}
break;
// Confirm quit menu
case STATE__CONFIRM_QUIT:
m_confirmQuitGuiFrame->think(_frames);
switch(m_responseFlag)
{
case RESPONSE__WAITING:
break;
case RESPONSE__CONTINUE:
case RESPONSE__QUIT:
ASSERT(0);
break;
case RESPONSE__CONFIRM_QUIT_YES:
m_confirmQuitGuiFrame->unselect();
CGameScene::setReadyToExit();
unselect();
break;
case RESPONSE__CONFIRM_QUIT_NO:
m_pauseGuiFrame->select();
m_confirmQuitGuiFrame->unselect();
m_currentState=STATE__MAIN_MENU;
m_responseFlag=RESPONSE__WAITING;
break;
}
break;
}
}
2001-06-27 20:06:59 +02:00
2001-07-10 21:43:13 +02:00
if(m_padDebounce)
{
m_padDebounce=false;
2001-02-09 22:41:55 +01:00
}
}
2001-02-09 18:48:35 +01:00
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
2001-02-09 22:41:55 +01:00
void CPauseMenu::render()
2001-02-09 18:48:35 +01:00
{
2001-02-09 22:41:55 +01:00
if(m_active)
{
2001-06-27 20:06:59 +02:00
switch(m_currentState)
{
case STATE__MAIN_MENU:
renderLives();
m_pauseGuiFrame->render();
break;
case STATE__CONFIRM_QUIT:
m_confirmQuitGuiFrame->render();
break;
}
2001-02-09 22:41:55 +01:00
}
2001-02-09 18:48:35 +01:00
}
2001-06-27 20:06:59 +02:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CPauseMenu::renderLives()
{
2001-06-28 16:14:07 +02:00
CGameSlotManager::GameSlot *gameSlot;
int x,y,textYOff;
2001-06-27 20:06:59 +02:00
SpriteBank *sb;
sFrameHdr *fh;
2001-06-28 16:14:07 +02:00
char buf[10];
gameSlot=CGameSlotManager::getSlotData();
2001-06-27 20:06:59 +02:00
2001-07-04 18:27:35 +02:00
/*
2001-06-28 16:14:07 +02:00
// Spat count
x=100;
y=137;
2001-06-27 20:06:59 +02:00
sb=GameScene.getSpriteBank();
2001-06-28 16:14:07 +02:00
fh=sb->getFrameHeader(FRM__SPATULA);
2001-06-27 20:06:59 +02:00
sb->printFT4(fh,x,y,0,0,0);
x+=fh->W;
2001-06-28 16:14:07 +02:00
sprintf(buf,"%d/%d",GameScene.getPlayer()->getSpatulasHeld(),GameScene.GetLevel().getTotalSpatCount());
textYOff=fh->H-m_fontBank->getStringHeight(buf);
y+=textYOff;
2001-06-27 20:06:59 +02:00
m_fontBank->print(x,y,buf);
2001-07-04 18:27:35 +02:00
*/
2001-06-27 20:06:59 +02:00
2001-06-28 16:14:07 +02:00
// Lives
x=350;
y=137;
sb=GameScene.getSpriteBank();
fh=sb->getFrameHeader(FRM__PANTS);
sb->printFT4(fh,x,y,0,0,0);
x+=fh->W;
sprintf(buf,"x%d",gameSlot->m_lives);
2001-07-04 18:27:35 +02:00
textYOff=fh->H-m_fontBank->getStringHeight(buf);
2001-06-28 16:14:07 +02:00
y+=textYOff;
m_fontBank->print(x,y,buf);
2001-06-27 20:06:59 +02:00
}
2001-02-09 18:48:35 +01:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
2001-02-09 22:41:55 +01:00
int CPauseMenu::isActive()
2001-02-09 18:48:35 +01:00
{
return m_active;
}
/*===========================================================================
end */