ScummVM API documentation
standard.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 MTROPOLIS_PLUGIN_STANDARD_H
23 #define MTROPOLIS_PLUGIN_STANDARD_H
24 
25 #include "mtropolis/modifiers.h"
26 #include "mtropolis/modifier_factory.h"
27 #include "mtropolis/runtime.h"
28 #include "mtropolis/plugin/standard_data.h"
29 
30 namespace MTropolis {
31 
32 class Runtime;
33 
34 namespace Standard {
35 
36 class StandardPlugIn;
37 
38 class CursorModifier : public Modifier {
39 public:
41 
42  bool load(const PlugInModifierLoaderContext &context, const Data::Standard::CursorModifier &data);
43 
44  bool respondsToEvent(const Event &evt) const override;
45  VThreadState consumeMessage(Runtime *runtime, const Common::SharedPtr<MessageProperties> &msg) override;
46  void disable(Runtime *runtime) override;
47 
48 #ifdef MTROPOLIS_DEBUG_ENABLE
49  const char *debugGetTypeName() const override { return "Cursor Modifier"; }
50  SupportStatus debugGetSupportStatus() const override { return kSupportStatusDone; }
51 #endif
52 
53 private:
54  Common::SharedPtr<Modifier> shallowClone() const override;
55  const char *getDefaultName() const override;
56 
57  Event _applyWhen;
58  Event _removeWhen;
59  uint32 _cursorID;
60 };
61 
62 // This appears to be basically a duplicate of scene transition modifier, except unlike that,
63 // its parameters are controllable via script, and the duration scaling appears to be different
64 // (probably 600000 max rate instead of 6000000)
65 class STransCtModifier : public Modifier {
66 public:
67  static const int32 kMaxDuration = 600000;
68 
70 
71  bool load(const PlugInModifierLoaderContext &context, const Data::Standard::STransCtModifier &data);
72 
73  bool respondsToEvent(const Event &evt) const override;
74  VThreadState consumeMessage(Runtime *runtime, const Common::SharedPtr<MessageProperties> &msg) override;
75  void disable(Runtime *runtime) override;
76 
77  bool readAttribute(MiniscriptThread *thread, DynamicValue &result, const Common::String &attrib) override;
78  MiniscriptInstructionOutcome writeRefAttribute(MiniscriptThread *thread, DynamicValueWriteProxy &result, const Common::String &attrib) override;
79 
80 #ifdef MTROPOLIS_DEBUG_ENABLE
81  const char *debugGetTypeName() const override { return "STransCt Scene Transition Modifier"; }
82  SupportStatus debugGetSupportStatus() const override { return kSupportStatusDone; }
83 #endif
84 
85 private:
86  Common::SharedPtr<Modifier> shallowClone() const override;
87  const char *getDefaultName() const override;
88 
89  MiniscriptInstructionOutcome scriptSetRate(MiniscriptThread *thread, const DynamicValue &value);
90  MiniscriptInstructionOutcome scriptSetSteps(MiniscriptThread *thread, const DynamicValue &value);
91 
92  Event _enableWhen;
93  Event _disableWhen;
94 
95  int32 _transitionType;
96  int32 _transitionDirection;
97  int32 _steps;
98  int32 _duration;
99  bool _fullScreen;
100 };
101 
103 public:
106 
107  bool load(const PlugInModifierLoaderContext &context, const Data::Standard::MediaCueMessengerModifier &data);
108 
109  bool respondsToEvent(const Event &evt) const override;
110  VThreadState consumeMessage(Runtime *runtime, const Common::SharedPtr<MessageProperties> &msg) override;
111  void disable(Runtime *runtime) override;
112 
113  Modifier *getMediaCueModifier() override;
114  Common::WeakPtr<Modifier> getMediaCueTriggerSource() const override;
115 
116 #ifdef MTROPOLIS_DEBUG_ENABLE
117  const char *debugGetTypeName() const override { return "Media Cue Modifier"; }
118  SupportStatus debugGetSupportStatus() const override { return kSupportStatusDone; }
119 #endif
120 
121 private:
122  enum CueSourceType {
123  kCueSourceInteger,
124  kCueSourceIntegerRange,
125  kCueSourceVariableReference,
126  kCueSourceLabel,
127  kCueSourceString,
128 
129  kCueSourceInvalid = -1,
130  };
131 
132  union CueSourceUnion {
133  CueSourceUnion();
134  ~CueSourceUnion();
135 
136  int32 asInt;
137  IntRange asIntRange;
138  uint32 asVarRefGUID;
139  Label asLabel;
140  uint64 asUnset;
141  Common::String asString;
142 
143  template<class T, T (CueSourceUnion::*TMember)>
144  void construct(const T &value);
145 
146  template<class T, T(CueSourceUnion::*TMember)>
147  void destruct();
148  };
149 
151 
152  Common::SharedPtr<Modifier> shallowClone() const override;
153  const char *getDefaultName() const override;
154 
155  void linkInternalReferences(ObjectLinkingScope *scope) override;
156  void visitInternalReferences(IStructuralReferenceVisitor *visitor) override;
157 
158  CueSourceType _cueSourceType;
159  CueSourceUnion _cueSource;
160 
161  Common::WeakPtr<Modifier> _cueSourceModifier;
162 
163  Event _enableWhen;
164  Event _disableWhen;
165 
166  MediaCueState _mediaCue;
167  bool _isActive;
168 };
169 
171 public:
173 
175 
176  bool varSetValue(MiniscriptThread *thread, const DynamicValue &value) override;
177  void varGetValue(DynamicValue &dest) const override;
178 
179  bool readAttribute(MiniscriptThread *thread, DynamicValue &result, const Common::String &attrib) override;
180  MiniscriptInstructionOutcome writeRefAttribute(MiniscriptThread *thread, DynamicValueWriteProxy &result, const Common::String &attrib) override;
181 
182 #ifdef MTROPOLIS_DEBUG_ENABLE
183  const char *debugGetTypeName() const override { return "Object Reference Variable Modifier"; }
184  SupportStatus debugGetSupportStatus() const override { return kSupportStatusDone; }
185  void debugInspect(IDebugInspectionReport *report) const override;
186 #endif
187 
188 private:
189  struct ObjectWriteInterface {
190  static MiniscriptInstructionOutcome write(MiniscriptThread *thread, const DynamicValue &dest, void *objectRef, uintptr ptrOrOffset);
191  static MiniscriptInstructionOutcome refAttrib(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, void *objectRef, uintptr ptrOrOffset, const Common::String &attrib);
192  static MiniscriptInstructionOutcome refAttribIndexed(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, void *objectRef, uintptr ptrOrOffset, const Common::String &attrib, const DynamicValue &index);
193  };
194 
195  Common::SharedPtr<Modifier> shallowClone() const override;
196  const char *getDefaultName() const override;
197 
198  MiniscriptInstructionOutcome scriptSetPath(MiniscriptThread *thread, const DynamicValue &value);
199  MiniscriptInstructionOutcome scriptSetObject(MiniscriptThread *thread, const DynamicValue &value);
200  MiniscriptInstructionOutcome scriptObjectRefAttrib(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, const Common::String &attrib);
201  MiniscriptInstructionOutcome scriptObjectRefAttribIndexed(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, const Common::String &attrib, const DynamicValue &index);
202 
203  void resolve(Runtime *runtime);
204  void resolveRelativePath(Runtime *runtime, RuntimeObject *obj, const Common::String &path, size_t startPos);
205  void resolveAbsolutePath(Runtime *runtime);
206 
207  static bool computeObjectPath(RuntimeObject *obj, Common::String &outPath);
208  static RuntimeObject *getObjectParent(RuntimeObject *obj);
209 
210  Event _setToSourceParentWhen;
211 };
212 
214 public:
215  friend class ObjectReferenceVariableModifier;
216 
218 
219  Common::SharedPtr<ModifierSaveLoad> getSaveLoad(Runtime *runtime) override;
220 
221  Common::SharedPtr<VariableStorage> clone() const override;
222 
223 private:
224  class SaveLoad : public ModifierSaveLoad {
225  public:
226  explicit SaveLoad(ObjectReferenceVariableStorage *storage);
227 
228  private:
229  void commitLoad() const override;
230  void saveInternal(Common::WriteStream *stream) const override;
231  bool loadInternal(Common::ReadStream *stream, uint32 saveFileVersion) override;
232 
234  Common::String _objectPath;
235  };
236 
237  Common::String _fullPath;
238  Common::String _objectPath;
239  mutable ObjectReference _object;
240 };
241 
243 public:
244  friend class ListVariableModifier;
245 
247 
248  Common::SharedPtr<ModifierSaveLoad> getSaveLoad(Runtime *runtime) override;
249 
250  Common::SharedPtr<VariableStorage> clone() const override;
251 
252 private:
253  class SaveLoad : public ModifierSaveLoad {
254  public:
255  explicit SaveLoad(ListVariableStorage *storage);
256 
257  private:
258  void commitLoad() const override;
259  void saveInternal(Common::WriteStream *stream) const override;
260  bool loadInternal(Common::ReadStream *stream, uint32 saveFileVersion) override;
261 
262  static void recursiveWriteList(DynamicList *list, Common::WriteStream *stream);
263  static Common::SharedPtr<DynamicList> recursiveReadList(Common::ReadStream *stream);
264 
265  ListVariableStorage *_storage;
267  };
268 
270  DynamicValueTypes::DynamicValueType _preferredContentType;
271 };
272 
274 public:
276 
277  bool load(const PlugInModifierLoaderContext &context, const Data::Standard::ListVariableModifier &data);
278 
279  bool varSetValue(MiniscriptThread *thread, const DynamicValue &value) override;
280  void varGetValue(DynamicValue &dest) const override;
281 
282  bool isListVariable() const override;
283 
284  bool readAttribute(MiniscriptThread *thread, DynamicValue &result, const Common::String &attrib) override;
285  bool readAttributeIndexed(MiniscriptThread *thread, DynamicValue &result, const Common::String &attrib, const DynamicValue &index) override;
286  MiniscriptInstructionOutcome writeRefAttribute(MiniscriptThread *thread, DynamicValueWriteProxy &writeProxy, const Common::String &attrib) override;
287  MiniscriptInstructionOutcome writeRefAttributeIndexed(MiniscriptThread *thread, DynamicValueWriteProxy &writeProxy, const Common::String &attrib, const DynamicValue &index) override;
288 
289 #ifdef MTROPOLIS_DEBUG_ENABLE
290  const char *debugGetTypeName() const override { return "List Variable Modifier"; }
291  SupportStatus debugGetSupportStatus() const override { return kSupportStatusDone; }
292  void debugInspect(IDebugInspectionReport *report) const override;
293 #endif
294 
295 private:
296  MiniscriptInstructionOutcome scriptSetCount(MiniscriptThread *thread, const DynamicValue &value);
297 
298  Common::SharedPtr<Modifier> shallowClone() const override;
299  const char *getDefaultName() const override;
300 };
301 
302 class SysInfoModifier : public Modifier {
303 public:
304  bool load(const PlugInModifierLoaderContext &context, const Data::Standard::SysInfoModifier &data);
305 
306  bool readAttribute(MiniscriptThread *thread, DynamicValue &result, const Common::String &attrib) override;
307 
308  void disable(Runtime *runtime) override {}
309 
310 #ifdef MTROPOLIS_DEBUG_ENABLE
311  const char *debugGetTypeName() const override { return "System Info Modifier"; }
312 #endif
313 
314 private:
315  Common::SharedPtr<Modifier> shallowClone() const override;
316  const char *getDefaultName() const override;
317 };
318 
321 
322  // If list mod values are illegible, just ignore them and flag it as garbled.
323  // Necessary to load object 00788ab9 (olL437Check) in Obsidian, which is supposed to be a list of
324  // 4 lists that are 3-size each, in the persistent data, but actually contains 4 identical values
325  // that appear to be garbage.
326  bool allowGarbledListModData;
327 };
328 
329 class PanningModifier : public Modifier {
330 public:
331  PanningModifier();
332  ~PanningModifier();
333 
334  bool load(const PlugInModifierLoaderContext &context, const Data::Standard::PanningModifier &data);
335 
336  bool respondsToEvent(const Event &evt) const override;
337  VThreadState consumeMessage(Runtime *runtime, const Common::SharedPtr<MessageProperties> &msg) override;
338 
339  void disable(Runtime *runtime) override;
340 
341 #ifdef MTROPOLIS_DEBUG_ENABLE
342  const char *debugGetTypeName() const override { return "Panning Modifier"; }
343  void debugInspect(IDebugInspectionReport *report) const override;
344 #endif
345 
346 private:
347  Common::SharedPtr<Modifier> shallowClone() const override;
348  const char *getDefaultName() const override;
349 };
350 
351 class FadeModifier : public Modifier {
352 public:
353  FadeModifier();
354  ~FadeModifier();
355 
356  bool load(const PlugInModifierLoaderContext &context, const Data::Standard::FadeModifier &data);
357 
358  void disable(Runtime *runtime) override;
359 
360 #ifdef MTROPOLIS_DEBUG_ENABLE
361  const char *debugGetTypeName() const override { return "Fade Modifier"; }
362 #endif
363 
364 private:
365  Common::SharedPtr<Modifier> shallowClone() const override;
366  const char *getDefaultName() const override;
367 };
368 
369 
371 public:
372  StandardPlugIn();
373  ~StandardPlugIn();
374 
375  void registerModifiers(IPlugInModifierRegistrar *registrar) const override;
376 
377  const StandardPlugInHacks &getHacks() const;
378  StandardPlugInHacks &getHacks();
379 
380 private:
389 
390  StandardPlugInHacks _hacks;
391 };
392 
393 } // End of namespace Standard
394 
395 } // End of namespace MTropolis
396 
397 #endif
Definition: runtime.h:816
Definition: runtime.h:418
Definition: str.h:59
Definition: runtime.h:330
Definition: ptr.h:115
Definition: stream.h:77
Definition: runtime.h:2453
Definition: runtime.h:1594
Definition: standard_data.h:46
Definition: standard.h:302
Definition: runtime.h:2052
Definition: runtime.h:1185
Definition: runtime.h:3035
Definition: miniscript.h:421
Definition: modifier_factory.h:57
Definition: runtime.h:544
Definition: modifier_factory.h:48
Definition: runtime.h:369
Definition: runtime.h:351
Definition: runtime.h:1307
Definition: runtime.h:2118
Definition: standard.h:351
Definition: runtime.h:1180
Definition: debug.h:59
Definition: standard_data.h:128
Definition: runtime.h:3124
Definition: standard_data.h:133
Definition: standard.h:370
Definition: runtime.h:744
Definition: actions.h:25
Definition: standard.h:38
Definition: stream.h:385
Definition: standard_data.h:144
Definition: standard.h:65
Definition: runtime.h:3011
Definition: ptr.h:159
Definition: standard.h:329
Definition: standard_data.h:33
Definition: runtime.h:2448
Definition: runtime.h:3116