ScummVM API documentation
messages.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 
22 #ifndef MADS_MESSAGES_H
23 #define MADS_MESSAGES_H
24 
25 #include "common/scummsys.h"
26 #include "common/array.h"
27 #include "mads/action.h"
28 #include "mads/font.h"
29 #include "mads/msurface.h"
30 
31 namespace MADS {
32 
33 #define KERNEL_MESSAGES_SIZE 10
34 #define INDEFINITE_TIMEOUT 9999999
35 #define TEXT_DISPLAY_SIZE 40
36 #define RANDOM_MESSAGE_SIZE 4
37 
38 enum KernelMessageFlags {
39  KMSG_QUOTED = 1, KMSG_PLAYER_TIMEOUT = 2, KMSG_SEQ_ENTRY = 4, KMSG_SCROLL = 8,
40  KMSG_RIGHT_ALIGN = 0x10, KMSG_CENTER_ALIGN = 0x20, KMSG_EXPIRE = 0x40,
41  KMSG_ACTIVE = 0x80, KMSG_ANIM = 0x100
42 };
43 
44 class MADSEngine;
45 
47 public:
48  uint16 _flags;
49  int _sequenceIndex;
50  int _color1;
51  int _color2;
52  Common::Point _position;
53  int _textDisplayIndex;
54  uint32 _msgOffset;
55  int _numTicks;
56  uint32 _frameTimer2;
57  uint32 _frameTimer;
58  int32 _timeout;
59  int _trigger;
60  TriggerMode _abortMode;
61  ActionDetails _actionDetails;
62  Common::String _msg;
63 
64  KernelMessage();
65 };
66 
67 struct RandomEntry {
68  int _handle;
69  int _quoteId;
70 
71  RandomEntry() { _handle = _quoteId = -1; }
72 };
73 
74 class RandomMessages : public Common::Array<RandomEntry> {
75 public:
76  Common::Rect _bounds;
77  int _randomSpacing;
78  int _color;
79  int _duration;
80  int _scrollRate;
81 public:
83 
84  void reset();
85 };
86 
88 private:
89  MADSEngine *_vm;
90 
91  Common::Array<int> _randomQuotes;
92  RandomMessages _randomMessages;
93 public:
95  Font *_talkFont;
96 public:
98  ~KernelMessages();
99 
100  void clear();
101  int add(const Common::Point &pt, uint fontColor, uint8 flags, int endTrigger,
102  uint32 timeout, const Common::String &msg);
103  int addQuote(int quoteId, int endTrigger, uint32 timeout);
104  void scrollMessage(int msgIndex, int numTicks, bool quoted);
105  void setSeqIndex(int msgIndex, int seqIndex);
106  void setAnim(int msgId, int seqId, int val3);
107  void remove(int msgIndex);
108  void reset();
109  void update();
110  void processText(int msgIndex);
111  void delay(uint32 priorFrameTime, uint32 currentTime);
112  void setQuoted(int msgIndex, int numTicks, bool quoted);
113 
114  void initRandomMessages(int maxSimultaneousMessages,
115  const Common::Rect &bounds, int minYSpacing, int scrollRate,
116  int color, int duration, int quoteId, ...);
117 
121  void randomServer();
122 
126  int checkRandom();
127 
131  bool generateRandom(int major, int minor);
132 };
133 
134 class TextDisplay {
135 public:
136  bool _active;
137  int _expire;
138  int _spacing;
139  Common::Rect _bounds;
140  uint8 _color1;
141  uint8 _color2;
142  Font *_font;
143  Common::String _msg;
144 
145  TextDisplay();
146 };
147 
148 #define TEXT_DISPLAY_SIZE 40
149 
150 class TextDisplayList : public Common::Array<TextDisplay> {
151 private:
152  MADSEngine *_vm;
153 public:
155 
159  void expire(int idx);
160 
161  int add(int xp, int yp, uint fontColor, int charSpacing, const Common::String &, Font *font);
162 
166  void reset();
167 
172  void draw(BaseSurface *s);
173 
177  void setDirtyAreas();
178 
182  void setDirtyAreas2();
183 
187  void cleanUp();
188 };
189 
190 } // End of namespace MADS
191 
192 #endif /* MADS_MESSAGES_H */
Definition: msurface.h:55
Definition: str.h:59
Definition: array.h:52
Definition: rect.h:144
Definition: messages.h:67
Definition: messages.h:74
Definition: rect.h:45
Definition: action.h:75
Definition: mads.h:87
Definition: font.h:47
Definition: messages.h:134
Definition: action.h:28
Definition: messages.h:150
Definition: messages.h:46
Definition: messages.h:87