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  void destructCueSource();
153 
154  Common::SharedPtr<Modifier> shallowClone() const override;
155  const char *getDefaultName() const override;
156 
157  void linkInternalReferences(ObjectLinkingScope *scope) override;
158  void visitInternalReferences(IStructuralReferenceVisitor *visitor) override;
159 
160  CueSourceType _cueSourceType;
161  CueSourceUnion _cueSource;
162 
163  Common::WeakPtr<Modifier> _cueSourceModifier;
164 
165  Event _enableWhen;
166  Event _disableWhen;
167 
168  MediaCueState _mediaCue;
169  bool _isActive;
170 };
171 
173 public:
175 
177 
178  bool varSetValue(MiniscriptThread *thread, const DynamicValue &value) override;
179  void varGetValue(DynamicValue &dest) const override;
180 
181  bool readAttribute(MiniscriptThread *thread, DynamicValue &result, const Common::String &attrib) override;
182  MiniscriptInstructionOutcome writeRefAttribute(MiniscriptThread *thread, DynamicValueWriteProxy &result, const Common::String &attrib) override;
183 
184 #ifdef MTROPOLIS_DEBUG_ENABLE
185  const char *debugGetTypeName() const override { return "Object Reference Variable Modifier"; }
186  SupportStatus debugGetSupportStatus() const override { return kSupportStatusDone; }
187  void debugInspect(IDebugInspectionReport *report) const override;
188 #endif
189 
190 private:
191  struct ObjectWriteInterface {
192  static MiniscriptInstructionOutcome write(MiniscriptThread *thread, const DynamicValue &dest, void *objectRef, uintptr ptrOrOffset);
193  static MiniscriptInstructionOutcome refAttrib(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, void *objectRef, uintptr ptrOrOffset, const Common::String &attrib);
194  static MiniscriptInstructionOutcome refAttribIndexed(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, void *objectRef, uintptr ptrOrOffset, const Common::String &attrib, const DynamicValue &index);
195  };
196 
197  Common::SharedPtr<Modifier> shallowClone() const override;
198  const char *getDefaultName() const override;
199 
200  MiniscriptInstructionOutcome scriptSetPath(MiniscriptThread *thread, const DynamicValue &value);
201  MiniscriptInstructionOutcome scriptSetObject(MiniscriptThread *thread, const DynamicValue &value);
202  MiniscriptInstructionOutcome scriptObjectRefAttrib(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, const Common::String &attrib);
203  MiniscriptInstructionOutcome scriptObjectRefAttribIndexed(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, const Common::String &attrib, const DynamicValue &index);
204 
205  void resolve(Runtime *runtime);
206  void resolveRelativePath(Runtime *runtime, RuntimeObject *obj, const Common::String &path, size_t startPos);
207  void resolveAbsolutePath(Runtime *runtime);
208 
209  static bool computeObjectPath(RuntimeObject *obj, Common::String &outPath);
210  static RuntimeObject *getObjectParent(RuntimeObject *obj);
211 
212  Event _setToSourceParentWhen;
213 };
214 
216 public:
217  friend class ObjectReferenceVariableModifier;
218 
220 
221  Common::SharedPtr<ModifierSaveLoad> getSaveLoad(Runtime *runtime) override;
222 
223  Common::SharedPtr<VariableStorage> clone() const override;
224 
225 private:
226  class SaveLoad : public ModifierSaveLoad {
227  public:
228  explicit SaveLoad(ObjectReferenceVariableStorage *storage);
229 
230  private:
231  void commitLoad() const override;
232  void saveInternal(Common::WriteStream *stream) const override;
233  bool loadInternal(Common::ReadStream *stream, uint32 saveFileVersion) override;
234 
236  Common::String _objectPath;
237  };
238 
239  Common::String _fullPath;
240  Common::String _objectPath;
241  mutable ObjectReference _object;
242 };
243 
245 public:
246  friend class ListVariableModifier;
247 
249 
250  Common::SharedPtr<ModifierSaveLoad> getSaveLoad(Runtime *runtime) override;
251 
252  Common::SharedPtr<VariableStorage> clone() const override;
253 
254 private:
255  class SaveLoad : public ModifierSaveLoad {
256  public:
257  explicit SaveLoad(ListVariableStorage *storage);
258 
259  private:
260  void commitLoad() const override;
261  void saveInternal(Common::WriteStream *stream) const override;
262  bool loadInternal(Common::ReadStream *stream, uint32 saveFileVersion) override;
263 
264  static void recursiveWriteList(DynamicList *list, Common::WriteStream *stream);
265  static Common::SharedPtr<DynamicList> recursiveReadList(Common::ReadStream *stream);
266 
267  ListVariableStorage *_storage;
269  };
270 
272  DynamicValueTypes::DynamicValueType _preferredContentType;
273 };
274 
276 public:
278 
279  bool load(const PlugInModifierLoaderContext &context, const Data::Standard::ListVariableModifier &data);
280 
281  bool varSetValue(MiniscriptThread *thread, const DynamicValue &value) override;
282  void varGetValue(DynamicValue &dest) const override;
283 
284  bool isListVariable() const override;
285 
286  bool readAttribute(MiniscriptThread *thread, DynamicValue &result, const Common::String &attrib) override;
287  bool readAttributeIndexed(MiniscriptThread *thread, DynamicValue &result, const Common::String &attrib, const DynamicValue &index) override;
288  MiniscriptInstructionOutcome writeRefAttribute(MiniscriptThread *thread, DynamicValueWriteProxy &writeProxy, const Common::String &attrib) override;
289  MiniscriptInstructionOutcome writeRefAttributeIndexed(MiniscriptThread *thread, DynamicValueWriteProxy &writeProxy, const Common::String &attrib, const DynamicValue &index) override;
290 
291 #ifdef MTROPOLIS_DEBUG_ENABLE
292  const char *debugGetTypeName() const override { return "List Variable Modifier"; }
293  SupportStatus debugGetSupportStatus() const override { return kSupportStatusDone; }
294  void debugInspect(IDebugInspectionReport *report) const override;
295 #endif
296 
297 private:
298  MiniscriptInstructionOutcome scriptSetCount(MiniscriptThread *thread, const DynamicValue &value);
299 
300  Common::SharedPtr<Modifier> shallowClone() const override;
301  const char *getDefaultName() const override;
302 };
303 
304 class SysInfoModifier : public Modifier {
305 public:
306  bool load(const PlugInModifierLoaderContext &context, const Data::Standard::SysInfoModifier &data);
307 
308  bool readAttribute(MiniscriptThread *thread, DynamicValue &result, const Common::String &attrib) override;
309 
310  void disable(Runtime *runtime) override {}
311 
312 #ifdef MTROPOLIS_DEBUG_ENABLE
313  const char *debugGetTypeName() const override { return "System Info Modifier"; }
314 #endif
315 
316 private:
317  Common::SharedPtr<Modifier> shallowClone() const override;
318  const char *getDefaultName() const override;
319 };
320 
323 
324  // If list mod values are illegible, just ignore them and flag it as garbled.
325  // Necessary to load object 00788ab9 (olL437Check) in Obsidian, which is supposed to be a list of
326  // 4 lists that are 3-size each, in the persistent data, but actually contains 4 identical values
327  // that appear to be garbage.
328  bool allowGarbledListModData;
329 };
330 
331 class PanningModifier : public Modifier {
332 public:
333  PanningModifier();
334  ~PanningModifier();
335 
336  bool load(const PlugInModifierLoaderContext &context, const Data::Standard::PanningModifier &data);
337 
338  bool respondsToEvent(const Event &evt) const override;
339  VThreadState consumeMessage(Runtime *runtime, const Common::SharedPtr<MessageProperties> &msg) override;
340 
341  void disable(Runtime *runtime) override;
342 
343 #ifdef MTROPOLIS_DEBUG_ENABLE
344  const char *debugGetTypeName() const override { return "Panning Modifier"; }
345  void debugInspect(IDebugInspectionReport *report) const override;
346 #endif
347 
348 private:
349  Common::SharedPtr<Modifier> shallowClone() const override;
350  const char *getDefaultName() const override;
351 };
352 
353 class FadeModifier : public Modifier {
354 public:
355  FadeModifier();
356  ~FadeModifier();
357 
358  bool load(const PlugInModifierLoaderContext &context, const Data::Standard::FadeModifier &data);
359 
360  void disable(Runtime *runtime) override;
361 
362 #ifdef MTROPOLIS_DEBUG_ENABLE
363  const char *debugGetTypeName() const override { return "Fade Modifier"; }
364 #endif
365 
366 private:
367  Common::SharedPtr<Modifier> shallowClone() const override;
368  const char *getDefaultName() const override;
369 };
370 
371 class PrintModifier : public Modifier {
372 public:
373  PrintModifier();
374  ~PrintModifier();
375 
376  bool respondsToEvent(const Event &evt) const override;
377  VThreadState consumeMessage(Runtime *runtime, const Common::SharedPtr<MessageProperties> &msg) override;
378  void disable(Runtime *runtime) override;
379 
380  MiniscriptInstructionOutcome writeRefAttribute(MiniscriptThread *thread, DynamicValueWriteProxy &writeProxy, const Common::String &attrib) override;
381 
382  bool load(const PlugInModifierLoaderContext &context, const Data::Standard::PrintModifier &data);
383 
384 #ifdef MTROPOLIS_DEBUG_ENABLE
385  const char *debugGetTypeName() const override { return "Print Modifier"; }
386  void debugInspect(IDebugInspectionReport *report) const override;
387 #endif
388 
389 private:
390  Common::SharedPtr<Modifier> shallowClone() const override;
391  const char *getDefaultName() const override;
392 
393  Event _executeWhen;
394  Common::String _filePath;
395 };
396 
397 class NavigateModifier : public Modifier {
398 public:
400  ~NavigateModifier();
401 
402  bool load(const PlugInModifierLoaderContext &context, const Data::Standard::NavigateModifier &data);
403 
404  bool respondsToEvent(const Event &evt) const override;
405  VThreadState consumeMessage(Runtime *runtime, const Common::SharedPtr<MessageProperties> &msg) override;
406 
407  void disable(Runtime *runtime) override;
408 
409 #ifdef MTROPOLIS_DEBUG_ENABLE
410  const char *debugGetTypeName() const override { return "Navigate Modifier"; }
411  void debugInspect(IDebugInspectionReport *report) const override;
412 #endif
413 
414 private:
415  Common::SharedPtr<Modifier> shallowClone() const override;
416  const char *getDefaultName() const override;
417 };
418 
419 class OpenTitleModifier : public Modifier {
420 public:
423 
424  bool load(const PlugInModifierLoaderContext &context, const Data::Standard::OpenTitleModifier &data);
425 
426  bool respondsToEvent(const Event &evt) const override;
427  VThreadState consumeMessage(Runtime *runtime, const Common::SharedPtr<MessageProperties> &msg) override;
428 
429  void disable(Runtime *runtime) override;
430 
431 #ifdef MTROPOLIS_DEBUG_ENABLE
432  const char *debugGetTypeName() const override { return "Open Title Modifier"; }
433  void debugInspect(IDebugInspectionReport *report) const override;
434 #endif
435 
436 private:
437  Common::SharedPtr<Modifier> shallowClone() const override;
438  const char *getDefaultName() const override;
439 
440  Event _executeWhen;
441  Common::String _pathOrUrl;
442  bool _addToReturnList;
443 };
444 
446 public:
447  StandardPlugIn();
448  ~StandardPlugIn();
449 
450  void registerModifiers(IPlugInModifierRegistrar *registrar) const override;
451 
452  const StandardPlugInHacks &getHacks() const;
453  StandardPlugInHacks &getHacks();
454 
455 private:
467 
468  StandardPlugInHacks _hacks;
469 };
470 
471 } // End of namespace Standard
472 
473 } // End of namespace MTropolis
474 
475 #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: standard_data.h:172
Definition: standard.h:419
Definition: runtime.h:1575
Definition: standard_data.h:46
Definition: standard.h:304
Definition: runtime.h:2052
Definition: standard_data.h:167
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:353
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:445
Definition: runtime.h:744
Definition: actions.h:25
Definition: standard.h:38
Definition: standard.h:397
Definition: stream.h:385
Definition: standard_data.h:144
Definition: standard.h:65
Definition: runtime.h:3011
Definition: ptr.h:159
Definition: standard.h:331
Definition: standard.h:371
Definition: standard_data.h:33
Definition: runtime.h:2448
Definition: runtime.h:3116
Definition: standard_data.h:155