ScummVM API documentation
gctfile.h
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 modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (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, see <http://www.gnu.org/licenses/>.
19  *
20  *
21  * This file is dual-licensed.
22  * In addition to the GPLv3 license mentioned above, this code is also
23  * licensed under LGPL 2.1. See LICENSES/COPYING.LGPL file for the
24  * full text of the license.
25  *
26  */
27 
28 #ifndef GOB_PREGOB_GCTFILE_H
29 #define GOB_PREGOB_GCTFILE_H
30 
31 #include "common/str.h"
32 #include "common/array.h"
33 #include "common/list.h"
34 
35 #include "gob/backbuffer.h"
36 
37 namespace Common {
38  class RandomSource;
39  class SeekableReadStream;
40 }
41 
42 namespace Gob {
43 
44 class Surface;
45 class Font;
46 
47 class GCTFile : public BackBuffer {
48 public:
49  static const uint16 kSelectorAll = 0xFFFE;
50  static const uint16 kSelectorRandom = 0xFFFF;
51 
52 
54  ~GCTFile();
55 
57  uint16 getLineCount(uint item) const;
58 
60  void setArea(int16 left, int16 top, int16 right, int16 bottom);
61 
63  void selectLine(uint item, uint16 line);
64 
66  void setText(uint item, uint16 line, const Common::String &text);
68  void setText(uint item, const Common::String &text);
69 
71  void reset();
72 
74  bool clear(Surface &dest, int16 &left, int16 &top, int16 &right, int16 &bottom);
75 
77  bool fill(Surface &dest, uint8 color, int16 &left, int16 &top, int16 &right, int16 &bottom);
78 
80  bool draw(Surface &dest, uint16 item, const Font &font, uint8 color,
81  int16 &left, int16 &top, int16 &right, int16 &bottom);
82 
84  bool finished() const;
85 
86 private:
88  enum ChunkType {
89  kChunkTypeNone = 0,
90  kChunkTypeString ,
91  kChunkTypeItem
92  };
93 
95  struct Chunk {
96  ChunkType type;
97 
98  Common::String text;
99 
100  int item;
101 
102  Chunk();
103  };
104 
105  typedef Common::List<Chunk> Chunks;
106 
108  struct Line {
109  Chunks chunks;
110  };
111 
112  typedef Common::Array<Line> Lines;
113 
115  struct Item {
116  Lines lines;
117  uint16 selector;
118  };
119 
120  typedef Common::Array<Item> Items;
121 
122 
123  Common::RandomSource *_rnd;
124 
125  Items _items;
126 
127  // The area on which to print
128  bool _hasArea;
129  int16 _areaLeft;
130  int16 _areaTop;
131  int16 _areaRight;
132  int16 _areaBottom;
133 
135  uint16 _currentItem;
137  Common::List<Common::String> _currentText;
138 
139 
140  // -- Loading helpers --
141 
142  void load(Common::SeekableReadStream &gct);
143  void readLine(Common::SeekableReadStream &gct, Line &line, uint16 lineSize) const;
144 
145 
146  // -- Draw helpers --
147 
148  Common::String getLineText(const Line &line) const;
149  void getItemText(uint item, Common::List<Common::String> &text) const;
150 };
151 
152 } // End of namespace Gob
153 
154 #endif // GOB_PREGOB_GCTFILE_H
Definition: str.h:59
Definition: random.h:44
Definition: gctfile.h:47
Definition: stream.h:745
Definition: video.h:40
Definition: backbuffer.h:37
Definition: anifile.h:40
Definition: algorithm.h:29
Definition: surface.h:100
signed char * fill(signed char *first, signed char *last, Value val)
Definition: algorithm.h:168