ScummVM API documentation
mti.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef MTROPOLIS_PLUGIN_MTI_H
23 #define MTROPOLIS_PLUGIN_MTI_H
24 
25 #include "mtropolis/modifier_factory.h"
26 #include "mtropolis/modifiers.h"
27 #include "mtropolis/plugin/mti_data.h"
28 #include "mtropolis/runtime.h"
29 
30 namespace Common {
31 
32 class RandomSource;
33 
34 } // End of namespace Common
35 
36 namespace MTropolis {
37 
38 namespace MTI {
39 
40 class MTIPlugIn;
41 
42 class ShanghaiModifier : public Modifier {
43 public:
46 
47  bool respondsToEvent(const Event &evt) const override;
48  VThreadState consumeMessage(Runtime *runtime, const Common::SharedPtr<MessageProperties> &msg) override;
49  void disable(Runtime *runtime) override;
50 
51  bool load(const PlugInModifierLoaderContext &context, const Data::MTI::ShanghaiModifier &data);
52 
53  void linkInternalReferences(ObjectLinkingScope *scope) override;
54  void visitInternalReferences(IStructuralReferenceVisitor *visitor) override;
55 
56 #ifdef MTROPOLIS_DEBUG_ENABLE
57  SupportStatus debugGetSupportStatus() const override { return kSupportStatusDone; }
58  const char *debugGetTypeName() const override { return "Shanghai Modifier"; }
59  void debugInspect(IDebugInspectionReport *report) const override;
60 #endif
61 
62 private:
63  static const uint kNumTiles = 28;
64  static const uint kNumFaces = 26;
65 
66  typedef uint32 BoardState_t;
67 
68  static const uint kBoardSizeX = 13;
69  static const uint kBoardSizeY = 7;
70  static const uint kBoardSizeZ = 3;
71 
72  struct TileCoordinate {
73  uint x;
74  uint y;
75  uint z;
76  };
77 
78  Common::SharedPtr<Modifier> shallowClone() const override;
79  const char *getDefaultName() const override;
80 
81  void resetTiles(Common::RandomSource &rng, uint (&tileFaces)[kNumTiles]) const;
82  static uint selectAndRemoveOne(Common::RandomSource &rng, uint *valuesList, uint &listSize);
83  bool boardStateHasValidMove(BoardState_t boardState) const;
84  bool tileIsExposed(BoardState_t boardState, uint tile) const;
85  bool tileExistsAtCoordinate(BoardState_t boardState, uint x, uint y, uint z) const;
86 
87  static BoardState_t boardStateBit(uint bit);
88  static BoardState_t emptyBoardState();
89 
90  Event _resetTileSetWhen;
91  VarReference _tileSetRef;
92 
93  static TileCoordinate _tileCoordinates[kNumTiles];
94  int8 _tileAtCoordinate[kBoardSizeX][kBoardSizeY][kBoardSizeZ];
95 };
96 
97 class PrintModifier : public Modifier {
98 public:
99  PrintModifier();
100  ~PrintModifier();
101 
102  bool respondsToEvent(const Event &evt) const override;
103  VThreadState consumeMessage(Runtime *runtime, const Common::SharedPtr<MessageProperties> &msg) override;
104  void disable(Runtime *runtime) override;
105 
106  MiniscriptInstructionOutcome writeRefAttribute(MiniscriptThread *thread, DynamicValueWriteProxy &writeProxy, const Common::String &attrib) override;
107 
108  bool load(const PlugInModifierLoaderContext &context, const Data::MTI::PrintModifier &data);
109 
110 #ifdef MTROPOLIS_DEBUG_ENABLE
111  const char *debugGetTypeName() const override { return "Print Modifier"; }
112  void debugInspect(IDebugInspectionReport *report) const override;
113 #endif
114 
115 private:
116  Common::SharedPtr<Modifier> shallowClone() const override;
117  const char *getDefaultName() const override;
118 
119  Event _executeWhen;
120  Common::String _filePath;
121 };
122 
123 class MPEGVideoPlayer;
124 
126 public:
127  virtual void onVideoCompleted() = 0;
128 };
129 
131 public:
132  SampleModifier();
133  ~SampleModifier();
134 
135  bool respondsToEvent(const Event &evt) const override;
136  VThreadState consumeMessage(Runtime *runtime, const Common::SharedPtr<MessageProperties> &msg) override;
137  void disable(Runtime *runtime) override;
138 
139  bool load(const PlugInModifierLoaderContext &context, const Data::MTI::SampleModifier &data);
140 
141  void onVideoCompleted() override;
142  void onKeyboardEvent(Runtime *runtime, const KeyboardInputEvent &keyEvt) override;
143 
144 #ifdef MTROPOLIS_DEBUG_ENABLE
145  const char *debugGetTypeName() const override { return "Sample Modifier"; }
146  void debugInspect(IDebugInspectionReport *report) const override;
147 #endif
148 
149 private:
150  Common::SharedPtr<Modifier> shallowClone() const override;
151  const char *getDefaultName() const override;
152 
153  void stopPlaying();
154 
155  Event _executeWhen;
156  int32 _videoNumber;
157 
160  Runtime *_runtime;
161  bool _isPlaying;
162 };
163 
164 
165 class MTIPlugIn : public MTropolis::PlugIn {
166 public:
167  MTIPlugIn();
168 
169  void registerModifiers(IPlugInModifierRegistrar *registrar) const override;
170 
171 private:
175 };
176 
177 } // End of namespace MTI
178 
179 } // End of namespace MTropolis
180 
181 #endif
Definition: mti_data.h:44
Definition: str.h:59
Definition: random.h:44
Definition: runtime.h:2409
Definition: runtime.h:1594
Definition: runtime.h:1185
Definition: runtime.h:3035
Definition: miniscript.h:421
Definition: modifier_factory.h:57
Definition: runtime.h:544
Definition: modifier_factory.h:48
Definition: mti_data.h:56
Definition: runtime.h:369
Definition: runtime.h:1307
Definition: runtime.h:2118
Definition: mti.h:97
Definition: runtime.h:1180
Definition: debug.h:59
Definition: algorithm.h:29
Definition: mti.h:165
Definition: actions.h:25
Definition: mti.h:130
Definition: runtime.h:391
Definition: ptr.h:159
Definition: runtime.h:1538
Definition: core.h:33