ScummVM API documentation
script.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 STARK_RESOURCES_SCRIPT_H
23 #define STARK_RESOURCES_SCRIPT_H
24 
25 #include "common/str.h"
26 
27 #include "engines/stark/resources/object.h"
28 
29 namespace Stark {
30 
31 namespace Formats {
32 class XRCReadStream;
33 }
34 
35 namespace Resources {
36 
37 class Command;
38 
45 class Script : public Object {
46 public:
47  static const Type::ResourceType TYPE = Type::kScript;
48 
49  enum SubType {
50  kSubTypeGameEvent = 4,
51  kSubTypePlayerAction = 5,
52  kSubTypeDialog = 6
53  };
54 
55  enum ScriptType {
56  kScriptTypeOnGameEvent = 0,
57  kScriptTypePassiveDialog = 1,
58  kScriptTypeOnPlayerAction = 2,
59  kScriptType3 = 3,
60  kScriptType4 = 4
61  };
62 
63  enum GameEvent {
64  kGameEventOnGameLoop = 0,
65  kGameEventOnEnterLocation = 1,
66  kGameEventOnExitLocation = 2
67  };
68 
76  enum CallMode {
77  kCallModeGameLoop = 1,
78  kCallModeExitLocation = 2,
79  kCallModeEnterLocation = 3,
80  kCallModePlayerAction = 4,
81  kCallModeDialogCreateSelections = 5,
82  kCallModeDialogAnswer = 6
83  };
84 
85  enum ResumeStatus {
86  kResumeComplete,
87  kResumeAbort,
88  kResumeSuspend
89  };
90 
91  Script(Object *parent, byte subType, uint16 index, const Common::String &name);
92  virtual ~Script();
93 
94  // Resource API
95  void readData(Formats::XRCReadStream *stream) override;
96  void saveLoad(ResourceSerializer *serializer) override;
97  void saveLoadCurrent(ResourceSerializer *serializer) override;
98  void onAllLoaded() override;
99  void onGameLoop() override;
100 
102  void reset();
103 
105  bool isEnabled();
106 
108  void enable(bool value);
109 
111  void stop();
112 
114  bool isOnBegin();
115 
117  bool isOnEnd();
118 
120  Command *getBeginCommand();
121 
123  void execute(uint32 callMode);
124 
126  void pause(int32 msecs);
127 
129  void suspend(Object *cause);
130 
132  bool isSuspended();
133 
135  Object *getSuspendingResource() const;
136 
138  bool shouldExecute(uint32 callMode);
139 
141  void goToNextCommand();
142 
148  void addReturnObject(Object *object);
149 
151  void setResumeStatus(ResumeStatus status);
152 
153 protected:
154  void print(uint depth) override;
155  void printData() override;
156 
157  void updateSuspended();
158 
159  void resumeCallerExecution(Object *callerObject);
160 
161  uint32 _scriptType;
162  uint32 _runEvent;
163  uint32 _minChapter;
164  uint32 _maxChapter;
165  bool _shouldResetGameSpeed;
166 
167  bool _enabled;
168  Command *_nextCommand;
169 
170  int32 _pauseTimeLeft;
171  Object *_suspendingResource;
172  ResumeStatus _resumeStatus;
173 
174  Common::Array<Object *> _returnObjects;
175 };
176 
177 } // End of namespace Resources
178 } // End of namespace Stark
179 
180 #endif // STARK_RESOURCES_SCRIPT_H
Definition: str.h:59
Definition: console.h:27
Definition: object.h:143
Definition: command.h:51
Definition: xrc.h:45
Definition: stateprovider.h:51
CallMode
Definition: script.h:76
Definition: script.h:45