1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef GOB_PREGOB_TXTFILE_H 24 #define GOB_PREGOB_TXTFILE_H 25 26 #include "common/system.h" 27 #include "common/str.h" 28 #include "common/array.h" 29 30 #include "gob/backbuffer.h" 31 32 namespace Common { 33 class SeekableReadStream; 34 } 35 36 namespace Gob { 37 38 class Surface; 39 class Font; 40 41 class TXTFile : public BackBuffer { 42 public: 43 enum Format { 44 kFormatString, 45 kFormatStringPosition, 46 kFormatStringPositionColor, 47 kFormatStringPositionColorFont 48 }; 49 50 struct Line { 51 Common::String text; 52 int x, y; 53 int color; 54 uint font; 55 }; 56 57 typedef Common::Array<Line> LineArray; 58 59 TXTFile(Common::SeekableReadStream &txt, Format format); 60 ~TXTFile(); 61 62 LineArray &getLines(); 63 64 bool draw( Surface &surface, const Font * const *fonts, uint fontCount, int color = -1); 65 bool draw(uint line, Surface &surface, const Font * const *fonts, uint fontCount, int color = -1); 66 67 bool draw( Surface &surface, int16 &left, int16 &top, int16 &right, int16 &bottom, 68 const Font * const *fonts, uint fontCount, int color = -1); 69 bool draw(uint line, Surface &surface, int16 &left, int16 &top, int16 &right, int16 &bottom, 70 const Font * const *fonts, uint fontCount, int color = -1); 71 72 bool clear(Surface &surface, int16 &left, int16 &top, int16 &right, int16 &bottom); 73 74 private: 75 LineArray _lines; 76 77 void load(Common::SeekableReadStream &txt, Format format); 78 79 Common::String getStr(Common::SeekableReadStream &txt); 80 int getInt(Common::SeekableReadStream &txt); 81 82 83 bool getArea( int16 &left, int16 &top, int16 &right, int16 &bottom, 84 const Font * const *fonts, uint fontCount) const; 85 bool getArea(uint line, int16 &left, int16 &top, int16 &right, int16 &bottom, 86 const Font * const *fonts, uint fontCount) const; 87 }; 88 89 } // End of namespace Gob 90 91 #endif // GOB_PREGOB_TXTFILE_H 92