This commit is contained in:
Paul 2001-01-22 20:57:39 +00:00
parent 69c516ecbf
commit 97a30e89cd
5 changed files with 67 additions and 72 deletions

View File

@ -41,6 +41,10 @@
#include "utils\utils.h" #include "utils\utils.h"
#endif #endif
#ifndef __GAME_CONVO_H__
#include "game\convo.h"
#endif
CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] = CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
{ {
@ -955,8 +959,6 @@ void CNpc::render()
void CNpc::processEvent( GAME_EVENT evt, CThing *sourceThing ) void CNpc::processEvent( GAME_EVENT evt, CThing *sourceThing )
{ {
CConversation *currentConversation = GameScene.getConversation();
if ( m_data[this->m_type].canTalk ) if ( m_data[this->m_type].canTalk )
{ {
DVECTOR sourcePos; DVECTOR sourcePos;
@ -974,9 +976,9 @@ void CNpc::processEvent( GAME_EVENT evt, CThing *sourceThing )
if ( xDiffSqr + yDiffSqr < 250 ) if ( xDiffSqr + yDiffSqr < 250 )
{ {
if( !currentConversation->isActive() ) if( !CConversation::isActive() )
{ {
currentConversation->trigger( SCRIPTS_SPEECHTEST_DAT ); CConversation::trigger( SCRIPTS_SPEECHTEST_DAT );
} }
} }
} }

View File

@ -99,6 +99,10 @@ CConversation::CHAR_ICON_FRAMES CConversation::s_characterIconFrames[]=
class CGUIGroupFrame *CConversation::s_guiFrame=NULL; class CGUIGroupFrame *CConversation::s_guiFrame=NULL;
class CGUISprite *CConversation::s_guiIcon=NULL; class CGUISprite *CConversation::s_guiIcon=NULL;
class CGUITextBox *CConversation::s_guiText=NULL; class CGUITextBox *CConversation::s_guiText=NULL;
class FontBank *CConversation::s_fontBank=NULL;
class CScript *CConversation::s_currentScript=NULL;
int CConversation::s_currentState=STATE_INACTIVE;
int CConversation::s_currentCharacterId=-1; int CConversation::s_currentCharacterId=-1;
int CConversation::s_currentTextId=-1; int CConversation::s_currentTextId=-1;
@ -133,11 +137,11 @@ void CConversation::init()
s_guiText->setObjectXYWH(FRAME_HEIGHT,TEXT_BORDER,FRAME_WIDTH-FRAME_HEIGHT-TEXT_BORDER,FRAME_HEIGHT-(TEXT_BORDER*2)); s_guiText->setObjectXYWH(FRAME_HEIGHT,TEXT_BORDER,FRAME_WIDTH-FRAME_HEIGHT-TEXT_BORDER,FRAME_HEIGHT-(TEXT_BORDER*2));
s_guiText->setOt(OT_POS); s_guiText->setOt(OT_POS);
m_fontBank=new ("Conversation Font") FontBank(); s_fontBank=new ("Conversation Font") FontBank();
m_fontBank->initialise(&standardFont); s_fontBank->initialise(&standardFont);
m_fontBank->setOt(0); s_fontBank->setOt(0);
m_currentState=STATE_INACTIVE; s_currentState=STATE_INACTIVE;
} }
@ -163,19 +167,19 @@ void CConversation::think(int _frames)
{ {
if(isActive()) if(isActive())
{ {
if(m_currentState==STATE_JUST_ACTIVATED) if(s_currentState==STATE_JUST_ACTIVATED)
{ {
m_currentState=STATE_ACTIVE; s_currentState=STATE_ACTIVE;
} }
s_guiFrame->think(_frames); s_guiFrame->think(_frames);
thinkQuestion(); thinkQuestion();
m_currentScript->run(); s_currentScript->run();
if(m_currentScript->isFinished()) if(s_currentScript->isFinished())
{ {
m_currentState=STATE_INACTIVE; s_currentState=STATE_INACTIVE;
} }
} }
} }
@ -189,7 +193,7 @@ void CConversation::think(int _frames)
---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
void CConversation::render() void CConversation::render()
{ {
if(m_currentState==STATE_ACTIVE) if(s_currentState==STATE_ACTIVE)
{ {
renderQuestion(); renderQuestion();
s_guiFrame->render(); s_guiFrame->render();
@ -219,10 +223,10 @@ void CConversation::trigger(FileEquate _feScript)
{ {
ASSERT(!isActive()); ASSERT(!isActive());
m_currentScript=new ("script") CScript(); s_currentScript=new ("script") CScript();
m_currentScript->initialise(_feScript); s_currentScript->initialise(_feScript);
m_currentState=STATE_JUST_ACTIVATED; s_currentState=STATE_JUST_ACTIVATED;
} }
@ -234,7 +238,7 @@ void CConversation::trigger(FileEquate _feScript)
---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
int CConversation::isActive() int CConversation::isActive()
{ {
return m_currentState!=STATE_INACTIVE; return s_currentState!=STATE_INACTIVE;
} }
@ -324,15 +328,15 @@ void CConversation::renderQuestion()
int xbase,y; int xbase,y;
xbase=(512-FRAME_WIDTH)/2; xbase=(512-FRAME_WIDTH)/2;
y=256-FRAME_BOTTOM_OFFSET-(TEXT_BORDER/2)-(m_fontBank->getCharHeight()/2); y=256-FRAME_BOTTOM_OFFSET-(TEXT_BORDER/2)-(s_fontBank->getCharHeight()/2);
switch(s_currentQuestion) switch(s_currentQuestion)
{ {
case QUESTION_OK: case QUESTION_OK:
{ {
m_fontBank->setColour(SELECT_TEXT_R,SELECT_TEXT_G,SELECT_TEXT_B); s_fontBank->setColour(SELECT_TEXT_R,SELECT_TEXT_G,SELECT_TEXT_B);
m_fontBank->setJustification(FontBank::JUST_RIGHT); s_fontBank->setJustification(FontBank::JUST_RIGHT);
m_fontBank->print(xbase+FRAME_WIDTH-TEXT_BORDER,y,STR__OK); s_fontBank->print(xbase+FRAME_WIDTH-TEXT_BORDER,y,STR__OK);
} }
break; break;
@ -340,25 +344,25 @@ void CConversation::renderQuestion()
{ {
if(s_currentSelectedAnswer==0) if(s_currentSelectedAnswer==0)
{ {
m_fontBank->setColour(SELECT_TEXT_R,SELECT_TEXT_G,SELECT_TEXT_B); s_fontBank->setColour(SELECT_TEXT_R,SELECT_TEXT_G,SELECT_TEXT_B);
} }
else else
{ {
m_fontBank->setColour(UNSELECT_TEXT_R,UNSELECT_TEXT_G,UNSELECT_TEXT_B); s_fontBank->setColour(UNSELECT_TEXT_R,UNSELECT_TEXT_G,UNSELECT_TEXT_B);
} }
m_fontBank->setJustification(FontBank::JUST_LEFT); s_fontBank->setJustification(FontBank::JUST_LEFT);
m_fontBank->print(xbase+FRAME_HEIGHT,y,STR__YES); s_fontBank->print(xbase+FRAME_HEIGHT,y,STR__YES);
if(s_currentSelectedAnswer==1) if(s_currentSelectedAnswer==1)
{ {
m_fontBank->setColour(SELECT_TEXT_R,SELECT_TEXT_G,SELECT_TEXT_B); s_fontBank->setColour(SELECT_TEXT_R,SELECT_TEXT_G,SELECT_TEXT_B);
} }
else else
{ {
m_fontBank->setColour(UNSELECT_TEXT_R,UNSELECT_TEXT_G,UNSELECT_TEXT_B); s_fontBank->setColour(UNSELECT_TEXT_R,UNSELECT_TEXT_G,UNSELECT_TEXT_B);
} }
m_fontBank->setJustification(FontBank::JUST_RIGHT); s_fontBank->setJustification(FontBank::JUST_RIGHT);
m_fontBank->print(xbase+FRAME_WIDTH-TEXT_BORDER,y,STR__NO); s_fontBank->print(xbase+FRAME_WIDTH-TEXT_BORDER,y,STR__NO);
} }
break; break;

View File

@ -37,16 +37,16 @@
class CConversation class CConversation
{ {
public: public:
void init(); static void init();
void shutdown(); static void shutdown();
void think(int _frames); static void think(int _frames);
void render(); static void render();
void registerConversationScript(FileEquate _feScript); static void registerConversationScript(FileEquate _feScript);
void trigger(FileEquate _feScript); static void trigger(FileEquate _feScript);
int isActive(); static int isActive();
static void setCharacterAndText(int _characterId,int _textId); static void setCharacterAndText(int _characterId,int _textId);
static void setResponseOptions(int _responseOptions); static void setResponseOptions(int _responseOptions);
@ -114,22 +114,19 @@ private:
}; };
void thinkQuestion(); static void thinkQuestion();
void renderQuestion(); static void renderQuestion();
// PKG - These don't need to be static..
// Make the sprites/text readouts maybe?
static class CGUIGroupFrame *s_guiFrame; static class CGUIGroupFrame *s_guiFrame;
static class CGUISprite *s_guiIcon; static class CGUISprite *s_guiIcon;
static class CGUITextBox *s_guiText; static class CGUITextBox *s_guiText;
static class FontBank *s_fontBank;
class FontBank *m_fontBank;
static CHAR_ICON_FRAMES s_characterIconFrames[MAX_CHARS]; static CHAR_ICON_FRAMES s_characterIconFrames[MAX_CHARS];
class CScript *m_currentScript; static class CScript *s_currentScript;
int m_currentState; static int s_currentState;
static int s_currentCharacterId; static int s_currentCharacterId;
static int s_currentTextId; static int s_currentTextId;

View File

@ -14,6 +14,10 @@
#include "gfx\font.h" #include "gfx\font.h"
#include "gfx\fdata.h" #include "gfx\fdata.h"
#ifndef __GAME_CONVO_H__
#include "game\convo.h"
#endif
#ifndef __PLAYER_PLAYER_H__ #ifndef __PLAYER_PLAYER_H__
#include "player\player.h" #include "player\player.h"
#endif #endif
@ -64,7 +68,7 @@ void CGameScene::init()
s_genericFont->initialise( &standardFont ); s_genericFont->initialise( &standardFont );
s_genericFont->setColour( 255, 255 , 0 ); s_genericFont->setColour( 255, 255 , 0 );
VidSetClearScreen(1); VidSetClearScreen(1);
m_conversation.init(); CConversation::init();
Level.init(); Level.init();
C2dEnemy *enemy; C2dEnemy *enemy;
@ -98,7 +102,7 @@ void CGameScene::shutdown()
CThing::shutdownAndDeleteAllThings(); CThing::shutdownAndDeleteAllThings();
Level.shutdown(); Level.shutdown();
m_conversation.shutdown(); CConversation::shutdown();
s_genericFont->dump(); delete s_genericFont; s_genericFont->dump(); delete s_genericFont;
} }
@ -107,7 +111,7 @@ void CGameScene::render()
{ {
CamMtx.t[2]=ZPos; // Temp CamMtx.t[2]=ZPos; // Temp
m_conversation.render(); CConversation::render();
CThing::renderAllThings(); CThing::renderAllThings();
Level.render(); Level.render();
} }
@ -116,14 +120,14 @@ void CGameScene::render()
void CGameScene::think(int _frames) void CGameScene::think(int _frames)
{ {
#ifdef __USER_paul__ #ifdef __USER_paul__
if(!m_conversation.isActive()&&PadGetDown(0)&PAD_START) if(!CConversation::isActive()&&PadGetDown(0)&PAD_START)
{ {
m_conversation.trigger(SCRIPTS_SPEECHTEST_DAT); CConversation::trigger(SCRIPTS_SPEECHTEST_DAT);
} }
#endif #endif
m_conversation.think(_frames); CConversation::think(_frames);
if(!m_conversation.isActive()) if(!CConversation::isActive())
{ {
CThing::thinkAllThings(_frames); CThing::thinkAllThings(_frames);
Level.setCameraCentre(m_player->getPos()); Level.setCameraCentre(m_player->getPos());
@ -150,9 +154,3 @@ void CGameScene::sendEvent( GAME_EVENT evt, CThing *sourceThing )
} }
/*****************************************************************************/ /*****************************************************************************/
CConversation * CGameScene::getConversation ()
{
return( &m_conversation );
}
/*****************************************************************************/

View File

@ -8,10 +8,6 @@
#include "system\gstate.h" #include "system\gstate.h"
#include "level\level.h" #include "level\level.h"
#ifndef __GAME_CONVO_H__
#include "game\convo.h"
#endif
#ifndef __GAME_EVENT_H__ #ifndef __GAME_EVENT_H__
#include "game\event.h" #include "game\event.h"
#endif #endif
@ -39,16 +35,14 @@ virtual ~CGameScene() {;}
static MATRIX *GetCamMtx() {return(&CamMtx);} static MATRIX *GetCamMtx() {return(&CamMtx);}
class CPlayer *getPlayer(); class CPlayer *getPlayer();
CConversation *getConversation();
void sendEvent( GAME_EVENT evt, CThing *sourceThing ); void sendEvent( GAME_EVENT evt, CThing *sourceThing );
private: private:
CLevel Level; CLevel Level;
class CPlayer *m_player; class CPlayer *m_player;
CConversation m_conversation; static FontBank *s_genericFont;
static FontBank *s_genericFont; static MATRIX CamMtx;
static MATRIX CamMtx;
//static class SpriteBank *s_sprites; <-- Was causing compile error, sorry //static class SpriteBank *s_sprites; <-- Was causing compile error, sorry
}; };