map_dialogue.h

Go to the documentation of this file.
00001 
00002 //            Copyright (C) 2004-2007 by The Allacrost Project
00003 //                         All Rights Reserved
00004 //
00005 // This code is licensed under the GNU GPL version 2. It is free software
00006 // and you may modify it and/or redistribute it under the terms of this license.
00007 // See http://www.gnu.org/copyleft/gpl.html for details.
00009 
00016 #ifndef __MAP_DIALOGUE_HEADER__
00017 #define __MAP_DIALOGUE_HEADER__
00018 
00019 #include "utils.h"
00020 #include "defs.h"
00021 #include "video.h"
00022 
00023 namespace hoa_map {
00024 
00025 namespace private_map {
00026 
00028 const int32 DIALOGUE_INFINITE = -1;
00029 
00030 
00039 class DialogueManager : public hoa_video::MenuWindow {
00040 public:
00041   DialogueManager();
00042 
00043   ~DialogueManager();
00044 
00046   void Update();
00047 
00049   void Draw();
00050 
00051   void SetCurrentDialogue(MapDialogue* dialogue)
00052     { _current_dialogue = dialogue; }
00053 
00054   void ClearDialogue()
00055     { _current_dialogue = NULL; }
00056 
00057   MapDialogue* GetCurrentDialogue() const
00058     { return _current_dialogue; }
00059 
00060 private:
00062   MapDialogue* _current_dialogue;
00063 
00065   hoa_video::StillImage _background_image;
00066 
00068   hoa_video::StillImage _nameplate_image;
00069 
00071   hoa_video::TextBox _display_textbox;
00072 }; // class DialogueManager : public hoa_video::MenuWindow
00073 
00074 
00098 class MapDialogue {
00099 public:
00105   MapDialogue(bool save_state = true);
00106 
00107   ~MapDialogue();
00108 
00119   void AddText(std::string text, uint32 speaker_id, int32 time = DIALOGUE_INFINITE, int32 action = -1);
00120 
00124   bool ReadNextLine();
00125 
00127 
00128 
00129   void ResetTimesSeen()
00130     { _seen = 0; }
00131 
00133   bool HasAlreadySeen() const
00134     { return (_seen == 0) ? false : true; }
00135 
00137   void IncrementTimesSeen()
00138     { _seen++; }
00139 
00141   void SetBlock(bool b)
00142     { _blocked = b; }
00143 
00144   void SetOwner(VirtualSprite* sprite)
00145     { _owner = sprite; }
00146 
00148   int32 GetTimesSeen() const
00149     { return _seen; }
00150 
00152   bool IsBlocked() const
00153     { return _blocked; }
00154 
00156   bool IsSaving() const
00157     { return _save_state; }
00158 
00159   VirtualSprite* GetOwner() const
00160     { return _owner; }
00161 
00163   uint32 GetNumLines() const
00164     { return _speakers.size(); }
00165 
00167   hoa_utils::ustring GetCurrentText() const
00168     { return _text[_current_line]; }
00169 
00171   uint32 GetCurrentSpeaker() const
00172     { return _speakers[_current_line]; }
00173 
00175   int32 GetCurrentTime() const
00176     { return _time[_current_line]; }
00177 
00179   ScriptObject* GetCurrentAction()
00180     { return _actions[_current_line]; }
00181 
00183   hoa_utils::ustring GetLineText(uint32 line) const
00184     { if (line > _text.size()) return hoa_utils::ustring(); else return _text[line]; }
00185 
00187   uint32 GetLineSpeaker(uint32 line) const
00188     { if (line > _speakers.size()) return 0; else return _speakers[line]; }
00189 
00191   int32 GetLineTime(uint32 line) const
00192     { if (line > _time.size()) return -1; else return _time[line]; }
00193 
00195   ScriptObject* GetLineAction(uint32 line)
00196     { if (line > _actions.size()) return NULL; else return _actions[line]; }
00198 
00199 
00200 private:
00202   uint32 _seen;
00203 
00205   uint32 _current_line;
00206 
00208   bool _blocked;
00209 
00211   bool _save_state;
00212 
00214   VirtualSprite* _owner;
00215 
00217   std::vector<hoa_utils::ustring> _text;
00218 
00220   std::vector<uint32> _speakers;
00221 
00223   std::vector<int32> _time;
00224 
00226   std::vector<ScriptObject*> _actions;
00227 }; // class MapDialogue
00228 
00229 } // namespace private_map
00230 
00231 } // namespace hoa_map
00232 
00233 #endif

Generated on Fri Jul 6 23:11:17 2007 for Hero of Allacrost by  doxygen 1.5.1