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 MPEGVideoPlayer;
98 
100 public:
101  virtual void onVideoCompleted() = 0;
102 };
103 
105 public:
106  SampleModifier();
107  ~SampleModifier();
108 
109  bool respondsToEvent(const Event &evt) const override;
110  VThreadState consumeMessage(Runtime *runtime, const Common::SharedPtr<MessageProperties> &msg) override;
111  void disable(Runtime *runtime) override;
112 
113  bool load(const PlugInModifierLoaderContext &context, const Data::MTI::SampleModifier &data);
114 
115  void onVideoCompleted() override;
116  void onKeyboardEvent(Runtime *runtime, const KeyboardInputEvent &keyEvt) override;
117 
118 #ifdef MTROPOLIS_DEBUG_ENABLE
119  const char *debugGetTypeName() const override { return "Sample Modifier"; }
120  void debugInspect(IDebugInspectionReport *report) const override;
121 #endif
122 
123 private:
124  Common::SharedPtr<Modifier> shallowClone() const override;
125  const char *getDefaultName() const override;
126 
127  void stopPlaying();
128 
129  Event _executeWhen;
130  int32 _videoNumber;
131 
134  Runtime *_runtime;
135  bool _isPlaying;
136 };
137 
138 
139 class MTIPlugIn : public MTropolis::PlugIn {
140 public:
141  MTIPlugIn();
142 
143  void registerModifiers(IPlugInModifierRegistrar *registrar) const override;
144 
145 private:
148 };
149 
150 } // End of namespace MTI
151 
152 } // End of namespace MTropolis
153 
154 #endif
Definition: random.h:44
Definition: runtime.h:2409
Definition: runtime.h:1575
Definition: runtime.h:1185
Definition: runtime.h:3035
Definition: modifier_factory.h:57
Definition: modifier_factory.h:48
Definition: mti_data.h:44
Definition: runtime.h:369
Definition: runtime.h:1307
Definition: runtime.h:2118
Definition: runtime.h:1180
Definition: debug.h:59
Definition: algorithm.h:29
Definition: mti.h:139
Definition: actions.h:25
Definition: mti.h:104
Definition: runtime.h:391
Definition: ptr.h:159
Definition: runtime.h:1519
Definition: core.h:33