This commit is contained in:
parent
104f5a734a
commit
e2dba7722f
@ -101,6 +101,10 @@ class CGUISprite *CConversation::s_guiIcon=NULL;
|
||||
class CGUITextBox *CConversation::s_guiText=NULL;
|
||||
class FontBank *CConversation::s_fontBank=NULL;
|
||||
|
||||
class CScript *CConversation::s_registeredScripts[MAX_LOADED_SCRIPTS];
|
||||
int CConversation::s_registeredScriptIds[MAX_LOADED_SCRIPTS];
|
||||
int CConversation::s_numRegisteredScripts=0;
|
||||
|
||||
class CScript *CConversation::s_currentScript=NULL;
|
||||
int CConversation::s_currentState=STATE_INACTIVE;
|
||||
|
||||
@ -119,6 +123,8 @@ int CConversation::s_currentSelectedAnswer=0;
|
||||
---------------------------------------------------------------------- */
|
||||
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);
|
||||
@ -142,6 +148,7 @@ void CConversation::init()
|
||||
s_fontBank->setOt(0);
|
||||
|
||||
s_currentState=STATE_INACTIVE;
|
||||
s_currentScript=NULL;
|
||||
}
|
||||
|
||||
|
||||
@ -153,6 +160,7 @@ void CConversation::init()
|
||||
---------------------------------------------------------------------- */
|
||||
void CConversation::shutdown()
|
||||
{
|
||||
dumpConversationScripts();
|
||||
s_guiFrame->shutdown(); delete s_guiFrame;
|
||||
}
|
||||
|
||||
@ -167,6 +175,8 @@ void CConversation::think(int _frames)
|
||||
{
|
||||
if(isActive())
|
||||
{
|
||||
ASSERT(s_currentScript);
|
||||
|
||||
if(s_currentState==STATE_JUST_ACTIVATED)
|
||||
{
|
||||
s_currentState=STATE_ACTIVE;
|
||||
@ -179,6 +189,7 @@ void CConversation::think(int _frames)
|
||||
s_currentScript->run();
|
||||
if(s_currentScript->isFinished())
|
||||
{
|
||||
s_currentScript=NULL;
|
||||
s_currentState=STATE_INACTIVE;
|
||||
}
|
||||
}
|
||||
@ -209,7 +220,13 @@ void CConversation::render()
|
||||
---------------------------------------------------------------------- */
|
||||
void CConversation::registerConversationScript(FileEquate _feScript)
|
||||
{
|
||||
// Blah blah..
|
||||
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++;
|
||||
}
|
||||
|
||||
|
||||
@ -221,12 +238,23 @@ void CConversation::registerConversationScript(FileEquate _feScript)
|
||||
---------------------------------------------------------------------- */
|
||||
void CConversation::trigger(FileEquate _feScript)
|
||||
{
|
||||
int i;
|
||||
|
||||
ASSERT(!isActive());
|
||||
|
||||
s_currentScript=new ("script") CScript();
|
||||
s_currentScript->initialise(_feScript);
|
||||
|
||||
// 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;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT(!"Script was not registered");
|
||||
}
|
||||
|
||||
|
||||
@ -373,5 +401,24 @@ void CConversation::renderQuestion()
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void CConversation::dumpConversationScripts()
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0;i<s_numRegisteredScripts;i++)
|
||||
{
|
||||
s_registeredScripts[i]->dump();
|
||||
}
|
||||
s_currentScript=NULL;
|
||||
s_numRegisteredScripts=0;
|
||||
}
|
||||
|
||||
|
||||
/*===========================================================================
|
||||
end */
|
||||
|
@ -44,7 +44,6 @@ public:
|
||||
static void render();
|
||||
|
||||
static void registerConversationScript(FileEquate _feScript);
|
||||
|
||||
static void trigger(FileEquate _feScript);
|
||||
static int isActive();
|
||||
|
||||
@ -113,10 +112,17 @@ private:
|
||||
STATE_ACTIVE,
|
||||
};
|
||||
|
||||
// Maximum number of scripts per level
|
||||
enum
|
||||
{
|
||||
MAX_LOADED_SCRIPTS=10,
|
||||
};
|
||||
|
||||
static void thinkQuestion();
|
||||
static void renderQuestion();
|
||||
|
||||
static void dumpConversationScripts();
|
||||
|
||||
|
||||
static class CGUIGroupFrame *s_guiFrame;
|
||||
static class CGUISprite *s_guiIcon;
|
||||
@ -125,6 +131,10 @@ private:
|
||||
|
||||
static CHAR_ICON_FRAMES s_characterIconFrames[MAX_CHARS];
|
||||
|
||||
static class CScript *s_registeredScripts[MAX_LOADED_SCRIPTS];
|
||||
static int s_registeredScriptIds[MAX_LOADED_SCRIPTS];
|
||||
static int s_numRegisteredScripts;
|
||||
|
||||
static class CScript *s_currentScript;
|
||||
static int s_currentState;
|
||||
|
||||
|
@ -68,7 +68,10 @@ void CGameScene::init()
|
||||
s_genericFont->initialise( &standardFont );
|
||||
s_genericFont->setColour( 255, 255 , 0 );
|
||||
VidSetClearScreen(1);
|
||||
|
||||
CConversation::init();
|
||||
CConversation::registerConversationScript(SCRIPTS_SPEECHTEST_DAT); // Register one script for testing..
|
||||
|
||||
Level.init();
|
||||
|
||||
C2dEnemy *enemy;
|
||||
|
@ -87,6 +87,19 @@ void CScript::initialise(FileEquate _fe)
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
void CScript::dump()
|
||||
{
|
||||
MemFree(m_stack);
|
||||
MemFree(m_code);
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
@ -125,12 +138,10 @@ void CScript::run()
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
int testval=2;
|
||||
void CScript::reset()
|
||||
{
|
||||
m_pc=0;
|
||||
m_sp=0;
|
||||
m_localVars[TMP1]=testval;
|
||||
m_state=RESET;
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@ class CScript
|
||||
{
|
||||
public:
|
||||
void initialise(FileEquate _fe);
|
||||
void dump();
|
||||
|
||||
void reset();
|
||||
void run();
|
||||
|
Loading…
Reference in New Issue
Block a user