ScummVM API documentation
teenagent.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 TEENAGENT_TEENAGENT_H
23 #define TEENAGENT_TEENAGENT_H
24 
25 #include "engines/engine.h"
26 
27 #include "audio/mixer.h"
28 
29 #include "common/random.h"
30 #include "common/array.h"
31 
32 #include "gui/debugger.h"
33 
34 #include "teenagent/console.h"
35 #include "teenagent/dialog.h"
36 
37 struct ADGameDescription;
38 
39 namespace Audio {
40 class AudioStream;
41 }
42 
43 namespace Common {
44 struct Point;
45 }
46 
55 namespace TeenAgent {
56 
57 struct Object;
58 struct UseHotspot;
59 class Scene;
60 class MusicPlayer;
61 class Resources;
62 class Inventory;
63 class Pack;
64 
65 #define TEENAGENT_DAT_VERSION 6
66 #define TEENAGENT_SAVEGAME_VERSION 1
67 
68 // Engine Debug Flags
69 enum {
70  kDebugActor = 1,
71  kDebugAnimation,
72  kDebugCallbacks,
73  kDebugDialog,
74  kDebugFont,
75  kDebugInventory,
76  kDebugMusic,
77  kDebugObject,
78  kDebugPack,
79  kDebugScene,
80  kDebugSurface,
81 };
82 
83 enum TEENAGENTActions {
84  kActionSkipIntro,
85  kActionSkipDialog,
86  kActionCloseInventory,
87  kActionToggleInventory,
88  kActionFastMode,
89 };
90 
91 const uint16 kScreenWidth = 320;
92 const uint16 kScreenHeight = 200;
93 
94 class TeenAgentEngine : public Engine {
95 public:
96  TeenAgentEngine(OSystem *system, const ADGameDescription *gd);
97  ~TeenAgentEngine();
98 
99  Common::Error run() override;
100  Common::String getSaveStateName(int slot) const override;
101  Common::Error loadGameState(int slot) override;
102  Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave = false) override;
103  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override { return true; }
104  bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override { return !_sceneBusy; }
105  bool hasFeature(EngineFeature f) const override;
106 
107  void init();
108 
109  enum Action { kActionNone, kActionExamine, kActionUse };
110 
111  void examine(const Common::Point &point, Object *object);
112  void use(Object *object);
113  inline void cancel() { _action = kActionNone; }
114 
115  bool processCallback(uint16 addr);
116  inline Scene *getScene() { return scene; }
117 
118  bool showLogo();
119  bool showCDLogo();
120  bool showMetropolis();
121  int skipEvents() const;
122 
123  Common::String parseMessage(uint32 addr);
124 
125  //event driven:
126  void displayMessage(uint32 addr, CharacterID characterID = kMark, uint16 x = 0, uint16 y = 0);
127  void displayMessage(const Common::String &str, uint16 voiceIndex, CharacterID characterID = kMark, uint16 x = 0, uint16 y = 0);
128  void displayAsyncMessage(uint32 addr, uint16 x, uint16 y, uint16 firstFrame, uint16 lastFrame, CharacterID characterID = kMark);
129  void displayAsyncMessageInSlot(uint32 addr, byte slot, uint16 firstFrame, uint16 lastFrame, byte color = textColorMark);
130  void displayCredits(uint32 addr, uint16 timer = 0);
131  void displayCutsceneMessage(uint32 addr, uint16 x, uint16 y);
132  void moveTo(const Common::Point &dst, byte o, bool warp = false);
133  void moveTo(uint16 x, uint16 y, byte o, bool warp = false);
134  void moveTo(Object *obj);
135  void moveRel(int16 x, int16 y, byte o, bool warp = false);
136  void playActorAnimation(uint16 id, bool async = false, bool ignore = false);
137  void playAnimation(uint16 id, byte slot, bool async = false, bool ignore = false, bool loop = false);
138  void loadScene(byte id, const Common::Point &pos, byte o = 0);
139  void loadScene(byte id, uint16 x, uint16 y, byte o = 0);
140  void enableOn(bool enable = true);
141  void setOns(byte id, byte value, byte sceneId = 0);
142  void setLan(byte id, byte value, byte sceneId = 0);
143  void setFlag(uint16 addr, byte value);
144  byte getFlag(uint16 addr);
145  void reloadLan();
146  void rejectMessage();
147  void bookColorMessage();
148 
149  void playMusic(byte id); //schedules play
150  void playSound(byte id, byte skipFrames);
151  void playSoundNow(Pack *pack, uint32 id);
152  void playVoiceNow(Pack *pack, uint32 id);
153  void stopVoice();
154  void enableObject(byte id, byte sceneId = 0);
155  void disableObject(byte id, byte sceneId = 0);
156  void hideActor();
157  void showActor();
158  void waitAnimation();
159  void waitLanAnimationFrame(byte slot, uint16 frame);
160  void setTimerCallback(uint16 addr, uint16 frames);
161  void shakeScreen();
162  void displayCredits();
163  void fadeIn();
164  void fadeOut();
165  void wait(uint16 frames);
166 
168 
169  Resources *res;
170  Scene *scene;
171  Inventory *inventory;
172  MusicPlayer *music;
173  Dialog *dialog;
174 
175  void setMusic(byte id);
176 
177  void sayText(const Common::String &text, bool isSubtitle = false);
178  void stopTextToSpeech();
179  void setTTSVoice(CharacterID characterID) const;
180 #ifdef USE_TTS
181  Common::U32String convertText(const Common::String &text) const;
182 #endif
183 
184  Common::String _previousSaid;
185  uint16 _previousVoiceId;
186 
187 private:
188  void processObject();
189  bool trySelectedObject();
190 
191  bool _sceneBusy;
192  Action _action;
193  Object *_dstObject;
194 
195  Audio::AudioStream *_musicStream;
196  Audio::SoundHandle _musicHandle, _soundHandle, _voiceHandle;
197  const ADGameDescription *_gameDescription;
198 
199  uint _markDelay, _gameDelay;
200 
202 
203  void fnIntro();
204  void fnPoleClimbFail();
205  void fnGotAnchor();
206  void fnGetOutOfLake();
207  void fnGuardDrinking();
208  void fnEgoDefaultPosition();
209  void fnEnterCave();
210  void fnEgoScaredBySpider();
211  void fnMoveToLadderAndLeaveCellar();
212  void fnLeaveCellar();
213  void fnPutRockInHole();
214  void fnEgoBottomRightTurn();
215  bool fnCheckingDrawers();
216  void fnDrawerOpenMessage();
217  bool fnRobotSafeAlreadyUnlockedCheck();
218  void fnRobotSafeUnlockCheck();
219  bool fnMansionIntrusionAttempt();
220  void fnSecondMansionIntrusion();
221  void fnThirdMansionIntrusion();
222  void fnFourthMansionIntrusion();
223  void fnFifthMansionIntrusion();
224  void fnSixthMansionIntrusion();
225  void fnTooDark();
226  bool fnIsCookGone();
227  void fnEgoSuspiciousPosition();
228  void fnGivingFlowerToOldLady();
229  void fnGiveAnotherFlowerToOldLady();
230  void fnGivingFlowerToAnne();
231  void fnGiveAnotherFlowerToAnne();
232 };
233 
234 extern TeenAgentEngine *g_engine;
235 
236 } // End of namespace TeenAgent
237 
238 #endif
Definition: str.h:59
Definition: music.h:32
EngineFeature
Definition: engine.h:260
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: teenagent.h:104
Definition: error.h:81
Definition: array.h:52
Definition: advancedDetector.h:164
Definition: teenagent.h:94
Definition: random.h:44
Definition: display_client.h:58
Definition: pack.h:31
Definition: objects.h:158
Engine * g_engine
Definition: resources.h:1522
Definition: mixer.h:49
Definition: scene.h:129
Definition: ustr.h:57
Definition: algorithm.h:29
Definition: rect.h:144
Definition: audiostream.h:50
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: teenagent.h:103
Definition: actor.h:29
Definition: dialog.h:115
Definition: system.h:163
Definition: engine.h:146
Definition: system.h:38
Definition: inventory.h:141