This commit is contained in:
Paul 2001-01-10 17:27:12 +00:00
parent bdce9e6b57
commit 69cacf1ddb
13 changed files with 554 additions and 28 deletions

View File

@ -1,8 +1,9 @@
// Question and answer responses
// Questions
#define QUESTION_OK 0
#define QUESTION_YES_NO 1
#define QUESTION_NONE 0
#define QUESTION_OK 1
#define QUESTION_YES_NO 2
// Answers
#define ANSWER_NONE 0

View File

@ -3,14 +3,35 @@
#include data/scripts/defs/charanim.scr
#include data/scripts/defs/items.scr
#include data/scripts/defs/response.scr
#include data/scripts/defs/text.scr
#include data/scripts/defs/trans.scr
_setCharacterAnimation(CHAR_SPONGEBOB,ANIM_QUIET);
_setText(C1_L1__KARATE_MOVES__SANDY_1);
_setResponseOptions(QUESTION_OK);
do
{
pause;
_setText(CHAR_SANDY,STR__INGAME__SANDY__TEST1);
_setResponseOptions(QUESTION_OK);
do
{
pause;
}
while(_getResponse()==ANSWER_NONE);
_setText(CHAR_SANDY,STR__INGAME__SANDY__TEST2);
_setResponseOptions(QUESTION_OK);
do
{
pause;
}
while(_getResponse()==ANSWER_NONE);
_setText(CHAR_SPONGEBOB,STR__INGAME__SPONGEBOB__TEST3);
_setResponseOptions(QUESTION_YES_NO);
do
{
pause;
}
while(_getResponse()==ANSWER_NONE);
}
while(_getResponse()!=ANSWER_NONE);
while(_getResponse()!=ANSWER_YES);
stop;

View File

@ -25,6 +25,7 @@ while(1==1)
{
// Readout for fps :)
$tmp0=_getFrameTime();
if($tmp0>10)$tmp0=10;
$tmp5=50;
do{
_drawSprite(FRM__BUTU,$tmp5,50,0);

View File

@ -15,6 +15,8 @@
; Some generic strings..
; ---------------------------------------------------------------
[STR__OK]
eng=OK
[STR__YES]
eng=Yes
[STR__NO]
@ -33,6 +35,8 @@ eng=NOW LOADING..
eng=
; ---------------------------------------------------------------
; Front end
; ---------------------------------------------------------------
@ -100,6 +104,25 @@ eng=SFX VOLUME
eng=SPEECH VOLUME
; ---------------------------------------------------------------
; Ingame text
; All ingame text *must* be prefixed with STR__INGAME__ otherwise
; it won't get passed to the script compiler!
; ---------------------------------------------------------------
; Chapter 1 - Level 1 - Test
[STR__INGAME__SANDY__TEST1]
eng=Take that 'ya sorry ol' clam. Y'all need to learn some manners!
[STR__INGAME__SANDY__TEST2]
eng=Hold on there little square dude if you want to defend yourself you need to do this!!!!
[STR__INGAME__SPONGEBOB__TEST3]
eng=Did that make sense..?
; ---------------------------------------------------------------
; Debugging text
; The following texts DO NOT require translation

View File

@ -142,11 +142,14 @@ TRANS_OUT_DAT := $(foreach FILE, $(LANGUAGES),$(TRANS_OUT_DIR)/$(FILE).dat) $(TR
#$(TRANS_OUT_KANJI_TAB)
TRANS_OUT_HDR := $(INC_DIR)/trans.h
SCRIPT_TRANS_HDR := $(GAME_DATA_DIR)/scripts/defs/trans.scr
TRANS_OUT_FILES := $(TRANS_OUT_HDR) $(TRANS_OUT_DAT) $(TRANS_OUT_LBM_LIST) $(TRANS_FINAL_DAT_FILE)
$(TRANS_OUT_FILES) : $(TRANS_IN_FILES)
perl tools/perl/pl/lang.pl $(TRANS_IN_ENG) $(TRANS_FINAL_DAT_FILE) $(ALL_TRANS_IN_FILES)
transtext $(LANG_OP) -h:$(TRANS_OUT_HDR) -o:$(TRANS_OUT_DIR) $(TRANS_FINAL_DAT_FILE)
perl tools/perl/pl/text_extract.pl $(TRANS_OUT_HDR) $(SCRIPT_TRANS_HDR) STR__INGAME__
translate : $(TRANS_OUT_FILES)
@$(ECHO) made translations
@ -165,7 +168,8 @@ UI_GFX_OUT_DIR := $(DATA_OUT)/ui
UI_GFX_FONT := font
UI_GFX_FONT_IN := $(foreach FILE,$(UI_GFX_FONT),$(UI_GFX_DIR)/$(FILE).anm)
UI_GFX_NONTRANS :=
UI_GFX_NONTRANS := faces\mr_krabs.bmp faces\patrick.bmp faces\plankton.bmp \
faces\sandy.bmp faces\spongebob.bmp faces\squidward.bmp
UI_GFX_NONTRANS_IN := $(foreach FILE,$(UI_GFX_NONTRANS),$(UI_GFX_DIR)/$(FILE))
UI_GFX_TRANS := +vbamboo.bmp +vbambootl.bmp +vbambootr.bmp +vbamboobl.bmp +vbamboobr.bmp \
@ -358,7 +362,8 @@ scripts : $(SCRIPTS_OUT)
cleanscripts:
@$(RM) -f $(SCRIPTS_OUT)
$(SCRIPTS_OUT_DIR)/%.dat : $(SCRIPTS_IN_DIR)/%.scr
# Saves a lot of hassle to make the scripts dependant upon the text database too..
$(SCRIPTS_OUT_DIR)/%.dat : $(SCRIPTS_IN_DIR)/%.scr $(SCRIPT_TRANS_HDR)
@scripter $< $@
GRAF_DIRS_TO_MAKE += $(SCRIPTS_OUT_DIR)

View File

@ -18,12 +18,54 @@
#include "game\convo.h"
#ifndef __MEMORY_HEADER__
#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"
#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
/* Std Lib
------- */
/* Data
---- */
#ifndef __SPR_UIGFX_H__
#include <uigfx.h>
#endif
#ifndef __STRING_ENUMS__
#include <trans.h>
#endif
/*----------------------------------------------------------------------
Tyepdefs && Defines
------------------- */
@ -40,15 +82,288 @@
Vars
---- */
CConversation::CHAR_ICON_FRAMES CConversation::s_characterIconFrames[]=
{
{ 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
};
class CGUIGroupFrame *CConversation::s_guiFrame=NULL;
class CGUISprite *CConversation::s_guiIcon=NULL;
class CGUITextBox *CConversation::s_guiText=NULL;
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;
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void somethingToStopTheLinkerComplaining()
void CConversation::init()
{
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_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(UI_UIGFX_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);
m_fontBank=new ("Conversation Font") FontBank();
m_fontBank->initialise(&standardFont);
m_fontBank->setOt(0);
m_currentState=STATE_INACTIVE;
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CConversation::shutdown()
{
s_guiFrame->shutdown(); delete s_guiFrame;
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CConversation::think(int _frames)
{
if(isActive())
{
if(m_currentState==STATE_JUST_ACTIVATED)
{
m_currentState=STATE_ACTIVE;
}
s_guiFrame->think(_frames);
thinkQuestion();
m_currentScript->run();
if(m_currentScript->isFinished())
{
m_currentState=STATE_INACTIVE;
}
}
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CConversation::render()
{
if(m_currentState==STATE_ACTIVE)
{
renderQuestion();
s_guiFrame->render();
}
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CConversation::registerConversationScript(FileEquate _feScript)
{
// Blah blah..
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CConversation::trigger(FileEquate _feScript)
{
ASSERT(!isActive());
m_currentScript=new ("script") CScript();
m_currentScript->initialise(_feScript);
m_currentState=STATE_JUST_ACTIVATED;
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
int CConversation::isActive()
{
return m_currentState!=STATE_INACTIVE;
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CConversation::setCharacterAndText(int _characterId,int _textId)
{
s_guiIcon->setFrame(s_characterIconFrames[_characterId].m_frame);
s_guiText->setText(_textId);
}
/*----------------------------------------------------------------------
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;
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CConversation::thinkQuestion()
{
if(s_currentQuestion!=QUESTION_NONE)
{
int pad=PadGetDown(0);
if(s_currentQuestion==QUESTION_YES_NO)
{
if(pad&PAD_CROSS)
{
s_currentAnswer=s_currentSelectedAnswer==0?ANSWER_YES:ANSWER_NO;
s_currentQuestion=QUESTION_NONE;
}
else if(pad&(PAD_LEFT|PAD_RIGHT))
{
s_currentSelectedAnswer^=1;
}
}
else if(s_currentQuestion==QUESTION_OK)
{
if(pad&PAD_CROSS)
{
s_currentAnswer=ANSWER_OK;
s_currentQuestion=QUESTION_NONE;
}
}
}
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CConversation::renderQuestion()
{
int xbase,y;
xbase=(512-FRAME_WIDTH)/2;
y=256-FRAME_BOTTOM_OFFSET-(TEXT_BORDER/2)-(m_fontBank->getCharHeight()/2);
switch(s_currentQuestion)
{
case QUESTION_OK:
{
m_fontBank->setColour(SELECT_TEXT_R,SELECT_TEXT_G,SELECT_TEXT_B);
m_fontBank->setJustification(FontBank::JUST_RIGHT);
m_fontBank->print(xbase+FRAME_WIDTH-TEXT_BORDER,y,STR__OK);
}
break;
case QUESTION_YES_NO:
{
if(s_currentSelectedAnswer==0)
{
m_fontBank->setColour(SELECT_TEXT_R,SELECT_TEXT_G,SELECT_TEXT_B);
}
else
{
m_fontBank->setColour(UNSELECT_TEXT_R,UNSELECT_TEXT_G,UNSELECT_TEXT_B);
}
m_fontBank->setJustification(FontBank::JUST_LEFT);
m_fontBank->print(xbase+FRAME_HEIGHT,y,STR__YES);
if(s_currentSelectedAnswer==1)
{
m_fontBank->setColour(SELECT_TEXT_R,SELECT_TEXT_G,SELECT_TEXT_B);
}
else
{
m_fontBank->setColour(UNSELECT_TEXT_R,UNSELECT_TEXT_G,UNSELECT_TEXT_B);
}
m_fontBank->setJustification(FontBank::JUST_RIGHT);
m_fontBank->print(xbase+FRAME_WIDTH-TEXT_BORDER,y,STR__NO);
}
break;
case QUESTION_NONE:
default:
break;
}
}
/*===========================================================================
end */

View File

@ -18,6 +18,11 @@
Includes
-------- */
#ifndef __FILE_EQUATES_H__
#include <biglump.h>
#endif
/* Std Lib
------- */
@ -29,6 +34,108 @@
Structure defintions
-------------------- */
class CConversation
{
public:
void init();
void shutdown();
void think(int _frames);
void render();
void registerConversationScript(FileEquate _feScript);
void trigger(FileEquate _feScript);
int isActive();
static void setCharacterAndText(int _characterId,int _textId);
static void setResponseOptions(int _responseOptions);
static int getResponse();
private:
enum
{
FRAME_WIDTH=400,
FRAME_HEIGHT=90,
FRAME_BOTTOM_OFFSET=40,
TEXT_BORDER=20,
OT_POS=0,
SELECT_TEXT_R=250,
SELECT_TEXT_G=250,
SELECT_TEXT_B=250,
UNSELECT_TEXT_R=100,
UNSELECT_TEXT_G=100,
UNSELECT_TEXT_B=100,
};
// This order is the same as in scripts/defs/charanim.scr
enum
{
CHAR_SPONGEBOB,
CHAR_SANDY,
CHAR_PATRICK,
CHAR_SQUIDWARD,
CHAR_KRABS,
CHAR_PLANKTON,
MAX_CHARS,
};
typedef struct
{
int m_frame;
} CHAR_ICON_FRAMES;
// These two are as in scripts/defs/response.scr
enum
{
QUESTION_NONE,
QUESTION_OK,
QUESTION_YES_NO,
MAX_QUESTIONS,
};
enum
{
ANSWER_NONE,
ANSWER_OK,
ANSWER_YES,
ANSWER_NO,
MAX_ANSWERS
};
// State of the conversation dialog
enum
{
STATE_INACTIVE,
STATE_JUST_ACTIVATED,
STATE_ACTIVE,
};
void thinkQuestion();
void renderQuestion();
// PKG - These don't need to be static..
// Make the sprites/text readouts maybe?
static class CGUIGroupFrame *s_guiFrame;
static class CGUISprite *s_guiIcon;
static class CGUITextBox *s_guiText;
class FontBank *m_fontBank;
static CHAR_ICON_FRAMES s_characterIconFrames[MAX_CHARS];
class CScript *m_currentScript;
int m_currentState;
static int s_currentCharacterId;
static int s_currentTextId;
static int s_currentQuestion;
static int s_currentAnswer;
static int s_currentSelectedAnswer;
};
/*----------------------------------------------------------------------
Globals
------- */

View File

@ -41,29 +41,35 @@ void CGameScene::init()
s_genericFont->initialise( &standardFont );
s_genericFont->setColour( 255, 255 , 0 );
VidSetClearScreen(1);
m_conversation.init();
Level.init();
}
/*****************************************************************************/
void CGameScene::shutdown()
{
s_genericFont->dump(); delete s_genericFont;
Level.shutdown();
m_conversation.shutdown();
s_genericFont->dump(); delete s_genericFont;
}
/*****************************************************************************/
void CGameScene::render()
{
m_conversation.render();
Level.render();
}
/*****************************************************************************/
void CGameScene::think(int _frames)
{
m_conversation.think(_frames);
Level.think(_frames);
if(!m_conversation.isActive()&&PadGetDown(0)&PAD_START)
m_conversation.trigger(SCRIPTS_SPEECHTEST_DAT);
}
/*****************************************************************************/

View File

@ -8,6 +8,10 @@
#include "system\gstate.h"
#include "level\level.h"
#ifndef __GAME_CONVO_H__
#include "game\convo.h"
#endif
/*****************************************************************************/
class FontBank;
@ -29,6 +33,7 @@ public:
private:
CLevel Level;
CConversation m_conversation;
static FontBank *s_genericFont;
//static class SpriteBank *s_sprites; <-- Was causing compile error, sorry

View File

@ -432,30 +432,49 @@ void initGUIStuff()
Params:
Returns:
---------------------------------------------------------------------- */
int abcd=3;
void drawBambooBorder(int _x,int _y,int _w,int _h,int _ot)
{
sFrameHdr *vbam,*hbam;
sFrameHdr *vbam,*hbam,*spr1,*spr2;
int totalSize,numSprites,step;
int x1,y1,x2,y2;
int i;
int i,x,y;
vbam=s_uiSpriteBank->getFrameHeader(FRM__VBAMBOO);
hbam=s_uiSpriteBank->getFrameHeader(FRM__HBAMBOO);
spr1=spr2=0; // Just to keep the compiler quiet.. :/
// Top & bottom
totalSize=_w-vbam->W-hbam->W;
totalSize=_w+vbam->W-hbam->W;
numSprites=(totalSize/hbam->W)+1;
if(abcd&1)
if(numSprites>1)
{
step=(totalSize<<4)/(numSprites-1);
x1=(_x+(vbam->W/2)+(hbam->W/2))<<4;
x1=(_x-(vbam->W/2)+(hbam->W/2))<<4;
y1=_y-(hbam->H/2);
y2=y1+_h;
for(i=0;i<numSprites;i++)
{
s_uiSpriteBank->printFT4(hbam,(x1>>4)-(hbam->W/2),y1,0,0,_ot);
s_uiSpriteBank->printFT4(hbam,(x1>>4)-(hbam->W/2),y2,0,0,_ot);
x=(x1>>4)-(hbam->W/2);
if(i==0)
{
spr1=s_uiSpriteBank->getFrameHeader(FRM__HBAMBOOTL);
spr2=s_uiSpriteBank->getFrameHeader(FRM__HBAMBOOBL);
s_uiSpriteBank->printFT4(spr1,x+hbam->W-spr1->W-1,y1,0,0,_ot);
s_uiSpriteBank->printFT4(spr2,x+hbam->W-spr2->W-1,y2,0,0,_ot);
}
else if(i<numSprites-1)
{
s_uiSpriteBank->printFT4(hbam,x,y1,0,0,_ot);
s_uiSpriteBank->printFT4(hbam,x,y2,0,0,_ot);
}
else
{
s_uiSpriteBank->printFT4(FRM__HBAMBOOTR,x,y1,0,0,_ot);
s_uiSpriteBank->printFT4(FRM__HBAMBOOBR,x,y2,0,0,_ot);
}
x1+=step;
}
}
@ -464,23 +483,40 @@ void drawBambooBorder(int _x,int _y,int _w,int _h,int _ot)
x1=_x-(_w-hbam->W)/2;
y1=_y-(hbam->H/2);
y2=y1+_h;
s_uiSpriteBank->printFT4(vbam,x1,y1,0,0,_ot);
s_uiSpriteBank->printFT4(vbam,x1,y2,0,0,_ot);
s_uiSpriteBank->printFT4(hbam,x1,y1,0,0,_ot);
s_uiSpriteBank->printFT4(hbam,x1,y2,0,0,_ot);
}
// Left & right
totalSize=_h-hbam->H-vbam->H;
totalSize=_h+hbam->H-vbam->H;
numSprites=(totalSize/vbam->H)+1;
if(abcd&2)
if(numSprites>1)
{
step=(totalSize<<4)/(numSprites-1);
y1=(_y+(hbam->H/2)+(vbam->H/2))<<4;
y1=(_y-(hbam->H/2)+(vbam->H/2))<<4;
x1=_x-(vbam->W/2);
x2=x1+_w;
for(i=0;i<numSprites;i++)
{
s_uiSpriteBank->printFT4(vbam,x1,(y1>>4)-(vbam->H/2),0,0,_ot);
s_uiSpriteBank->printFT4(vbam,x2,(y1>>4)-(vbam->H/2),0,0,_ot);
y=(y1>>4)-(vbam->H/2);
if(i==0)
{
spr1=s_uiSpriteBank->getFrameHeader(FRM__VBAMBOOTL);
spr2=s_uiSpriteBank->getFrameHeader(FRM__VBAMBOOTR);
s_uiSpriteBank->printFT4(spr1,x1,y+vbam->H-spr1->H-1,0,0,_ot);
s_uiSpriteBank->printFT4(spr2,x2,y+vbam->H-spr2->H-1,0,0,_ot);
}
else if(i<numSprites-1)
{
s_uiSpriteBank->printFT4(vbam,x1,y,0,0,_ot);
s_uiSpriteBank->printFT4(vbam,x2,y,0,0,_ot);
}
else
{
s_uiSpriteBank->printFT4(FRM__VBAMBOOBL,x1,y,0,0,_ot);
s_uiSpriteBank->printFT4(FRM__VBAMBOOBR,x2,y,0,0,_ot);
}
y1+=step;
}
}

View File

@ -31,6 +31,10 @@ question/response
#include "system\gstate.h"
#endif
#ifndef __GAME_CONVO_H__
#include "game\convo.h"
#endif
/* Std Lib
------- */
@ -126,6 +130,7 @@ static signed short func_setCharacterAnimation(unsigned short *_args)
---------------------------------------------------------------------- */
static signed short func_setText(unsigned short *_args)
{
CConversation::setCharacterAndText(_args[0],_args[1]);
return 0;
}
@ -163,6 +168,7 @@ static signed short func_gotItem(unsigned short *_args)
---------------------------------------------------------------------- */
static signed short func_setResponseOptions(unsigned short *_args)
{
CConversation::setResponseOptions(_args[0]);
return 0;
}
@ -175,7 +181,7 @@ static signed short func_setResponseOptions(unsigned short *_args)
---------------------------------------------------------------------- */
static signed short func_getResponse(unsigned short *_args)
{
return 0;
return CConversation::getResponse();
}

Binary file not shown.

View File

@ -716,7 +716,7 @@ SOURCE=..\..\..\data\scripts\defs\response.scr
# End Source File
# Begin Source File
SOURCE=..\..\..\data\scripts\defs\text.scr
SOURCE=..\..\..\data\scripts\defs\trans.scr
# End Source File
# End Group
# Begin Source File