TextParser Class Reference

The parser and trigger handler for the game script. More...

#include <textparser.h>

List of all members.

Public Types

enum  Filter { FILTER_NONE = 0, FILTER_CROSS_EXAMINE }
 Filters for trigger classification. More...

Public Member Functions

 TextParser (Game *game)
 Constructor.
void setBlock (const ustring &block)
 Set a text block to parse.
void reset ()
 Reset the parser.
bool paused () const
 See if parsing the block has paused.
bool done () const
 See if this parser is done with the current block.
bool isBlocking () const
 See if this block's dialogue can't be skipped.
bool dialogueDone () const
 See if the current dialogue string is still being drawn.
void lockTalk (bool t)
 Manually lock/unlock the speaking character's _talk animation.
bool talkLocked () const
 See if the script requests that dialogue not be spoken (disable _talk animation).
void setSpeaker (const ustring &speaker)
 Manually set the speaker.
ustring getSpeaker () const
 Return the currently speaking character, if any.
ustring parse (bool drawDialogue)
 Parse the given control block.
void nextStep ()
 Move on to the next break point.

Static Public Attributes

static const int NORMAL_FONT_SPEED = 50
 Regular text speed.
static const uchar TEXT_SPEED_INCR_CHAR = '['
 Character to increase text speed.
static const uchar TEXT_SPEED_DECR_CHAR = ']'
 Character to decrease text speed.
static const uchar TEXT_SPEED_NORM_CHAR = '|'
 Character to normalize text speed.
static const uchar SHAKE_SCREEN_CHAR = '#'
 Character to shake the screen.

Private Member Functions

bool shouldPlayDialogueEffect (uchar prev, uchar ch, uchar next)
 See if a dialogue sound effect should be played for a given character.
bool preparseTrigger (const ustring &trigger)
 See if a trigger should be executed right away.
bool filterTrigger (const ustring &trigger, const Filter &filter)
 See if a trigger matches a filter.
void parseTag (const ustring &tag)
 Parse a tag and apply styling.
void clearFormatting ()
 Clear current font formatting.
void executeNextTrigger ()
 Execute the next scheduled trigger.
ustring doTrigger (const ustring &trigger, const ustring &command)
 Execute a trigger.

Private Attributes

ustring m_Block
 The current block.
ustring m_NextBlock
 The next block to parse.
ustring m_Speaker
 Internal name of current speaking character.
Character::Gender m_SpeakerGender
 Gender of the current speaking character.
int m_BreakPoint
 Position in block where parser was paused.
bool m_Pause
 Whether or not the parser is paused.
bool m_Done
 Whether or not the parser is done with the current block.
bool m_Direct
 Flag if the parser should go right to the next block.
bool m_BlockDiag
 Flag if the dialogue should be blocked from being skipped.
bool m_TalkLocked
 Flag if the speaking character's _talk animation should be disabled.
ustring m_Dialogue
 Current dialogue string data.
int m_StrPos
 Position in current dialogue.
int m_LastChar
 The last time the previous character was drawn.
int m_Speed
 Speed of font drawing.
bool m_TagOpen
 Flag whether or not the a styling tag is open.
ustring m_CurTag
 The current styling tag, if any.
FontStyle m_FontStyle
 Current font formatting.
std::queue< StringPair > m_QueuedTriggers
 Triggers to be executed in a linear manner.
ustring m_QueuedFade
 Scheduled fade out.
ustring m_QueuedTestimony
 Scheduled testimony sprite sequence.
ustring m_QueuedExamination
 Scheduled cross examination sprite sequence.
ustring m_QueuedResume
 Scheduled cross examination to resume.
int m_TimedGoto
 Wait time before parsing block.
Gamem_Game
 Pointer to Game engine object.
ustring m_QueuedEvent
 Generic scheduled events to perform.
ustring m_QueuedEventArgs
 Generic scheduled events to perform.


Detailed Description

The parser and trigger handler for the game script.

The TextParser class forms the foundation of the entire game engine. It handles text blocks, extracts and draws dialogue strings with correct timing, and executes triggers.


Member Enumeration Documentation

enum TextParser::Filter

Filters for trigger classification.

Enumerator:
FILTER_NONE  Don't filter anything.
FILTER_CROSS_EXAMINE  Remove any trigger that shouldn't show up in cross examination.


Constructor & Destructor Documentation

TextParser::TextParser ( Game game  ) 

Constructor.

Parameters:
game Pointer to the Game engine object


Member Function Documentation

void TextParser::setBlock ( const ustring &  block  ) 

Set a text block to parse.

Parameters:
block The block to parse

bool TextParser::paused (  )  const [inline]

See if parsing the block has paused.

Returns:
true if done, false otherwise

bool TextParser::done (  )  const [inline]

See if this parser is done with the current block.

Returns:
true if done, false otherwise

bool TextParser::isBlocking (  )  const [inline]

See if this block's dialogue can't be skipped.

Returns:
true if dialogue can be skipped, false otherwise

bool TextParser::dialogueDone (  )  const [inline]

See if the current dialogue string is still being drawn.

Returns:
true if done, false otherwise

void TextParser::lockTalk ( bool  t  )  [inline]

Manually lock/unlock the speaking character's _talk animation.

Parameters:
t true to lock the animation, false to unlock

bool TextParser::talkLocked (  )  const [inline]

See if the script requests that dialogue not be spoken (disable _talk animation).

Returns:
true if the animation should be disabled, false otherwise
See also:
TextParser::lockTalk()

void TextParser::setSpeaker ( const ustring &  speaker  )  [inline]

Manually set the speaker.

Parameters:
speaker ID of the speaking character

ustring TextParser::getSpeaker (  )  const [inline]

Return the currently speaking character, if any.

Returns:
The speaking character

ustring TextParser::parse ( bool  drawDialogue  ) 

Parse the given control block.

Parameters:
drawDialogue Flag whether or not to draw the dialogue text
Returns:
ID of next block to parse, STR_NULL if no other block is to follow

bool TextParser::shouldPlayDialogueEffect ( uchar  prev,
uchar  ch,
uchar  next 
) [private]

See if a dialogue sound effect should be played for a given character.

Parameters:
prev The previous character
ch The current character
next The next character
Returns:
true is a sound effect should be played, false otherwise

bool TextParser::preparseTrigger ( const ustring &  trigger  )  [private]

See if a trigger should be executed right away.

Parameters:
trigger The trigger to test
Returns:
true to execute immediately, false otherwise

bool TextParser::filterTrigger ( const ustring &  trigger,
const Filter filter 
) [private]

See if a trigger matches a filter.

Parameters:
trigger The trigger to test
filter The filter to test against
Returns:
true if the trigger should be filtered, false otherwise

void TextParser::parseTag ( const ustring &  tag  )  [private]

Parse a tag and apply styling.

Parameters:
tag The tag to handle

ustring TextParser::doTrigger ( const ustring &  trigger,
const ustring &  command 
) [private]

Execute a trigger.

Parameters:
trigger The trigger to execute
command The trigger parameters
Returns:
The return value of a trigger


The documentation for this class was generated from the following files:
Generated on Fri Feb 22 22:29:23 2008 for Phoenix Wright Case Player API by  doxygen 1.5.3