textparser.h

00001 /***************************************************************************
00002  *   Copyright (C) 2007 by Mike Polan                                      *
00003  *   kanadakid@gmail.com                                                   *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 // textparser.h: the TextParser class
00021 
00022 #ifndef TEXTPARSER_H
00023 #define TEXTPARSER_H
00024 
00025 #include <iostream>
00026 #include <queue>
00027 #include <map>
00028 
00029 #include "common.h"
00030 
00031 class Game;
00032 class ValueRange;
00033 
00035 struct _FontStyle {
00036         ustring type;
00037         Color color;
00038         int speed;
00039         ColorRangeVector colors;
00040 };
00041 typedef struct _FontStyle FontStyle;
00042 
00048 class TextParser {
00049         public:
00051                 enum Filter { FILTER_NONE=0,            
00052                               FILTER_CROSS_EXAMINE      
00053                             };
00054                 
00055                 // constants
00056                 static const int NORMAL_FONT_SPEED=50;          
00057                 static const uchar TEXT_SPEED_INCR_CHAR='[';    
00058                 static const uchar TEXT_SPEED_DECR_CHAR=']';    
00059                 static const uchar TEXT_SPEED_NORM_CHAR='|';    
00060                 static const uchar SHAKE_SCREEN_CHAR='#';       
00061                 
00065                 TextParser(Game *game);
00066                 
00070                 void setBlock(const ustring &block);
00071                 
00073                 void reset();
00074                 
00078                 bool paused() const { return m_Pause; }
00079                 
00083                 bool done() const { return m_Done; }
00084                 
00088                 bool isBlocking() const { return m_BlockDiag; }
00089                 
00093                 bool dialogueDone() const { return (m_StrPos==m_Dialogue.size()); }
00094                 
00098                 void lockTalk(bool t) { m_TalkLocked=t; };
00099                 
00104                 bool talkLocked() const { return m_TalkLocked; }
00105                 
00109                 void setSpeaker(const ustring &speaker) { m_Speaker=speaker; }
00110                 
00114                 ustring getSpeaker() const { return m_Speaker; }
00115                 
00120                 ustring parse(bool drawDialogue);
00121                 
00123                 void nextStep();
00124                 
00125         private:
00132                 bool shouldPlayDialogueEffect(uchar prev, uchar ch, uchar next);
00133                 
00138                 bool preparseTrigger(const ustring &trigger);
00139                 
00145                 bool filterTrigger(const ustring &trigger, const Filter &filter);
00146                 
00150                 void parseTag(const ustring &tag);
00151                 
00153                 void clearFormatting();
00154                 
00156                 void executeNextTrigger();
00157                 
00163                 ustring doTrigger(const ustring &trigger, const ustring &command);
00164                 
00166                 ustring m_Block;
00167                 
00169                 ustring m_NextBlock;
00170                 
00172                 ustring m_Speaker;
00173                 
00175                 Character::Gender m_SpeakerGender;
00176                 
00178                 int m_BreakPoint;
00179                 
00181                 bool m_Pause;
00182                 
00184                 bool m_Done;
00185                 
00187                 bool m_Direct;
00188                 
00190                 bool m_BlockDiag;
00191                 
00193                 bool m_TalkLocked;
00194                 
00196                 ustring m_Dialogue;
00197                 
00199                 int m_StrPos;
00200                 
00202                 int m_LastChar;
00203                 
00205                 int m_Speed;
00206                 
00208                 bool m_TagOpen;
00209                 
00211                 ustring m_CurTag;
00212                 
00214                 FontStyle m_FontStyle;
00215                 
00217                 std::queue<StringPair> m_QueuedTriggers;
00218                 
00220                 ustring m_QueuedFade;
00221                 
00223                 ustring m_QueuedTestimony;
00224                 
00226                 ustring m_QueuedExamination;
00227                 
00229                 ustring m_QueuedResume;
00230                 
00232 
00233                 ustring m_QueuedEvent;
00234                 ustring m_QueuedEventArgs;
00236                 
00238                 int m_TimedGoto;
00239                 
00241                 Game *m_Game;
00242 };
00243 
00244 #endif

Generated on Fri Feb 22 22:29:23 2008 for Phoenix Wright Case Player API by  doxygen 1.5.3