22 #ifndef MTROPOLIS_RUNTIME_H 23 #define MTROPOLIS_RUNTIME_H 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" 35 #include "graphics/pixelformat.h" 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" 63 struct WinCursorGroup;
76 class AssetManagerInterface;
77 class CoroutineManager;
79 class CursorGraphicCollection;
81 class GraphicModifier;
82 class KeyboardInputEvent;
83 class MessageDispatch;
84 class MiniscriptThread;
86 class ObjectLinkingScope;
93 class SystemInterface;
96 class WorldManagerInterface;
98 struct DynamicValueWriteProxy;
99 struct IBoundaryDetector;
101 struct ILoadUIProvider;
102 struct IMessageConsumer;
103 struct IModifierContainer;
104 struct IPlugInModifierFactory;
105 struct IPlugInModifierFactoryAndDataFactory;
107 struct ISaveUIProvider;
109 struct IStructuralReferenceVisitor;
110 struct MessageProperties;
111 struct ModifierLoaderContext;
112 struct PlugInModifierLoaderContext;
113 struct SIModifierFactory;
116 #ifdef MTROPOLIS_DEBUG_ENABLE 120 char invariantToLower(
char c);
125 enum ColorDepthMode {
130 kColorDepthMode16Bit,
131 kColorDepthMode32Bit,
133 kColorDepthModeCount,
135 kColorDepthModeInvalid,
138 namespace SceneTransitionTypes {
140 enum SceneTransitionType {
151 bool loadFromData(SceneTransitionType &transType, int32 data);
155 namespace SceneTransitionDirections {
157 enum SceneTransitionDirection {
164 bool loadFromData(SceneTransitionDirection &transDir, int32 data);
168 enum ConstraintDirection {
169 kConstraintDirectionNone,
170 kConstraintDirectionHorizontal,
171 kConstraintDirectionVertical,
174 enum MouseInteractivityTestType {
175 kMouseInteractivityTestAnything,
176 kMouseInteractivityTestMouseClick,
179 namespace DynamicValueSourceTypes {
180 enum DynamicValueSourceType {
189 namespace DynamicValueTypes {
192 enum DynamicValueType {
215 namespace AttributeIDs {
230 kAttribLoopBackForth = 59,
231 kAttribPlayEveryFrame = 60,
232 kAttribTimeValue = 16,
233 kAttribTrackDisable = 51,
234 kAttribTrackEnable = 50,
238 kAttribMasterVolume = 18,
239 kAttribUserTimeout = 19,
249 kElementEnableEdit = 207,
250 kElementDisableEdit = 220,
251 kElementSelect = 209,
252 kElementDeselect = 210,
253 kElementToggleSelect = 213,
254 kElementUpdatedCalculated = 219,
258 kElementScrollUp = 1001,
259 kElementScrollDown = 1002,
260 kElementScrollRight = 1005,
261 kElementScrollLeft = 1006,
263 kMotionStarted = 501,
266 kTransitionStarted = 503,
267 kTransitionEnded = 504,
273 kMouseTrackedInside = 305,
274 kMouseTrackedOutside = 306,
275 kMouseTracking = 307,
276 kMouseUpInside = 309,
277 kMouseUpOutside = 310,
281 kSceneDeactivated = 103,
282 kSceneReactivated = 104,
283 kSceneTransitionEnded = 506,
285 kSharedSceneReturnedToScene = 401,
286 kSharedSceneSceneChanged = 402,
287 kSharedSceneNoNextScene = 403,
288 kSharedSceneNoPrevScene = 404,
290 kParentEnabled = 2001,
291 kParentDisabled = 2002,
292 kParentChanged = 227,
294 kPreloadMedia = 1701,
296 kPrerollMedia = 1704,
298 kCloseProject = 1601,
301 kProjectStarted = 1802,
302 kProjectEnded = 1803,
303 kFlushAllMedia = 1804,
320 kAuthorMessage = 900,
323 bool isCommand(EventID eventID);
339 inline bool operator==(
const IntRange &other)
const {
340 return min == other.min && max == other.max;
343 inline bool operator!=(
const IntRange &other)
const {
344 return !((*this) == other);
353 Label(int32 psuperGroupID, int32 pid);
360 inline bool operator==(
const Label &other)
const {
361 return superGroupID == other.superGroupID &&
id == other.id;
364 inline bool operator!=(
const Label &other)
const {
365 return !((*this) == other);
371 Event(EventIDs::EventID peventType, uint32 peventInfo);
373 EventIDs::EventID eventType;
378 bool respondsTo(
const Event &otherEvent)
const;
382 inline bool operator==(
const Event &other)
const {
383 return eventType == other.eventType && eventInfo == other.eventInfo;
386 inline bool operator!=(
const Event &other)
const {
387 return !((*this) == other);
399 inline bool operator==(
const VarReference &other)
const {
400 return guid == other.guid && source == other.source;
403 inline bool operator!=(
const VarReference &other)
const {
404 return !((*this) == other);
428 return !
object.owner_before(other.object) && !other.object.owner_before(
object);
432 return !((*this) == other);
435 inline void reset() {
447 return angleDegrees == other.angleDegrees && magnitude == other.magnitude;
451 return !((*this) == other);
454 inline static AngleMagVector createRadians(
double angleRadians,
double magnitude) {
458 inline static AngleMagVector createDegrees(
double angleDegrees,
double magnitude) {
479 inline bool operator==(
const ColorRGB8 &other)
const {
480 return r == other.r && g == other.g && b == other.b;
483 inline bool operator!=(
const ColorRGB8 &other)
const {
484 return !((*this) == other);
504 typedef MiniscriptInstructionOutcome (*writeFunc_t)(
MiniscriptThread *thread,
const DynamicValue &dest,
void *objectRef, uintptr ptrOrOffset);
509 refAttribFunc_t refAttrib;
510 refAttribIndexedFunc_t refAttribIndexed;
529 static_cast<DynamicValueWriteInterface::writeFunc_t
>(T::write),
530 static_cast<DynamicValueWriteInterface::refAttribFunc_t>(T::refAttrib),
531 static_cast<DynamicValueWriteInterface::refAttribIndexedFunc_t
>(T::refAttribIndexed),
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;
567 virtual const void *getConstArrayPtr()
const = 0;
568 virtual void *getArrayPtr() = 0;
569 virtual size_t getSize()
const = 0;
575 static void defaultSet(int32 &value);
576 static void defaultSet(
double &value);
578 static void defaultSet(
IntRange &value);
579 static void defaultSet(
bool &value);
581 static void defaultSet(
Label &value);
582 static void defaultSet(
Event &value);
590 typedef T DynamicValuePODType_t;
592 static const T &dereference(
const T *source) {
return *source; }
596 static bool importValue(
const DynamicValue &dynValue,
const int32 *&outPtr);
597 static bool importValue(
const DynamicValue &dynValue,
const double *&outPtr);
600 static bool importValue(
const DynamicValue &dynValue,
const bool *&outPtr);
610 static void exportValue(
DynamicValue &dynValue,
const int32 &value);
611 static void exportValue(
DynamicValue &dynValue,
const double &value);
614 static void exportValue(
DynamicValue &dynValue,
const bool &value);
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;
631 const void *getConstArrayPtr()
const override;
632 void *getArrayPtr()
override;
633 size_t getSize()
const override;
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;
651 const void *getConstArrayPtr()
const override;
652 void *getArrayPtr()
override;
653 size_t getSize()
const override;
663 const typename DynamicListValueConverter<T>::DynamicValuePODType_t *valuePtr =
nullptr;
664 if (!DynamicListValueImporter::importValue(dynValue, valuePtr))
667 _array.reserve(index + 1);
668 if (_array.size() <= index) {
669 if (_array.size() < index) {
671 DynamicListDefaultSetter::defaultSet(defaultValue);
672 while (_array.size() < index) {
673 _array.push_back(defaultValue);
686 if (_array.size() > sz)
693 if (_array.size() < sz) {
695 DynamicListDefaultSetter::defaultSet(defaultValue);
696 while (_array.size() < sz) {
697 _array.push_back(defaultValue);
706 if (index >= _array.size())
709 DynamicListValueExporter::exportValue(dynValue, _array[index]);
730 return _array.size();
736 return _array == otherTyped._array;
749 DynamicValueTypes::DynamicValueType getType()
const;
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;
782 void forceType(DynamicValueTypes::DynamicValueType type);
784 static bool dynamicValueToIndex(
size_t &outIndex,
const DynamicValue &value);
789 inline bool operator!=(
const DynamicList &other)
const {
790 return !((*this) == other);
800 struct WriteProxyInterface {
807 void destroyContainer();
808 bool createContainerAndSetType(DynamicValueTypes::DynamicValueType type);
810 DynamicValueTypes::DynamicValueType _type;
824 DynamicValueTypes::DynamicValueType getType()
const;
826 const int32 &getInt()
const;
827 const double &getFloat()
const;
829 const IntRange &getIntRange()
const;
831 const Label &getLabel()
const;
832 const Event &getEvent()
const;
834 const bool &getBool()
const;
841 void setInt(int32 value);
842 void setFloat(
double value);
844 void setIntRange(
const IntRange &value);
846 void setLabel(
const Label &value);
847 void setEvent(
const Event &value);
849 void setBool(
bool value);
855 bool roundToInt(int32 &outInt)
const;
857 bool convertToType(DynamicValueTypes::DynamicValueType targetType,
DynamicValue &result)
const;
864 inline bool operator!=(
const DynamicValue &other)
const {
865 return !((*this) == other);
888 template<
class T, T(ValueUnion::*TMember)>
889 void construct(
const T &value);
891 template<
class T, T(ValueUnion::*TMember)>
892 void construct(T &&value);
894 template<
class T, T(ValueUnion::*TMember)>
895 void assign(
const T &value);
897 template<
class T, T(ValueUnion::*TMember)>
898 void assign(T &&value);
900 template<
class T, T(ValueUnion::*TMember)>
905 void internalSwap(T &a, T &b) {
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;
916 bool convertToTypeNoDereference(DynamicValueTypes::DynamicValueType targetType,
DynamicValue &result)
const;
921 DynamicValueTypes::DynamicValueType _type;
934 DynamicValueSourceTypes::DynamicValueSourceType getSourceType()
const;
955 void destructValue();
959 DynamicValueSourceTypes::DynamicValueSourceType _sourceType;
960 ValueUnion _valueUnion;
963 template<
class TFloat>
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;
977 return kMiniscriptInstructionOutcomeFailed;
981 return kMiniscriptInstructionOutcomeFailed;
984 return kMiniscriptInstructionOutcomeFailed;
988 proxy.pod.ptrOrOffset = 0;
989 proxy.pod.objectRef = floatValue;
994 template<
class TInteger>
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;
1008 return kMiniscriptInstructionOutcomeFailed;
1012 return kMiniscriptInstructionOutcomeFailed;
1015 return kMiniscriptInstructionOutcomeFailed;
1019 proxy.pod.ptrOrOffset = 0;
1020 proxy.pod.objectRef = intValue;
1057 template<
class TClass, MiniscriptInstructionOutcome (TClass::*TWriteMethod)(MiniscriptThread *thread, const DynamicValue &dest), MiniscriptInstructionOutcome (TClass::*TRefAttribMethod)(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, const Common::String &attrib)>
1062 return (static_cast<TClass *>(objectRef)->*TWriteMethod)(thread, derefValue);
1065 return (static_cast<TClass *>(objectRef)->*TRefAttribMethod)(thread, proxy, attrib);
1068 return kMiniscriptInstructionOutcomeFailed;
1072 proxy.pod.ptrOrOffset = 0;
1073 proxy.pod.objectRef = obj;
1078 template<
class TClass, MiniscriptInstructionOutcome (TClass::*TWriteMethod)(MiniscriptThread *thread, const DynamicValue &dest),
bool TDereference>
1082 return (static_cast<TClass *>(objectRef)->*TWriteMethod)(thread, dest.dereference());
1084 return (static_cast<TClass *>(objectRef)->*TWriteMethod)(thread, dest);
1087 return kMiniscriptInstructionOutcomeFailed;
1090 return kMiniscriptInstructionOutcomeFailed;
1094 proxy.pod.ptrOrOffset = 0;
1095 proxy.pod.objectRef = obj;
1125 kLinkTypeNotYetLinked,
1126 kLinkTypeStructural,
1129 kLinkTypeUnresolved,
1144 static bool isSceneFilter(
Structural *section);
1145 static bool isSectionFilter(
Structural *section);
1146 static bool isSubsectionFilter(
Structural *section);
1147 static bool isElementFilter(
Structural *section);
1150 enum MessageDestination {
1151 kMessageDestNone = 0,
1153 kMessageDestSharedScene = 0x65,
1154 kMessageDestScene = 0x66,
1155 kMessageDestSection = 0x67,
1156 kMessageDestProject = 0x68,
1157 kMessageDestActiveScene = 0x69,
1158 kMessageDestElementsParent = 0x6a,
1159 kMessageDestChildren = 0x6b,
1160 kMessageDestModifiersParent = 0x6c,
1161 kMessageDestSubsection = 0x6d,
1163 kMessageDestElement = 0xc9,
1164 kMessageDestSourcesParent = 0xcf,
1166 kMessageDestBehavior = 0xd4,
1167 kMessageDestNextElement = 0xd1,
1168 kMessageDestPrevElement = 0xd2,
1169 kMessageDestBehaviorsParent = 0xd3,
1246 enum ProjectPlatform {
1247 kProjectPlatformUnknown,
1249 kProjectPlatformWindows,
1250 kProjectPlatformMacintosh,
1258 void addSegment(
int volumeID,
const char *filePath);
1274 ProjectPlatform getPlatform()
const;
1275 RuntimeVersion getRuntimeVersion()
const;
1276 bool isRuntimeVersionAuto()
const;
1291 ProjectPlatform _platform;
1292 RuntimeVersion _runtimeVersion;
1293 bool _isRuntimeVersionAuto;
1333 kShowDefaultVisibleElements,
1341 ActionType getActionType()
const;
1348 ActionType _actionType;
1363 kTypeChangeSharedScene,
1364 kTypeForceLoadScene,
1365 kTypeRequestUnloadScene,
1372 bool addToDestinationScene;
1373 bool addToReturnList;
1381 SceneTransitionTypes::SceneTransitionType _transitionType;
1382 SceneTransitionDirections::SceneTransitionDirection _transitionDirection;
1390 bool isTerminated()
const;
1391 VThreadState continuePropagating(
Runtime *runtime);
1396 bool isCascade()
const;
1397 bool isRelay()
const;
1400 struct PropagationStack {
1407 enum PropagationStage {
1408 kStageSendToModifier,
1409 kStageSendToModifierContainer,
1411 kStageSendToStructuralSelf,
1412 kStageSendToStructuralModifiers,
1413 kStageSendToStructuralChildren,
1415 kStageCheckAndSendToModifier,
1416 kStageCheckAndSendToStructural,
1417 kStageCheckAndSendCommand,
1422 PropagationStage propagationStage;
1443 static bool keyboardMessengerFilterFunc(
void *userData,
RuntimeObject *
object);
1445 bool isTerminated()
const;
1446 VThreadState continuePropagating(
Runtime *runtime);
1450 size_t _dispatchIndex;
1461 uint64 getScheduledTime()
const;
1462 void activate(
Runtime *runtime)
const;
1468 void (*_activateFunc)(
void *obj,
Runtime *runtime);
1470 uint64 _scheduledTime;
1481 template<
class T,
void (T::*TMethodPtr)(Runtime *)>
1489 void descheduleFirstEvent();
1492 template<
class T,
void (T::*TMethodPtr)(Runtime *)>
1493 static void methodActivateHelper(
void *obj,
Runtime *runtime) {
1494 (
static_cast<T *
>(obj)->*TMethodPtr)(runtime);
1504 kOSEventTypeMouseDown,
1505 kOSEventTypeMouseUp,
1506 kOSEventTypeMouseMove,
1508 kOSEventTypeKeyboard,
1515 explicit OSEvent(OSEventType eventType);
1518 OSEventType getEventType()
const;
1521 OSEventType _eventType;
1526 explicit MouseInputEvent(OSEventType eventType, int32 x, int32 y, Actions::MouseButton button);
1530 Actions::MouseButton getButton()
const;
1535 Actions::MouseButton _button;
1543 bool isRepeat()
const;
1554 explicit ActionEvent(OSEventType osEventType, Actions::Action action);
1556 Actions::Action getAction()
const;
1559 Actions::Action _action;
1565 ConstraintDirection constraintDirection;
1567 bool constrainToParent;
1576 virtual void onProjectStarted(
Runtime *runtime);
1584 void initDefaultPalette(
int version);
1586 const byte *getPalette()
const;
1588 static const uint kNumColors = 256;
1591 byte _colors[kNumColors * 3];
1603 void closeProject();
1605 void addVolume(
int volumeID,
const char *name,
bool isMounted);
1606 bool getVolumeState(
const Common::String &name,
int &outVolumeID,
bool &outIsMounted)
const;
1608 void addSceneReturn();
1618 uint32 allocateRuntimeGUID();
1621 void removeWindow(
Window *window);
1626 bool isDisplayModeSupported(ColorDepthMode displayMode)
const;
1630 bool switchDisplayMode(ColorDepthMode realDisplayMode, ColorDepthMode fakeDisplayMode);
1632 void setDisplayResolution(uint16 width, uint16 height);
1633 void getDisplayResolution(uint16 &outWidth, uint16 &outHeight)
const;
1635 ColorDepthMode getRealColorDepth()
const;
1636 ColorDepthMode getFakeColorDepth()
const;
1646 bool mustDraw()
const;
1648 uint64 getRealTime()
const;
1649 uint64 getPlayTime()
const;
1657 CORO_DEFINE_RETURN_TYPE(
void);
1673 void setVolume(
double volume);
1675 void onMouseDown(int32 x, int32 y, Actions::MouseButton mButton);
1676 void onMouseMove(int32 x, int32 y);
1677 void onMouseUp(int32 x, int32 y, Actions::MouseButton mButton);
1679 void onAction(MTropolis::Actions::Action action);
1682 void setModifierCursorOverride(uint32 cursorID);
1683 void clearModifierCursorOverride();
1684 void forceCursorRefreshOnce();
1685 void setAutoResetCursor(
bool enabled);
1687 uint getMultiClickCount()
const;
1689 bool isAwaitingSceneTransition()
const;
1702 const Hacks &getHacks()
const;
1704 void setSceneGraphDirty();
1705 void clearSceneGraphDirty();
1706 bool isSceneGraphDirty()
const;
1709 void removeCollider(
ICollider *collider);
1710 void checkCollisions(
ICollider *optRestrictToCollider);
1713 void updateCursorElementPosition();
1717 void checkBoundaries();
1723 const Palette &getGlobalPalette()
const;
1724 void setGlobalPalette(
const Palette &palette);
1726 void addMouseBlocker();
1727 void removeMouseBlocker();
1729 const Common::String *resolveAttributeIDName(uint32 attribID)
const;
1736 bool isIdle()
const;
1746 #ifdef MTROPOLIS_DEBUG_ENABLE 1747 void debugSetEnabled(
bool enabled);
1749 Debugger *debugGetDebugger()
const;
1755 enum SceneTransitionState {
1756 kSceneTransitionStateNotTransitioning,
1757 kSceneTransitionStateWaitingForDraw,
1758 kSceneTransitionStateTransitioning,
1761 struct SceneStackEntry {
1772 bool onlyRemoveChildren;
1775 struct SceneReturnListEntry {
1776 SceneReturnListEntry();
1779 bool isAddToDestinationSceneTransition;
1782 struct DispatchMethodTaskData {
1786 struct DispatchKeyTaskData {
1790 struct DispatchActionTaskData {
1791 DispatchActionTaskData();
1793 Actions::Action action;
1796 struct ConsumeMessageTaskData {
1797 ConsumeMessageTaskData();
1803 struct ConsumeCommandTaskData {
1804 ConsumeCommandTaskData();
1810 struct ApplyDefaultVisibilityTaskData {
1811 ApplyDefaultVisibilityTaskData();
1814 bool targetVisibility;
1817 struct UpdateMouseStateTaskData {
1818 UpdateMouseStateTaskData();
1823 struct UpdateMousePositionTaskData {
1824 UpdateMousePositionTaskData();
1830 struct CollisionCheckState {
1831 CollisionCheckState();
1837 struct BoundaryCheckState {
1838 BoundaryCheckState();
1841 uint currentContacts;
1843 bool positionResolved;
1846 struct ColliderInfo {
1849 size_t sceneStackDepth;
1856 void executeTeardown(
const Teardown &teardown);
1858 void executeHighLevelSceneReturn();
1861 void executeSharedScenePostSceneChangeActions();
1862 void executeSceneChangeRecursiveVisibilityChange(
Structural *structural,
bool showing);
1867 void recursiveAutoPlayMedia(
Structural *structural);
1868 void recursiveDeactivateStructural(
Structural *structural);
1869 void recursiveActivateStructural(
Structural *structural);
1871 static bool isStructuralMouseInteractive(
Structural *structural, MouseInteractivityTestType testType);
1872 static bool isModifierMouseInteractive(
Modifier *modifier, MouseInteractivityTestType testType);
1873 static void recursiveFindMouseCollision(
Structural *&bestResult, int32 &bestLayer, int32 &bestStackHeight,
bool &bestDirect,
Structural *candidate, int32 stackHeight, int32 relativeX, int32 relativeY, MouseInteractivityTestType testType);
1875 void queueEventAsLowLevelSceneStateTransitionAction(
const Event &evt,
Structural *root,
bool cascade,
bool relay);
1879 void ensureMainWindowExists();
1881 void unloadProject();
1882 void refreshPlayTime();
1884 VThreadState dispatchMessageTask(
const DispatchMethodTaskData &data);
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);
1893 void updateMainWindowCursor();
1896 static bool sortColliderPredicate(
const ColliderInfo &a,
const ColliderInfo &b);
1915 uint _pendingSceneReturnCount;
1922 SceneTransitionState _sceneTransitionState;
1928 uint32 _sceneTransitionStartTime;
1929 uint32 _sceneTransitionEndTime;
1930 bool _sharedSceneWasSetExplicitly;
1939 uint32 _nextRuntimeGUID;
1941 bool _displayModeSupported[kColorDepthModeCount];
1943 ColorDepthMode _realDisplayMode;
1944 ColorDepthMode _fakeDisplayMode;
1945 uint16 _displayWidth;
1946 uint16 _displayHeight;
1948 uint64 _realTimeBase;
1949 uint64 _playTimeBase;
1964 bool _lastFrameMouseVisible;
1967 bool _mouseFocusFlags[Actions::kMouseButtonCount];
1991 bool _trackedMouseOutside;
1992 bool _forceCursorRefreshOnce;
1993 bool _autoResetCursor;
1995 uint32 _modifierOverrideCursorID;
1996 bool _haveModifierOverrideCursor;
1997 bool _haveCursorElement;
1999 uint32 _multiClickStartTime;
2000 uint32 _multiClickInterval;
2001 uint _multiClickCount;
2003 uint _numMouseBlockers;
2005 bool _defaultVolumeState;
2008 bool _sceneGraphChanged;
2014 uint32 _collisionCheckTime;
2029 #ifdef MTROPOLIS_DEBUG_ENABLE 2037 virtual void removeModifier(
const Modifier *modifier) = 0;
2044 void removeModifier(
const Modifier *modifier)
override;
2053 template<
typename TElement,
typename TElementData>
2060 uint32 getStaticGUID()
const;
2061 uint32 getRuntimeGUID()
const;
2063 void setRuntimeGUID(uint32 runtimeGUID);
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;
2090 uint32 _runtimeGUID;
2106 const Event &getEvent()
const;
2127 virtual bool respondsToEvent(
const Event &evt)
const = 0;
2147 bool _combineRedraws;
2148 bool _postponeRedraws;
2164 const int kFullVolume = 7;
2188 virtual void onCreate(
Structural *structural);
2189 virtual void onPostActivate(
Structural *structural);
2192 virtual void onHidden(
Structural *structural,
bool &visible);
2197 enum class SceneLoadState {
2207 bool isStructural()
const override;
2208 SceneLoadState getSceneLoadState()
const;
2209 void setSceneLoadState(SceneLoadState sceneLoadState);
2217 void removeAllChildren();
2218 void removeAllModifiers();
2220 void removeAllAssets();
2236 void removeModifier(
const Modifier *modifier)
override;
2238 bool respondsToEvent(
const Event &evt)
const override;
2245 CORO_DEFINE_RETURN_TYPE(
void);
2251 virtual void activate();
2252 virtual void deactivate();
2264 #ifdef MTROPOLIS_DEBUG_ENABLE 2265 SupportStatus debugGetSupportStatus()
const override;
2269 virtual void debugSkipMovies();
2286 virtual void onPauseStateChanged();
2306 int32 _flushPriority;
2307 SceneLoadState _sceneLoadState;
2320 uint32 bitsPerPixel;
2330 kTypeCountedModifierList,
2331 kTypeFlagTerminatedModifierList,
2334 kTypeFilteredElements,
2339 bool (*filterFunc)(Data::DataObjectTypes::DataObjectType dataObjectType);
2350 uint remainingCount;
2391 virtual void onSegmentUnloaded(
int segmentIndex) = 0;
2399 void onSegmentUnloaded();
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;
2440 virtual void getCollisionProperties(
Modifier *&modifier, uint &edgeFlags,
bool &mustBeCompletelyOutside,
bool &continuous)
const = 0;
2441 virtual void triggerCollision(
Runtime *runtime) = 0;
2449 virtual Modifier *getMediaCueModifier() = 0;
2454 enum TriggerTiming {
2455 kTriggerTimingStart = 0,
2456 kTriggerTimingDuring = 1,
2457 kTriggerTimingEnd = 2,
2464 TriggerTiming triggerTiming;
2469 void checkTimestampChange(
Runtime *runtime, uint32 oldTS, uint32 newTS,
bool continuousTimestamps,
bool canTriggerDuring);
2490 bool isProject()
const override;
2494 bool getAssetIDByName(
const Common::String &assetName, uint32 &outAssetID)
const;
2497 size_t getSegmentForStreamIndex(
size_t streamIndex)
const;
2498 void openSegmentStream(
int segmentIndex);
2499 void closeSegmentStream(
int segmentIndex);
2504 void onPostRender();
2511 const char *findAuthorMessageName(uint32
id)
const;
2517 RuntimeVersion getRuntimeVersion()
const;
2518 ProjectPlatform getPlatform()
const;
2523 #ifdef MTROPOLIS_DEBUG_ENABLE 2524 const char *debugGetTypeName()
const override {
return "Project"; }
2528 struct LabelSuperGroup {
2531 size_t firstRootNodeIndex;
2532 size_t numRootNodes;
2533 size_t numTotalNodes;
2535 uint32 superGroupID;
2542 size_t firstChildIndex;
2570 StreamType streamType;
2571 uint16 segmentIndex;
2581 uint32 filePosition;
2589 void loadBootStream(
size_t streamIndex,
const Hacks &hacks);
2611 Data::ProjectFormat _projectFormat;
2620 bool _haveGlobalObjectInfo;
2621 bool _haveProjectStructuralDef;
2638 ProjectPlatform _platform;
2643 RuntimeVersion _runtimeVersion;
2644 bool _isRuntimeVersionAutoDetect;
2651 bool isSection()
const override;
2656 #ifdef MTROPOLIS_DEBUG_ENABLE 2657 const char *debugGetTypeName()
const override {
return "Section"; }
2676 bool isSubsection()
const override;
2681 #ifdef MTROPOLIS_DEBUG_ENABLE 2682 const char *debugGetTypeName()
const override {
return "Subsection"; }
2697 virtual bool isVisual()
const = 0;
2698 virtual bool canAutoPlay()
const;
2699 virtual void queueAutoPlayEvents(
Runtime *runtime,
bool isAutoPlaying);
2701 bool isElement()
const override;
2703 uint32 getStreamLocator()
const;
2708 void triggerAutoPlay(
Runtime *runtime);
2711 virtual bool resolveMediaMarkerLabel(
const Label &label, int32 &outResolution)
const;
2720 uint32 _streamLocator;
2725 bool _haveCheckedAutoPlay;
2732 uint8 getAlpha()
const;
2733 void setAlpha(uint8 alpha);
2735 bool isDirty()
const;
2750 kInkModeTransparent = 0x1,
2751 kInkModeGhost = 0x3,
2752 kInkModeReverseCopy = 0x4,
2753 kInkModeReverseGhost = 0x7,
2754 kInkModeReverseTransparent = 0x9,
2755 kInkModeBlend = 0x20,
2756 kInkModeBackgroundTransparent = 0x24,
2757 kInkModeChameleonDark = 0x25,
2758 kInkModeChameleonLight = 0x27,
2759 kInkModeBackgroundMatte = 0x224,
2760 kInkModeInvisible = 0xffff,
2762 kInkModeXor = 0x7ffffff0,
2763 kInkModeDefault = 0x7fffffff,
2768 kShapeRoundedRect = 0x2,
2770 kShapePolygon = 0x9,
2774 kShapeObsidianCanvasPuzzleTri1 = 0x7ffffff1,
2775 kShapeObsidianCanvasPuzzleTri2 = 0x7ffffff2,
2776 kShapeObsidianCanvasPuzzleTri3 = 0x7ffffff3,
2777 kShapeObsidianCanvasPuzzleTri4 = 0x7ffffff4,
2780 InkMode getInkMode()
const;
2781 void setInkMode(InkMode inkMode);
2783 Shape getShape()
const;
2784 void setShape(Shape shape);
2787 void setForeColor(
const ColorRGB8 &color);
2790 void setBackColor(
const ColorRGB8 &color);
2792 const ColorRGB8 &getBorderColor()
const;
2793 void setBorderColor(
const ColorRGB8 &color);
2795 const ColorRGB8 &getShadowColor()
const;
2796 void setShadowColor(
const ColorRGB8 &color);
2798 uint16 getBorderSize()
const;
2799 void setBorderSize(uint16 size);
2801 uint16 getShadowSize()
const;
2802 void setShadowSize(uint16 size);
2807 bool isDirty()
const;
2831 bool isVisual()
const override;
2832 virtual bool isTextLabel()
const;
2835 CORO_DEFINE_RETURN_TYPE(
void);
2841 bool respondsToEvent(
const Event &evt)
const override;
2844 bool isVisible()
const;
2845 bool isVisibleByDefault()
const;
2846 void setVisible(
Runtime *runtime,
bool visible);
2848 bool isDirectToScreen()
const;
2849 void setDirectToScreen(
bool directToScreen);
2851 uint16 getLayer()
const;
2852 void setLayer(uint16 layer);
2854 bool isMouseInsideDrawableArea(int32 relativeX, int32 relativeY)
const;
2857 virtual bool isMouseCollisionAtPoint(int32 relativeX, int32 relativeY)
const;
2872 void setCachedAbsoluteOrigin(
const Common::Point &absOrigin);
2892 void setShading(int16 topLeftBevelShading, int16 bottomRightBevelShading, int16 interiorShading, uint32 bevelSize);
2897 bool needsRender()
const;
2898 virtual void render(
Window *window) = 0;
2899 void finalizeRender();
2906 void pushVisibilityChangeTask(
Runtime *runtime,
bool desiredVisibility);
2908 #ifdef MTROPOLIS_DEBUG_ENABLE 2915 bool loadCommon(
const Common::String &name, uint32 guid,
const Data::Rect &rect, uint32 elementFlags, uint16 layer, uint32 streamLocator, uint16 sectionID);
2934 void offsetTranslate(int32 xDelta, int32 yDelta,
bool cachedOriginOnly);
2935 void resize(int32 width, int32 height);
2940 CORO_DEFINE_RETURN_TYPE(
void);
2957 static uint32 quantizeShading(uint32 mask, int16 shading);
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);
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);
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);
2967 bool _directToScreen;
2969 bool _visibleByDefault;
2974 int16 _topLeftBevelShading;
2975 int16 _bottomRightBevelShading;
2976 int16 _interiorShading;
2991 bool _contentsDirty;
2996 bool isVisual()
const override;
2998 bool loadCommon(
const Common::String &name, uint32 guid, uint32 elementFlags);
3005 bool load(
const uint32 dataModifierFlags);
3007 bool isLastModifier : 1;
3008 bool flagsWereLoaded : 1;
3017 virtual void commitLoad()
const = 0;
3032 virtual void onCreate(
Modifier *modifier);
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;
3052 bool isModifier()
const override;
3064 bool respondsToEvent(
const Event &evt)
const override;
3077 virtual const char *getDefaultName()
const = 0;
3094 virtual void disable(
Runtime *runtime) = 0;
3096 #ifdef MTROPOLIS_DEBUG_ENABLE 3097 SupportStatus debugGetSupportStatus()
const override;
3129 virtual bool isVariable()
const override;
3130 virtual bool isListVariable()
const;
3138 virtual void varGetValue(
DynamicValue &dest)
const = 0;
3142 void disable(
Runtime *runtime)
override;
3146 #ifdef MTROPOLIS_DEBUG_ENABLE 3153 struct WriteProxyInterface {
3168 kAssetTypeColorTable,
3187 uint32 getAssetID()
const;
3189 virtual AssetType getAssetType()
const = 0;
Definition: managed_surface.h:51
Definition: runtime.h:1353
Definition: runtime.h:1058
Definition: runtime.h:816
Definition: runtime.h:418
Definition: runtime.h:1299
Definition: runtime.h:2151
Definition: runtime.h:2093
Definition: runtime.h:2034
Definition: runtime.h:3028
Definition: runtime.h:514
Definition: runtime.h:1172
Definition: runtime.h:469
Definition: runtime.h:2359
Definition: runtime.h:2413
Definition: runtime.h:1474
Definition: runtime.h:330
Definition: modifier_factory.h:30
Definition: runtime.h:3003
Definition: runtime.h:925
Definition: runtime.h:1656
Definition: runtime.h:1562
Definition: runtime.h:1401
Definition: runtime.h:1192
Definition: runtime.h:2315
Definition: runtime.h:995
Definition: runtime.h:2337
EventType
Definition: events.h:49
Definition: runtime.h:1203
Definition: modifier_factory.h:44
Definition: runtime.h:2195
Definition: runtime.h:2409
Definition: runtime.h:2444
Definition: runtime.h:440
Definition: runtime.h:1594
Definition: runtime.h:488
Definition: runtime.h:503
Definition: runtime.h:2244
Definition: runtime.h:2693
Definition: runtime.h:2342
Definition: runtime.h:2052
Definition: runtime.h:2879
Definition: runtime.h:1185
Definition: runtime.h:2743
Definition: runtime.h:3035
Definition: runtime.h:2040
Definition: runtime.h:2647
Definition: runtime.h:2390
Definition: runtime.h:1049
Definition: miniscript.h:421
Definition: runtime.h:2827
Definition: runtime.h:544
Definition: archive.h:141
Definition: runtime.h:1197
Definition: runtime.h:1231
Definition: modifier_factory.h:48
Definition: noncopyable.h:39
Definition: runtime.h:369
Definition: runtime.h:2131
Definition: runtime.h:351
Definition: runtime.h:1079
Definition: runtime.h:1456
Definition: runtime.h:1579
Definition: runtime.h:1307
Definition: runtime.h:609
Definition: runtime.h:2432
Definition: runtime.h:1210
Definition: runtime.h:2355
Definition: runtime.h:574
Definition: runtime.h:2118
Definition: runtime.h:1326
Definition: runtime.h:624
Definition: runtime.h:2668
Definition: atari-cursor.h:38
Definition: runtime.h:1100
Definition: runtime.h:2944
Definition: runtime.h:1180
Definition: subtitles.h:123
Definition: runtime.h:3182
Definition: algorithm.h:29
Definition: formatinfo.h:28
Definition: runtime.h:1108
Definition: runtime.h:3124
Definition: runtime.h:2939
Definition: runtime.h:1041
Definition: runtime.h:2162
Definition: runtime.h:1220
Definition: runtime.h:1552
Definition: saveload.h:59
Definition: runtime.h:3175
Definition: runtime.h:589
Definition: runtime.h:2994
Definition: vthread.h:133
Definition: runtime.h:114
Definition: runtime.h:744
Definition: runtime.h:1033
Definition: runtime.h:559
Definition: modifier_factory.h:40
Definition: saveload.h:54
Definition: runtime.h:2323
Definition: keyboard.h:294
Definition: runtime.h:1570
Definition: runtime.h:2125
Definition: runtime.h:1360
Definition: runtime.h:2327
Definition: runtime.h:2184
Definition: runtime.h:391
Definition: runtime.h:3011
Definition: runtime.h:2103
Definition: runtime.h:2427
Definition: runtime.h:1513
Definition: runtime.h:551
Definition: runtime.h:1253
Definition: runtime.h:2728
Definition: runtime.h:1438
Definition: runtime.h:2472
Definition: runtime.h:2394
Definition: runtime.h:1025
Definition: runtime.h:1376
Definition: runtime.h:2834
Definition: runtime.h:1385
Definition: runtime.h:536
Definition: runtime.h:964
Definition: runtime.h:595
Definition: runtime.h:3116
Language
Definition: language.h:45