ScummVM API documentation
runtime.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_RUNTIME_H
23#define MTROPOLIS_RUNTIME_H
24
25#include "common/archive.h"
26#include "common/array.h"
27#include "common/events.h"
28#include "common/language.h"
29#include "common/platform.h"
30#include "common/ptr.h"
31#include "common/stream.h"
32#include "common/hashmap.h"
33#include "common/hash-str.h"
34
35#include "graphics/pixelformat.h"
36
37#include "mtropolis/actions.h"
38#include "mtropolis/core.h"
39#include "mtropolis/coroutine_protos.h"
40#include "mtropolis/data.h"
41#include "mtropolis/debug.h"
42#include "mtropolis/hacks.h"
43#include "mtropolis/miniscript_protos.h"
44#include "mtropolis/subtitles.h"
45#include "mtropolis/vthread.h"
46
47class OSystem;
48
49namespace Audio {
50
51class Mixer;
52
53} // End of namespace Audio
54
55namespace Common {
56
57class RandomSource;
58
59} // End of namespace Common
60
61namespace Graphics {
62
63struct WinCursorGroup;
64class MacCursor;
65class MacFontManager;
66class ManagedSurface;
67class Cursor;
68struct PixelFormat;
69struct Surface;
70
71} // End of namespace Graphics
72
73namespace MTropolis {
74
75class Asset;
76class AssetManagerInterface;
77class CoroutineManager;
78class CursorGraphic;
79class CursorGraphicCollection;
80class Element;
81class GraphicModifier;
82class KeyboardInputEvent;
83class MessageDispatch;
84class MiniscriptThread;
85class Modifier;
86class ObjectLinkingScope;
87class PlugInModifier;
88class RuntimeObject;
89class PlugIn;
90class Project;
91class Runtime;
92class Structural;
93class SystemInterface;
94class VisualElement;
95class Window;
96class WorldManagerInterface;
97struct DynamicValue;
98struct DynamicValueWriteProxy;
99struct IBoundaryDetector;
100struct ICollider;
101struct ILoadUIProvider;
102struct IMessageConsumer;
103struct IModifierContainer;
104struct IPlugInModifierFactory;
105struct IPlugInModifierFactoryAndDataFactory;
106struct IPostEffect;
107struct ISaveUIProvider;
108struct ISaveWriter;
109struct IStructuralReferenceVisitor;
110struct MessageProperties;
111struct ModifierLoaderContext;
112struct PlugInModifierLoaderContext;
113struct SIModifierFactory;
114template<typename TElement, typename TElementData> class ElementFactory;
115
116#ifdef MTROPOLIS_DEBUG_ENABLE
118#endif
119
120char invariantToLower(char c);
121Common::String toCaseInsensitive(const Common::String &str);
122bool caseInsensitiveEqual(const Common::String &str1, const Common::String &str2);
123size_t caseInsensitiveFind(const Common::String &stringToSearch, const Common::String &stringToFind);
124
125enum ColorDepthMode {
126 kColorDepthMode1Bit,
127 kColorDepthMode2Bit,
128 kColorDepthMode4Bit,
129 kColorDepthMode8Bit,
130 kColorDepthMode16Bit,
131 kColorDepthMode32Bit,
132
133 kColorDepthModeCount,
134
135 kColorDepthModeInvalid,
136};
137
138namespace SceneTransitionTypes {
139
140enum SceneTransitionType {
141 kNone,
142 kPatternDissolve,
143 kRandomDissolve, // No steps
144 kFade,
145 kSlide, // Directional
146 kPush, // Directional
147 kZoom,
148 kWipe, // Directional
149};
150
151bool loadFromData(SceneTransitionType &transType, int32 data);
152
153} // End of namespace SceneTransitionTypes
154
155namespace SceneTransitionDirections {
156
157enum SceneTransitionDirection {
158 kUp,
159 kDown,
160 kLeft,
161 kRight,
162};
163
164bool loadFromData(SceneTransitionDirection &transDir, int32 data);
165
166} // End of namespace SceneTransitionDirections
167
168enum ConstraintDirection {
169 kConstraintDirectionNone,
170 kConstraintDirectionHorizontal,
171 kConstraintDirectionVertical,
172};
173
174enum MouseInteractivityTestType {
175 kMouseInteractivityTestAnything,
176 kMouseInteractivityTestMouseClick,
177};
178
179namespace DynamicValueSourceTypes {
180 enum DynamicValueSourceType {
181 kInvalid,
182
183 kConstant,
184 kVariableReference,
185 kIncomingData,
186 };
187}
188
189namespace DynamicValueTypes {
190
191// These values are stored in the saved game format, so they must be stable
192enum DynamicValueType {
193 kInvalid = 0,
194
195 kNull = 1,
196 kInteger = 2,
197 kFloat = 3,
198 kPoint = 4,
199 kIntegerRange = 5,
200 kBoolean = 6,
201 kVector = 7,
202 kLabel = 8,
203 kEvent = 9,
204
205 kString = 12,
206 kList = 13,
207 kObject = 14,
208 kWriteProxy = 15,
209
210 kUnspecified = 16,
211};
212
213} // End of namespace DynamicValuesTypes
214
215namespace AttributeIDs {
216
217enum AttributeID {
218 kAttribCache = 55,
219 kAttribDirect = 56,
220 kAttribVisible = 58,
221 kAttribLayer = 24,
222 kAttribPaused = 25,
223 kAttribLoop = 57,
224 kAttribPosition = 1,
225 kAttribWidth = 2,
226 kAttribHeight = 3,
227 kAttribRate = 4,
228 kAttribRange = 5,
229 kAttribCel = 6,
230 kAttribLoopBackForth = 59,
231 kAttribPlayEveryFrame = 60,
232 kAttribTimeValue = 16,
233 kAttribTrackDisable = 51,
234 kAttribTrackEnable = 50,
235 kAttribVolume = 13,
236 kAttribBalance = 26,
237 kAttribText = 7,
238 kAttribMasterVolume = 18,
239 kAttribUserTimeout = 19,
240};
241
242} // End of namespace AttributeIDs
243
244namespace EventIDs {
245
246enum EventID {
247 kNothing = 0,
248
249 kElementEnableEdit = 207,
250 kElementDisableEdit = 220,
251 kElementSelect = 209,
252 kElementDeselect = 210,
253 kElementToggleSelect = 213,
254 kElementUpdatedCalculated = 219,
255 kElementShow = 222,
256 kElementHide = 223,
257
258 kElementScrollUp = 1001,
259 kElementScrollDown = 1002,
260 kElementScrollRight = 1005,
261 kElementScrollLeft = 1006,
262
263 kMotionStarted = 501,
264 kMotionEnded = 502,
265
266 kTransitionStarted = 503,
267 kTransitionEnded = 504,
268
269 kMouseDown = 301,
270 kMouseUp = 302,
271 kMouseOver = 303,
272 kMouseOutside = 304,
273 kMouseTrackedInside = 305,
274 kMouseTrackedOutside = 306,
275 kMouseTracking = 307,
276 kMouseUpInside = 309,
277 kMouseUpOutside = 310,
278
279 kSceneStarted = 101,
280 kSceneEnded = 102,
281 kSceneDeactivated = 103,
282 kSceneReactivated = 104,
283 kSceneTransitionEnded = 506,
284
285 kSharedSceneReturnedToScene = 401,
286 kSharedSceneSceneChanged = 402,
287 kSharedSceneNoNextScene = 403,
288 kSharedSceneNoPrevScene = 404,
289
290 kParentEnabled = 2001,
291 kParentDisabled = 2002,
292 kParentChanged = 227,
293
294 kPreloadMedia = 1701,
295 kFlushMedia = 1703,
296 kPrerollMedia = 1704,
297
298 kCloseProject = 1601,
299
300 kUserTimeout = 1801,
301 kProjectStarted = 1802,
302 kProjectEnded = 1803,
303 kFlushAllMedia = 1804,
304
305 kAttribGet = 1300,
306 kAttribSet = 1200,
307
308 kClone = 226,
309 kKill = 228,
310
311 kPlay = 201,
312 kStop = 202,
313 kPause = 801,
314 kUnpause = 802,
315 kTogglePause = 803,
316 kAtFirstCel = 804,
317 kAtLastCel = 805,
318
319
320 kAuthorMessage = 900,
321};
322
323bool isCommand(EventID eventID);
324
325} // End of namespace EventIDs
326
327MiniscriptInstructionOutcome pointWriteRefAttrib(Common::Point &point, MiniscriptThread *thread, DynamicValueWriteProxy &proxy, const Common::String &attrib);
328Common::String pointToString(const Common::Point &point);
329
330struct IntRange {
331 IntRange();
332 IntRange(int32 pmin, int32 pmax);
333
334 int32 min;
335 int32 max;
336
337 bool load(const Data::IntRange &range);
338
339 inline bool operator==(const IntRange &other) const {
340 return min == other.min && max == other.max;
341 }
342
343 inline bool operator!=(const IntRange &other) const {
344 return !((*this) == other);
345 }
346
347 MiniscriptInstructionOutcome refAttrib(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, const Common::String &attrib);
348 Common::String toString() const;
349};
350
351struct Label {
352 Label();
353 Label(int32 psuperGroupID, int32 pid);
354
355 uint32 superGroupID;
356 uint32 id;
357
358 bool load(const Data::Label &label);
359
360 inline bool operator==(const Label &other) const {
361 return superGroupID == other.superGroupID && id == other.id;
362 }
363
364 inline bool operator!=(const Label &other) const {
365 return !((*this) == other);
366 }
367};
368
369struct Event {
370 Event();
371 Event(EventIDs::EventID peventType, uint32 peventInfo);
372
373 EventIDs::EventID eventType;
374 uint32 eventInfo;
375
376 // Returns true if this event, interpreted as a filter, recognizes another event.
377 // Handles cases where eventInfo is ignored (hopefully).
378 bool respondsTo(const Event &otherEvent) const;
379
380 bool load(const Data::Event &data);
381
382 inline bool operator==(const Event &other) const {
383 return eventType == other.eventType && eventInfo == other.eventInfo;
384 }
385
386 inline bool operator!=(const Event &other) const {
387 return !((*this) == other);
388 }
389};
390
392 VarReference();
393 VarReference(uint32 pguid, const Common::String &psource);
394
395 uint32 guid;
396 Common::String source;
397 Common::WeakPtr<Modifier> resolution; // NOTE: This may not be a variable
398
399 inline bool operator==(const VarReference &other) const {
400 return guid == other.guid && source == other.source;
401 }
402
403 inline bool operator!=(const VarReference &other) const {
404 return !((*this) == other);
405 }
406
407 bool resolve(Structural *structuralScope, Common::WeakPtr<RuntimeObject> &outObject) const;
408 bool resolve(Modifier *modifierScope, Common::WeakPtr<RuntimeObject> &outObject) const;
409
410 void linkInternalReferences(ObjectLinkingScope *scope);
411 void visitInternalReferences(IStructuralReferenceVisitor *visitor);
412
413private:
414 bool resolveContainer(IModifierContainer *modifierContainer, Common::WeakPtr<RuntimeObject> &outObject) const;
415 bool resolveSingleModifier(Modifier *modifier, Common::WeakPtr<RuntimeObject> &outObject) const;
416};
417
420
421 inline ObjectReference() {
422 }
423
424 inline explicit ObjectReference(const Common::WeakPtr<RuntimeObject> &objectPtr) : object(objectPtr) {
425 }
426
427 inline bool operator==(const ObjectReference &other) const {
428 return !object.owner_before(other.object) && !other.object.owner_before(object);
429 }
430
431 inline bool operator!=(const ObjectReference &other) const {
432 return !((*this) == other);
433 }
434
435 inline void reset() {
436 object.reset();
437 }
438};
439
442
443 double angleDegrees; // These are stored as radians in the data but scripts treat them as degrees so it's just pointless constantly doing conversion...
444 double magnitude;
445
446 inline bool operator==(const AngleMagVector &other) const {
447 return angleDegrees == other.angleDegrees && magnitude == other.magnitude;
448 }
449
450 inline bool operator!=(const AngleMagVector &other) const {
451 return !((*this) == other);
452 }
453
454 inline static AngleMagVector createRadians(double angleRadians, double magnitude) {
455 return AngleMagVector(angleRadians * (180.0 / M_PI), magnitude);
456 }
457
458 inline static AngleMagVector createDegrees(double angleDegrees, double magnitude) {
459 return AngleMagVector(angleDegrees, magnitude);
460 }
461
462 MiniscriptInstructionOutcome refAttrib(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, const Common::String &attrib);
463 Common::String toString() const;
464
465private:
466 AngleMagVector(double angleDegrees, double magnitude);
467};
468
469struct ColorRGB8 {
470 ColorRGB8();
471 ColorRGB8(uint8 pr, uint8 pg, uint8 pb);
472
473 uint8 r;
474 uint8 g;
475 uint8 b;
476
477 bool load(const Data::ColorRGB16 &color);
478
479 inline bool operator==(const ColorRGB8 &other) const {
480 return r == other.r && g == other.g && b == other.b;
481 }
482
483 inline bool operator!=(const ColorRGB8 &other) const {
484 return !((*this) == other);
485 }
486};
487
489 MessageFlags();
490
491 bool relay : 1;
492 bool cascade : 1;
493 bool immediate : 1;
494};
495
496struct DynamicValue;
497struct DynamicList;
498
499// This should be an interface, but since this exists to make global singletons that JUST supply a vtable,
500// GCC complains about there being a global destructor, unless we delete the destructor, in which case
501// it complains about a class having virtual functions but not having a virtual destructor, so we have to
502// do this dispatch table stuff just to make GCC be quiet.
504 typedef MiniscriptInstructionOutcome (*writeFunc_t)(MiniscriptThread *thread, const DynamicValue &dest, void *objectRef, uintptr ptrOrOffset);
505 typedef MiniscriptInstructionOutcome (*refAttribFunc_t)(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, void *objectRef, uintptr ptrOrOffset, const Common::String &attrib);
506 typedef MiniscriptInstructionOutcome (*refAttribIndexedFunc_t)(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, void *objectRef, uintptr ptrOrOffset, const Common::String &attrib, const DynamicValue &index);
507
508 writeFunc_t write;
509 refAttribFunc_t refAttrib;
510 refAttribIndexedFunc_t refAttribIndexed;
511};
512
513template<class T>
515public:
516 static const DynamicValueWriteInterface *getInstance();
517
518private:
519 static DynamicValueWriteInterface _instance;
520};
521
522template<class T>
524 return &_instance;
525}
526
527template<class T>
528DynamicValueWriteInterface DynamicValueWriteInterfaceGlue<T>::_instance = {
529 static_cast<DynamicValueWriteInterface::writeFunc_t>(T::write),
530 static_cast<DynamicValueWriteInterface::refAttribFunc_t>(T::refAttrib),
531 static_cast<DynamicValueWriteInterface::refAttribIndexedFunc_t>(T::refAttribIndexed),
532};
533
534
535
537 uintptr ptrOrOffset;
538 void *objectRef;
540
541 static DynamicValueWriteProxyPOD createDefault();
542};
543
546
548 Common::SharedPtr<DynamicList> containerList;
549};
550
552 int16 x;
553 int16 y;
554
555 Common::Point toScummVMPoint() const;
556};
557
558
560public:
562 virtual bool setAtIndex(size_t index, const DynamicValue &dynValue) = 0;
563 virtual bool getAtIndex(size_t index, DynamicValue &dynValue) const = 0;
564 virtual void truncateToSize(size_t sz) = 0;
565 virtual bool expandToMinimumSize(size_t sz) = 0;
566 virtual void setFrom(const DynamicListContainerBase &other) = 0; // Only supports setting same type!
567 virtual const void *getConstArrayPtr() const = 0;
568 virtual void *getArrayPtr() = 0;
569 virtual size_t getSize() const = 0;
570 virtual bool compareEqual(const DynamicListContainerBase &other) const = 0;
571 virtual DynamicListContainerBase *clone() const = 0;
572};
573
575 static void defaultSet(int32 &value);
576 static void defaultSet(double &value);
577 static void defaultSet(Common::Point &value);
578 static void defaultSet(IntRange &value);
579 static void defaultSet(bool &value);
580 static void defaultSet(AngleMagVector &value);
581 static void defaultSet(Label &value);
582 static void defaultSet(Event &value);
583 static void defaultSet(Common::String &value);
584 static void defaultSet(Common::SharedPtr<DynamicList> &value);
585 static void defaultSet(ObjectReference &value);
586};
587
588template<class T>
590 typedef T DynamicValuePODType_t;
591
592 static const T &dereference(const T *source) { return *source; }
593};
594
596 static bool importValue(const DynamicValue &dynValue, const int32 *&outPtr);
597 static bool importValue(const DynamicValue &dynValue, const double *&outPtr);
598 static bool importValue(const DynamicValue &dynValue, const Common::Point *&outPtr);
599 static bool importValue(const DynamicValue &dynValue, const IntRange *&outPtr);
600 static bool importValue(const DynamicValue &dynValue, const bool *&outPtr);
601 static bool importValue(const DynamicValue &dynValue, const AngleMagVector *&outPtr);
602 static bool importValue(const DynamicValue &dynValue, const Label *&outPtr);
603 static bool importValue(const DynamicValue &dynValue, const Event *&outPtr);
604 static bool importValue(const DynamicValue &dynValue, const Common::String *&outPtr);
605 static bool importValue(const DynamicValue &dynValue, const Common::SharedPtr<DynamicList> *&outPtr);
606 static bool importValue(const DynamicValue &dynValue, const ObjectReference *&outPtr);
607};
608
610 static void exportValue(DynamicValue &dynValue, const int32 &value);
611 static void exportValue(DynamicValue &dynValue, const double &value);
612 static void exportValue(DynamicValue &dynValue, const Common::Point &value);
613 static void exportValue(DynamicValue &dynValue, const IntRange &value);
614 static void exportValue(DynamicValue &dynValue, const bool &value);
615 static void exportValue(DynamicValue &dynValue, const AngleMagVector &value);
616 static void exportValue(DynamicValue &dynValue, const Label &value);
617 static void exportValue(DynamicValue &dynValue, const Event &value);
618 static void exportValue(DynamicValue &dynValue, const Common::String &value);
619 static void exportValue(DynamicValue &dynValue, const Common::SharedPtr<DynamicList> &value);
620 static void exportValue(DynamicValue &dynValue, const ObjectReference &value);
621};
622
623template<class T>
625public:
626 bool setAtIndex(size_t index, const DynamicValue &dynValue) override;
627 bool getAtIndex(size_t index, DynamicValue &dynValue) const override;
628 void truncateToSize(size_t sz) override;
629 bool expandToMinimumSize(size_t sz) override;
630 void setFrom(const DynamicListContainerBase &other) override;
631 const void *getConstArrayPtr() const override;
632 void *getArrayPtr() override;
633 size_t getSize() const override;
634 bool compareEqual(const DynamicListContainerBase &other) const override;
635 DynamicListContainerBase *clone() const override;
636
637private:
638 Common::Array<T> _array;
639};
640
641template<>
643public:
645
646 bool setAtIndex(size_t index, const DynamicValue &dynValue) override;
647 bool getAtIndex(size_t index, DynamicValue &dynValue) const override;
648 void truncateToSize(size_t sz) override;
649 bool expandToMinimumSize(size_t sz) override;
650 void setFrom(const DynamicListContainerBase &other) override;
651 const void *getConstArrayPtr() const override;
652 void *getArrayPtr() override;
653 size_t getSize() const override;
654 bool compareEqual(const DynamicListContainerBase &other) const override;
655 DynamicListContainerBase *clone() const override;
656
657public:
658 size_t _size;
659};
660
661template<class T>
662bool DynamicListContainer<T>::setAtIndex(size_t index, const DynamicValue &dynValue) {
663 const typename DynamicListValueConverter<T>::DynamicValuePODType_t *valuePtr = nullptr;
664 if (!DynamicListValueImporter::importValue(dynValue, valuePtr))
665 return false;
666
667 _array.reserve(index + 1);
668 if (_array.size() <= index) {
669 if (_array.size() < index) {
670 T defaultValue;
671 DynamicListDefaultSetter::defaultSet(defaultValue);
672 while (_array.size() < index) {
673 _array.push_back(defaultValue);
674 }
675 }
676 _array.push_back(DynamicListValueConverter<T>::dereference(valuePtr));
677 } else {
678 _array[index] = DynamicListValueConverter<T>::dereference(valuePtr);
679 }
680
681 return true;
682}
683
684template<class T>
685void DynamicListContainer<T>::truncateToSize(size_t sz) {
686 if (_array.size() > sz)
687 _array.resize(sz);
688}
689
690template<class T>
691bool DynamicListContainer<T>::expandToMinimumSize(size_t sz) {
692 _array.reserve(sz);
693 if (_array.size() < sz) {
694 T defaultValue;
695 DynamicListDefaultSetter::defaultSet(defaultValue);
696 while (_array.size() < sz) {
697 _array.push_back(defaultValue);
698 }
699 }
700
701 return true;
702}
703
704template<class T>
705bool DynamicListContainer<T>::getAtIndex(size_t index, DynamicValue &dynValue) const {
706 if (index >= _array.size())
707 return false;
708
709 DynamicListValueExporter::exportValue(dynValue, _array[index]);
710 return true;
711}
712
713template<class T>
714void DynamicListContainer<T>::setFrom(const DynamicListContainerBase &other) {
715 _array = static_cast<const DynamicListContainer<T> &>(other)._array;
716}
717
718template<class T>
719const void *DynamicListContainer<T>::getConstArrayPtr() const {
720 return &_array;
721}
722
723template<class T>
724void *DynamicListContainer<T>::getArrayPtr() {
725 return &_array;
726}
727
728template<class T>
729size_t DynamicListContainer<T>::getSize() const {
730 return _array.size();
731}
732
733template<class T>
734bool DynamicListContainer<T>::compareEqual(const DynamicListContainerBase &other) const {
735 const DynamicListContainer<T> &otherTyped = static_cast<const DynamicListContainer<T> &>(other);
736 return _array == otherTyped._array;
737}
738
739template<class T>
740DynamicListContainerBase *DynamicListContainer<T>::clone() const {
741 return new DynamicListContainer<T>(*this);
742}
743
745 DynamicList();
746 DynamicList(const DynamicList &other);
747 ~DynamicList();
748
749 DynamicValueTypes::DynamicValueType getType() const;
750
751 const Common::Array<int32> &getInt() const;
752 const Common::Array<double> &getFloat() const;
753 const Common::Array<Common::Point> &getPoint() const;
754 const Common::Array<IntRange> &getIntRange() const;
755 const Common::Array<AngleMagVector> &getVector() const;
756 const Common::Array<Label> &getLabel() const;
757 const Common::Array<Event> &getEvent() const;
758 const Common::Array<Common::String> &getString() const;
759 const Common::Array<bool> &getBool() const;
760 const Common::Array<Common::SharedPtr<DynamicList> > &getList() const;
761 const Common::Array<ObjectReference> &getObjectReference() const;
762
763 Common::Array<int32> &getInt();
764 Common::Array<double> &getFloat();
766 Common::Array<IntRange> &getIntRange();
768 Common::Array<Label> &getLabel();
769 Common::Array<Event> &getEvent();
771 Common::Array<bool> &getBool();
773 Common::Array<ObjectReference> &getObjectReference();
774
775 bool getAtIndex(size_t index, DynamicValue &value) const;
776 bool setAtIndex(size_t index, const DynamicValue &value);
777 void deleteAtIndex(size_t index);
778 void truncateToSize(size_t sz);
779 void expandToMinimumSize(size_t sz);
780 size_t getSize() const;
781
782 void forceType(DynamicValueTypes::DynamicValueType type);
783
784 static bool dynamicValueToIndex(size_t &outIndex, const DynamicValue &value);
785
786 DynamicList &operator=(const DynamicList &other);
787
788 bool operator==(const DynamicList &other) const;
789 inline bool operator!=(const DynamicList &other) const {
790 return !((*this) == other);
791 }
792
793 void swap(DynamicList &other);
794
795 Common::SharedPtr<DynamicList> clone() const;
796
797 void createWriteProxyForIndex(size_t index, DynamicValueWriteProxy &proxy);
798
799private:
800 struct WriteProxyInterface {
801 static MiniscriptInstructionOutcome write(MiniscriptThread *thread, const DynamicValue &dest, void *objectRef, uintptr ptrOrOffset);
802 static MiniscriptInstructionOutcome refAttrib(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, void *objectRef, uintptr ptrOrOffset, const Common::String &attrib);
803 static MiniscriptInstructionOutcome refAttribIndexed(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, void *objectRef, uintptr ptrOrOffset, const Common::String &attrib, const DynamicValue &index);
804 };
805
806 void initFromOther(const DynamicList &other);
807 void destroyContainer();
808 bool createContainerAndSetType(DynamicValueTypes::DynamicValueType type);
809
810 DynamicValueTypes::DynamicValueType _type;
811 DynamicListContainerBase *_container;
812};
813
814// Dynamic value container. Somewhat importantly, lists stored in dynamic values
815// are BY REFERENCE and must be cloned as necessary.
817 DynamicValue();
818 DynamicValue(const DynamicValue &other);
820
821 bool loadConstant(const Data::InternalTypeTaggedValue &data, const Common::String &varString);
822 bool loadConstant(const Data::PlugInTypeTaggedValue &data);
823
824 DynamicValueTypes::DynamicValueType getType() const;
825
826 const int32 &getInt() const;
827 const double &getFloat() const;
828 const Common::Point &getPoint() const;
829 const IntRange &getIntRange() const;
830 const AngleMagVector &getVector() const;
831 const Label &getLabel() const;
832 const Event &getEvent() const;
833 const Common::String &getString() const;
834 const bool &getBool() const;
835 const Common::SharedPtr<DynamicList> &getList() const;
836 const ObjectReference &getObject() const;
837 const DynamicValueWriteProxy &getWriteProxy() const;
838
839 void clear();
840
841 void setInt(int32 value);
842 void setFloat(double value);
843 void setPoint(const Common::Point &value);
844 void setIntRange(const IntRange &value);
845 void setVector(const AngleMagVector &value);
846 void setLabel(const Label &value);
847 void setEvent(const Event &value);
848 void setString(const Common::String &value);
849 void setBool(bool value);
850 void setList(const Common::SharedPtr<DynamicList> &value);
851 void setObject(const ObjectReference &value);
852 void setObject(const Common::WeakPtr<RuntimeObject> &value);
853 void setWriteProxy(const DynamicValueWriteProxy &writeProxy);
854
855 bool roundToInt(int32 &outInt) const;
856
857 bool convertToType(DynamicValueTypes::DynamicValueType targetType, DynamicValue &result) const;
858
859 DynamicValue dereference() const;
860
861 DynamicValue &operator=(const DynamicValue &other);
862
863 bool operator==(const DynamicValue &other) const;
864 inline bool operator!=(const DynamicValue &other) const {
865 return !((*this) == other);
866 }
867
868private:
869 union ValueUnion {
870 ValueUnion();
871 ~ValueUnion();
872
873 double asFloat;
874 int32 asInt;
875 IntRange asIntRange;
876 AngleMagVector asVector;
877 Label asLabel;
878 Event asEvent;
879 Common::Point asPoint;
880 bool asBool;
881 DynamicValueWriteProxy asWriteProxy;
882 Common::String asString;
884 ObjectReference asObj;
885
886 uint64 asUnset;
887
888 template<class T, T(ValueUnion::*TMember)>
889 void construct(const T &value);
890
891 template<class T, T(ValueUnion::*TMember)>
892 void construct(T &&value);
893
894 template<class T, T(ValueUnion::*TMember)>
895 void assign(const T &value);
896
897 template<class T, T(ValueUnion::*TMember)>
898 void assign(T &&value);
899
900 template<class T, T(ValueUnion::*TMember)>
901 void destruct();
902 };
903
904 template<class T>
905 void internalSwap(T &a, T &b) {
906 T temp = a;
907 a = b;
908 b = temp;
909 }
910
911 bool convertIntToType(DynamicValueTypes::DynamicValueType targetType, DynamicValue &result) const;
912 bool convertFloatToType(DynamicValueTypes::DynamicValueType targetType, DynamicValue &result) const;
913 bool convertBoolToType(DynamicValueTypes::DynamicValueType targetType, DynamicValue &result) const;
914 bool convertStringToType(DynamicValueTypes::DynamicValueType targetType, DynamicValue &result) const;
915
916 bool convertToTypeNoDereference(DynamicValueTypes::DynamicValueType targetType, DynamicValue &result) const;
917
918 void setFromOther(const DynamicValue &other);
919 void setFromOther(DynamicValue &&other);
920
921 DynamicValueTypes::DynamicValueType _type;
922 ValueUnion _value;
923};
924
930
931 DynamicValueSource &operator=(const DynamicValueSource &other);
932 DynamicValueSource &operator=(DynamicValueSource &&other);
933
934 DynamicValueSourceTypes::DynamicValueSourceType getSourceType() const;
935 const DynamicValue &getConstant() const;
936 const VarReference &getVarReference() const;
937
938 bool load(const Data::InternalTypeTaggedValue &data, const Common::String &varSource, const Common::String &varString);
939 bool load(const Data::PlugInTypeTaggedValue &data);
940
941 void linkInternalReferences(ObjectLinkingScope *scope);
942 void visitInternalReferences(IStructuralReferenceVisitor *visitor);
943
944 DynamicValue produceValue(const DynamicValue &incomingData) const;
945
946private:
947 union ValueUnion {
948 ValueUnion();
949 ~ValueUnion();
950
951 DynamicValue _constValue;
952 VarReference _varReference;
953 };
954
955 void destructValue();
956 void initFromOther(const DynamicValueSource &other);
957 void initFromOther(DynamicValueSource &&other);
958
959 DynamicValueSourceTypes::DynamicValueSourceType _sourceType;
960 ValueUnion _valueUnion;
961};
962
963template<class TFloat>
965 static MiniscriptInstructionOutcome write(MiniscriptThread *thread, const DynamicValue &value, void *objectRef, uintptr ptrOrOffset) {
966 DynamicValue derefValue = value.dereference();
967
968 TFloat &dest = *static_cast<TFloat *>(objectRef);
969 switch (derefValue.getType()) {
970 case DynamicValueTypes::kFloat:
971 dest = static_cast<TFloat>(derefValue.getFloat());
972 return kMiniscriptInstructionOutcomeContinue;
973 case DynamicValueTypes::kInteger:
974 dest = static_cast<TFloat>(derefValue.getInt());
975 return kMiniscriptInstructionOutcomeContinue;
976 default:
977 return kMiniscriptInstructionOutcomeFailed;
978 }
979 }
980 static MiniscriptInstructionOutcome refAttrib(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, void *objectRef, uintptr ptrOrOffset, const Common::String &attrib) {
981 return kMiniscriptInstructionOutcomeFailed;
982 }
983 static MiniscriptInstructionOutcome refAttribIndexed(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, void *objectRef, uintptr ptrOrOffset, const Common::String &attrib, const DynamicValue &index) {
984 return kMiniscriptInstructionOutcomeFailed;
985 }
986
987 static void create(TFloat *floatValue, DynamicValueWriteProxy &proxy) {
988 proxy.pod.ptrOrOffset = 0;
989 proxy.pod.objectRef = floatValue;
991 }
992};
993
994template<class TInteger>
996 static MiniscriptInstructionOutcome write(MiniscriptThread *thread, const DynamicValue &value, void *objectRef, uintptr ptrOrOffset) {
997 DynamicValue derefValue = value.dereference();
998
999 TInteger &dest = *static_cast<TInteger *>(objectRef);
1000 switch (derefValue.getType()) {
1001 case DynamicValueTypes::kFloat:
1002 dest = static_cast<TInteger>(floor(derefValue.getFloat() + 0.5));
1003 return kMiniscriptInstructionOutcomeContinue;
1004 case DynamicValueTypes::kInteger:
1005 dest = static_cast<TInteger>(derefValue.getInt());
1006 return kMiniscriptInstructionOutcomeContinue;
1007 default:
1008 return kMiniscriptInstructionOutcomeFailed;
1009 }
1010 }
1011 static MiniscriptInstructionOutcome refAttrib(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, void *objectRef, uintptr ptrOrOffset, const Common::String &attrib) {
1012 return kMiniscriptInstructionOutcomeFailed;
1013 }
1014 static MiniscriptInstructionOutcome refAttribIndexed(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, void *objectRef, uintptr ptrOrOffset, const Common::String &attrib, const DynamicValue &index) {
1015 return kMiniscriptInstructionOutcomeFailed;
1016 }
1017
1018 static void create(TInteger *intValue, DynamicValueWriteProxy &proxy) {
1019 proxy.pod.ptrOrOffset = 0;
1020 proxy.pod.objectRef = intValue;
1022 }
1023};
1024
1026 static MiniscriptInstructionOutcome write(MiniscriptThread *thread, const DynamicValue &value, void *objectRef, uintptr ptrOrOffset);
1027 static MiniscriptInstructionOutcome refAttrib(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, void *objectRef, uintptr ptrOrOffset, const Common::String &attrib);
1028 static MiniscriptInstructionOutcome refAttribIndexed(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, void *objectRef, uintptr ptrOrOffset, const Common::String &attrib, const DynamicValue &index);
1029
1030 static void create(Common::Point *pointValue, DynamicValueWriteProxy &proxy);
1031};
1032
1034 static MiniscriptInstructionOutcome write(MiniscriptThread *thread, const DynamicValue &value, void *objectRef, uintptr ptrOrOffset);
1035 static MiniscriptInstructionOutcome refAttrib(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, void *objectRef, uintptr ptrOrOffset, const Common::String &attrib);
1036 static MiniscriptInstructionOutcome refAttribIndexed(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, void *objectRef, uintptr ptrOrOffset, const Common::String &attrib, const DynamicValue &index);
1037
1038 static void create(bool *boolValue, DynamicValueWriteProxy &proxy);
1039};
1040
1042 static MiniscriptInstructionOutcome write(MiniscriptThread *thread, const DynamicValue &value, void *objectRef, uintptr ptrOrOffset);
1043 static MiniscriptInstructionOutcome refAttrib(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, void *objectRef, uintptr ptrOrOffset, const Common::String &attrib);
1044 static MiniscriptInstructionOutcome refAttribIndexed(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, void *objectRef, uintptr ptrOrOffset, const Common::String &attrib, const DynamicValue &index);
1045
1046 static void create(Common::String *strValue, DynamicValueWriteProxy &proxy);
1047};
1048
1050 static MiniscriptInstructionOutcome write(MiniscriptThread *thread, const DynamicValue &value, void *objectRef, uintptr ptrOrOffset);
1051 static MiniscriptInstructionOutcome refAttrib(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, void *objectRef, uintptr ptrOrOffset, const Common::String &attrib);
1052 static MiniscriptInstructionOutcome refAttribIndexed(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, void *objectRef, uintptr ptrOrOffset, const Common::String &attrib, const DynamicValue &index);
1053
1054 static void create(DynamicValueWriteProxy &proxy);
1055};
1056
1057template<class TClass, MiniscriptInstructionOutcome (TClass::*TWriteMethod)(MiniscriptThread *thread, const DynamicValue &dest), MiniscriptInstructionOutcome (TClass::*TRefAttribMethod)(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, const Common::String &attrib)>
1059 static MiniscriptInstructionOutcome write(MiniscriptThread *thread, const DynamicValue &dest, void *objectRef, uintptr ptrOrOffset) {
1060 DynamicValue derefValue = dest.dereference();
1061
1062 return (static_cast<TClass *>(objectRef)->*TWriteMethod)(thread, derefValue);
1063 }
1064 static MiniscriptInstructionOutcome refAttrib(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, void *objectRef, uintptr ptrOrOffset, const Common::String &attrib) {
1065 return (static_cast<TClass *>(objectRef)->*TRefAttribMethod)(thread, proxy, attrib);
1066 }
1067 static MiniscriptInstructionOutcome refAttribIndexed(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, void *objectRef, uintptr ptrOrOffset, const Common::String &attrib, const DynamicValue &index) {
1068 return kMiniscriptInstructionOutcomeFailed;
1069 }
1070
1071 static void create(TClass *obj, DynamicValueWriteProxy &proxy) {
1072 proxy.pod.ptrOrOffset = 0;
1073 proxy.pod.objectRef = obj;
1075 }
1076};
1077
1078template<class TClass, MiniscriptInstructionOutcome (TClass::*TWriteMethod)(MiniscriptThread *thread, const DynamicValue &dest), bool TDereference>
1080 static MiniscriptInstructionOutcome write(MiniscriptThread *thread, const DynamicValue &dest, void *objectRef, uintptr ptrOrOffset) {
1081 if (TDereference) {
1082 return (static_cast<TClass *>(objectRef)->*TWriteMethod)(thread, dest.dereference());
1083 } else
1084 return (static_cast<TClass *>(objectRef)->*TWriteMethod)(thread, dest);
1085 }
1086 static MiniscriptInstructionOutcome refAttrib(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, void *objectRef, uintptr ptrOrOffset, const Common::String &attrib) {
1087 return kMiniscriptInstructionOutcomeFailed;
1088 }
1089 static MiniscriptInstructionOutcome refAttribIndexed(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, void *objectRef, uintptr ptrOrOffset, const Common::String &attrib, const DynamicValue &index) {
1090 return kMiniscriptInstructionOutcomeFailed;
1091 }
1092
1093 static void create(TClass *obj, DynamicValueWriteProxy &proxy) {
1094 proxy.pod.ptrOrOffset = 0;
1095 proxy.pod.objectRef = obj;
1097 }
1098};
1099
1101 static MiniscriptInstructionOutcome write(MiniscriptThread *thread, const DynamicValue &value, void *objectRef, uintptr ptrOrOffset);
1102 static MiniscriptInstructionOutcome refAttrib(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, void *objectRef, uintptr ptrOrOffset, const Common::String &attrib);
1103 static MiniscriptInstructionOutcome refAttribIndexed(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, void *objectRef, uintptr ptrOrOffset, const Common::String &attrib, const DynamicValue &index);
1104
1105 static void create(RuntimeObject *obj, DynamicValueWriteProxy &proxy);
1106};
1107
1110
1111 bool load(const Data::Event &dataEvent, uint32 dataMessageFlags, const Data::InternalTypeTaggedValue &dataLocator, const Common::String &dataWithSource, const Common::String &dataWithString, uint32 dataDestination);
1112 bool load(const Data::PlugInTypeTaggedValue &dataEvent, const MessageFlags &dataMessageFlags, const Data::PlugInTypeTaggedValue &dataWith, uint32 dataDestination);
1113
1114 void linkInternalReferences(ObjectLinkingScope *outerScope);
1115 void visitInternalReferences(IStructuralReferenceVisitor *visitor);
1116
1117 void resolveDestination(Runtime *runtime, Modifier *sender, RuntimeObject *triggerSource, Common::WeakPtr<Structural> &outStructuralDest, Common::WeakPtr<Modifier> &outModifierDest, RuntimeObject *customDestination) const;
1118
1119 static void resolveVariableObjectType(RuntimeObject *obj, Common::WeakPtr<Structural> &outStructuralDest, Common::WeakPtr<Modifier> &outModifierDest);
1120
1121 void sendFromMessenger(Runtime *runtime, Modifier *sender, RuntimeObject *triggerSource, const DynamicValue &incomingData, RuntimeObject *customDestination) const;
1122 void sendFromMessengerWithCustomData(Runtime *runtime, Modifier *sender, RuntimeObject *triggerSource, const DynamicValue &data, RuntimeObject *customDestination) const;
1123
1124 enum LinkType {
1125 kLinkTypeNotYetLinked,
1126 kLinkTypeStructural,
1127 kLinkTypeModifier,
1128 kLinkTypeCoded,
1129 kLinkTypeUnresolved,
1130 };
1131
1132 Event send;
1133 MessageFlags messageFlags;
1134 DynamicValueSource with;
1135 uint32 destination; // May be a MessageDestination or GUID
1136
1137 LinkType _linkType;
1138 Common::WeakPtr<Structural> _resolvedStructuralDest;
1139 Common::WeakPtr<Modifier> _resolvedModifierDest;
1140 Common::WeakPtr<Modifier> _resolvedVarSource;
1141
1142private:
1143 void resolveHierarchyStructuralDestination(Runtime *runtime, Modifier *sender, Common::WeakPtr<Structural> &outStructuralDest, Common::WeakPtr<Modifier> &outModifierDest, bool (*compareFunc)(Structural *structural)) const;
1144 static bool isSceneFilter(Structural *section);
1145 static bool isSectionFilter(Structural *section);
1146 static bool isSubsectionFilter(Structural *section);
1147 static bool isElementFilter(Structural *section);
1148};
1149
1150enum MessageDestination {
1151 kMessageDestNone = 0,
1152
1153 kMessageDestSharedScene = 0x65,
1154 kMessageDestScene = 0x66,
1155 kMessageDestSection = 0x67,
1156 kMessageDestProject = 0x68,
1157 kMessageDestActiveScene = 0x69,
1158 kMessageDestElementsParent = 0x6a,
1159 kMessageDestChildren = 0x6b, // Saw this somewhere but can't find it any more?
1160 kMessageDestModifiersParent = 0x6c,
1161 kMessageDestSubsection = 0x6d,
1162
1163 kMessageDestElement = 0xc9,
1164 kMessageDestSourcesParent = 0xcf,
1165
1166 kMessageDestBehavior = 0xd4,
1167 kMessageDestNextElement = 0xd1,
1168 kMessageDestPrevElement = 0xd2,
1169 kMessageDestBehaviorsParent = 0xd3,
1170};
1171
1174
1175 int volumeID;
1176 Common::String filePath;
1178};
1179
1181 virtual void registerPlugInModifier(const char *name, const Data::IPlugInModifierDataFactory *loader, const IPlugInModifierFactory *factory) = 0;
1182 void registerPlugInModifier(const char *name, const IPlugInModifierFactoryAndDataFactory *loaderFactory);
1183};
1184
1185class PlugIn {
1186public:
1187 virtual ~PlugIn();
1188
1189 virtual void registerModifiers(IPlugInModifierRegistrar *registrar) const = 0;
1190};
1191
1193public:
1195};
1196
1198 virtual ~ProjectResources();
1199
1201};
1202
1204public:
1205 virtual ~CursorGraphic();
1206
1207 virtual Graphics::Cursor *getCursor() const = 0;
1208};
1209
1211public:
1213
1214 Graphics::Cursor *getCursor() const override;
1215
1216private:
1218};
1219
1221public:
1222 explicit WinCursorGraphic(const Common::SharedPtr<Graphics::WinCursorGroup> &winCursorGroup, Graphics::Cursor *cursor);
1223
1224 Graphics::Cursor *getCursor() const override;
1225
1226private:
1228 Graphics::Cursor *_cursor;
1229};
1230
1232public:
1235
1236 void addWinCursorGroup(uint32 cursorGroupID, const Common::SharedPtr<Graphics::WinCursorGroup> &cursorGroup);
1237 void addMacCursor(uint32 cursorID, const Common::SharedPtr<Graphics::MacCursor> &cursor);
1238
1239 Common::SharedPtr<CursorGraphic> getGraphicByID(uint32 id) const;
1240
1241private:
1243};
1244
1245// The project platform is the platform that the project is running on (not the format of the project)
1246enum ProjectPlatform {
1247 kProjectPlatformUnknown,
1248
1249 kProjectPlatformWindows,
1250 kProjectPlatformMacintosh,
1251};
1252
1254public:
1255 ProjectDescription(ProjectPlatform platform, RuntimeVersion runtimeVersion, bool autoDetectVersion, Common::Archive *rootArchive, const Common::Path &projectRootDir);
1257
1258 void addSegment(int volumeID, const char *filePath);
1259 void addSegment(int volumeID, Common::SeekableReadStream *stream);
1260 const Common::Array<SegmentDescription> &getSegments() const;
1261
1262 void addPlugIn(const Common::SharedPtr<PlugIn> &plugIn);
1263 const Common::Array<Common::SharedPtr<PlugIn> > &getPlugIns() const;
1264
1265 void setResources(const Common::SharedPtr<ProjectResources> &resources);
1266 const Common::SharedPtr<ProjectResources> &getResources() const;
1267
1268 void setCursorGraphics(const Common::SharedPtr<CursorGraphicCollection> &cursorGraphics);
1269 const Common::SharedPtr<CursorGraphicCollection> &getCursorGraphics() const;
1270
1271 void setLanguage(Common::Language language);
1272 Common::Language getLanguage() const;
1273
1274 ProjectPlatform getPlatform() const;
1275 RuntimeVersion getRuntimeVersion() const;
1276 bool isRuntimeVersionAuto() const;
1277
1278 Common::Archive *getRootArchive() const;
1279 const Common::Path &getProjectRootDir() const;
1280
1281 const SubtitleTables &getSubtitles() const;
1282 void setSubtitles(const SubtitleTables &subs);
1283
1284private:
1289 Common::Language _language;
1290 SubtitleTables _subtitles;
1291 ProjectPlatform _platform;
1292 RuntimeVersion _runtimeVersion;
1293 bool _isRuntimeVersionAuto;
1294
1295 Common::Archive *_rootArchive;
1296 Common::Path _projectRootDir;
1297};
1298
1300 VolumeState();
1301
1302 Common::String name;
1303 int volumeID;
1304 bool isMounted;
1305};
1306
1308public:
1311
1312 void setParent(ObjectLinkingScope *parent);
1313 void addObject(uint32 guid, const Common::String &name, const Common::WeakPtr<RuntimeObject> &object);
1314 Common::WeakPtr<RuntimeObject> resolve(uint32 staticGUID) const;
1315 Common::WeakPtr<RuntimeObject> resolve(const Common::String &name, bool isNameAlreadyInsensitive) const;
1316 Common::WeakPtr<RuntimeObject> resolve(uint32 staticGUID, const Common::String &name, bool isNameAlreadyInsensitive) const;
1317
1318 void reset();
1319
1320private:
1323 ObjectLinkingScope *_parent;
1324};
1325
1327 enum ActionType {
1328 kLoad,
1329 kUnload,
1330 kSendMessage,
1331 kAutoResetCursor,
1332 kHideAllElements,
1333 kShowDefaultVisibleElements,
1334 };
1335
1337 explicit LowLevelSceneStateTransitionAction(ActionType actionType);
1339 LowLevelSceneStateTransitionAction(const Common::SharedPtr<Structural> &scene, ActionType actionType);
1340
1341 ActionType getActionType() const;
1342 const Common::SharedPtr<Structural> &getScene() const;
1343 const Common::SharedPtr<MessageDispatch> &getMessage() const;
1344
1346
1347private:
1348 ActionType _actionType;
1351};
1352
1355
1358};
1359
1361 enum Type {
1362 kTypeChangeToScene,
1363 kTypeChangeSharedScene,
1364 kTypeForceLoadScene,
1365 kTypeRequestUnloadScene,
1366 };
1367
1368 HighLevelSceneTransition(const Common::SharedPtr<Structural> &hlst_scene, Type hlst_type, bool hlst_addToDestinationScene, bool hlst_addToReturnList);
1369
1371 Type type;
1372 bool addToDestinationScene;
1373 bool addToReturnList;
1374};
1375
1378
1379 uint32 _duration; // 6000000 is maximum
1380 uint16 _steps;
1381 SceneTransitionTypes::SceneTransitionType _transitionType;
1382 SceneTransitionDirections::SceneTransitionDirection _transitionDirection;
1383};
1384
1386public:
1387 enum class RootType {
1388 Invalid,
1389
1390 Command,
1391 Structural,
1392 Modifier,
1393 };
1394
1395 MessageDispatch(const Common::SharedPtr<MessageProperties> &msgProps, Structural *root, bool cascade, bool relay, bool couldBeCommand);
1396 MessageDispatch(const Common::SharedPtr<MessageProperties> &msgProps, Modifier *root, bool cascade, bool relay, bool couldBeCommand);
1397
1398 const Common::SharedPtr<MessageProperties> &getMsg() const;
1399 RuntimeObject *getRootPropagator() const;
1400
1401 bool isCascade() const;
1402 bool isRelay() const;
1403
1404 RootType getRootType() const;
1405 const Common::WeakPtr<RuntimeObject> &getRootWeakPtr() const;
1406
1407private:
1409
1411
1412 bool _cascade; // Traverses structure tree
1413 bool _relay; // Fire on multiple modifiers
1414 bool _isCommand;
1415
1416 RootType _rootType;
1417};
1418
1420public:
1422
1423 Common::Array<Common::WeakPtr<RuntimeObject> > &getKeyboardMessengerArray();
1424 static bool keyboardMessengerFilterFunc(void *userData, RuntimeObject *object);
1425
1426 bool isTerminated() const;
1427 VThreadState continuePropagating(Runtime *runtime);
1428
1429private:
1431 size_t _dispatchIndex;
1433};
1434
1435class Scheduler;
1436
1438 friend class Scheduler;
1439
1440public:
1441 void cancel();
1442 uint64 getScheduledTime() const;
1443 void activate(Runtime *runtime) const;
1444
1445private:
1446 ScheduledEvent(void *obj, void (*activateFunc)(void *, Runtime *), uint64 scheduledTime, Scheduler *scheduler);
1447
1448 void *_obj;
1449 void (*_activateFunc)(void *obj, Runtime *runtime);
1450
1451 uint64 _scheduledTime;
1452 Scheduler *_scheduler;
1453};
1454
1456 friend class ScheduledEvent;
1457
1458public:
1459 Scheduler();
1460 ~Scheduler();
1461
1462 template<class T, void (T::*TMethodPtr)(Runtime *)>
1463 Common::SharedPtr<ScheduledEvent> scheduleMethod(uint64 scheduledTime, T* obj) {
1464 Common::SharedPtr<ScheduledEvent> evt(new ScheduledEvent(obj, Scheduler::methodActivateHelper<T, TMethodPtr>, scheduledTime, this));
1465 insertEvent(evt);
1466 return evt;
1467 }
1468
1469 Common::SharedPtr<ScheduledEvent> getFirstEvent() const;
1470 void descheduleFirstEvent();
1471
1472private:
1473 template<class T, void (T::*TMethodPtr)(Runtime *)>
1474 static void methodActivateHelper(void *obj, Runtime *runtime) {
1475 (static_cast<T *>(obj)->*TMethodPtr)(runtime);
1476 }
1477
1478 void insertEvent(const Common::SharedPtr<ScheduledEvent> &evt);
1479 void removeEvent(const ScheduledEvent *evt);
1480
1482};
1483
1484enum OSEventType {
1485 kOSEventTypeMouseDown,
1486 kOSEventTypeMouseUp,
1487 kOSEventTypeMouseMove,
1488
1489 kOSEventTypeKeyboard,
1490
1491 kOSEventTypeAction,
1492};
1493
1494class OSEvent {
1495public:
1496 explicit OSEvent(OSEventType eventType);
1497 virtual ~OSEvent();
1498
1499 OSEventType getEventType() const;
1500
1501private:
1502 OSEventType _eventType;
1503};
1504
1505class MouseInputEvent : public OSEvent {
1506public:
1507 explicit MouseInputEvent(OSEventType eventType, int32 x, int32 y, Actions::MouseButton button);
1508
1509 int32 getX() const;
1510 int32 getY() const;
1511 Actions::MouseButton getButton() const;
1512
1513private:
1514 int32 _x;
1515 int32 _y;
1516 Actions::MouseButton _button;
1517};
1518
1520public:
1521 explicit KeyboardInputEvent(OSEventType osEventType, Common::EventType keyEventType, bool repeat, const Common::KeyState &keyEvt);
1522
1523 Common::EventType getKeyEventType() const;
1524 bool isRepeat() const;
1525 const Common::KeyState &getKeyState() const;
1526
1527private:
1528 Common::EventType _keyEventType;
1529 bool _repeat;
1530 const Common::KeyState _keyEvt;
1531};
1532
1533class ActionEvent : public OSEvent {
1534public:
1535 explicit ActionEvent(OSEventType osEventType, Actions::Action action);
1536
1537 Actions::Action getAction() const;
1538
1539private:
1540 Actions::Action _action;
1541};
1542
1545
1546 ConstraintDirection constraintDirection;
1547 Common::Rect constraintMargin;
1548 bool constrainToParent;
1549};
1550
1552public:
1553 virtual ~SceneTransitionHooks();
1554
1555 virtual void onSceneTransitionSetup(Runtime *runtime, const Common::WeakPtr<Structural> &oldScene, const Common::WeakPtr<Structural> &newScene);
1556 virtual void onSceneTransitionEnded(Runtime *runtime, const Common::WeakPtr<Structural> &newScene);
1557 virtual void onProjectStarted(Runtime *runtime);
1558};
1559
1560class Palette {
1561public:
1562 Palette();
1563 explicit Palette(const ColorRGB8 *colors);
1564
1565 void initDefaultPalette(int version);
1566
1567 const byte *getPalette() const;
1568
1569 static const uint kNumColors = 256;
1570
1571private:
1572 byte _colors[kNumColors * 3];
1573};
1574
1575class Runtime {
1576public:
1577 explicit Runtime(OSystem *system, Audio::Mixer *mixer, ISaveUIProvider *saveProvider, ILoadUIProvider *loadProvider, const Common::SharedPtr<SubtitleRenderer> &subRenderer);
1578 ~Runtime();
1579
1580 bool runFrame();
1581 void drawFrame();
1582
1583 void queueProject(const Common::SharedPtr<ProjectDescription> &desc);
1584 void closeProject();
1585
1586 void addVolume(int volumeID, const char *name, bool isMounted);
1587 bool getVolumeState(const Common::String &name, int &outVolumeID, bool &outIsMounted) const;
1588
1589 void addSceneReturn();
1590 void addSceneStateTransition(const HighLevelSceneTransition &transition);
1591
1592 void setSceneTransitionEffect(bool isInDestinationScene, SceneTransitionEffect *effect);
1593
1594 Project *getProject() const;
1595
1596 void postConsumeMessageTask(IMessageConsumer *msgConsumer, const Common::SharedPtr<MessageProperties> &msg);
1597 void postConsumeCommandTask(Structural *structural, const Common::SharedPtr<MessageProperties> &msg);
1598
1599 uint32 allocateRuntimeGUID();
1600
1601 void addWindow(const Common::SharedPtr<Window> &window);
1602 void removeWindow(Window *window);
1603
1604 // Sets up a supported display mode
1605 void setupDisplayMode(ColorDepthMode displayMode, const Graphics::PixelFormat &pixelFormat);
1606
1607 bool isDisplayModeSupported(ColorDepthMode displayMode) const;
1608
1609 // Switches to a specified display mode. Returns true if the mode was actually changed. If so, all windows will need
1610 // to be recreated.
1611 bool switchDisplayMode(ColorDepthMode realDisplayMode, ColorDepthMode fakeDisplayMode);
1612
1613 void setDisplayResolution(uint16 width, uint16 height);
1614 void getDisplayResolution(uint16 &outWidth, uint16 &outHeight) const;
1615
1616 ColorDepthMode getRealColorDepth() const;
1617 ColorDepthMode getFakeColorDepth() const; // Fake color depth that will be reported to scripts
1618
1619 const Graphics::PixelFormat &getRenderPixelFormat() const;
1620
1621 const Common::SharedPtr<Graphics::MacFontManager> &getMacFontManager() const;
1622
1623 const Common::SharedPtr<Structural> &getActiveMainScene() const;
1624 const Common::SharedPtr<Structural> &getActiveSharedScene() const;
1625 void getSceneStack(Common::Array<Common::SharedPtr<Structural> > &sceneStack) const;
1626
1627 bool mustDraw() const;
1628
1629 uint64 getRealTime() const;
1630 uint64 getPlayTime() const;
1631
1632 VThread &getVThread() const;
1633
1634 // Sending a message on the VThread means "immediately"
1635 void sendMessageOnVThread(const Common::SharedPtr<MessageDispatch> &dispatch);
1636
1638 CORO_DEFINE_RETURN_TYPE(void);
1639 CORO_DEFINE_PARAMS_2(Runtime *, runtime, Common::SharedPtr<MessageDispatch>, dispatch);
1640 };
1641
1642 void queueMessage(const Common::SharedPtr<MessageDispatch> &dispatch);
1643
1644 void queueOSEvent(const Common::SharedPtr<OSEvent> &osEvent);
1645
1646 Scheduler &getScheduler();
1647
1648 void getScenesInRenderOrder(Common::Array<Structural *> &scenes) const;
1649
1650 void instantiateIfAlias(Common::SharedPtr<Modifier> &modifier, const Common::WeakPtr<RuntimeObject> &relinkParent);
1651
1652 Common::SharedPtr<Window> findTopWindow(int32 x, int32 y) const;
1653
1654 void setVolume(double volume);
1655
1656 void onMouseDown(int32 x, int32 y, Actions::MouseButton mButton);
1657 void onMouseMove(int32 x, int32 y);
1658 void onMouseUp(int32 x, int32 y, Actions::MouseButton mButton);
1659 void onKeyboardEvent(const Common::EventType evtType, bool repeat, const Common::KeyState &keyEvt);
1660 void onAction(MTropolis::Actions::Action action);
1661
1662 const Common::Point &getCachedMousePosition() const;
1663 void setModifierCursorOverride(uint32 cursorID);
1664 void clearModifierCursorOverride();
1665 void forceCursorRefreshOnce();
1666 void setAutoResetCursor(bool enabled);
1667
1668 uint getMultiClickCount() const;
1669
1670 bool isAwaitingSceneTransition() const;
1671
1672 Common::RandomSource *getRandom() const;
1673 WorldManagerInterface *getWorldManagerInterface() const;
1674 AssetManagerInterface *getAssetManagerInterface() const;
1675 SystemInterface *getSystemInterface() const;
1676
1677 ISaveUIProvider *getSaveProvider() const;
1678 ILoadUIProvider *getLoadProvider() const;
1679
1680 Audio::Mixer *getAudioMixer() const;
1681
1682 Hacks &getHacks();
1683 const Hacks &getHacks() const;
1684
1685 void setSceneGraphDirty();
1686 void clearSceneGraphDirty();
1687 bool isSceneGraphDirty() const;
1688
1689 void addCollider(ICollider *collider);
1690 void removeCollider(ICollider *collider);
1691 void checkCollisions(ICollider *optRestrictToCollider);
1692
1693 void setCursorElement(const Common::WeakPtr<VisualElement> &element);
1694 void updateCursorElementPosition();
1695
1696 void addBoundaryDetector(IBoundaryDetector *boundaryDetector);
1697 void removeBoundaryDetector(IBoundaryDetector *boundaryDetector);
1698 void checkBoundaries();
1699
1700 void addPostEffect(IPostEffect *postEffect);
1701 void removePostEffect(IPostEffect *postEffect);
1702 const Common::Array<IPostEffect *> &getPostEffects() const;
1703
1704 const Palette &getGlobalPalette() const;
1705 void setGlobalPalette(const Palette &palette);
1706
1707 void addMouseBlocker();
1708 void removeMouseBlocker();
1709
1710 const Common::String *resolveAttributeIDName(uint32 attribID) const;
1711
1712 const Common::WeakPtr<Window> &getMainWindow() const;
1713
1714 const Common::SharedPtr<Graphics::ManagedSurface> &getSaveScreenshotOverride() const;
1715 void setSaveScreenshotOverride(const Common::SharedPtr<Graphics::ManagedSurface> &screenshot);
1716
1717 bool isIdle() const;
1718
1719 const Common::SharedPtr<SubtitleRenderer> &getSubtitleRenderer() const;
1720
1721 void queueCloneObject(const Common::WeakPtr<RuntimeObject> &obj);
1722 void queueKillObject(const Common::WeakPtr<RuntimeObject> &obj);
1723 void queueChangeObjectParent(const Common::WeakPtr<RuntimeObject> &obj, const Common::WeakPtr<RuntimeObject> &newParent);
1724
1725 void hotLoadScene(Structural *structural);
1726
1727#ifdef MTROPOLIS_DEBUG_ENABLE
1728 void debugSetEnabled(bool enabled);
1729 void debugBreak();
1730 Debugger *debugGetDebugger() const;
1731
1732 void debugGetPrimaryTaskList(Common::Array<Common::SharedPtr<DebugPrimaryTaskList> > &primaryTaskLists);
1733#endif
1734
1735private:
1736 enum SceneTransitionState {
1737 kSceneTransitionStateNotTransitioning,
1738 kSceneTransitionStateWaitingForDraw,
1739 kSceneTransitionStateTransitioning,
1740 };
1741
1742 struct SceneStackEntry {
1743 SceneStackEntry();
1744
1746 };
1747
1748 struct Teardown {
1749 Teardown();
1750
1751 Common::WeakPtr<Structural> structural;
1753 bool onlyRemoveChildren;
1754 };
1755
1756 struct SceneReturnListEntry {
1757 SceneReturnListEntry();
1758
1760 bool isAddToDestinationSceneTransition;
1761 };
1762
1763 struct DispatchMethodTaskData {
1765 };
1766
1767 struct DispatchKeyTaskData {
1769 };
1770
1771 struct DispatchActionTaskData {
1772 DispatchActionTaskData();
1773
1774 Actions::Action action;
1775 };
1776
1777 struct ConsumeMessageTaskData {
1778 ConsumeMessageTaskData();
1779
1780 IMessageConsumer *consumer;
1782 };
1783
1784 struct ConsumeCommandTaskData {
1785 ConsumeCommandTaskData();
1786
1787 Structural *structural;
1789 };
1790
1791 struct ApplyDefaultVisibilityTaskData {
1792 ApplyDefaultVisibilityTaskData();
1793
1794 VisualElement *element;
1795 bool targetVisibility;
1796 };
1797
1798 struct UpdateMouseStateTaskData {
1799 UpdateMouseStateTaskData();
1800
1801 bool mouseDown;
1802 };
1803
1804 struct UpdateMousePositionTaskData {
1805 UpdateMousePositionTaskData();
1806
1807 int32 x;
1808 int32 y;
1809 };
1810
1811 struct CollisionCheckState {
1812 CollisionCheckState();
1813
1815 ICollider *collider;
1816 };
1817
1818 struct BoundaryCheckState {
1819 BoundaryCheckState();
1820
1821 IBoundaryDetector *detector;
1822 uint currentContacts;
1823 Common::Point position;
1824 bool positionResolved;
1825 };
1826
1827 struct ColliderInfo {
1828 ColliderInfo();
1829
1830 size_t sceneStackDepth;
1831 uint16 layer;
1832 VisualElement *element;
1833 Common::Rect absRect;
1834 };
1835
1836 static Common::SharedPtr<Structural> findDefaultSharedSceneForScene(Structural *scene);
1837 void executeTeardown(const Teardown &teardown);
1838 void executeLowLevelSceneStateTransition(const LowLevelSceneStateTransitionAction &transitionAction);
1839 void executeHighLevelSceneReturn();
1840 void executeHighLevelSceneTransition(const HighLevelSceneTransition &transition);
1841 void executeCompleteTransitionToScene(const Common::SharedPtr<Structural> &scene);
1842 void executeSharedScenePostSceneChangeActions();
1843 void executeSceneChangeRecursiveVisibilityChange(Structural *structural, bool showing);
1844 void executeChangeObjectParent(RuntimeObject *object, RuntimeObject *newParent);
1845 void executeCloneObject(RuntimeObject *object);
1846 void executeKillObject(RuntimeObject *object);
1847
1848 void recursiveAutoPlayMedia(Structural *structural);
1849 void recursiveDeactivateStructural(Structural *structural);
1850 void recursiveActivateStructural(Structural *structural);
1851
1852 static bool isStructuralMouseInteractive(Structural *structural, MouseInteractivityTestType testType);
1853 static bool isModifierMouseInteractive(Modifier *modifier, MouseInteractivityTestType testType);
1854 static void recursiveFindMouseCollision(Structural *&bestResult, int32 &bestLayer, int32 &bestStackHeight, bool &bestDirect, Structural *candidate, int32 stackHeight, int32 relativeX, int32 relativeY, MouseInteractivityTestType testType);
1855
1856 void queueEventAsLowLevelSceneStateTransitionAction(const Event &evt, Structural *root, bool cascade, bool relay);
1857
1858 void loadScene(const Common::SharedPtr<Structural> &scene);
1859
1860 void ensureMainWindowExists();
1861
1862 void unloadProject();
1863 void refreshPlayTime(); // Updates play time to be in sync with the system clock. Used so that events occurring after storage access don't skip.
1864
1865 struct DispatchMessageCoroutine {
1866 CORO_DEFINE_RETURN_TYPE(void);
1867 CORO_DEFINE_PARAMS_2(Runtime *, runtime, Common::SharedPtr<MessageDispatch>, dispatch);
1868 };
1869
1870 struct SendMessageToStructuralCoroutine {
1871 CORO_DEFINE_RETURN_TYPE(void);
1872 CORO_DEFINE_PARAMS_4(Runtime *, runtime, bool *, isTerminatedPtr, Structural *, structural, MessageDispatch *, dispatch);
1873 };
1874
1875 struct SendMessageToModifierContainerCoroutine {
1876 CORO_DEFINE_RETURN_TYPE(void);
1877 CORO_DEFINE_PARAMS_4(Runtime *, runtime, bool *, isTerminatedPtr, IModifierContainer *, modifierContainer, MessageDispatch *, dispatch);
1878 };
1879
1880 struct SendMessageToModifierCoroutine {
1881 CORO_DEFINE_RETURN_TYPE(void);
1882 CORO_DEFINE_PARAMS_4(Runtime *, runtime, bool *, isTerminatedPtr, Modifier *, modifier, MessageDispatch *, dispatch);
1883 };
1884
1885 VThreadState dispatchKeyTask(const DispatchKeyTaskData &data);
1886 VThreadState dispatchActionTask(const DispatchActionTaskData &data);
1887 VThreadState consumeMessageTask(const ConsumeMessageTaskData &data);
1888 VThreadState consumeCommandTask(const ConsumeCommandTaskData &data);
1889 VThreadState updateMouseStateTask(const UpdateMouseStateTaskData &data);
1890 VThreadState updateMousePositionTask(const UpdateMousePositionTaskData &data);
1891 VThreadState applyDefaultVisibility(const ApplyDefaultVisibilityTaskData &data);
1892
1893 void updateMainWindowCursor();
1894
1895 static void recursiveFindColliders(Structural *structural, size_t sceneStackDepth, Common::Array<ColliderInfo> &colliders, int32 parentOriginX, int32 parentOriginY, bool isRoot);
1896 static bool sortColliderPredicate(const ColliderInfo &a, const ColliderInfo &b);
1897
1899
1901 Common::SharedPtr<ProjectDescription> _queuedProjectDesc;
1906 ObjectLinkingScope _rootLinkingScope;
1907
1908 Common::Array<Teardown> _pendingTeardowns;
1909 Common::Array<LowLevelSceneStateTransitionAction> _pendingLowLevelTransitions;
1912 Common::Array<Common::WeakPtr<Structural> > _pendingPostCloneShowChecks;
1913 Common::Array<Common::WeakPtr<Structural> > _pendingShowClonedObject;
1914 Common::Array<ObjectParentChange> _pendingParentChanges;
1915 uint _pendingSceneReturnCount;
1916 Common::Array<HighLevelSceneTransition> _pendingSceneTransitions;
1918 Common::SharedPtr<Structural> _activeMainScene;
1919 Common::SharedPtr<Structural> _activeSharedScene;
1920 Common::Array<SceneReturnListEntry> _sceneReturnList;
1921
1922 SceneTransitionState _sceneTransitionState;
1923 SceneTransitionEffect _sourceSceneTransitionEffect;
1924 SceneTransitionEffect _destinationSceneTransitionEffect;
1925 SceneTransitionEffect *_activeSceneTransitionEffect;
1926 Common::SharedPtr<Graphics::ManagedSurface> _sceneTransitionOldFrame;
1927 Common::SharedPtr<Graphics::ManagedSurface> _sceneTransitionNewFrame;
1928 uint32 _sceneTransitionStartTime;
1929 uint32 _sceneTransitionEndTime;
1930 bool _sharedSceneWasSetExplicitly;
1931
1932 Common::WeakPtr<Window> _mainWindow;
1934
1936
1938
1939 uint32 _nextRuntimeGUID;
1940
1941 bool _displayModeSupported[kColorDepthModeCount];
1942 Graphics::PixelFormat _displayModePixelFormats[kColorDepthModeCount];
1943 ColorDepthMode _realDisplayMode;
1944 ColorDepthMode _fakeDisplayMode;
1945 uint16 _displayWidth;
1946 uint16 _displayHeight;
1947
1948 uint64 _realTimeBase;
1949 uint64 _playTimeBase;
1950
1951 uint32 _realTime;
1952 uint32 _playTime;
1953
1954 Scheduler _scheduler;
1955 OSystem *_system;
1956 Audio::Mixer *_mixer;
1957
1958 ISaveUIProvider *_saveProvider;
1959 ILoadUIProvider *_loadProvider;
1960 Common::SharedPtr<Graphics::ManagedSurface> _saveScreenshotOverride;
1961
1962 Common::SharedPtr<CursorGraphic> _lastFrameCursor;
1963 Common::SharedPtr<CursorGraphic> _defaultCursor;
1964 bool _lastFrameMouseVisible;
1965
1966 Common::WeakPtr<Window> _mouseFocusWindow;
1967 bool _mouseFocusFlags[Actions::kMouseButtonCount];
1968
1969 Common::WeakPtr<Window> _keyFocusWindow;
1970
1971 Common::SharedPtr<SystemInterface> _systemInterface;
1972 Common::SharedPtr<WorldManagerInterface> _worldManagerInterface;
1973 Common::SharedPtr<AssetManagerInterface> _assetManagerInterface;
1974
1975 // The cached mouse position is updated at frame end
1976 Common::Point _cachedMousePosition;
1977
1978 // The real mouse position is updated all the time (even when suspended)
1979 Common::Point _realMousePosition;
1980
1981 // Mouse control is tracked in two ways: Mouse over is detected with mouse movement AND when
1982 // "refreshCursor" is set on the world manager, it indicates the frontmost object that
1983 // responds to any mouse event. The mouse tracking object is the object that was clicked.
1984 // These can differ if the user holds down the mouse and moves it to a spot where the tracked
1985 // object is either not clickable, or is behind another object with mouse collision.
1986 // Note that mouseOverObject is also NOT necessarily what will receive mouse down events.
1987 Common::WeakPtr<Structural> _mouseOverObject;
1988 Common::WeakPtr<Structural> _mouseTrackingObject;
1989 Common::Point _mouseTrackingDragStart;
1990 Common::Point _mouseTrackingObjectInitialOrigin;
1991 bool _trackedMouseOutside;
1992 bool _forceCursorRefreshOnce;
1993 bool _autoResetCursor;
1994
1995 uint32 _modifierOverrideCursorID;
1996 bool _haveModifierOverrideCursor;
1997 bool _haveCursorElement;
1998
1999 uint32 _multiClickStartTime;
2000 uint32 _multiClickInterval;
2001 uint _multiClickCount;
2002
2003 uint _numMouseBlockers;
2004
2005 bool _defaultVolumeState;
2006
2007 // True if any elements were added to the scene, removed from the scene, or reparented since last draw
2008 bool _sceneGraphChanged;
2009
2010 bool _isQuitting;
2011
2013 Common::Array<BoundaryCheckState> _boundaryChecks;
2014 uint32 _collisionCheckTime;
2015
2016 Common::WeakPtr<VisualElement> _elementTrackedToCursor;
2017 //uint32 _elementCursorUpdateTime;
2018
2019 Common::Array<IPostEffect *> _postEffects;
2020
2021 Palette _globalPalette;
2022
2023 Common::SharedPtr<SubtitleRenderer> _subtitleRenderer;
2024
2025 Hacks _hacks;
2026
2027 Common::HashMap<uint32, Common::String> _getSetAttribIDsToAttribName;
2028
2029#ifdef MTROPOLIS_DEBUG_ENABLE
2031#endif
2032};
2033
2035 virtual const Common::Array<Common::SharedPtr<Modifier> > &getModifiers() const = 0;
2036 virtual void appendModifier(const Common::SharedPtr<Modifier> &modifier) = 0;
2037 virtual void removeModifier(const Modifier *modifier) = 0;
2038};
2039
2041public:
2042 const Common::Array<Common::SharedPtr<Modifier> > &getModifiers() const override;
2043 void appendModifier(const Common::SharedPtr<Modifier> &modifier) override;
2044 void removeModifier(const Modifier *modifier) override;
2045
2046 void clear();
2047
2048private:
2050};
2051
2053 template<typename TElement, typename TElementData>
2054 friend class ElementFactory;
2055
2056public:
2057 RuntimeObject();
2058 virtual ~RuntimeObject();
2059
2060 uint32 getStaticGUID() const;
2061 uint32 getRuntimeGUID() const;
2062
2063 void setRuntimeGUID(uint32 runtimeGUID);
2064
2065 void setSelfReference(const Common::WeakPtr<RuntimeObject> &selfReference);
2066 const Common::WeakPtr<RuntimeObject> &getSelfReference() const;
2067
2068 virtual bool isStructural() const;
2069 virtual bool isProject() const;
2070 virtual bool isSection() const;
2071 virtual bool isSubsection() const;
2072 virtual bool isModifier() const;
2073 virtual bool isElement() const;
2074
2075 virtual bool readAttribute(MiniscriptThread *thread, DynamicValue &result, const Common::String &attrib);
2076 virtual bool readAttributeIndexed(MiniscriptThread *thread, DynamicValue &result, const Common::String &attrib, const DynamicValue &index);
2077 virtual MiniscriptInstructionOutcome writeRefAttribute(MiniscriptThread *thread, DynamicValueWriteProxy &result, const Common::String &attrib);
2078 virtual MiniscriptInstructionOutcome writeRefAttributeIndexed(MiniscriptThread *thread, DynamicValueWriteProxy &result, const Common::String &attrib, const DynamicValue &index);
2079
2080protected:
2081 MiniscriptInstructionOutcome scriptSetClone(MiniscriptThread *thread, const DynamicValue &value);
2082 MiniscriptInstructionOutcome scriptSetKill(MiniscriptThread *thread, const DynamicValue &value);
2083 MiniscriptInstructionOutcome scriptSetParent(MiniscriptThread *thread, const DynamicValue &value);
2084
2085 // This is the static GUID stored in the data, it is not guaranteed
2086 // to be globally unique at runtime. In particular, cloning an object
2087 // and using aliased modifiers will cause multiple objects with the same
2088 // static GUID to exist with separate runtime GUIDs.
2089 uint32 _guid;
2090 uint32 _runtimeGUID;
2091 Common::WeakPtr<RuntimeObject> _selfReference;
2092
2094 static MiniscriptInstructionOutcome write(MiniscriptThread *thread, const DynamicValue &dest, void *objectRef, uintptr ptrOrOffset);
2095 static MiniscriptInstructionOutcome refAttrib(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, void *objectRef, uintptr ptrOrOffset, const Common::String &attrib);
2096 static MiniscriptInstructionOutcome refAttribIndexed(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, void *objectRef, uintptr ptrOrOffset, const Common::String &attrib, const DynamicValue &index);
2097
2098 private:
2099 static RuntimeObject *resolveObjectParent(RuntimeObject *obj);
2100 };
2101};
2102
2104 MessageProperties(const Event &evt, const DynamicValue &value, const Common::WeakPtr<RuntimeObject> &source);
2105
2106 const Event &getEvent() const;
2107 const DynamicValue &getValue() const;
2108 const Common::WeakPtr<RuntimeObject> &getSource() const;
2109
2110 void setValue(const DynamicValue &value);
2111
2112private:
2113 Event _evt;
2114 DynamicValue _value;
2116};
2117
2119 virtual void visitChildStructuralRef(Common::SharedPtr<Structural> &structural) = 0;
2120 virtual void visitChildModifierRef(Common::SharedPtr<Modifier> &modifier) = 0;
2121 virtual void visitWeakStructuralRef(Common::WeakPtr<Structural> &structural) = 0;
2122 virtual void visitWeakModifierRef(Common::WeakPtr<Modifier> &modifier) = 0;
2123};
2124
2126 // These should only be implemented as direct responses - child traversal is handled by the message propagation process
2127 virtual bool respondsToEvent(const Event &evt) const = 0;
2128 virtual VThreadState consumeMessage(Runtime *runtime, const Common::SharedPtr<MessageProperties> &msg) = 0;
2129};
2130
2132public:
2134
2135 bool readAttribute(MiniscriptThread *thread, DynamicValue &result, const Common::String &attrib) override;
2136 MiniscriptInstructionOutcome writeRefAttribute(MiniscriptThread *thread, DynamicValueWriteProxy &result, const Common::String &attrib) override;
2137
2138private:
2139 MiniscriptInstructionOutcome setCurrentScene(MiniscriptThread *thread, const DynamicValue &value);
2140 MiniscriptInstructionOutcome setRefreshCursor(MiniscriptThread *thread, const DynamicValue &value);
2141 MiniscriptInstructionOutcome setAutoResetCursor(MiniscriptThread *thread, const DynamicValue &value);
2142 MiniscriptInstructionOutcome setWinSndBufferSize(MiniscriptThread *thread, const DynamicValue &value);
2143 MiniscriptInstructionOutcome setCursor(MiniscriptThread *thread, const DynamicValue &value);
2144
2145 int32 _opInt;
2146 bool _gameMode;
2147 bool _combineRedraws;
2148 bool _postponeRedraws;
2149};
2150
2152public:
2154
2155 bool readAttribute(MiniscriptThread *thread, DynamicValue &result, const Common::String &attrib) override;
2156 MiniscriptInstructionOutcome writeRefAttribute(MiniscriptThread *thread, DynamicValueWriteProxy &result, const Common::String &attrib) override;
2157
2158private:
2159 Common::String _opString;
2160};
2161
2163public:
2164 const int kFullVolume = 7;
2165
2167
2168 bool readAttribute(MiniscriptThread *thread, DynamicValue &result, const Common::String &attrib) override;
2169 bool readAttributeIndexed(MiniscriptThread *thread, DynamicValue &result, const Common::String &attrib, const DynamicValue &index) override;
2170 MiniscriptInstructionOutcome writeRefAttribute(MiniscriptThread *thread, DynamicValueWriteProxy &result, const Common::String &attrib) override;
2171
2172private:
2173 MiniscriptInstructionOutcome setEjectCD(MiniscriptThread *thread, const DynamicValue &value);
2174 MiniscriptInstructionOutcome setGameMode(MiniscriptThread *thread, const DynamicValue &value);
2175 MiniscriptInstructionOutcome setMasterVolume(MiniscriptThread *thread, const DynamicValue &value);
2176 MiniscriptInstructionOutcome setMonitorBitDepth(MiniscriptThread *thread, const DynamicValue &value);
2177 MiniscriptInstructionOutcome setVolumeName(MiniscriptThread *thread, const DynamicValue &value);
2178
2179 Common::String _volumeName;
2180 Common::String _opString;
2181 int _masterVolume;
2182};
2183
2185public:
2186 virtual ~StructuralHooks();
2187
2188 virtual void onCreate(Structural *structural);
2189 virtual void onPostActivate(Structural *structural);
2190 virtual void onSetPosition(Runtime *runtime, Structural *structural, const Common::Point &oldPt, Common::Point &pt);
2191 virtual void onStopPlayingMToon(Structural *structural, bool &visible, bool &stopped, Graphics::ManagedSurface *lastSurf);
2192 virtual void onHidden(Structural *structural, bool &visible);
2193};
2194
2196public:
2197 enum class SceneLoadState {
2198 kNotAScene,
2199 kSceneNotLoaded,
2200 kSceneLoaded,
2201 };
2202
2203 Structural();
2204 explicit Structural(Runtime *runtime);
2205 virtual ~Structural();
2206
2207 bool isStructural() const override;
2208 SceneLoadState getSceneLoadState() const;
2209 void setSceneLoadState(SceneLoadState sceneLoadState);
2210
2211 bool readAttribute(MiniscriptThread *thread, DynamicValue &result, const Common::String &attrib) override;
2212 bool readAttributeIndexed(MiniscriptThread *thread, DynamicValue &result, const Common::String &attrib, const DynamicValue &index) override;
2213 MiniscriptInstructionOutcome writeRefAttribute(MiniscriptThread *thread, DynamicValueWriteProxy &result, const Common::String &attrib) override;
2214
2215 const Common::Array<Common::SharedPtr<Structural> > &getChildren() const;
2216 void addChild(const Common::SharedPtr<Structural> &child);
2217 void removeAllChildren();
2218 void removeAllModifiers();
2219 void removeChild(Structural *child);
2220 void removeAllAssets();
2221
2222 void holdAssets(const Common::Array<Common::SharedPtr<Asset> > &assets);
2223
2224 Structural *getParent() const;
2225 Structural *findNextSibling() const;
2226 Structural *findPrevSibling() const;
2227 void setParent(Structural *parent);
2228
2229 // Helper that finds the scene containing the structural object, or itself if it is the scene
2230 VisualElement *findScene();
2231
2232 const Common::String &getName() const;
2233
2234 const Common::Array<Common::SharedPtr<Modifier> > &getModifiers() const override;
2235 void appendModifier(const Common::SharedPtr<Modifier> &modifier) override;
2236 void removeModifier(const Modifier *modifier) override;
2237
2238 bool respondsToEvent(const Event &evt) const override;
2239 VThreadState consumeMessage(Runtime *runtime, const Common::SharedPtr<MessageProperties> &msg) override;
2240
2241 void materializeSelfAndDescendents(Runtime *runtime, ObjectLinkingScope *outerScope);
2242 void materializeDescendents(Runtime *runtime, ObjectLinkingScope *outerScope);
2243
2245 CORO_DEFINE_RETURN_TYPE(void);
2246 CORO_DEFINE_PARAMS_3(Structural *, self, Runtime *, runtime, Common::SharedPtr<MessageProperties>, msg);
2247 };
2248
2249 virtual VThreadState asyncConsumeCommand(Runtime *runtime, const Common::SharedPtr<MessageProperties> &msg);
2250
2251 virtual void activate();
2252 virtual void deactivate();
2253
2254 void recursiveCollectObjectsMatchingCriteria(Common::Array<Common::WeakPtr<RuntimeObject> > &results, bool (*evalFunc)(void *userData, RuntimeObject *object), void *userData, bool onlyEnabled);
2255
2256 void setHooks(const Common::SharedPtr<StructuralHooks> &hooks);
2257 const Common::SharedPtr<StructuralHooks> &getHooks() const;
2258
2259 // Shallow clones only need to copy the object. Descendent copies are done using visitInternalReferences.
2260 virtual Common::SharedPtr<Structural> shallowClone() const = 0;
2261
2262 virtual void visitInternalReferences(IStructuralReferenceVisitor *visitor);
2263
2264#ifdef MTROPOLIS_DEBUG_ENABLE
2265 SupportStatus debugGetSupportStatus() const override;
2266 const Common::String &debugGetName() const override;
2267 void debugInspect(IDebugInspectionReport *report) const override;
2268
2269 virtual void debugSkipMovies();
2270#endif
2271
2272protected:
2273 explicit Structural(const Structural &other);
2274
2275 virtual ObjectLinkingScope *getPersistentStructuralScope();
2276 virtual ObjectLinkingScope *getPersistentModifierScope();
2277
2278 MiniscriptInstructionOutcome scriptSetPaused(MiniscriptThread *thread, const DynamicValue &value);
2279 MiniscriptInstructionOutcome scriptSetLoop(MiniscriptThread *thread, const DynamicValue &value);
2280 MiniscriptInstructionOutcome scriptSetDebug(MiniscriptThread *thread, const DynamicValue &value);
2281 MiniscriptInstructionOutcome scriptSetUnload(MiniscriptThread *thread, const DynamicValue &value);
2282
2283 // If you override this, you must override visitInternalReferences too.
2284 virtual void linkInternalReferences(ObjectLinkingScope *outerScope);
2285
2286 virtual void onPauseStateChanged();
2287
2288 Runtime *getRuntime() const;
2289
2290 Structural *_parent;
2293 Common::String _name;
2294
2296
2297 // "paused" attrib is available for ALL structural types, even when it doesn't do anything.
2298 // Changing it does not affect modifiers on the object that play media, but does fire
2299 // "Paused"/"Unpaused" events.
2300 bool _paused;
2301
2302 // "loop" appears to have been made available on everything in 1.2. Obsidian depends on it
2303 // being available for sound indexes to be properly set up.
2304 bool _loop;
2305
2306 int32 _flushPriority;
2307 SceneLoadState _sceneLoadState;
2308
2310
2311private:
2312 Runtime *_runtime;
2313};
2314
2317
2318 uint16 width;
2319 uint16 height;
2320 uint32 bitsPerPixel;
2321};
2322
2325};
2326
2328 enum Type {
2329 kTypeUnknown,
2330 kTypeCountedModifierList,
2331 kTypeFlagTerminatedModifierList,
2332 kTypeProject,
2333 kTypeSection,
2334 kTypeFilteredElements,
2335 };
2336
2338 Structural *structural;
2339 bool (*filterFunc)(Data::DataObjectTypes::DataObjectType dataObjectType);
2340 };
2341
2343 IModifierContainer *modifierContainer;
2344 Structural *structural;
2345 FilteredElements filteredElements;
2346 };
2347
2349
2350 uint remainingCount;
2351 Type type;
2352 ContainerUnion containerUnion;
2353};
2354
2357};
2358
2360public:
2362
2363 void registerPlugInModifier(const char *name, const Data::IPlugInModifierDataFactory *dataFactory, const IPlugInModifierFactory *factory) override;
2364
2365 const Data::PlugInModifierRegistry &getDataLoaderRegistry() const;
2366 const IPlugInModifierFactory *findPlugInModifierFactory(const char *name) const;
2367
2368private:
2369 Data::PlugInModifierRegistry _dataLoaderRegistry;
2371};
2372
2374 virtual void playMedia(Runtime *runtime, Project *project) = 0;
2375};
2376
2378public:
2381
2382 void playMedia(Runtime *runtime, Project *project);
2383 void addReceiver(IPlayMediaSignalReceiver *receiver);
2384 void removeReceiver(IPlayMediaSignalReceiver *receiver);
2385
2386private:
2388};
2389
2391 virtual void onSegmentUnloaded(int segmentIndex) = 0;
2392};
2393
2395public:
2396 explicit SegmentUnloadSignaller(Project *project, int segmentIndex);
2398
2399 void onSegmentUnloaded();
2400 void addReceiver(ISegmentUnloadSignalReceiver *receiver);
2401 void removeReceiver(ISegmentUnloadSignalReceiver *receiver);
2402
2403private:
2404 Project *_project;
2405 int _segmentIndex;
2407};
2408
2410 virtual void onKeyboardEvent(Runtime *runtime, const KeyboardInputEvent &keyEvt) = 0;
2411};
2412
2414public:
2417
2418 void onKeyboardEvent(Runtime *runtime, const KeyboardInputEvent &keyEvt);
2419 void addReceiver(IKeyboardEventReceiver *receiver);
2420 void removeReceiver(IKeyboardEventReceiver *receiver);
2421
2422private:
2425};
2426
2427struct ICollider : public IInterfaceBase {
2428 virtual void getCollisionProperties(Modifier *&modifier, bool &collideInFront, bool &collideBehind, bool &excludeParents) const = 0;
2429 virtual void triggerCollision(Runtime *runtime, Structural *collidingElement, bool wasInContact, bool isInContact, bool &outShouldStop) = 0;
2430};
2431
2433 enum EdgeFlags {
2434 kEdgeTop = 0x1,
2435 kEdgeBottom = 0x2,
2436 kEdgeLeft = 0x4,
2437 kEdgeRight = 0x8,
2438 };
2439
2440 virtual void getCollisionProperties(Modifier *&modifier, uint &edgeFlags, bool &mustBeCompletelyOutside, bool &continuous) const = 0;
2441 virtual void triggerCollision(Runtime *runtime) = 0;
2442};
2443
2445 virtual void renderPostEffect(Graphics::ManagedSurface &surface) const = 0;
2446};
2447
2449 virtual Modifier *getMediaCueModifier() = 0;
2450 virtual Common::WeakPtr<Modifier> getMediaCueTriggerSource() const = 0;
2451};
2452
2454 enum TriggerTiming {
2455 kTriggerTimingStart = 0,
2456 kTriggerTimingDuring = 1,
2457 kTriggerTimingEnd = 2,
2458 };
2459
2460 int32 minTime;
2461 int32 maxTime;
2462
2463 IMediaCueModifier *sourceModifier;
2464 TriggerTiming triggerTiming;
2465 MessengerSendSpec send;
2466 DynamicValue incomingData;
2467
2468 MediaCueState();
2469 void checkTimestampChange(Runtime *runtime, uint32 oldTS, uint32 newTS, bool continuousTimestamps, bool canTriggerDuring);
2470};
2471
2472class Project : public Structural {
2473public:
2474 explicit Project(Runtime *runtime);
2475 ~Project();
2476
2477 VThreadState asyncConsumeCommand(Runtime *runtime, const Common::SharedPtr<MessageProperties> &msg) override;
2478
2479 MiniscriptInstructionOutcome writeRefAttribute(MiniscriptThread *thread, DynamicValueWriteProxy &result, const Common::String &attrib) override;
2480
2481 void loadFromDescription(const ProjectDescription &desc, const Hacks &hacks);
2482 void loadSceneFromStream(const Common::SharedPtr<Structural> &structural, uint32 streamID, const Hacks &hacks);
2483
2484 Common::SharedPtr<Modifier> resolveAlias(uint32 aliasID) const;
2485 Common::SharedPtr<Modifier> findGlobalVarWithName(const Common::String &name) const;
2486 void materializeGlobalVariables(Runtime *runtime, ObjectLinkingScope *scope);
2487
2488 const ProjectPresentationSettings &getPresentationSettings() const;
2489
2490 bool isProject() const override;
2491
2492 Common::String getAssetNameByID(uint32 assetID) const;
2493 Common::WeakPtr<Asset> getAssetByID(uint32 assetID) const;
2494 bool getAssetIDByName(const Common::String &assetName, uint32 &outAssetID) const;
2495 void forceLoadAsset(uint32 assetID, Common::Array<Common::SharedPtr<Asset> > &outHoldAssets);
2496
2497 size_t getSegmentForStreamIndex(size_t streamIndex) const;
2498 void openSegmentStream(int segmentIndex);
2499 void closeSegmentStream(int segmentIndex);
2500 Common::SeekableReadStream *getStreamForSegment(int segmentIndex);
2501
2502 const Common::String *findNameOfLabel(const Label &label) const;
2503
2504 void onPostRender();
2505 void onKeyboardEvent(Runtime *runtime, const KeyboardInputEvent &keyEvt);
2506
2507 Common::SharedPtr<SegmentUnloadSignaller> notifyOnSegmentUnload(int segmentIndex, ISegmentUnloadSignalReceiver *receiver);
2510
2511 const char *findAuthorMessageName(uint32 id) const;
2512
2513 const Common::SharedPtr<CursorGraphicCollection> &getCursorGraphics() const;
2514
2515 const SubtitleTables &getSubtitles() const;
2516
2517 RuntimeVersion getRuntimeVersion() const;
2518 ProjectPlatform getPlatform() const;
2519
2520 void visitInternalReferences(IStructuralReferenceVisitor *visitor) override;
2521 Common::SharedPtr<Structural> shallowClone() const override;
2522
2523#ifdef MTROPOLIS_DEBUG_ENABLE
2524 const char *debugGetTypeName() const override { return "Project"; }
2525#endif
2526
2527private:
2528 struct LabelSuperGroup {
2529 LabelSuperGroup();
2530
2531 size_t firstRootNodeIndex;
2532 size_t numRootNodes;
2533 size_t numTotalNodes;
2534
2535 uint32 superGroupID;
2536 Common::String name;
2537 };
2538
2539 struct LabelTree {
2540 LabelTree();
2541
2542 size_t firstChildIndex;
2543 size_t numChildren;
2544
2545 uint32 id;
2546 Common::String name;
2547 };
2548
2549 struct Segment {
2550 Segment();
2551
2552 SegmentDescription desc;
2554
2555 Common::SeekableReadStream *weakStream;
2557 };
2558
2559 enum StreamType {
2560 kStreamTypeUnknown,
2561
2562 kStreamTypeAsset,
2563 kStreamTypeBoot,
2564 kStreamTypeScene,
2565 };
2566
2567 struct StreamDesc {
2568 StreamDesc();
2569
2570 StreamType streamType;
2571 uint16 segmentIndex;
2572 uint32 size;
2573 uint32 pos;
2574 };
2575
2576 struct AssetDesc {
2577 AssetDesc();
2578
2579 uint32 typeCode;
2580 uint32 streamID;
2581 uint32 filePosition;
2582 size_t id;
2583 Common::String name;
2584
2585 // If the asset is live, this will be its asset info
2587 };
2588
2589 void loadBootStream(size_t streamIndex, const Hacks &hacks);
2590
2591 void loadPresentationSettings(const Data::PresentationSettings &presentationSettings);
2592 void loadAssetCatalog(const Data::AssetCatalog &assetCatalog);
2593 void loadGlobalObjectInfo(ChildLoaderStack &loaderStack, const Data::GlobalObjectInfo &globalObjectInfo);
2594 void loadAssetDef(size_t streamIndex, AssetDefLoaderContext &context, const Data::DataObject &dataObject);
2595 void loadContextualObject(size_t streamIndex, ChildLoaderStack &stack, const Data::DataObject &dataObject);
2596 Common::SharedPtr<Modifier> loadModifierObject(ModifierLoaderContext &loaderContext, const Data::DataObject &dataObject);
2597 void loadLabelMap(const Data::ProjectLabelMap &projectLabelMap);
2598 static size_t recursiveCountLabels(const Data::ProjectLabelMap::LabelTree &tree);
2599
2600 ObjectLinkingScope *getPersistentStructuralScope() override;
2601 ObjectLinkingScope *getPersistentModifierScope() override;
2602
2603 void assignAssets(const Common::Array<Common::SharedPtr<Asset> > &assets, const Hacks &hacks);
2604
2605 void initAdditionalSegments(const Common::String &projectName);
2606
2607 Common::Array<Segment> _segments;
2609 Common::Array<LabelTree> _labelTree;
2610 Common::Array<LabelSuperGroup> _labelSuperGroups;
2611 Data::ProjectFormat _projectFormat;
2612
2613 Common::Array<AssetDesc *> _assetsByID;
2614 Common::Array<AssetDesc> _realAssets;
2615
2617
2618 ProjectPresentationSettings _presentationSettings;
2619
2620 bool _haveGlobalObjectInfo;
2621 bool _haveProjectStructuralDef;
2622 SimpleModifierContainer _globalModifiers;
2623
2624 ProjectPlugInRegistry _plugInRegistry;
2625
2629
2630 ObjectLinkingScope _structuralScope;
2631 ObjectLinkingScope _modifierScope;
2632
2633 Common::SharedPtr<PlayMediaSignaller> _playMediaSignaller;
2634 Common::SharedPtr<KeyboardEventSignaller> _keyboardEventSignaller;
2635
2636 SubtitleTables _subtitles;
2637
2638 ProjectPlatform _platform;
2639
2640 Common::Archive *_rootArchive;
2641 Common::Path _projectRootDir;
2642
2643 RuntimeVersion _runtimeVersion;
2644 bool _isRuntimeVersionAutoDetect;
2645};
2646
2647class Section : public Structural {
2648public:
2649 bool load(const Data::SectionStructuralDef &data);
2650
2651 bool isSection() const override;
2652
2653 Common::SharedPtr<Structural> shallowClone() const override;
2654 void visitInternalReferences(IStructuralReferenceVisitor *visitor) override;
2655
2656#ifdef MTROPOLIS_DEBUG_ENABLE
2657 const char *debugGetTypeName() const override { return "Section"; }
2658#endif
2659
2660private:
2661 ObjectLinkingScope *getPersistentStructuralScope() override;
2662 ObjectLinkingScope *getPersistentModifierScope() override;
2663
2664 ObjectLinkingScope _structuralScope;
2665 ObjectLinkingScope _modifierScope;
2666};
2667
2668class Subsection : public Structural {
2669public:
2670 bool load(const Data::SubsectionStructuralDef &data);
2671
2672 bool readAttribute(MiniscriptThread *thread, DynamicValue &result, const Common::String &attrib) override;
2673
2674 ObjectLinkingScope *getSceneLoadMaterializeScope();
2675
2676 bool isSubsection() const override;
2677
2678 Common::SharedPtr<Structural> shallowClone() const override;
2679 void visitInternalReferences(IStructuralReferenceVisitor *visitor) override;
2680
2681#ifdef MTROPOLIS_DEBUG_ENABLE
2682 const char *debugGetTypeName() const override { return "Subsection"; }
2683#endif
2684
2685private:
2686 ObjectLinkingScope *getPersistentStructuralScope() override;
2687 ObjectLinkingScope *getPersistentModifierScope() override;
2688
2689 ObjectLinkingScope _structuralScope;
2690 ObjectLinkingScope _modifierScope;
2691};
2692
2693class Element : public Structural {
2694public:
2695 Element();
2696
2697 virtual bool isVisual() const = 0;
2698 virtual bool canAutoPlay() const;
2699 virtual void queueAutoPlayEvents(Runtime *runtime, bool isAutoPlaying);
2700
2701 bool isElement() const override;
2702
2703 uint32 getStreamLocator() const;
2704
2705 void addMediaCue(MediaCueState *mediaCue);
2706 void removeMediaCue(const MediaCueState *mediaCue);
2707
2708 void triggerAutoPlay(Runtime *runtime);
2709 virtual void tryAutoSetName(Runtime *runtime, Project *project);
2710
2711 virtual bool resolveMediaMarkerLabel(const Label &label, int32 &outResolution) const;
2712
2713 void visitInternalReferences(IStructuralReferenceVisitor *visitor) override;
2714
2716
2717protected:
2718 Element(const Element &other);
2719
2720 uint32 _streamLocator;
2721 uint16 _sectionID;
2722
2724
2725 bool _haveCheckedAutoPlay;
2726};
2727
2729public:
2731
2732 uint8 getAlpha() const;
2733 void setAlpha(uint8 alpha);
2734
2735 bool isDirty() const;
2736 void clearDirty();
2737
2738private:
2739 uint8 _alpha;
2740 bool _isDirty;
2741};
2742
2744public:
2747
2748 enum InkMode {
2749 kInkModeCopy = 0x0,
2750 kInkModeTransparent = 0x1, // src*dest
2751 kInkModeGhost = 0x3, // (1-src)+dest
2752 kInkModeReverseCopy = 0x4, // 1-src
2753 kInkModeReverseGhost = 0x7, // src+dest
2754 kInkModeReverseTransparent = 0x9, // (1-src)*dest
2755 kInkModeBlend = 0x20, // (src*bgcolor)+(dest*(1-bgcolor)
2756 kInkModeBackgroundTransparent = 0x24, // BG color is transparent
2757 kInkModeChameleonDark = 0x25, // src+dest
2758 kInkModeChameleonLight = 0x27, // src*dest
2759 kInkModeBackgroundMatte = 0x224, // BG color is transparent and non-interactive
2760 kInkModeInvisible = 0xffff, // Not drawn, but interactive
2761
2762 kInkModeXor = 0x7ffffff0, // Fake ink mode for Obsidian canvas puzzle, not a valid value from data
2763 kInkModeDefault = 0x7fffffff, // Not a valid value from data
2764 };
2765
2766 enum Shape {
2767 kShapeRect = 0x1,
2768 kShapeRoundedRect = 0x2,
2769 kShapeOval = 0x3,
2770 kShapePolygon = 0x9,
2771 kShapeStar = 0xb, // 5-point star, horizontal arms are at (top+bottom*2)/3
2772
2773 // Fake shapes for Obsidian canvas puzzle, not a valid from data
2774 kShapeObsidianCanvasPuzzleTri1 = 0x7ffffff1,
2775 kShapeObsidianCanvasPuzzleTri2 = 0x7ffffff2,
2776 kShapeObsidianCanvasPuzzleTri3 = 0x7ffffff3,
2777 kShapeObsidianCanvasPuzzleTri4 = 0x7ffffff4,
2778 };
2779
2780 InkMode getInkMode() const;
2781 void setInkMode(InkMode inkMode);
2782
2783 Shape getShape() const;
2784 void setShape(Shape shape);
2785
2786 const ColorRGB8 &getForeColor() const;
2787 void setForeColor(const ColorRGB8 &color);
2788
2789 const ColorRGB8 &getBackColor() const;
2790 void setBackColor(const ColorRGB8 &color);
2791
2792 const ColorRGB8 &getBorderColor() const;
2793 void setBorderColor(const ColorRGB8 &color);
2794
2795 const ColorRGB8 &getShadowColor() const;
2796 void setShadowColor(const ColorRGB8 &color);
2797
2798 uint16 getBorderSize() const;
2799 void setBorderSize(uint16 size);
2800
2801 uint16 getShadowSize() const;
2802 void setShadowSize(uint16 size);
2803
2804 const Common::Array<Common::Point> &getPolyPoints() const;
2805 Common::Array<Common::Point> &modifyPolyPoints();
2806
2807 bool isDirty() const;
2808 void clearDirty();
2809
2811
2812private:
2813 InkMode _inkMode;
2814 Shape _shape;
2815 ColorRGB8 _foreColor;
2816 ColorRGB8 _backColor;
2817 uint16 _borderSize;
2818 ColorRGB8 _borderColor;
2819 uint16 _shadowSize;
2820 ColorRGB8 _shadowColor;
2821
2822 Common::Array<Common::Point> _polyPoints;
2823
2824 bool _isDirty;
2825};
2826
2827class VisualElement : public Element {
2828public:
2829 VisualElement();
2830
2831 bool isVisual() const override;
2832 virtual bool isTextLabel() const;
2833
2835 CORO_DEFINE_RETURN_TYPE(void);
2836 CORO_DEFINE_PARAMS_3(VisualElement *, self, Runtime *, runtime, Common::SharedPtr<MessageProperties>, msg);
2837 };
2838
2839 VThreadState asyncConsumeCommand(Runtime *runtime, const Common::SharedPtr<MessageProperties> &msg) override;
2840
2841 bool respondsToEvent(const Event &evt) const override;
2842 VThreadState consumeMessage(Runtime *runtime, const Common::SharedPtr<MessageProperties> &msg) override;
2843
2844 bool isVisible() const;
2845 bool isVisibleByDefault() const;
2846 void setVisible(Runtime *runtime, bool visible);
2847
2848 bool isDirectToScreen() const;
2849 void setDirectToScreen(bool directToScreen);
2850
2851 uint16 getLayer() const;
2852 void setLayer(uint16 layer);
2853
2854 bool isMouseInsideDrawableArea(int32 relativeX, int32 relativeY) const;
2855
2856 // Returns true if there is mouse collision at a specified point, assuming it has already passed isMouseInsideBox
2857 virtual bool isMouseCollisionAtPoint(int32 relativeX, int32 relativeY) const;
2858
2859 bool readAttribute(MiniscriptThread *thread, DynamicValue &result, const Common::String &attrib) override;
2860 MiniscriptInstructionOutcome writeRefAttribute(MiniscriptThread *thread, DynamicValueWriteProxy &writeProxy, const Common::String &attrib) override;
2861
2862 Common::Point getParentOrigin() const;
2863 Common::Point getGlobalPosition() const;
2864 const Common::Rect &getRelativeRect() const;
2865 virtual Common::Rect getRelativeCollisionRect() const;
2866
2867 void setRelativeRect(const Common::Rect &rect);
2868
2869 // The cached absolute origin is from the last time the element was rendered.
2870 // Do not rely on it mid-frame.
2871 const Common::Point &getCachedAbsoluteOrigin() const;
2872 void setCachedAbsoluteOrigin(const Common::Point &absOrigin);
2873
2874 void setDragMotionProperties(const Common::SharedPtr<DragMotionProperties> &dragProps);
2875 const Common::SharedPtr<DragMotionProperties> &getDragMotionProperties() const;
2876
2877 void handleDragMotion(Runtime *runtime, const Common::Point &initialOrigin, const Common::Point &targetOrigin);
2878
2880 OffsetTranslateTaskData() : dx(0), dy(0) {}
2881
2882 int32 dx;
2883 int32 dy;
2884 };
2885
2886 VThreadState offsetTranslateTask(const OffsetTranslateTaskData &data);
2887
2888 void setRenderProperties(const VisualElementRenderProperties &props, const Common::WeakPtr<GraphicModifier> &primaryGraphicModifier);
2889 const VisualElementRenderProperties &getRenderProperties() const;
2890 const Common::WeakPtr<GraphicModifier> &getPrimaryGraphicModifier() const;
2891
2892 void setShading(int16 topLeftBevelShading, int16 bottomRightBevelShading, int16 interiorShading, uint32 bevelSize);
2893
2894 void setTransitionProperties(const VisualElementTransitionProperties &props);
2895 const VisualElementTransitionProperties &getTransitionProperties() const;
2896
2897 bool needsRender() const;
2898 virtual void render(Window *window) = 0;
2899 void finalizeRender();
2900
2901 void setPalette(const Common::SharedPtr<Palette> &palette);
2902 const Common::SharedPtr<Palette> &getPalette() const;
2903
2904 void visitInternalReferences(IStructuralReferenceVisitor *visitor) override;
2905
2906 void pushVisibilityChangeTask(Runtime *runtime, bool desiredVisibility);
2907
2908#ifdef MTROPOLIS_DEBUG_ENABLE
2909 void debugInspect(IDebugInspectionReport *report) const override;
2910#endif
2911
2912protected:
2913 VisualElement(const VisualElement &other);
2914
2915 bool loadCommon(const Common::String &name, uint32 guid, const Data::Rect &rect, uint32 elementFlags, uint16 layer, uint32 streamLocator, uint16 sectionID);
2916
2917 MiniscriptInstructionOutcome scriptSetDirect(MiniscriptThread *thread, const DynamicValue &dest);
2918 MiniscriptInstructionOutcome scriptSetPosition(MiniscriptThread *thread, const DynamicValue &dest);
2919 MiniscriptInstructionOutcome scriptSetPositionX(MiniscriptThread *thread, const DynamicValue &dest);
2920 MiniscriptInstructionOutcome scriptSetPositionY(MiniscriptThread *thread, const DynamicValue &dest);
2921 MiniscriptInstructionOutcome scriptSetCenterPosition(MiniscriptThread *thread, const DynamicValue &dest);
2922 MiniscriptInstructionOutcome scriptSetCenterPositionX(MiniscriptThread *thread, const DynamicValue &dest);
2923 MiniscriptInstructionOutcome scriptSetCenterPositionY(MiniscriptThread *thread, const DynamicValue &dest);
2924 MiniscriptInstructionOutcome scriptSetVisibility(MiniscriptThread *thread, const DynamicValue &result);
2925 MiniscriptInstructionOutcome scriptSetSize(MiniscriptThread *thread, const DynamicValue &dest);
2926 MiniscriptInstructionOutcome scriptSetWidth(MiniscriptThread *thread, const DynamicValue &dest);
2927 MiniscriptInstructionOutcome scriptSetHeight(MiniscriptThread *thread, const DynamicValue &dest);
2928 MiniscriptInstructionOutcome scriptSetLayer(MiniscriptThread *thread, const DynamicValue &dest);
2929
2930 MiniscriptInstructionOutcome scriptWriteRefPositionAttribute(MiniscriptThread *thread, DynamicValueWriteProxy &writeProxy, const Common::String &attrib);
2931 MiniscriptInstructionOutcome scriptWriteRefSizeAttribute(MiniscriptThread *thread, DynamicValueWriteProxy &writeProxy, const Common::String &attrib);
2932 MiniscriptInstructionOutcome scriptWriteRefCenterPositionAttribute(MiniscriptThread *thread, DynamicValueWriteProxy &writeProxy, const Common::String &attrib);
2933
2934 void offsetTranslate(int32 xDelta, int32 yDelta, bool cachedOriginOnly);
2935 void resize(int32 width, int32 height);
2936
2937 Common::Point getCenterPosition() const;
2938
2940 CORO_DEFINE_RETURN_TYPE(void);
2941 CORO_DEFINE_PARAMS_3(VisualElement *, self, Runtime *, runtime, bool, desiredFlag);
2942 };
2943
2945 ChangeFlagTaskData() : desiredFlag(false), runtime(nullptr) {}
2946
2947 bool desiredFlag;
2948 Runtime *runtime;
2949 };
2950
2951 VThreadState changeVisibilityTask(const ChangeFlagTaskData &taskData);
2952
2953 static VisualElement *recursiveFindItemWithLayer(VisualElement *element, int32 layer);
2954
2955 void renderShading(Graphics::Surface &surf) const;
2956
2957 static uint32 quantizeShading(uint32 mask, int16 shading);
2958
2959 static void renderShadingScanlineDynamic(void *data, size_t numElements, uint32 rMask, uint32 rAdd, uint32 gMask, uint32 gAdd, uint32 bMask, uint32 bAdd, bool isBrighten, byte bytesPerPixel);
2960
2961 template<class TElement>
2962 static void renderBrightenScanline(TElement *element, size_t numElements, TElement rMask, TElement rAdd, TElement gMask, TElement gAdd, TElement bMask, TElement bAdd);
2963
2964 template<class TElement>
2965 static void renderDarkenScanline(TElement *element, size_t numElements, TElement rMask, TElement rSub, TElement gMask, TElement gSub, TElement bMask, TElement bSub);
2966
2967 bool _directToScreen;
2968 bool _visible;
2969 bool _visibleByDefault;
2970 Common::Rect _rect;
2971 Common::Point _cachedAbsoluteOrigin;
2972 uint16 _layer;
2973
2974 int16 _topLeftBevelShading;
2975 int16 _bottomRightBevelShading;
2976 int16 _interiorShading;
2977 uint32 _bevelSize;
2978
2980
2981 // Quirk: When a graphic modifier is applied, it becomes the primary graphic modifier, and disabling it
2982 // will only take effect if it's the primary graphic modifier.
2983 VisualElementRenderProperties _renderProps;
2984 Common::WeakPtr<GraphicModifier> _primaryGraphicModifier;
2985
2986 VisualElementTransitionProperties _transitionProps;
2987
2989
2990 Common::Rect _prevRect;
2991 bool _contentsDirty;
2992};
2993
2995public:
2996 bool isVisual() const override;
2997
2998 bool loadCommon(const Common::String &name, uint32 guid, uint32 elementFlags);
2999
3001};
3002
3004 ModifierFlags();
3005 bool load(const uint32 dataModifierFlags);
3006
3007 bool isLastModifier : 1;
3008 bool flagsWereLoaded : 1;
3009};
3010
3012public:
3013 virtual ~ModifierSaveLoad();
3014
3015 void save(Modifier *modifier, Common::WriteStream *stream);
3016 bool load(Modifier *modifier, Common::ReadStream *stream, uint32 saveFileVersion);
3017 virtual void commitLoad() const = 0;
3018
3019protected:
3020 // Saves the modifier state to a stream
3021 virtual void saveInternal(Common::WriteStream *stream) const = 0;
3022
3023 // Loads the modifier state from a stream into the save/load state and returns true
3024 // if successful. This will not trigger any actual changes until "commit" is called.
3025 virtual bool loadInternal(Common::ReadStream *stream, uint32 saveFileVersion) = 0;
3026};
3027
3029public:
3030 virtual ~ModifierHooks();
3031
3032 virtual void onCreate(Modifier *modifier);
3033};
3034
3035class Modifier : public RuntimeObject, public IMessageConsumer, public Debuggable {
3036public:
3037 Modifier();
3038 virtual ~Modifier();
3039
3040 bool readAttribute(MiniscriptThread *thread, DynamicValue &result, const Common::String &attrib) override;
3041 MiniscriptInstructionOutcome writeRefAttribute(MiniscriptThread *thread, DynamicValueWriteProxy &writeProxy, const Common::String &attrib) override;
3042
3043 void materialize(Runtime *runtime, ObjectLinkingScope *outerScope);
3044
3045 virtual bool isAlias() const;
3046 virtual bool isVariable() const;
3047 virtual bool isBehavior() const;
3048 virtual bool isCompoundVariable() const;
3049 virtual bool isKeyboardMessenger() const;
3050 virtual Common::SharedPtr<ModifierSaveLoad> getSaveLoad(Runtime *runtime);
3051
3052 bool isModifier() const override;
3053
3054 // This should only return a propagation container if messages should actually be propagated (i.e. NOT switched-off behaviors!)
3055 virtual IModifierContainer *getMessagePropagationContainer();
3056 virtual IModifierContainer *getChildContainer();
3057
3058 const Common::WeakPtr<RuntimeObject> &getParent() const;
3059 void setParent(const Common::WeakPtr<RuntimeObject> &parent);
3060
3061 Modifier *findNextSibling() const;
3062 Modifier *findPrevSibling() const;
3063
3064 bool respondsToEvent(const Event &evt) const override;
3065 VThreadState consumeMessage(Runtime *runtime, const Common::SharedPtr<MessageProperties> &msg) override;
3066
3067 void setName(const Common::String &name);
3068 const Common::String &getName() const;
3069
3070 const ModifierFlags &getModifierFlags() const;
3071
3072 // Shallow clones only need to copy the object. Descendent copies are done using visitInternalReferences.
3073 virtual Common::SharedPtr<Modifier> shallowClone() const = 0;
3074
3075 // Returns the default name of the modifier. This isn't optional: It can cause behavioral changes, e.g.
3076 // Obsidian depends on this working properly to resolve the TextWork modifier in the Piazza.
3077 virtual const char *getDefaultName() const = 0;
3078
3079 // Visits any internal references in the object.
3080 // Any references to other elements owned by the object MUST be SharedPtr, any references to non-owned objects
3081 // MUST be WeakPtr, in order for the cloning and materialization logic to work correctly.
3082 virtual void visitInternalReferences(IStructuralReferenceVisitor *visitor);
3083
3084 bool loadPlugInHeader(const PlugInModifierLoaderContext &plugInContext);
3085
3086 void recursiveCollectObjectsMatchingCriteria(Common::Array<Common::WeakPtr<RuntimeObject> > &results, bool (*evalFunc)(void *userData, RuntimeObject *object), void *userData, bool onlyEnabled);
3087
3088 Structural *findStructuralOwner() const;
3089
3090 void setHooks(const Common::SharedPtr<ModifierHooks> &hooks);
3091 const Common::SharedPtr<ModifierHooks> &getHooks() const;
3092
3093 // Recursively disable due to containing behavior being disabled
3094 virtual void disable(Runtime *runtime) = 0;
3095
3096#ifdef MTROPOLIS_DEBUG_ENABLE
3097 SupportStatus debugGetSupportStatus() const override;
3098 const Common::String &debugGetName() const override;
3099 void debugInspect(IDebugInspectionReport *report) const override;
3100#endif
3101
3102protected:
3103 bool loadTypicalHeader(const Data::TypicalModifierHeader &typicalHeader);
3104
3105 // Links any references contained in the object, resolving static GUIDs to runtime object references.
3106 // If you override this, you should override visitInternalReferences too
3107 virtual void linkInternalReferences(ObjectLinkingScope *scope);
3108
3109 Common::String _name;
3110 ModifierFlags _modifierFlags;
3112
3114};
3115
3117public:
3118 virtual ~VariableStorage();
3119 virtual Common::SharedPtr<ModifierSaveLoad> getSaveLoad(Runtime *runtime) = 0;
3120
3121 virtual Common::SharedPtr<VariableStorage> clone() const = 0;
3122};
3123
3125public:
3127 VariableModifier(const VariableModifier &other);
3128
3129 virtual bool isVariable() const override;
3130 virtual bool isListVariable() const;
3131
3132 virtual Common::SharedPtr<ModifierSaveLoad> getSaveLoad(Runtime *runtime) override final;
3133
3134 const Common::SharedPtr<VariableStorage> &getStorage() const;
3135 void setStorage(const Common::SharedPtr<VariableStorage> &storage);
3136
3137 virtual bool varSetValue(MiniscriptThread *thread, const DynamicValue &value) = 0;
3138 virtual void varGetValue(DynamicValue &dest) const = 0;
3139
3140 bool readAttribute(MiniscriptThread *thread, DynamicValue &result, const Common::String &attrib) override;
3141
3142 void disable(Runtime *runtime) override;
3143
3144 virtual DynamicValueWriteProxy createWriteProxy();
3145
3146#ifdef MTROPOLIS_DEBUG_ENABLE
3147 void debugInspect(IDebugInspectionReport *report) const override;
3148#endif
3149
3150private:
3151 VariableModifier() = delete;
3152
3153 struct WriteProxyInterface {
3154 static MiniscriptInstructionOutcome write(MiniscriptThread *thread, const DynamicValue &dest, void *objectRef, uintptr ptrOrOffset);
3155 static MiniscriptInstructionOutcome refAttrib(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, void *objectRef, uintptr ptrOrOffset, const Common::String &attrib);
3156 static MiniscriptInstructionOutcome refAttribIndexed(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, void *objectRef, uintptr ptrOrOffset, const Common::String &attrib, const DynamicValue &index);
3157 };
3158
3159protected:
3161};
3162
3163enum AssetType {
3164 kAssetTypeNone,
3165
3166 kAssetTypeMovie,
3167 kAssetTypeAudio,
3168 kAssetTypeColorTable,
3169 kAssetTypeImage,
3170 kAssetTypeText,
3171 kAssetTypeMToon,
3172 kAssetTypeAVIMovie,
3173};
3174
3176public:
3177 virtual ~AssetHooks();
3178
3179 virtual void onLoaded(Asset *asset, const Common::String &name);
3180};
3181
3182class Asset {
3183public:
3184 Asset();
3185 virtual ~Asset();
3186
3187 uint32 getAssetID() const;
3188
3189 virtual AssetType getAssetType() const = 0;
3190
3191protected:
3192 uint32 _assetID;
3193};
3194
3195
3196} // End of namespace MTropolis
3197
3198#endif
Definition: mixer.h:70
Definition: archive.h:141
Definition: array.h:52
Definition: hashmap.h:85
Definition: noncopyable.h:39
Definition: path.h:52
Definition: random.h:44
Definition: stream.h:385
Definition: ptr.h:572
Definition: stream.h:745
Definition: ptr.h:159
Definition: str.h:59
Definition: ptr.h:381
Definition: stream.h:77
Definition: cursor.h:42
Definition: managed_surface.h:51
Definition: runtime.h:1533
Definition: runtime.h:3175
Definition: runtime.h:3182
Definition: runtime.h:2151
Definition: runtime.h:1231
Definition: runtime.h:1203
Definition: data.h:518
Definition: debug.h:110
Definition: debug.h:83
Definition: debug.h:145
Definition: runtime.h:559
Definition: runtime.h:624
Definition: runtime.h:114
Definition: runtime.h:2693
Definition: runtime.h:1419
Definition: runtime.h:2413
Definition: runtime.h:1519
Definition: runtime.h:1210
Definition: runtime.h:1385
Definition: miniscript.h:421
Definition: runtime.h:3028
Definition: runtime.h:3035
Definition: runtime.h:3011
Definition: runtime.h:1505
Definition: runtime.h:2994
Definition: runtime.h:1494
Definition: runtime.h:1307
Definition: runtime.h:1560
Definition: runtime.h:2377
Definition: runtime.h:1185
Definition: runtime.h:1253
Definition: runtime.h:2472
Definition: runtime.h:1192
Definition: runtime.h:2359
Definition: runtime.h:1575
Definition: runtime.h:2052
Definition: runtime.h:1551
Definition: runtime.h:1437
Definition: runtime.h:1455
Definition: runtime.h:2647
Definition: runtime.h:2394
Definition: runtime.h:2040
Definition: runtime.h:2184
Definition: runtime.h:2195
Definition: runtime.h:2668
Definition: runtime.h:2162
Definition: vthread.h:133
Definition: runtime.h:3124
Definition: runtime.h:3116
Definition: runtime.h:2827
Definition: runtime.h:1220
Definition: render.h:93
Definition: runtime.h:2131
Definition: system.h:166
Definition: atari-screen.h:42
EventType
Definition: events.h:49
Language
Definition: language.h:45
Definition: system.h:39
Definition: algorithm.h:29
Definition: formatinfo.h:28
Definition: actions.h:25
Definition: keyboard.h:294
Definition: rect.h:144
Definition: rect.h:536
Definition: atari-cursor.h:35
Definition: pixelformat.h:138
Definition: surface.h:67
Definition: runtime.h:440
Definition: runtime.h:2323
Definition: runtime.h:2327
Definition: runtime.h:2355
Definition: runtime.h:469
Definition: data.h:612
Definition: data.h:365
Definition: data.h:356
Definition: data.h:942
Definition: data.h:375
Definition: data.h:399
Definition: data.h:547
Definition: data.h:332
Definition: runtime.h:1543
Definition: runtime.h:574
Definition: runtime.h:744
Definition: runtime.h:589
Definition: runtime.h:609
Definition: runtime.h:595
Definition: runtime.h:816
Definition: runtime.h:925
Definition: runtime.h:1033
Definition: runtime.h:1079
Definition: runtime.h:503
Definition: runtime.h:1025
Definition: runtime.h:544
Definition: runtime.h:536
Definition: runtime.h:369
Definition: hacks.h:40
Definition: runtime.h:1360
Definition: runtime.h:2432
Definition: runtime.h:2427
Definition: debug.h:59
Definition: core.h:33
Definition: runtime.h:2409
Definition: saveload.h:59
Definition: runtime.h:2448
Definition: runtime.h:2125
Definition: runtime.h:2034
Definition: runtime.h:2373
Definition: modifier_factory.h:44
Definition: modifier_factory.h:40
Definition: runtime.h:1180
Definition: runtime.h:2444
Definition: saveload.h:54
Definition: runtime.h:2390
Definition: runtime.h:2118
Definition: runtime.h:330
Definition: runtime.h:351
Definition: runtime.h:2453
Definition: runtime.h:488
Definition: runtime.h:2103
Definition: runtime.h:1108
Definition: runtime.h:3003
Definition: modifier_factory.h:30
Definition: runtime.h:1353
Definition: runtime.h:418
Definition: modifier_factory.h:48
Definition: runtime.h:551
Definition: runtime.h:2315
Definition: runtime.h:1197
Definition: runtime.h:1376
Definition: runtime.h:1172
Definition: subtitles.h:123
Definition: runtime.h:391
Definition: runtime.h:1299