ScummVM API documentation
converse.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 TSAGE_CONVERSE_H
23 #define TSAGE_CONVERSE_H
24 
25 #include "tsage/core.h"
26 #include "tsage/dialogs.h"
27 #include "tsage/sound.h"
28 
29 namespace TsAGE {
30 
31 class StripCallback : public Action {
32 public:
33  virtual void stripCallback(int v) = 0;
34 };
35 
36 typedef void (*SequenceCallback)(int v1, int v2);
37 
38 class SequenceManager : public Action {
39 private:
40  void setup();
41  uint16 getNextValue();
42  void setMessage(int resNum, int lineNum, int color, const Common::Point &pt, int width);
43  void setMessage(int resNum, int lineNum, int fontNum, int color1, int color2, int color3,
44  const Common::Point &pt, int width);
45  SequenceManager *globalManager();
46 public:
47  SceneText _sceneText;
48  int _resNum;
49  uint _sequenceOffset;
50  bool _keepActive;
51  int _fontNum;
52  int _field26;
53  Common::Array<byte> _sequenceData;
54  int _objectIndex;
55  SceneObject *_sceneObject;
56  SceneObject *_objectList[6];
57  ASound _soundHandler;
58  SequenceCallback _onCallback;
59 public:
61 
62  Common::String getClassName() override { return "SequenceManager"; }
63  void synchronize(Serializer &s) override;
64  void remove() override;
65  void signal() override;
66  void process(Event &event) override;
67  void attached(EventHandler *newOwner, EventHandler *endHandler, va_list va) override;
68 };
69 
70 
71 class Speaker : public EventHandler {
72 public:
73  Rect _fieldA;
74  Action *_field18;
75  Common::String _speakerName;
76  int _newSceneNumber;
77  int _oldSceneNumber;
78  SceneObjectList _objectList;
79  Rect _sceneBounds;
80  SceneText _sceneText;
81  int _textWidth;
82  Common::Point _textPos;
83  int _fontNumber;
84  TextAlign _textMode;
85  int _color1, _color2, _color3;
86  bool _hideObjects;
87 public:
88  Speaker();
89 
90  Common::String getClassName() override { return "Speaker"; }
91  void synchronize(Serializer &s) override;
92  void remove() override;
93  virtual void startSpeaking(Action *action);
94  virtual void setText(const Common::String &msg);
95  virtual void removeText();
96  virtual void stopSpeaking() {}
97 
98  void setTextPos(const Common::Point &pt) { _textPos = pt; }
99 };
100 
101 class SpeakerGameText : public Speaker {
102 public:
103  SpeakerGameText();
104 
105  Common::String getClassName() override { return "SpeakerGameText"; }
106 };
107 
108 class ScreenSpeaker : public Speaker {
109 public:
110  SceneItem *_npc;
111 public:
112  ScreenSpeaker();
113 
114  Common::String getClassName() override { return "ScreenSpeaker"; }
115  void setText(const Common::String &msg) override;
116 };
117 
118 class SpeakerAction : public Action {
119 public:
120  void signal() override;
121 
122  Common::String getClassName() override { return "SpeakerAction"; }
123 };
124 
125 class AnimatedSpeaker : public Speaker {
126 public:
127  SceneObject _object1;
128  SceneObject _object2;
129  SpeakerAction _speakerAction;
130 public:
131  Common::String getClassName() override { return "AnimatedSpeaker"; }
132  void removeText() override;
133 };
134 
135 class ChoiceEntry {
136 public:
137  Common::String _msg;
138  Rect _bounds;
139 
140  ChoiceEntry() {}
141  ChoiceEntry(const Common::String &msg, const Rect &bounds) {
142  _msg = msg;
143  _bounds = bounds;
144  }
145 };
146 
148 private:
149  int textLeft() const;
150  int textMaxWidth() const;
151  int numberLeft() const;
152 public:
153  int _stdColor;
154  int _highlightColor;
155  int _fontNumber;
156  int _savedFgColor;
157  int _savedFontNumber;
158  Common::Array<ChoiceEntry> _choiceList;
159  uint _selectedIndex;
160 public:
162 
163  void setColors(int stdColor, int highlightColor) {
164  _stdColor = stdColor;
165  _highlightColor = highlightColor;
166  }
167  void setFontNumber(int fontNum) { _fontNumber = fontNum; }
168  int execute(const Common::StringArray &choiceList);
169 
170  void draw() override;
171 };
172 
173 class Obj0A : public Serialisable {
174 public:
175  int _id;
176  uint _scriptOffset;
177 
178  void synchronize(Serializer &s) override {
179  s.syncAsSint32LE(_id);
180  s.syncAsUint32LE(_scriptOffset);
181  }
182 };
183 
184 #define OBJ44_LIST_SIZE 5
185 #define OBJ0A_LIST_SIZE ((g_vm->getGameID() == GType_Ringworld2) ? 8 : 5)
186 
187 class Obj44 : public Serialisable {
188 public:
189  int _id;
190  int _callbackId[OBJ44_LIST_SIZE];
191  Obj0A _list[8];
192  uint _speakerOffset;
193 
194  // Return to Ringworld specific field
195  int _mode;
196  int _lookupValue, _lookupIndex, _exitMode;
197  int _speakerMode;
198  int _field16[11];
199 public:
200  void load(const byte *dataP);
201  void synchronize(Serializer &s) override;
202 };
203 
204 typedef void (*StripProc)();
205 
206 class StripManager : public Action {
207 private:
208  void reset();
209  void load();
210  Speaker *getSpeaker(const char *speakerName);
211  int getNewIndex(int newId);
212 public:
213  int _stripNum;
214  int _obj44ListIndex;
215  int _useless;
216  int _sceneNumber;
217  Rect _sceneBounds;
218  ConversationChoiceDialog _choiceDialog;
219  Common::Array<Speaker *> _speakerList;
220  StripCallback *_callbackObject;
221  Speaker *_activeSpeaker;
222  bool _textShown;
223  bool _uselessFl;
224  int _currObj44Id;
225  int _exitMode;
226  Common::Array<Obj44> _obj44List;
227  Common::Array<byte> _script;
228  StripProc _onBegin;
229  StripProc _onEnd;
230 
231  // Ringworld 2 specific fields
232  byte *_lookupList;
233 public:
234  StripManager();
235  ~StripManager() override;
236 
237  void synchronize(Serializer &s) override;
238  void remove() override;
239  void dispatch() override;
240  void signal() override;
241  void process(Event &event) override;
242 
243  void start(int stripNum, EventHandler *owner, StripCallback *callback = NULL);
244  void start3(int stripNum, EventHandler *owner, byte *lookupList);
245  void setCallback(StripCallback *callback) { _callbackObject = callback; }
246  void setColors(int stdColor, int highlightColor) { _choiceDialog.setColors(stdColor, highlightColor); }
247  void setFontNumber(int fontNum) { _choiceDialog.setFontNumber(fontNum); }
248  void addSpeaker(Speaker *speaker);
249 };
250 
251 } // End of namespace TsAGE
252 
253 #endif
Definition: converse.h:147
Definition: str.h:59
Definition: converse.h:118
Definition: saveload.h:84
Definition: converse.h:187
Definition: core.h:115
Definition: converse.h:71
Definition: core.h:736
Definition: converse.h:135
Definition: core.h:134
Definition: core.h:407
Definition: sound.h:366
Definition: converse.h:31
Definition: converse.h:125
Definition: converse.h:101
Definition: converse.h:173
Definition: rect.h:45
Definition: events.h:47
Definition: blueforce_dialogs.h:30
Definition: saveload.h:63
Definition: converse.h:108
Definition: converse.h:206
Definition: core.h:519
Definition: graphics.h:40
Definition: core.h:625
Definition: dialogs.h:47
Definition: converse.h:38