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/nebular/core/action.h"
28 #include "mads/nebular/core/font.h"
29 #include "mads/nebular/core/msurface.h"
30 
31 namespace MADS {
32 namespace Nebular {
33 
34 #define KERNEL_MESSAGES_SIZE 10
35 #define INDEFINITE_TIMEOUT 9999999
36 #define TEXT_DISPLAY_SIZE 40
37 #define RANDOM_MESSAGE_SIZE 4
38 
39 enum KernelMessageFlags {
40  KMSG_QUOTED = 1, KMSG_PLAYER_TIMEOUT = 2, KMSG_SEQ_ENTRY = 4, KMSG_SCROLL = 8,
41  KMSG_RIGHT_ALIGN = 0x10, KMSG_CENTER_ALIGN = 0x20, KMSG_EXPIRE = 0x40,
42  KMSG_ACTIVE = 0x80, KMSG_ANIM = 0x100
43 };
44 
45 class RexNebularEngine;
46 
48 public:
49  uint16 _flags;
50  int _sequenceIndex;
51  int _color1;
52  int _color2;
53  Common::Point _position;
54  int _textDisplayIndex;
55  uint32 _msgOffset;
56  int _numTicks;
57  uint32 _frameTimer2;
58  uint32 _frameTimer;
59  int32 _timeout;
60  int _trigger;
61  TriggerMode _abortMode;
62  ActionDetails _actionDetails;
63  Common::String _msg;
64 
65  KernelMessage();
66 };
67 
68 struct RandomEntry {
69  int _handle;
70  int _quoteId;
71 
72  RandomEntry() {
73  _handle = _quoteId = -1;
74  }
75 };
76 
77 class RandomMessages : public Common::Array<RandomEntry> {
78 public:
79  Common::Rect _bounds;
80  int _randomSpacing;
81  int _color;
82  int _duration;
83  int _scrollRate;
84 public:
86 
87  void reset();
88 };
89 
91 private:
92  RexNebularEngine *_vm;
93 
94  Common::Array<int> _randomQuotes;
95  RandomMessages _randomMessages;
96 public:
98  Font *_talkFont;
99 public:
101  ~KernelMessages();
102 
103  void clear();
104  int add(const Common::Point &pt, uint fontColor, uint8 flags, int endTrigger,
105  uint32 timeout, const Common::String &msg);
106  int addQuote(int quoteId, int endTrigger, uint32 timeout);
107  void scrollMessage(int msgIndex, int numTicks, bool quoted);
108  void setSeqIndex(int msgIndex, int seqIndex);
109  void setAnim(int msgId, int seqId, int val3);
110  void remove(int msgIndex);
111  void reset();
112  void update();
113  void processText(int msgIndex);
114  void delay(uint32 priorFrameTime, uint32 currentTime);
115  void setQuoted(int msgIndex, int numTicks, bool quoted);
116 
117  void initRandomMessages(int maxSimultaneousMessages,
118  const Common::Rect &bounds, int minYSpacing, int scrollRate,
119  int color, int duration, int quoteId, ...);
120 
124  void randomServer();
125 
129  int checkRandom();
130 
134  bool generateRandom(int major, int minor);
135 };
136 
137 class TextDisplay {
138 public:
139  bool _active;
140  int _expire;
141  int _spacing;
142  Common::Rect _bounds;
143  uint8 _color1;
144  uint8 _color2;
145  Font *_font;
146  Common::String _msg;
147 
148  TextDisplay();
149 };
150 
151 #define TEXT_DISPLAY_SIZE 40
152 
153 class TextDisplayList : public Common::Array<TextDisplay> {
154 private:
155  RexNebularEngine *_vm;
156 public:
158 
162  void expire(int idx);
163 
164  int add(int xp, int yp, uint fontColor, int charSpacing, const Common::String &, Font *font);
165 
169  void reset();
170 
175  void draw(BaseSurface *s);
176 
180  void setDirtyAreas();
181 
185  void setDirtyAreas2();
186 
190  void cleanUp();
191 };
192 
193 } // namsepace Nebular
194 } // namespace MADS
195 
196 #endif
Definition: str.h:59
Definition: nebular.h:51
Definition: messages.h:68
Definition: array.h:52
Definition: messages.h:137
Definition: rect.h:524
Definition: messages.h:47
Definition: msurface.h:56
Definition: font.h:48
Definition: messages.h:153
Definition: rect.h:144
Definition: messages.h:77
Definition: sound_manager.h:38
Definition: messages.h:90
Definition: action.h:78