This commit is contained in:
Paul 2001-07-01 18:40:03 +00:00
parent 6061ee9bb7
commit 6490c61642
5 changed files with 188 additions and 45 deletions

View File

@ -10,7 +10,7 @@
#define CHAR_MERMAIDMAN 6
#define CHAR_BARNACLEBOY 7
#define CHAR_JACKCUSTARD 8
#define CHAR_GARY 8
#define CHAR_GARY 9
#define ANIM_QUIET 0
#define ANIM_TALKING 1

View File

@ -272,6 +272,7 @@ CConversation::CHAR_ICON_FRAMES CConversation::s_characterIconFrames[]=
{ FRM_MERMAIDMAN }, // CHAR_MERMAIDMAN,
{ FRM_BARNACLEBOY }, // CHAR_BARNACLEBOY,
{ -1 }, // CHAR_JACKCUSTARD
{ FRM_GARY }, // CHAR_GARY
};
@ -291,8 +292,10 @@ int CConversation::s_currentSelectedAnswer;
int CConversation::s_faceFrame;
int CConversation::s_speechId;
int CConversation::s_textOffset;
int CConversation::s_maxTextOffset;
int CConversation::s_textPageOffset;
int CConversation::s_maxTextPageOffset;
SpriteBank *CConversation::s_sprites;
static xmPlayingId s_playingSfxId;
@ -310,7 +313,6 @@ void CConversation::init()
s_textFontBank=new ("Conversation Font") FontBank();
s_textFontBank->initialise(&standardFont);
s_textFontBank->setOt(0);
s_textFontBank->setPrintArea(TEXTBOX_X,TEXTBOX_Y,TEXTBOX_WIDTH,TEXTBOX_HEIGHT);
s_textFontBank->setColour(TEXT_R,TEXT_G,TEXT_B);
s_questionFontBank=new ("Conversation Font") FontBank();
@ -319,6 +321,9 @@ void CConversation::init()
s_currentState=STATE_INACTIVE;
s_currentScript=NULL;
s_sprites=new ("ConvoSprites") SpriteBank();
s_sprites->load(SPRITES_SPRITES_SPR);
}
@ -330,6 +335,7 @@ void CConversation::init()
---------------------------------------------------------------------- */
void CConversation::shutdown()
{
s_sprites->dump(); delete s_sprites;
s_questionFontBank->dump(); delete s_questionFontBank;
s_textFontBank->dump(); delete s_textFontBank;
dumpConversationScripts();
@ -388,8 +394,15 @@ void CConversation::render()
{
renderText();
renderQuestion();
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);
}
}
}
@ -462,11 +475,15 @@ int CConversation::isActive()
---------------------------------------------------------------------- */
void CConversation::setCharacterAndText(int _characterId,int _textId)
{
RECT clipTextRegion;
s_faceFrame=(s_characterIconFrames[_characterId].m_frame);
s_speechId=_textId;
s_textOffset=0;
s_maxTextOffset=s_textFontBank->getStringHeight((char*)TranslationDatabase::getString(s_speechId))-TEXTBOX_HEIGHT;
if(s_maxTextOffset<0)s_maxTextOffset=0;
s_textPageOffset=0;
clipTextRegion=getTextRegion();
s_textFontBank->setPrintArea(clipTextRegion.x,clipTextRegion.y,clipTextRegion.w,clipTextRegion.h);
s_maxTextPageOffset=(s_textFontBank->getStringHeight((char*)TranslationDatabase::getString(s_speechId))-s_textFontBank->getCharHeight())/(s_textFontBank->getCharHeight()*TEXTBOX_FONT_NUM_LINES_IN_BOX);
if(s_maxTextPageOffset<0)s_maxTextPageOffset=0;
for (int i=0; i<SpeechTableSize; i++)
{
@ -517,12 +534,12 @@ void CConversation::thinkText()
if(PadGetRepeat(0)&PAD_DOWN)
{
if(s_textOffset<s_maxTextOffset)
if(s_textPageOffset<s_maxTextPageOffset)
{
s_textOffset+=TEXT_STEP_SIZE;
if(s_textOffset>s_maxTextOffset)
s_textPageOffset++;
if(s_textPageOffset>s_maxTextPageOffset)
{
s_textOffset=s_maxTextOffset;
s_textPageOffset=s_maxTextPageOffset;
}
sfx=CSoundMediator::SFX_FRONT_END__MOVE_CURSOR;
}
@ -533,12 +550,12 @@ void CConversation::thinkText()
}
else if(PadGetRepeat(0)&PAD_UP)
{
if(s_textOffset>0)
if(s_textPageOffset>0)
{
s_textOffset-=TEXT_STEP_SIZE;
if(s_textOffset<0)
s_textPageOffset--;
if(s_textPageOffset<0)
{
s_textOffset=0;
s_textPageOffset=0;
}
sfx=CSoundMediator::SFX_FRONT_END__MOVE_CURSOR;
}
@ -603,11 +620,35 @@ void CConversation::thinkQuestion()
---------------------------------------------------------------------- */
void CConversation::renderText()
{
RECT clipTextRegion={TEXTBOX_X,TEXTBOX_Y,TEXTBOX_WIDTH,TEXTBOX_HEIGHT};
RECT clipTextRegion;
char buf[1024],*pBuf;
int i;
clipTextRegion=getTextRegion();
PrimFullScreen(0);
s_textFontBank->print(0,-s_textOffset,s_speechId);
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..
pBuf+=s_textFontBank->printTillEndOfLine(0,-50,pBuf);
}
for(i=0;i<TEXTBOX_FONT_NUM_LINES_IN_BOX&&pBuf;i++)
{
pBuf+=s_textFontBank->printTillEndOfLine(0,i*TEXTBOX_FONT_LINE_SPACING,pBuf);
}
PrimClip(&clipTextRegion,0);
// 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);
}
}
@ -617,7 +658,6 @@ void CConversation::renderText()
Params:
Returns:
---------------------------------------------------------------------- */
//drawSpeechBubbleBorder(TEXTBOX_X,TEXTBOX_Y,TEXTBOX_WIDTH,TEXTBOX_HEIGHT+TEXTBOX_QUESTIONHEIGHT,0,s_faceFrame);
void CConversation::renderQuestion()
{
int y;
@ -807,5 +847,26 @@ void CConversation::registerConversationLevelScripts(int level)
break;
}
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
RECT CConversation::getTextRegion()
{
RECT clipRegion={TEXTBOX_X,TEXTBOX_Y,TEXTBOX_WIDTH,TEXTBOX_HEIGHT};
if(s_faceFrame==-1)
{
// Narrators box..
clipRegion.x=TEXTBOX_X_FOR_NARRATOR;
clipRegion.w=TEXTBOX_WIDTH_FOR_NARRATOR;
}
return clipRegion;
}
/*===========================================================================
end */

View File

@ -18,6 +18,10 @@
Includes
-------- */
#ifndef _GLOBAL_HEADER_
#include "system\global.h"
#endif
#ifndef __FILE_EQUATES_H__
#include <biglump.h>
#endif
@ -51,6 +55,7 @@ public:
static void setCharacterAndText(int _characterId,int _textId);
static void setResponseOptions(int _responseOptions);
static int getResponse();
static RECT getTextRegion();
private:
@ -58,12 +63,18 @@ private:
{
TEXTBOX_X=125,
TEXTBOX_Y=140,
TEXTBOX_Y=35,
TEXTBOX_WIDTH=357,
TEXTBOX_HEIGHT=50,
TEXTBOX_HEIGHT=62,
TEXTBOX_X_FOR_NARRATOR=512-TEXTBOX_X-TEXTBOX_WIDTH,
TEXTBOX_WIDTH_FOR_NARRATOR=512-(TEXTBOX_X_FOR_NARRATOR*2),
TEXTBOX_QUESTIONHEIGHT=16,
TEXT_STEP_SIZE=5,
OT_POS=0,
TEXTBOX_FONT_LINE_SPACING=14,
TEXTBOX_FONT_NUM_LINES_IN_BOX=4,
TEXTBOX_BUTTONS_XOFF=0,
TEXTBOX_BUTTONS_YOFF=68,
TEXTBOX_BUTTONS_GAP=20,
// Main text
TEXT_R=120,
TEXT_G=115,
@ -89,6 +100,7 @@ private:
CHAR_MERMAIDMAN,
CHAR_BARNACLEBOY,
CHAR_JACKCUSTARD,
CHAR_GARY,
MAX_CHARS,
};
typedef struct
@ -153,8 +165,9 @@ private:
static int s_faceFrame;
static int s_speechId;
static int s_textOffset;
static int s_maxTextOffset;
static int s_textPageOffset;
static int s_maxTextPageOffset;
static class SpriteBank *s_sprites;
};

View File

@ -186,6 +186,74 @@ void FontBank::print( int _x, int _y, const char *_text )
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
int FontBank::printTillEndOfLine( int _x, int _y, const char *_text )
{
ASSERT( m_initialised );
int Size;
int StartX;
int Length=0;
int RectWidth;
int numCharsPrinted=0;
switch(m_justification)
{
case JUST_CENTRE:
RectWidth=m_printArea.w;
break;
default:
RectWidth=m_printArea.w-_x;
break;
}
_x+=m_printArea.x;
_y+=m_printArea.y;
_y+=getCharHeight(); // origin at top left please...
StartX=_x;
while (*_text)
{
Length=getStrWrapLen(_text,RectWidth);
switch (m_justification)
{
case JUST_LEFT:
_x=StartX;
break;
case JUST_RIGHT:
_x=StartX/*+RectWidth*/-Length;
break;
case JUST_CENTRE:
_x=StartX-(Length/2);
break;
}
int fy=_y;
while(*_text && Length>0)
{
if(m_wobble)
{
fy=_y+(msin((s_wobbleValue+(_x*wstep))&4095)/wscale);
}
Size=printChar(*_text++,_x,fy)+getCharGapX();
numCharsPrinted++;
_x+=Size;
Length-=Size;
}
break;
// _y+=(getCharHeight());
// if(*_text=='\n') _text++; // kill newline if there is one ( preserve multiple \n )
// while (*_text==' ') _text++; // kill trailing spaces
}
return numCharsPrinted;
}
/*----------------------------------------------------------------------
Function:
Purpose:

View File

@ -51,8 +51,9 @@ public:
virtual void initialise( FontData *_fontData );
void dump();
int isInitialised() { return m_initialised; }
virtual void print( int _x, int _y, const char *_text );
void print( int _x, int _y, s32 _textId );
virtual void print( int _x, int _y, const char *_text );
int printTillEndOfLine( int _x, int _y, const char *_text );
void setColour( u8 _r, u8 _g, u8 _b );
void setJustification( Justification _justification );
void setOt( u16 _ot );