diff --git a/source/game/convo.cpp b/source/game/convo.cpp index fe55b5197..be46a1b67 100644 --- a/source/game/convo.cpp +++ b/source/game/convo.cpp @@ -22,16 +22,8 @@ #include "mem\memory.h" #endif -#ifndef __GUI_GFRAME_H__ -#include "gui\gframe.h" -#endif - -#ifndef __GUI_GSPRITE_H__ -#include "gui\gsprite.h" -#endif - -#ifndef __GUI_GTEXTBOX_H__ -#include "gui\gtextbox.h" +#ifndef __GUI_GUI_H__ +#include "gui\gui.h" #endif #ifndef __GFX_SPRBANK_H__ @@ -92,14 +84,12 @@ CConversation::CHAR_ICON_FRAMES CConversation::s_characterIconFrames[]= { FRM_PLANKTON }, // CHAR_PLANKTON { FRM_MERMAIDMAN }, // CHAR_MERMAIDMAN, { FRM_BARNACLEBOY }, // CHAR_BARNACLEBOY, - { FRM_JACK_CUSTARD }, // CHAR_JACKCUSTARD + { -1 }, // CHAR_JACKCUSTARD }; -class CGUIGroupFrame *CConversation::s_guiFrame=NULL; -class CGUISprite *CConversation::s_guiIcon=NULL; -class CGUITextBox *CConversation::s_guiText=NULL; -class FontBank *CConversation::s_fontBank=NULL; +class FontBank *CConversation::s_textFontBank=NULL; +class FontBank *CConversation::s_questionFontBank=NULL; class CScript *CConversation::s_registeredScripts[MAX_LOADED_SCRIPTS]; int CConversation::s_registeredScriptIds[MAX_LOADED_SCRIPTS]; @@ -108,12 +98,14 @@ int CConversation::s_numRegisteredScripts=0; class CScript *CConversation::s_currentScript=NULL; int CConversation::s_currentState=STATE_INACTIVE; -int CConversation::s_currentCharacterId=-1; -int CConversation::s_currentTextId=-1; int CConversation::s_currentQuestion=QUESTION_NONE; int CConversation::s_currentAnswer=ANSWER_NONE; int CConversation::s_currentSelectedAnswer=0; +static int s_faceFrame=-1; +static int s_speechId=-1; +static int s_TextOffset=0; + /*---------------------------------------------------------------------- Function: @@ -125,27 +117,14 @@ void CConversation::init() { ASSERT(s_numRegisteredScripts==0); - s_guiFrame=new ("Conversation GUI") CGUIGroupFrame(); - s_guiFrame->init(0); - s_guiFrame->setObjectXYWH((512-FRAME_WIDTH)/2,256-FRAME_BOTTOM_OFFSET-FRAME_HEIGHT,FRAME_WIDTH,FRAME_HEIGHT); - s_guiFrame->setOt(OT_POS); - s_guiFrame->setFlags(CGUIObject::FLAG_DRAWBORDER); + s_textFontBank=new ("Conversation Font") FontBank(); + s_textFontBank->initialise(&standardFont); + s_textFontBank->setOt(0); + s_textFontBank->setPrintArea(125,140,357,60); - s_guiIcon=new("Conversation Icon") CGUISprite(); - s_guiIcon->init(s_guiFrame); - s_guiIcon->setObjectXYWH(0,0,FRAME_HEIGHT,FRAME_HEIGHT); - s_guiIcon->setOt(OT_POS); - s_guiIcon->setSpriteBank(SPRITES_SPRITES_SPR); - s_guiIcon->setFrame(0); - - s_guiText=new("Conversation Text") CGUITextBox(); - s_guiText->init(s_guiFrame); - s_guiText->setObjectXYWH(FRAME_HEIGHT,TEXT_BORDER,FRAME_WIDTH-FRAME_HEIGHT-TEXT_BORDER,FRAME_HEIGHT-(TEXT_BORDER*2)); - s_guiText->setOt(OT_POS); - - s_fontBank=new ("Conversation Font") FontBank(); - s_fontBank->initialise(&standardFont); - s_fontBank->setOt(0); + s_questionFontBank=new ("Conversation Font") FontBank(); + s_questionFontBank->initialise(&standardFont); + s_questionFontBank->setOt(0); s_currentState=STATE_INACTIVE; s_currentScript=NULL; @@ -160,9 +139,9 @@ void CConversation::init() ---------------------------------------------------------------------- */ void CConversation::shutdown() { - s_fontBank->dump(); delete s_fontBank; + s_questionFontBank->dump(); delete s_questionFontBank; + s_textFontBank->dump(); delete s_textFontBank; dumpConversationScripts(); - s_guiFrame->shutdown(); } @@ -186,8 +165,7 @@ void CConversation::think(int _frames) s_currentState=STATE_ACTIVE; } - s_guiFrame->think(_frames); - + thinkText(); thinkQuestion(); s_currentScript->run(); @@ -210,8 +188,9 @@ void CConversation::render() { if(s_currentState==STATE_ACTIVE) { + renderText(); renderQuestion(); - s_guiFrame->render(); + drawSpeechBubbleBorder(125,140,357,80,0,s_faceFrame); } } @@ -283,8 +262,9 @@ int CConversation::isActive() ---------------------------------------------------------------------- */ void CConversation::setCharacterAndText(int _characterId,int _textId) { - s_guiIcon->setFrame(s_characterIconFrames[_characterId].m_frame); - s_guiText->setText(_textId); + s_faceFrame=(s_characterIconFrames[_characterId].m_frame); + s_speechId=_textId; + s_TextOffset=0; } @@ -314,6 +294,29 @@ int CConversation::getResponse() } +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +void CConversation::thinkText() +{ + if(PadGetRepeat(0)&PAD_DOWN) + { + s_TextOffset-=s_textFontBank->getCharHeight(); + } + else if(PadGetRepeat(0)&PAD_UP) + { + s_TextOffset+=s_textFontBank->getCharHeight(); + if(s_TextOffset>0) + { + s_TextOffset=0; + } + } +} + + /*---------------------------------------------------------------------- Function: Purpose: @@ -350,6 +353,22 @@ void CConversation::thinkQuestion() } +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +void CConversation::renderText() +{ + RECT clipTextRegion={125,140,357,60}; + + PrimFullScreen(0); + s_textFontBank->print(0,s_TextOffset,s_speechId); + PrimClip(&clipTextRegion,0); +} + + /*---------------------------------------------------------------------- Function: Purpose: @@ -361,15 +380,15 @@ void CConversation::renderQuestion() int xbase,y; xbase=(512-FRAME_WIDTH)/2; - y=256-FRAME_BOTTOM_OFFSET-(TEXT_BORDER/2)-(s_fontBank->getCharHeight()/2); + y=256-FRAME_BOTTOM_OFFSET-(TEXT_BORDER/2)-(s_questionFontBank->getCharHeight()/2); switch(s_currentQuestion) { case QUESTION_OK: { - s_fontBank->setColour(SELECT_TEXT_R,SELECT_TEXT_G,SELECT_TEXT_B); - s_fontBank->setJustification(FontBank::JUST_RIGHT); - s_fontBank->print(xbase+FRAME_WIDTH-TEXT_BORDER,y,STR__OK); + s_questionFontBank->setColour(SELECT_TEXT_R,SELECT_TEXT_G,SELECT_TEXT_B); + s_questionFontBank->setJustification(FontBank::JUST_RIGHT); + s_questionFontBank->print(xbase+FRAME_WIDTH-TEXT_BORDER,y,STR__OK); } break; @@ -377,25 +396,25 @@ void CConversation::renderQuestion() { if(s_currentSelectedAnswer==0) { - s_fontBank->setColour(SELECT_TEXT_R,SELECT_TEXT_G,SELECT_TEXT_B); + s_questionFontBank->setColour(SELECT_TEXT_R,SELECT_TEXT_G,SELECT_TEXT_B); } else { - s_fontBank->setColour(UNSELECT_TEXT_R,UNSELECT_TEXT_G,UNSELECT_TEXT_B); + s_questionFontBank->setColour(UNSELECT_TEXT_R,UNSELECT_TEXT_G,UNSELECT_TEXT_B); } - s_fontBank->setJustification(FontBank::JUST_LEFT); - s_fontBank->print(xbase+FRAME_HEIGHT,y,STR__YES); + s_questionFontBank->setJustification(FontBank::JUST_LEFT); + s_questionFontBank->print(xbase+FRAME_HEIGHT,y,STR__YES); if(s_currentSelectedAnswer==1) { - s_fontBank->setColour(SELECT_TEXT_R,SELECT_TEXT_G,SELECT_TEXT_B); + s_questionFontBank->setColour(SELECT_TEXT_R,SELECT_TEXT_G,SELECT_TEXT_B); } else { - s_fontBank->setColour(UNSELECT_TEXT_R,UNSELECT_TEXT_G,UNSELECT_TEXT_B); + s_questionFontBank->setColour(UNSELECT_TEXT_R,UNSELECT_TEXT_G,UNSELECT_TEXT_B); } - s_fontBank->setJustification(FontBank::JUST_RIGHT); - s_fontBank->print(xbase+FRAME_WIDTH-TEXT_BORDER,y,STR__NO); + s_questionFontBank->setJustification(FontBank::JUST_RIGHT); + s_questionFontBank->print(xbase+FRAME_WIDTH-TEXT_BORDER,y,STR__NO); } break; diff --git a/source/game/convo.h b/source/game/convo.h index 4ae4ba0ab..c484babb1 100644 --- a/source/game/convo.h +++ b/source/game/convo.h @@ -119,16 +119,16 @@ private: MAX_LOADED_SCRIPTS=10, }; + static void thinkText(); static void thinkQuestion(); + static void renderText(); static void renderQuestion(); static void dumpConversationScripts(); - static class CGUIGroupFrame *s_guiFrame; - static class CGUISprite *s_guiIcon; - static class CGUITextBox *s_guiText; - static class FontBank *s_fontBank; + static class FontBank *s_textFontBank; + static class FontBank *s_questionFontBank; static CHAR_ICON_FRAMES s_characterIconFrames[MAX_CHARS]; @@ -139,8 +139,6 @@ private: static class CScript *s_currentScript; static int s_currentState; - static int s_currentCharacterId; - static int s_currentTextId; static int s_currentQuestion; static int s_currentAnswer; static int s_currentSelectedAnswer; diff --git a/source/gui/gui.cpp b/source/gui/gui.cpp index 9836ee5fa..e423b1c20 100644 --- a/source/gui/gui.cpp +++ b/source/gui/gui.cpp @@ -167,28 +167,9 @@ void CGUIObject::render() setRGB0(f4, 0, 0, 90); setSemiTrans(f4,true); AddPrimToList(f4,ot); - - /* - g4=GetPrimG4(); - setXYWH(g4,x,y,w,h/2); - setRGB0(g4,107,105, 98); - setRGB1(g4,107,105, 98); - setRGB2(g4, 0, 0, 90); - setRGB3(g4, 0, 0, 90); - setSemiTrans(g4,true); - AddPrimToList(g4,ot); - - g4=GetPrimG4(); - setXYWH(g4,x,y+h/2,w,h/2); - setRGB0(g4, 0, 0, 90); - setRGB1(g4, 0, 0, 90); - setRGB2(g4,107,105, 98); - setRGB3(g4,107,105, 98); - setSemiTrans(g4,true); - AddPrimToList(g4,ot); - */ } + #ifdef __USER_paul__ if(forceBorderDraw) { @@ -492,5 +473,115 @@ void drawBambooBorder(int _x,int _y,int _w,int _h,int _ot) } +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +typedef struct +{ + int gapfromheadtobubble; + int speechmarkgapfromtop; + int speechmarkheight; +}_sbb; +_sbb sbb= +{ + 32, + 5, + 10, +}; +void drawSpeechBubbleBorder(int _x,int _y,int _w,int _h,int _ot,int _faceFrame) +{ +/* +DrawLine(_x ,_y ,_x+_w,_y ,255,0,255,0); +DrawLine(_x+_w,_y ,_x+_w,_y+_h,255,0,255,0); +DrawLine(_x+_w,_y+_h,_x ,_y+_h,255,0,255,0); +DrawLine(_x ,_y+_h,_x ,_y ,255,0,255,0); +*/ + + sFrameHdr *cornerFh; + POLY_FT4 *ft4; + LINE_F2 *f2; + POLY_F4 *f4; + int centreX,centreY; + sFrameHdr *faceFh; + POLY_F3 *f3; + + + // Squeeze in the corners a bit.. + _x+=4; + _y+=5; + _w-=8; + _h-=10; + + // Sprite corner pieces + cornerFh=s_uiSpriteBank->getFrameHeader(FRM__SPEECHBUBBLECORNER); + ft4=s_uiSpriteBank->printFT4(cornerFh,_x-cornerFh->W,_y-cornerFh->H,0,0,_ot);setSemiTrans(ft4,true); + ft4=s_uiSpriteBank->printFT4(cornerFh,_x+_w+cornerFh->W+1,_y-cornerFh->H,1,0,_ot);setSemiTrans(ft4,true); + ft4=s_uiSpriteBank->printFT4(cornerFh,_x-cornerFh->W,_y+_h+cornerFh->H+1,0,1,_ot);setSemiTrans(ft4,true); + ft4=s_uiSpriteBank->printFT4(cornerFh,_x+_w+cornerFh->W+1,_y+_h+cornerFh->H+1,1,1,_ot);setSemiTrans(ft4,true); + + // Black edge lines + f2=DrawLine(_x,_y-cornerFh->H-1,_x+_w,_y-cornerFh->H-1,0,0,0,_ot);setSemiTrans(f2,true); + f2=DrawLine(_x+_w+cornerFh->W+1,_y,_x+_w+cornerFh->W+1,_y+_h,0,0,0,_ot);setSemiTrans(f2,true); + f2=DrawLine(_x+_w,_y+_h+cornerFh->H+1,_x,_y+_h+cornerFh->H+1,0,0,0,_ot);setSemiTrans(f2,true); + + // White middle + f4=GetPrimF4(); + setXYWH(f4,_x,_y-cornerFh->H,_w+1,cornerFh->H); + setRGB0(f4,255,255,255); + setSemiTrans(f4,true); + AddPrimToList(f4,_ot); + f4=GetPrimF4(); + setXYWH(f4,_x-cornerFh->W,_y,_w+(cornerFh->W*2)+1,_h+1); + setRGB0(f4,255,255,255); + setSemiTrans(f4,true); + AddPrimToList(f4,_ot); + f4=GetPrimF4(); + setXYWH(f4,_x,_y+_h+1,_w+1,cornerFh->H); + setRGB0(f4,255,255,255); + setSemiTrans(f4,true); + AddPrimToList(f4,_ot); + + if(_faceFrame!=-1) + { + // Speaking characters head + centreX=_x-cornerFh->W-sbb.gapfromheadtobubble-(64/2); + centreY=_y+(_h/2); + faceFh=s_uiSpriteBank->getFrameHeader(_faceFrame); + ft4=s_uiSpriteBank->printFT4(faceFh,centreX-(faceFh->W/2),centreY-(faceFh->H/2),0,0,_ot);//setSemiTrans(ft4,true); + + // White speech bubble triangle shaped piece with black outlines.. (!?) + int speechmarkEndX,speechmarkEndY; + speechmarkEndX=_x-cornerFh->W-sbb.gapfromheadtobubble; + speechmarkEndY=centreY; + f2=DrawLine(_x-cornerFh->W-1,_y,_x-cornerFh->W-1,_y+sbb.speechmarkgapfromtop-1,0,0,0,_ot);setSemiTrans(f2,true); + f2=DrawLine(_x-cornerFh->W-1,_y+sbb.speechmarkgapfromtop,speechmarkEndX,speechmarkEndY,0,0,0,_ot);setSemiTrans(f2,true); + f2=DrawLine(speechmarkEndX,speechmarkEndY,_x-cornerFh->W-1,_y+sbb.speechmarkgapfromtop+sbb.speechmarkheight,0,0,0,_ot);setSemiTrans(f2,true); + f2=DrawLine(_x-cornerFh->W-1,_y+sbb.speechmarkgapfromtop+sbb.speechmarkheight+1,_x-cornerFh->W-1,_y+_h,0,0,0,_ot);setSemiTrans(f2,true); + f3=GetPrimF3(); + setXY3(f3,_x-cornerFh->W,_y+sbb.speechmarkgapfromtop, + speechmarkEndX,speechmarkEndY, + _x-cornerFh->W,_y+sbb.speechmarkgapfromtop+sbb.speechmarkheight); + setRGB0(f3,255,255,255); + setSemiTrans(f3,true); + AddPrimToList(f3,_ot); + } + else + { + // Fill in the left hand black edge line + f2=DrawLine(_x-cornerFh->W-1,_y,_x-cornerFh->W-1,_y+_h,0,0,0,_ot);setSemiTrans(f2,true); + } + + // Background + f4=GetPrimF4(); + setXYWH(f4,0,0,512,256); + setRGB0(f4, 0, 0, 90); + setSemiTrans(f4,true); + AddPrimToList(f4,_ot); +} + + /*=========================================================================== end */ diff --git a/source/gui/gui.h b/source/gui/gui.h index 66857aa92..360f253e3 100644 --- a/source/gui/gui.h +++ b/source/gui/gui.h @@ -48,10 +48,10 @@ public: typedef enum { - FLAG_NONE= 0, - FLAG_SELECTED= 1<<0, - FLAG_HIDDEN= 1<<2, - FLAG_DRAWBORDER= 1<<3, + FLAG_NONE= 0, + FLAG_SELECTED= 1<<0, + FLAG_HIDDEN= 1<<2, + FLAG_DRAWBORDER= 1<<3, } GUI_FLAGS; enum @@ -191,6 +191,7 @@ private: extern void initGUIStuff(); extern void drawBambooBorder(int _x,int _y,int _w,int _h,int _ot); +extern void drawSpeechBubbleBorder(int _x,int _y,int _w,int _h,int _ot,int _faceFrame=-1); /*---------------------------------------------------------------------- */ diff --git a/source/player/player.cpp b/source/player/player.cpp index 2dc221fdc..5f9c43a60 100644 --- a/source/player/player.cpp +++ b/source/player/player.cpp @@ -827,11 +827,16 @@ int itembaseX=110; int itembaseY=60; int itemgap=40; - +#include "gui\gui.h" void CPlayer::render() { - CPlayerThing::render(); +//drawSpeechBubbleBorder(125,140,357,80,0,FRM_BARNACLEBOY); + + + CPlayerThing::render(); + + #ifdef _STATE_DEBUG_ char buf[100]; #ifdef __USER_paul__