SBSPSS/source/game/convo.cpp

999 lines
23 KiB
C++
Raw Normal View History

2001-01-05 22:43:21 +01:00
/*=========================================================================
convo.cpp
Author: PKG
Created:
Project: Spongebob
Purpose:
Copyright (c) 2000 Climax Development Ltd
===========================================================================*/
/*----------------------------------------------------------------------
Includes
-------- */
#include "game\convo.h"
2001-01-10 18:27:12 +01:00
#ifndef __MEMORY_HEADER__
#include "mem\memory.h"
#endif
2001-05-03 03:59:46 +02:00
#ifndef __GUI_GUI_H__
#include "gui\gui.h"
2001-01-10 18:27:12 +01:00
#endif
#ifndef __GFX_SPRBANK_H__
#include "gfx\sprbank.h"
#endif
#ifndef __GFX_FONT_H__
#include "gfx\font.h"
#endif
#ifndef __SCRIPT_SCRIPT_H__
#include "script\script.h"
#endif
#ifndef __PAD_PADS_H__
#include "pad\pads.h"
#endif
2001-05-03 15:11:45 +02:00
#ifndef __LEVEL_LEVEL_H__
#include "level\level.h"
#endif
2001-05-09 00:09:00 +02:00
#ifndef __SOUND_SOUND_H__
#include "sound\sound.h"
#endif
#ifndef __SPEECH_DEFINES_H__
#include "sound\speech.h"
#endif
#ifndef __LOCALE_TEXTDBASE_H__
#include "locale\textdbase.h"
#endif
2001-01-10 18:27:12 +01:00
2001-01-05 22:43:21 +01:00
/* Std Lib
------- */
/* Data
---- */
2001-04-20 16:53:35 +02:00
#ifndef __SPR_SPRITES_H__
#include <sprites.h>
2001-01-10 18:27:12 +01:00
#endif
#ifndef __STRING_ENUMS__
#include <trans.h>
#endif
2001-05-03 15:11:45 +02:00
2001-01-05 22:43:21 +01:00
/*----------------------------------------------------------------------
Tyepdefs && Defines
------------------- */
/*----------------------------------------------------------------------
Structure defintions
-------------------- */
/*----------------------------------------------------------------------
Function Prototypes
------------------- */
/*----------------------------------------------------------------------
Vars
---- */
2001-05-05 23:18:12 +02:00
struct sSpeechTable
{
int SpeechID;
2001-06-22 22:14:08 +02:00
int TextID;
2001-05-05 23:18:12 +02:00
};
const sSpeechTable SpeechTable[]=
{
2001-06-22 22:14:08 +02:00
{SPEECH_001,STR__INGAME__FMA_C1_INTRO0},
{SPEECH_002,STR__INGAME__FMA_C1_INTRO1},
{SPEECH_003,STR__INGAME__FMA_C1_SB0},
{SPEECH_004,STR__INGAME__FMA_C1_SB1},
{SPEECH_005,STR__INGAME__FMA_C1_SB2},
{SPEECH_006,STR__INGAME__FMA_C1_BB0},
{SPEECH_007,STR__INGAME__FMA_C1_BB1},
{SPEECH_008,STR__INGAME__FMA_C1_MM0},
{SPEECH_009,STR__INGAME__GARY_MEOW},
{SPEECH_010,STR__INGAME__CH1__L1__SPONGEY1},
{SPEECH_011,STR__INGAME__CH1__L1__SQUIDWARD1},
{SPEECH_012,STR__INGAME__CH1__L1__SQUIDWARD2},
2001-07-03 00:57:52 +02:00
{SPEECH_013,STR__INGAME__CH1__L1__SBCELEBRATE},
2001-06-22 22:14:08 +02:00
{SPEECH_014,STR__INGAME__CH1__L2__SANDY1},
{SPEECH_015,STR__INGAME__CH1__L2__SANDY2},
{SPEECH_016,STR__INGAME__CH1__L2__SANDY3},
2001-07-03 00:57:52 +02:00
{SPEECH_017,STR__INGAME__CH1__L2__SBCELEBRATE},
{SPEECH_018,STR__INGAME__CH1__L3__SBCELEBRATE},
2001-06-22 22:14:08 +02:00
{SPEECH_019,STR__INGAME__CH1__L4__KRUSTY1},
{SPEECH_020,STR__INGAME__CH1__L4__KRUSTY2},
{SPEECH_021,STR__INGAME__FMA_C2_MM_ZZZ},
{SPEECH_022,STR__INGAME__FMA_C2_BB_ZZZ},
{SPEECH_023,STR__INGAME__FMA_C2_SB0},
{SPEECH_024,STR__INGAME__FMA_C2_BB0},
{SPEECH_025,STR__INGAME__FMA_C2_SB1},
{SPEECH_026,STR__INGAME__CH2__L1__KRUSTY1},
{SPEECH_027,STR__INGAME__CH2__L1__KRUSTY2},
{SPEECH_028,-1},
{SPEECH_029,-1}, // Another Meow
2001-07-03 00:57:52 +02:00
{SPEECH_030,STR__INGAME__CH2__L1__SBCELEBRATE},
2001-06-22 22:14:08 +02:00
{SPEECH_031,STR__INGAME__CH2__L2__PATRICK1},
{SPEECH_032,STR__INGAME__CH2__L2__PATRICK2},
2001-07-03 00:57:52 +02:00
{SPEECH_033,STR__INGAME__CH2__L2__SBCELEBRATE},
{SPEECH_034,STR__INGAME__CH2__L3__SBCELEBRATE},
{SPEECH_035,STR__INGAME__CH2__L4__SBCELEBRATE},
2001-06-22 22:14:08 +02:00
{SPEECH_036,STR__INGAME__FMA_C3_SB0},
2001-07-11 17:10:05 +02:00
{SPEECH_037,STR__INGAME__FMA_C3_BB0},
2001-06-22 22:14:08 +02:00
{SPEECH_038,STR__INGAME__FMA_C3_SB1},
{SPEECH_039,STR__INGAME__FMA_C3_BB1},
{SPEECH_040,STR__INGAME__FMA_C3_SB2},
2001-07-02 18:17:31 +02:00
{SPEECH_041,STR__INGAME__FMA_PLANKTON},
2001-07-03 00:57:52 +02:00
{SPEECH_042,STR__INGAME__CH3__L1__SBCELEBRATE},
{SPEECH_043,STR__INGAME__CH3__L2__SBCELEBRATE},
2001-06-22 22:14:08 +02:00
{SPEECH_044,STR__INGAME__CH3__L3__PATRICK1},
{SPEECH_045,STR__INGAME__CH3__L3__PATRICK2},
2001-07-03 00:57:52 +02:00
{SPEECH_046,STR__INGAME__CH3__L3__SBCELEBRATE},
{SPEECH_047,STR__INGAME__CH3__L4__SBCELEBRATE},
2001-06-22 22:14:08 +02:00
{SPEECH_048,STR__INGAME__FMA_C4_SB0},
{SPEECH_049,STR__INGAME__FMA_C4_MM_GASP},
{SPEECH_050,STR__INGAME__FMA_C4_BB_GASP},
{SPEECH_051,STR__INGAME__FMA_C4_SB1},
{SPEECH_052,STR__INGAME__FMA_C4_BB0},
2001-07-03 00:57:52 +02:00
{SPEECH_053,STR__INGAME__CH4__L1__SBCELEBRATE},
{SPEECH_054,STR__INGAME__CH4__L2__SBCELEBRATE},
2001-06-22 22:14:08 +02:00
{SPEECH_055,STR__INGAME__CH4__L3__KRUSTY1},
{SPEECH_056,STR__INGAME__CH4__L3__KRUSTY2},
2001-07-03 00:57:52 +02:00
{SPEECH_057,STR__INGAME__CH4__L3__SBCELEBRATE},
{SPEECH_058,STR__INGAME__CH4__L4__SBCELEBRATE},
2001-06-22 22:14:08 +02:00
{SPEECH_059,STR__INGAME__FMA_C5_SB0},
{SPEECH_060,STR__INGAME__FMA_C5_BB0},
{SPEECH_061,STR__INGAME__FMA_C5_SB1},
2001-07-03 00:57:52 +02:00
{SPEECH_062,STR__INGAME__CH5__L1__SBCELEBRATE},
{SPEECH_063,STR__INGAME__CH5__L2__SBCELEBRATE},
{SPEECH_064,STR__INGAME__CH5__L3__SBCELEBRATE},
{SPEECH_065,STR__INGAME__CH5__L4__SBCELEBRATE},
2001-06-22 22:14:08 +02:00
{SPEECH_066,STR__INGAME__FMA_C6_SB0},
{SPEECH_067,STR__INGAME__FMA_C6_SB1},
{SPEECH_068,STR__INGAME__FMA_C6_BB0},
{SPEECH_069,STR__INGAME__FMA_C6_SB2},
{SPEECH_070,STR__INGAME__FMA_C6_BB1},
{SPEECH_071,STR__INGAME__FMA_C6_BB_MM0},
{SPEECH_072,-1},
2001-07-06 00:58:05 +02:00
{SPEECH_073,STR__INGAME__FMA_PARTY_SB0},
{SPEECH_074,STR__INGAME__FMA_PARTY_PAT0},
{SPEECH_075,STR__INGAME__FMA_PARTY_VO0},
{SPEECH_076,STR__INGAME__FMA_PARTY_SB},
{SPEECH_077,STR__INGAME__FMA_PARTY_MM},
{SPEECH_078,STR__INGAME__FMA_PARTY_BB},
{SPEECH_079,STR__INGAME__FMA_PARTY_GARY},
{SPEECH_080,STR__INGAME__FMA_PARTY_PLANKTON},
{SPEECH_081,STR__INGAME__FMA_PARTY_PAT},
{SPEECH_082,STR__INGAME__FMA_PARTY_KRABS},
{SPEECH_083,STR__INGAME__FMA_PARTY_SQUIDWARD},
{SPEECH_084,STR__INGAME__FMA_PARTY_SANDY},
2001-06-22 22:14:08 +02:00
{SPEECH_085,-1},
{SPEECH_086,-1},
{SPEECH_087,-1},
{SPEECH_088,-1},
{SPEECH_089,-1},
2001-06-28 22:48:32 +02:00
{SPEECH_090,STR__INGAME__CH3__L2__SANDY1},
{SPEECH_091,STR__INGAME__CH3__L2__SANDY2},
2001-06-22 22:14:08 +02:00
{SPEECH_092,-1},
{SPEECH_093,-1},
{SPEECH_094,-1},
{SPEECH_095,-1},
{SPEECH_096,-1},
{SPEECH_097,-1},
{SPEECH_098,-1},
{SPEECH_099,-1},
{SPEECH_100,-1},
{SPEECH_101,-1},
{SPEECH_102,-1},
{SPEECH_103,-1},
{SPEECH_104,-1},
{SPEECH_105,-1},
{SPEECH_106,-1},
{SPEECH_107,-1},
{SPEECH_108,-1},
{SPEECH_109,-1},
{SPEECH_110,-1},
{SPEECH_111,-1},
{SPEECH_112,-1},
{SPEECH_113,-1},
{SPEECH_114,-1},
{SPEECH_115,-1},
{SPEECH_116,-1},
{SPEECH_117,-1},
{SPEECH_118,-1},
{SPEECH_119,-1},
{SPEECH_120,-1},
{SPEECH_121,-1},
{SPEECH_122,-1},
{SPEECH_123,-1},
{SPEECH_124,-1},
{SPEECH_125,-1},
{SPEECH_126,-1},
{SPEECH_127,-1},
{SPEECH_128,-1},
{SPEECH_129,-1},
{SPEECH_130,-1},
{SPEECH_131,-1},
{SPEECH_132,-1},
{SPEECH_133,-1},
{SPEECH_134,-1},
{SPEECH_135,-1},
{SPEECH_136,-1},
{SPEECH_137,-1},
{SPEECH_138,-1},
{SPEECH_139,-1},
{SPEECH_140,-1},
{SPEECH_141,-1},
{SPEECH_142,-1},
{SPEECH_143,-1},
{SPEECH_144,-1},
{SPEECH_145,-1},
{SPEECH_146,-1},
{SPEECH_147,-1},
{SPEECH_148,-1},
{SPEECH_149,-1},
{SPEECH_150,-1},
{SPEECH_151,-1},
{SPEECH_152,-1},
2001-07-13 21:38:13 +02:00
{SPEECH_153,-1},
2001-06-22 22:14:08 +02:00
{SPEECH_154,-1},
{SPEECH_155,-1},
{SPEECH_156,-1},
{SPEECH_157,-1},
{SPEECH_158,-1},
{SPEECH_159,-1},
2001-05-05 23:18:12 +02:00
};
const int SpeechTableSize=sizeof(SpeechTable)/sizeof(sSpeechTable);
2001-01-05 22:43:21 +01:00
2001-01-10 18:27:12 +01:00
CConversation::CHAR_ICON_FRAMES CConversation::s_characterIconFrames[]=
{
2001-01-11 22:54:44 +01:00
{ FRM_SPONGEBOB, }, // CHAR_SPONGEBOB
{ FRM_SANDY }, // CHAR_SANDY
{ FRM_PATRICK }, // CHAR_PATRICK
{ FRM_SQUIDWARD }, // CHAR_SQUIDWARD
{ FRM_MR_KRABS }, // CHAR_KRABS
{ FRM_PLANKTON }, // CHAR_PLANKTON
{ FRM_MERMAIDMAN }, // CHAR_MERMAIDMAN,
{ FRM_BARNACLEBOY }, // CHAR_BARNACLEBOY,
2001-05-03 03:59:46 +02:00
{ -1 }, // CHAR_JACKCUSTARD
2001-07-01 20:40:03 +02:00
{ FRM_GARY }, // CHAR_GARY
2001-01-11 22:54:44 +01:00
2001-01-10 18:27:12 +01:00
};
2001-05-03 03:59:46 +02:00
class FontBank *CConversation::s_textFontBank=NULL;
class FontBank *CConversation::s_questionFontBank=NULL;
2001-01-22 21:57:39 +01:00
2001-01-23 22:05:48 +01:00
class CScript *CConversation::s_registeredScripts[MAX_LOADED_SCRIPTS];
int CConversation::s_registeredScriptIds[MAX_LOADED_SCRIPTS];
int CConversation::s_numRegisteredScripts=0;
2001-01-22 21:57:39 +01:00
class CScript *CConversation::s_currentScript=NULL;
int CConversation::s_currentState=STATE_INACTIVE;
2001-01-10 18:27:12 +01:00
2001-07-01 20:40:03 +02:00
int CConversation::s_currentQuestion;
int CConversation::s_currentAnswer;
int CConversation::s_currentSelectedAnswer;
int CConversation::s_faceFrame;
int CConversation::s_speechId;
int CConversation::s_textPageOffset;
int CConversation::s_maxTextPageOffset;
SpriteBank *CConversation::s_sprites;
2001-05-09 00:09:00 +02:00
2001-07-24 17:06:30 +02:00
int CConversation::s_ignoreNewlyPressedButtonsOnPadThisThink;
2001-01-10 18:27:12 +01:00
2001-07-01 20:40:03 +02:00
static xmPlayingId s_playingSfxId;
2001-05-03 03:59:46 +02:00
2001-01-10 18:27:12 +01:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CConversation::init()
{
2001-01-23 22:05:48 +01:00
ASSERT(s_numRegisteredScripts==0);
2001-05-03 03:59:46 +02:00
s_textFontBank=new ("Conversation Font") FontBank();
s_textFontBank->initialise(&standardFont);
s_textFontBank->setOt(0);
2001-05-14 15:55:53 +02:00
s_textFontBank->setColour(TEXT_R,TEXT_G,TEXT_B);
2001-01-10 18:27:12 +01:00
2001-05-03 03:59:46 +02:00
s_questionFontBank=new ("Conversation Font") FontBank();
s_questionFontBank->initialise(&standardFont);
s_questionFontBank->setOt(0);
2001-01-10 18:27:12 +01:00
2001-01-22 21:57:39 +01:00
s_currentState=STATE_INACTIVE;
2001-01-23 22:05:48 +01:00
s_currentScript=NULL;
2001-07-01 20:40:03 +02:00
s_sprites=new ("ConvoSprites") SpriteBank();
s_sprites->load(SPRITES_SPRITES_SPR);
2001-07-24 17:06:30 +02:00
s_ignoreNewlyPressedButtonsOnPadThisThink=false;
2001-01-10 18:27:12 +01:00
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CConversation::shutdown()
{
2001-07-01 20:40:03 +02:00
s_sprites->dump(); delete s_sprites;
2001-05-03 03:59:46 +02:00
s_questionFontBank->dump(); delete s_questionFontBank;
s_textFontBank->dump(); delete s_textFontBank;
2001-01-23 22:05:48 +01:00
dumpConversationScripts();
2001-01-10 18:27:12 +01:00
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CConversation::think(int _frames)
{
if(isActive())
{
2001-01-23 22:05:48 +01:00
ASSERT(s_currentScript);
2001-01-22 21:57:39 +01:00
if(s_currentState==STATE_JUST_ACTIVATED)
2001-01-10 18:27:12 +01:00
{
2001-02-02 21:00:04 +01:00
// Need to make sure that the conversation box isn't rendered on the first frame
// ( ie: before it's had time to think ) or it will still be displaying old info
// from the last time it was up
2001-01-22 21:57:39 +01:00
s_currentState=STATE_ACTIVE;
2001-01-10 18:27:12 +01:00
}
2001-07-24 17:06:30 +02:00
if(!s_ignoreNewlyPressedButtonsOnPadThisThink)
{
thinkText();
thinkQuestion();
}
2001-01-10 18:27:12 +01:00
2001-01-22 21:57:39 +01:00
s_currentScript->run();
if(s_currentScript->isFinished())
2001-01-10 18:27:12 +01:00
{
2001-01-23 22:05:48 +01:00
s_currentScript=NULL;
2001-01-22 21:57:39 +01:00
s_currentState=STATE_INACTIVE;
2001-05-05 23:18:12 +02:00
CSoundMediator::stopSpeech();
2001-05-09 00:09:00 +02:00
if(s_playingSfxId!=NOT_PLAYING)
{
CSoundMediator::stopAndUnlockSfx(s_playingSfxId);
s_playingSfxId=NOT_PLAYING;
}
s_playingSfxId=CSoundMediator::playSfx(CSoundMediator::SFX_FRONT_END__OK);
2001-01-10 18:27:12 +01:00
}
2001-07-24 17:06:30 +02:00
s_ignoreNewlyPressedButtonsOnPadThisThink=false;
2001-01-10 18:27:12 +01:00
}
}
2001-01-05 22:43:21 +01:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
2001-01-10 18:27:12 +01:00
void CConversation::render()
2001-01-05 22:43:21 +01:00
{
2001-01-22 21:57:39 +01:00
if(s_currentState==STATE_ACTIVE)
2001-01-10 18:27:12 +01:00
{
2001-05-03 03:59:46 +02:00
renderText();
2001-01-10 18:27:12 +01:00
renderQuestion();
2001-07-01 20:40:03 +02:00
if(s_faceFrame!=-1)
{
drawSpeechBubbleBorder(TEXTBOX_X,TEXTBOX_Y,TEXTBOX_WIDTH,TEXTBOX_HEIGHT+TEXTBOX_QUESTIONHEIGHT,0,s_faceFrame);
}
else
{
drawSpeechBubbleBorder(TEXTBOX_X_FOR_NARRATOR,TEXTBOX_Y,TEXTBOX_WIDTH_FOR_NARRATOR,TEXTBOX_HEIGHT+TEXTBOX_QUESTIONHEIGHT,0,-1);
}
2001-01-10 18:27:12 +01:00
}
2001-01-05 22:43:21 +01:00
}
2001-01-10 18:27:12 +01:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CConversation::registerConversationScript(FileEquate _feScript)
{
2001-01-23 22:05:48 +01:00
ASSERT(s_numRegisteredScripts<MAX_LOADED_SCRIPTS);
// Load in the script and register its id
s_registeredScripts[s_numRegisteredScripts]=new ("conversation script") CScript();
s_registeredScripts[s_numRegisteredScripts]->initialise(_feScript);
s_registeredScriptIds[s_numRegisteredScripts]=_feScript;
s_numRegisteredScripts++;
2001-01-10 18:27:12 +01:00
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CConversation::trigger(FileEquate _feScript)
{
2001-01-23 22:05:48 +01:00
int i;
2001-01-10 18:27:12 +01:00
ASSERT(!isActive());
2001-05-09 00:09:00 +02:00
s_playingSfxId=NOT_PLAYING;
2001-01-23 22:05:48 +01:00
// Is this script already registered?
for(i=0;i<s_numRegisteredScripts;i++)
{
if(s_registeredScriptIds[i]==_feScript)
{
// Found it..
s_currentScript=s_registeredScripts[i];
s_currentState=STATE_JUST_ACTIVATED;
2001-02-02 21:00:04 +01:00
s_currentScript->reset();
2001-01-23 22:05:48 +01:00
return;
}
}
2001-01-10 18:27:12 +01:00
2001-01-23 22:05:48 +01:00
ASSERT(!"Script was not registered");
2001-01-10 18:27:12 +01:00
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
int CConversation::isActive()
{
2001-01-22 21:57:39 +01:00
return s_currentState!=STATE_INACTIVE;
2001-01-10 18:27:12 +01:00
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CConversation::setCharacterAndText(int _characterId,int _textId)
{
2001-07-18 18:11:03 +02:00
char buf[1024],*pBuf;
2001-07-01 20:40:03 +02:00
RECT clipTextRegion;
2001-07-18 18:11:03 +02:00
int i;
2001-07-01 20:40:03 +02:00
2001-05-03 03:59:46 +02:00
s_faceFrame=(s_characterIconFrames[_characterId].m_frame);
s_speechId=_textId;
2001-07-18 18:11:03 +02:00
sprintf(buf,TranslationDatabase::getString(s_speechId));
pBuf=buf;
2001-07-01 20:40:03 +02:00
clipTextRegion=getTextRegion();
s_textFontBank->setPrintArea(clipTextRegion.x,clipTextRegion.y,clipTextRegion.w,clipTextRegion.h);
2001-07-21 00:09:21 +02:00
i=-1;
2001-07-18 18:11:03 +02:00
while(*pBuf)
2001-05-05 23:18:12 +02:00
{
2001-07-18 18:11:03 +02:00
// yes.. i know it's gay but it works..
2001-07-21 00:09:21 +02:00
pBuf+=s_textFontBank->printTillEndOfLine(0,-90,pBuf);
2001-07-18 18:11:03 +02:00
i++;
2001-05-05 23:18:12 +02:00
}
2001-07-18 18:11:03 +02:00
s_maxTextPageOffset=i/TEXTBOX_FONT_NUM_LINES_IN_BOX;
s_textPageOffset=0;
2001-07-18 22:39:48 +02:00
for (int i=0; i<SpeechTableSize; i++)
{
if (SpeechTable[i].TextID==_textId)
{
CSoundMediator::playSpeech((SpeechEquate)SpeechTable[i].SpeechID);
break;
}
}
2001-01-10 18:27:12 +01:00
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CConversation::setResponseOptions(int _responseOptions)
{
s_currentQuestion=_responseOptions;
s_currentAnswer=ANSWER_NONE;
s_currentSelectedAnswer=0;
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
int CConversation::getResponse()
{
return s_currentAnswer;
}
2001-05-03 03:59:46 +02:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CConversation::thinkText()
{
2001-05-09 00:09:00 +02:00
int sfx=-1;
2001-05-03 03:59:46 +02:00
if(PadGetRepeat(0)&PAD_DOWN)
{
2001-07-01 20:40:03 +02:00
if(s_textPageOffset<s_maxTextPageOffset)
2001-05-09 00:09:00 +02:00
{
2001-07-01 20:40:03 +02:00
s_textPageOffset++;
if(s_textPageOffset>s_maxTextPageOffset)
2001-05-09 00:09:00 +02:00
{
2001-07-01 20:40:03 +02:00
s_textPageOffset=s_maxTextPageOffset;
2001-05-09 00:09:00 +02:00
}
sfx=CSoundMediator::SFX_FRONT_END__MOVE_CURSOR;
}
else
{
sfx=CSoundMediator::SFX_FRONT_END__ERROR;
}
2001-05-03 03:59:46 +02:00
}
else if(PadGetRepeat(0)&PAD_UP)
{
2001-07-01 20:40:03 +02:00
if(s_textPageOffset>0)
2001-05-09 00:09:00 +02:00
{
2001-07-01 20:40:03 +02:00
s_textPageOffset--;
if(s_textPageOffset<0)
2001-05-09 00:09:00 +02:00
{
2001-07-01 20:40:03 +02:00
s_textPageOffset=0;
2001-05-09 00:09:00 +02:00
}
sfx=CSoundMediator::SFX_FRONT_END__MOVE_CURSOR;
}
else
{
sfx=CSoundMediator::SFX_FRONT_END__ERROR;
}
}
if(sfx!=-1)
{
if(s_playingSfxId!=NOT_PLAYING)
2001-05-03 03:59:46 +02:00
{
2001-05-09 00:09:00 +02:00
CSoundMediator::stopAndUnlockSfx(s_playingSfxId);
2001-05-03 03:59:46 +02:00
}
2001-05-09 00:09:00 +02:00
s_playingSfxId=CSoundMediator::playSfx((CSoundMediator::SFXID)sfx,true);
2001-05-03 03:59:46 +02:00
}
}
2001-01-10 18:27:12 +01:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CConversation::thinkQuestion()
{
if(s_currentQuestion!=QUESTION_NONE)
{
int pad=PadGetDown(0);
if(s_currentQuestion==QUESTION_YES_NO)
{
2001-08-14 20:52:34 +02:00
if(pad&PAD_CROSS)
2001-01-10 18:27:12 +01:00
{
s_currentAnswer=s_currentSelectedAnswer==0?ANSWER_YES:ANSWER_NO;
s_currentQuestion=QUESTION_NONE;
}
2001-08-14 20:52:34 +02:00
else if(pad&(PAD_LEFT|PAD_RIGHT))
2001-01-10 18:27:12 +01:00
{
s_currentSelectedAnswer^=1;
}
}
else if(s_currentQuestion==QUESTION_OK)
{
2001-08-14 20:52:34 +02:00
if(pad&PAD_CROSS)
2001-01-10 18:27:12 +01:00
{
s_currentAnswer=ANSWER_OK;
s_currentQuestion=QUESTION_NONE;
}
}
}
}
2001-05-03 03:59:46 +02:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CConversation::renderText()
{
2001-07-01 20:40:03 +02:00
RECT clipTextRegion;
char buf[1024],*pBuf;
int i;
clipTextRegion=getTextRegion();
2001-05-03 03:59:46 +02:00
2001-07-01 20:40:03 +02:00
sprintf(buf,TranslationDatabase::getString(s_speechId));
pBuf=buf;
for(i=0;i<s_textPageOffset*TEXTBOX_FONT_NUM_LINES_IN_BOX;i++)
{
// yes.. i know it's gay but it works..
2001-07-21 00:09:21 +02:00
pBuf+=s_textFontBank->printTillEndOfLine(0,-90,pBuf);
2001-07-01 20:40:03 +02:00
}
for(i=0;i<TEXTBOX_FONT_NUM_LINES_IN_BOX&&pBuf;i++)
{
pBuf+=s_textFontBank->printTillEndOfLine(0,i*TEXTBOX_FONT_LINE_SPACING,pBuf);
}
// Render up/down button hints
if(s_textPageOffset!=0)
{
s_sprites->printFT4(FRM__BUTU,clipTextRegion.x+TEXTBOX_BUTTONS_XOFF,TEXTBOX_Y+TEXTBOX_BUTTONS_YOFF,0,0,0);
}
if(s_textPageOffset<s_maxTextPageOffset)
{
s_sprites->printFT4(FRM__BUTD,clipTextRegion.x+TEXTBOX_BUTTONS_XOFF+TEXTBOX_BUTTONS_GAP,TEXTBOX_Y+TEXTBOX_BUTTONS_YOFF,0,0,0);
}
2001-07-18 00:39:53 +02:00
// Render X button hint
int xofs;
if(s_faceFrame!=-1)
{
xofs=clipTextRegion.x+TEXTBOX_BUTTONS_XOFF+TEXTBOX_WIDTH-TEXTBOX_XBUTTON_XOFFSET;
}
else
{
xofs=clipTextRegion.x+TEXTBOX_BUTTONS_XOFF+TEXTBOX_WIDTH_FOR_NARRATOR-TEXTBOX_XBUTTON_XOFFSET;
}
s_sprites->printFT4(FRM__BUTX,xofs,TEXTBOX_Y+TEXTBOX_BUTTONS_YOFF,0,0,0);
2001-05-03 03:59:46 +02:00
}
2001-01-10 18:27:12 +01:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CConversation::renderQuestion()
{
2001-05-09 00:09:00 +02:00
int y;
2001-01-10 18:27:12 +01:00
2001-05-09 00:09:00 +02:00
y=TEXTBOX_Y+TEXTBOX_HEIGHT+TEXTBOX_QUESTIONHEIGHT-s_questionFontBank->getCharHeight();
2001-01-10 18:27:12 +01:00
switch(s_currentQuestion)
{
case QUESTION_OK:
{
2001-05-03 03:59:46 +02:00
s_questionFontBank->setColour(SELECT_TEXT_R,SELECT_TEXT_G,SELECT_TEXT_B);
s_questionFontBank->setJustification(FontBank::JUST_RIGHT);
2001-05-09 00:09:00 +02:00
s_questionFontBank->print(TEXTBOX_X+TEXTBOX_WIDTH,y,STR__OK);
2001-01-10 18:27:12 +01:00
}
break;
case QUESTION_YES_NO:
{
if(s_currentSelectedAnswer==0)
{
2001-05-03 03:59:46 +02:00
s_questionFontBank->setColour(SELECT_TEXT_R,SELECT_TEXT_G,SELECT_TEXT_B);
2001-01-10 18:27:12 +01:00
}
else
{
2001-05-03 03:59:46 +02:00
s_questionFontBank->setColour(UNSELECT_TEXT_R,UNSELECT_TEXT_G,UNSELECT_TEXT_B);
2001-01-10 18:27:12 +01:00
}
2001-05-03 03:59:46 +02:00
s_questionFontBank->setJustification(FontBank::JUST_LEFT);
2001-05-09 00:09:00 +02:00
s_questionFontBank->print(TEXTBOX_X+TEXTBOX_WIDTH,y,STR__YES);
2001-01-10 18:27:12 +01:00
if(s_currentSelectedAnswer==1)
{
2001-05-03 03:59:46 +02:00
s_questionFontBank->setColour(SELECT_TEXT_R,SELECT_TEXT_G,SELECT_TEXT_B);
2001-01-10 18:27:12 +01:00
}
else
{
2001-05-03 03:59:46 +02:00
s_questionFontBank->setColour(UNSELECT_TEXT_R,UNSELECT_TEXT_G,UNSELECT_TEXT_B);
2001-01-10 18:27:12 +01:00
}
2001-05-03 03:59:46 +02:00
s_questionFontBank->setJustification(FontBank::JUST_RIGHT);
2001-05-09 00:09:00 +02:00
s_questionFontBank->print(TEXTBOX_X,y,STR__NO);
2001-01-10 18:27:12 +01:00
}
break;
case QUESTION_NONE:
default:
break;
}
}
2001-01-23 22:05:48 +01:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CConversation::dumpConversationScripts()
{
int i;
for(i=0;i<s_numRegisteredScripts;i++)
{
s_registeredScripts[i]->dump();
2001-02-09 18:31:20 +01:00
delete s_registeredScripts[i];
2001-01-23 22:05:48 +01:00
}
s_currentScript=NULL;
s_numRegisteredScripts=0;
}
2001-05-03 00:49:59 +02:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CConversation::registerConversationLevelScripts(int level)
{
2001-05-03 15:11:45 +02:00
switch( CLevel::getCurrentChapter() )
2001-05-03 00:49:59 +02:00
{
2001-05-03 15:11:45 +02:00
case 1:
{
switch ( CLevel::getCurrentChapterLevel() )
{
case 1:
{
CConversation::registerConversationScript(SCRIPTS_CH1L1_01_DAT);
CConversation::registerConversationScript(SCRIPTS_CH1L1_02_DAT);
2001-07-03 00:57:52 +02:00
CConversation::registerConversationScript(SCRIPTS_C1L1_CELEBRATE_DAT);
2001-05-03 15:11:45 +02:00
break;
}
case 2:
{
CConversation::registerConversationScript(SCRIPTS_CH1L2_01_DAT);
CConversation::registerConversationScript(SCRIPTS_CH1L2_02_DAT);
CConversation::registerConversationScript(SCRIPTS_CH1L2_03_DAT);
2001-07-03 00:57:52 +02:00
CConversation::registerConversationScript(SCRIPTS_C1L2_CELEBRATE_DAT);
break;
}
case 3:
{
CConversation::registerConversationScript(SCRIPTS_C1L3_CELEBRATE_DAT);
2001-05-03 15:11:45 +02:00
break;
}
case 4:
{
CConversation::registerConversationScript(SCRIPTS_CH1L4_01_DAT);
CConversation::registerConversationScript(SCRIPTS_CH1L4_02_DAT);
2001-07-03 00:57:52 +02:00
CConversation::registerConversationScript(SCRIPTS_C1L4_CELEBRATE_DAT);
2001-05-03 15:11:45 +02:00
break;
}
default:
break;
}
break;
}
case 2:
2001-05-03 00:49:59 +02:00
{
2001-05-03 15:11:45 +02:00
switch ( CLevel::getCurrentChapterLevel() )
{
case 1:
{
CConversation::registerConversationScript(SCRIPTS_CH2L1_01_DAT);
CConversation::registerConversationScript(SCRIPTS_CH2L1_02_DAT);
2001-07-03 00:57:52 +02:00
CConversation::registerConversationScript(SCRIPTS_C2L1_CELEBRATE_DAT);
2001-05-03 15:11:45 +02:00
break;
}
case 2:
{
CConversation::registerConversationScript(SCRIPTS_CH2L2_01_DAT);
CConversation::registerConversationScript(SCRIPTS_CH2L2_02_DAT);
2001-07-03 00:57:52 +02:00
CConversation::registerConversationScript(SCRIPTS_C2L2_CELEBRATE_DAT);
break;
}
case 3:
{
CConversation::registerConversationScript(SCRIPTS_C2L3_CELEBRATE_DAT);
break;
}
case 4:
{
CConversation::registerConversationScript(SCRIPTS_C2L4_CELEBRATE_DAT);
2001-05-03 15:11:45 +02:00
break;
}
default:
break;
}
break;
}
case 3:
{
switch ( CLevel::getCurrentChapterLevel() )
{
2001-07-03 00:57:52 +02:00
case 1:
{
2001-07-19 16:04:59 +02:00
CConversation::registerConversationScript(SCRIPTS_CH4L3_01_DAT);
CConversation::registerConversationScript(SCRIPTS_CH4L3_02_DAT);
2001-07-03 00:57:52 +02:00
CConversation::registerConversationScript(SCRIPTS_C3L1_CELEBRATE_DAT);
break;
}
2001-05-03 15:11:45 +02:00
2001-06-28 23:24:02 +02:00
case 2:
{
CConversation::registerConversationScript(SCRIPTS_CH3L2_01_DAT);
2001-07-03 00:57:52 +02:00
CConversation::registerConversationScript(SCRIPTS_C3L2_CELEBRATE_DAT);
2001-06-28 23:24:02 +02:00
break;
}
2001-05-03 15:11:45 +02:00
case 3:
{
CConversation::registerConversationScript(SCRIPTS_CH3L3_01_DAT);
CConversation::registerConversationScript(SCRIPTS_CH3L3_02_DAT);
2001-07-03 00:57:52 +02:00
CConversation::registerConversationScript(SCRIPTS_C3L3_CELEBRATE_DAT);
break;
}
case 4:
{
CConversation::registerConversationScript(SCRIPTS_C3L4_CELEBRATE_DAT);
2001-05-03 15:11:45 +02:00
break;
}
default:
break;
}
break;
}
case 4:
{
switch ( CLevel::getCurrentChapterLevel() )
{
2001-07-03 00:57:52 +02:00
case 1:
{
CConversation::registerConversationScript(SCRIPTS_C4L1_CELEBRATE_DAT);
break;
}
case 2:
{
CConversation::registerConversationScript(SCRIPTS_C4L2_CELEBRATE_DAT);
break;
}
2001-05-03 15:11:45 +02:00
case 3:
{
2001-07-03 00:57:52 +02:00
CConversation::registerConversationScript(SCRIPTS_C4L3_CELEBRATE_DAT);
break;
}
case 4:
{
CConversation::registerConversationScript(SCRIPTS_C4L4_CELEBRATE_DAT);
break;
}
default:
break;
}
break;
}
case 5:
{
switch ( CLevel::getCurrentChapterLevel() )
{
case 1:
{
CConversation::registerConversationScript(SCRIPTS_C5L1_CELEBRATE_DAT);
break;
}
case 2:
{
CConversation::registerConversationScript(SCRIPTS_C5L2_CELEBRATE_DAT);
break;
}
case 3:
{
CConversation::registerConversationScript(SCRIPTS_C5L3_CELEBRATE_DAT);
break;
}
case 4:
{
CConversation::registerConversationScript(SCRIPTS_C5L4_CELEBRATE_DAT);
2001-05-03 15:11:45 +02:00
break;
}
default:
break;
}
2001-05-03 00:49:59 +02:00
break;
}
default:
break;
}
}
2001-07-01 20:40:03 +02:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
RECT CConversation::getTextRegion()
{
2001-07-27 16:50:13 +02:00
RECT clipRegion={TEXTBOX_X,TEXTBOX_Y-3,TEXTBOX_WIDTH,TEXTBOX_HEIGHT};
2001-07-01 20:40:03 +02:00
if(s_faceFrame==-1)
{
// Narrators box..
clipRegion.x=TEXTBOX_X_FOR_NARRATOR;
clipRegion.w=TEXTBOX_WIDTH_FOR_NARRATOR;
}
return clipRegion;
}
2001-07-24 17:06:30 +02:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CConversation::ignoreNewlyPressedButtonsOnPadThisThink()
{
s_ignoreNewlyPressedButtonsOnPadThisThink=true;
}
2001-01-05 22:43:21 +01:00
/*===========================================================================
end */