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 // Engine Debug Flags
66 enum {
67  kDebugActor = (1 << 0),
68  kDebugAnimation = (1 << 1),
69  kDebugCallbacks = (1 << 2),
70  kDebugDialog = (1 << 3),
71  kDebugFont = (1 << 4),
72  kDebugInventory = (1 << 5),
73  kDebugMusic = (1 << 6),
74  kDebugObject = (1 << 7),
75  kDebugPack = (1 << 8),
76  kDebugScene = (1 << 9),
77  kDebugSurface = (1 << 10)
78 };
79 
80 const uint16 kScreenWidth = 320;
81 const uint16 kScreenHeight = 200;
82 
83 class TeenAgentEngine : public Engine {
84 public:
85  TeenAgentEngine(OSystem *system, const ADGameDescription *gd);
86  ~TeenAgentEngine();
87 
88  Common::Error run() override;
89  Common::String getSaveStateName(int slot) const override;
90  Common::Error loadGameState(int slot) override;
91  Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave = false) override;
92  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override { return true; }
93  bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override { return !_sceneBusy; }
94  bool hasFeature(EngineFeature f) const override;
95 
96  void init();
97 
98  enum Action { kActionNone, kActionExamine, kActionUse };
99 
100  void examine(const Common::Point &point, Object *object);
101  void use(Object *object);
102  inline void cancel() { _action = kActionNone; }
103 
104  bool processCallback(uint16 addr);
105  inline Scene *getScene() { return scene; }
106 
107  bool showLogo();
108  bool showCDLogo();
109  bool showMetropolis();
110  int skipEvents() const;
111 
112  Common::String parseMessage(uint16 addr);
113 
114  //event driven:
115  void displayMessage(uint16 addr, byte color = textColorMark, uint16 x = 0, uint16 y = 0);
116  void displayMessage(const Common::String &str, byte color = textColorMark, uint16 x = 0, uint16 y = 0);
117  void displayAsyncMessage(uint16 addr, uint16 x, uint16 y, uint16 firstFrame, uint16 lastFrame, byte color = textColorMark);
118  void displayAsyncMessageInSlot(uint16 addr, byte slot, uint16 firstFrame, uint16 lastFrame, byte color = textColorMark);
119  void displayCredits(uint16 addr, uint16 timer = 0);
120  void displayCutsceneMessage(uint16 addr, uint16 x, uint16 y);
121  void moveTo(const Common::Point &dst, byte o, bool warp = false);
122  void moveTo(uint16 x, uint16 y, byte o, bool warp = false);
123  void moveTo(Object *obj);
124  void moveRel(int16 x, int16 y, byte o, bool warp = false);
125  void playActorAnimation(uint16 id, bool async = false, bool ignore = false);
126  void playAnimation(uint16 id, byte slot, bool async = false, bool ignore = false, bool loop = false);
127  void loadScene(byte id, const Common::Point &pos, byte o = 0);
128  void loadScene(byte id, uint16 x, uint16 y, byte o = 0);
129  void enableOn(bool enable = true);
130  void setOns(byte id, byte value, byte sceneId = 0);
131  void setLan(byte id, byte value, byte sceneId = 0);
132  void setFlag(uint16 addr, byte value);
133  byte getFlag(uint16 addr);
134  void reloadLan();
135  void rejectMessage();
136 
137  void playMusic(byte id); //schedules play
138  void playSound(byte id, byte skipFrames);
139  void playSoundNow(Pack *pack, byte id);
140  void enableObject(byte id, byte sceneId = 0);
141  void disableObject(byte id, byte sceneId = 0);
142  void hideActor();
143  void showActor();
144  void waitAnimation();
145  void waitLanAnimationFrame(byte slot, uint16 frame);
146  void setTimerCallback(uint16 addr, uint16 frames);
147  void shakeScreen();
148  void displayCredits();
149  void fadeIn();
150  void fadeOut();
151  void wait(uint16 frames);
152 
154 
155  Resources *res;
156  Scene *scene;
157  Inventory *inventory;
158  MusicPlayer *music;
159  Dialog *dialog;
160 
161  void setMusic(byte id);
162 
163 private:
164  void processObject();
165  bool trySelectedObject();
166 
167  bool _sceneBusy;
168  Action _action;
169  Object *_dstObject;
170 
171  Audio::AudioStream *_musicStream;
172  Audio::SoundHandle _musicHandle, _soundHandle;
173  const ADGameDescription *_gameDescription;
174 
175  uint _markDelay, _gameDelay;
176 
178 
179  void fnIntro();
180  void fnPoleClimbFail();
181  void fnGotAnchor();
182  void fnGetOutOfLake();
183  void fnGuardDrinking();
184  void fnEgoDefaultPosition();
185  void fnEnterCave();
186  void fnEgoScaredBySpider();
187  void fnMoveToLadderAndLeaveCellar();
188  void fnLeaveCellar();
189  void fnPutRockInHole();
190  void fnEgoBottomRightTurn();
191  bool fnCheckingDrawers();
192  void fnDrawerOpenMessage();
193  bool fnRobotSafeAlreadyUnlockedCheck();
194  void fnRobotSafeUnlockCheck();
195  bool fnMansionIntrusionAttempt();
196  void fnSecondMansionIntrusion();
197  void fnThirdMansionIntrusion();
198  void fnFourthMansionIntrusion();
199  void fnFifthMansionIntrusion();
200  void fnSixthMansionIntrusion();
201  void fnTooDark();
202  bool fnIsCookGone();
203  void fnEgoSuspiciousPosition();
204  void fnGivingFlowerToOldLady();
205  void fnGiveAnotherFlowerToOldLady();
206  void fnGivingFlowerToAnne();
207  void fnGiveAnotherFlowerToAnne();
208 };
209 
210 } // End of namespace TeenAgent
211 
212 #endif
Definition: str.h:59
Definition: music.h:32
EngineFeature
Definition: engine.h:250
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: teenagent.h:93
Definition: error.h:84
Definition: array.h:52
Definition: advancedDetector.h:120
Definition: teenagent.h:83
Definition: random.h:44
Definition: display_client.h:58
Definition: pack.h:31
Definition: objects.h:158
Definition: resources.h:1163
Definition: mixer.h:49
Definition: scene.h:126
Definition: ustr.h:57
Definition: algorithm.h:29
Definition: rect.h:45
Definition: audiostream.h:50
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: teenagent.h:92
Definition: actor.h:29
Definition: dialog.h:59
Definition: system.h:167
Definition: engine.h:143
Definition: system.h:37
Definition: inventory.h:139