ScummVM API documentation
obsidian.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_OBSIDIAN_H
23 #define MTROPOLIS_PLUGIN_OBSIDIAN_H
24 
25 #include "mtropolis/modifiers.h"
26 #include "mtropolis/modifier_factory.h"
27 #include "mtropolis/runtime.h"
28 #include "mtropolis/plugin/obsidian_data.h"
29 
30 namespace MTropolis {
31 
32 namespace Obsidian {
33 
34 class ObsidianPlugIn;
35 class WordGameData;
36 
37 class MovementModifier : public Modifier {
38 public:
41 
42  bool load(const PlugInModifierLoaderContext &context, const Data::Obsidian::MovementModifier &data);
43 
44  bool respondsToEvent(const Event &evt) const override;
45  VThreadState consumeMessage(Runtime *runtime, const Common::SharedPtr<MessageProperties> &msg) override;
46 
47  MiniscriptInstructionOutcome writeRefAttribute(MiniscriptThread *thread, DynamicValueWriteProxy &result, const Common::String &attrib) override;
48 
49  void disable(Runtime *runtime) override;
50 
51 #ifdef MTROPOLIS_DEBUG_ENABLE
52  const char *debugGetTypeName() const override { return "Movement Modifier"; }
53  void debugInspect(IDebugInspectionReport *report) const override;
54 #endif
55 
56 private:
57  Common::SharedPtr<Modifier> shallowClone() const override;
58  const char *getDefaultName() const override;
59 
60  void triggerMove(Runtime *runtime);
61 
62  Common::Point _dest;
63  bool _type;
64  double _rate;
65  int32 _frequency;
66 
67  Event _enableWhen;
68  Event _disableWhen;
69 
70  Event _triggerEvent;
71 
72  Common::Point _moveStartPoint;
73  uint64 _moveStartTime;
74 
76  Runtime *_runtime;
77 };
78 
79 class RectShiftModifier : public Modifier, public IPostEffect {
80 public:
83 
84  bool respondsToEvent(const Event &evt) const override;
85  VThreadState consumeMessage(Runtime *runtime, const Common::SharedPtr<MessageProperties> &msg) override;
86  void disable(Runtime *runtime) override;
87 
88  bool load(const PlugInModifierLoaderContext &context, const Data::Obsidian::RectShiftModifier &data);
89 
90  MiniscriptInstructionOutcome writeRefAttribute(MiniscriptThread *thread, DynamicValueWriteProxy &result, const Common::String &attrib) override;
91 
92  void renderPostEffect(Graphics::ManagedSurface &surface) const override;
93 
94 #ifdef MTROPOLIS_DEBUG_ENABLE
95  const char *debugGetTypeName() const override { return "Rect Shift Modifier"; }
96  void debugInspect(IDebugInspectionReport *report) const override;
97 #endif
98 
99 private:
100  Common::SharedPtr<Modifier> shallowClone() const override;
101  const char *getDefaultName() const override;
102 
103  Event _enableWhen;
104  Event _disableWhen;
105 
106  int32 _direction;
107 
108  Runtime *_runtime;
109  bool _isActive;
110 };
111 
112 class TextWorkModifier : public Modifier {
113 public:
115 
116  bool load(const PlugInModifierLoaderContext &context, const Data::Obsidian::TextWorkModifier &data);
117 
118  bool readAttribute(MiniscriptThread *thread, DynamicValue &result, const Common::String &attrib) override;
119  MiniscriptInstructionOutcome writeRefAttribute(MiniscriptThread *thread, DynamicValueWriteProxy &result, const Common::String &attrib) override;
120 
121  void disable(Runtime *runtime) override {}
122 
123 #ifdef MTROPOLIS_DEBUG_ENABLE
124  const char *debugGetTypeName() const override { return "TextWork Modifier"; }
125  SupportStatus debugGetSupportStatus() const override { return kSupportStatusDone; }
126 #endif
127 
128 private:
129  Common::SharedPtr<Modifier> shallowClone() const override;
130  const char *getDefaultName() const override;
131 
132  MiniscriptInstructionOutcome scriptSetFirstWord(MiniscriptThread *thread, const DynamicValue &value);
133  MiniscriptInstructionOutcome scriptSetLastWord(MiniscriptThread *thread, const DynamicValue &value);
134 
135  Common::String _string;
136  Common::String _token;
137 
138  // These appear to be 1-based?
139  int32 _firstChar;
140  int32 _lastChar;
141 };
142 
143 class DictionaryModifier : public Modifier {
144 public:
146 
147  bool load(const PlugInModifierLoaderContext &context, const Data::Obsidian::DictionaryModifier &data);
148 
149  bool readAttribute(MiniscriptThread *thread, DynamicValue &result, const Common::String &attrib) override;
150  MiniscriptInstructionOutcome writeRefAttribute(MiniscriptThread *thread, DynamicValueWriteProxy &result, const Common::String &attrib) override;
151 
152  void disable(Runtime *runtime) override {}
153 
154 #ifdef MTROPOLIS_DEBUG_ENABLE
155  const char *debugGetTypeName() const override { return "Dictionary Modifier"; }
156  SupportStatus debugGetSupportStatus() const override { return kSupportStatusDone; }
157 #endif
158 
159 private:
160  void resolveStringIndex();
161  MiniscriptInstructionOutcome scriptSetString(MiniscriptThread *thread, const DynamicValue &value);
162  MiniscriptInstructionOutcome scriptSetIndex(MiniscriptThread *thread, const DynamicValue &value);
163 
164  Common::SharedPtr<Modifier> shallowClone() const override;
165  const char *getDefaultName() const override;
166 
167  Common::String _str;
168 
169  const ObsidianPlugIn *_plugIn;
170  int32 _index;
171  bool _isIndexResolved;
172 };
173 
174 class WordMixerModifier : public Modifier {
175 public:
177 
178  bool load(const PlugInModifierLoaderContext &context, const Data::Obsidian::WordMixerModifier &data);
179 
180  bool readAttribute(MiniscriptThread *thread, DynamicValue &result, const Common::String &attrib) override;
181  MiniscriptInstructionOutcome writeRefAttribute(MiniscriptThread *thread, DynamicValueWriteProxy &result, const Common::String &attrib) override;
182 
183  void disable(Runtime *runtime) override {}
184 
185 #ifdef MTROPOLIS_DEBUG_ENABLE
186  const char *debugGetTypeName() const override { return "WordMixer Modifier"; }
187  SupportStatus debugGetSupportStatus() const override { return kSupportStatusDone; }
188 #endif
189 
190 private:
191  Common::SharedPtr<Modifier> shallowClone() const override;
192  const char *getDefaultName() const override;
193 
194  MiniscriptInstructionOutcome scriptSetInput(MiniscriptThread *thread, const DynamicValue &value);
195  MiniscriptInstructionOutcome scriptSetSearch(MiniscriptThread *thread, const DynamicValue &value);
196 
197  Common::String _input;
198  Common::String _output;
199  int _matches;
200  int _result;
201 
202  const ObsidianPlugIn *_plugIn;
203 };
204 
205 class XorModModifier : public Modifier {
206 public:
207  XorModModifier();
208 
209  bool load(const PlugInModifierLoaderContext &context, const Data::Obsidian::XorModModifier &data);
210 
211  bool respondsToEvent(const Event &evt) const override;
212  VThreadState consumeMessage(Runtime *runtime, const Common::SharedPtr<MessageProperties> &msg) override;
213  void disable(Runtime *runtime) override;
214 
215 #ifdef MTROPOLIS_DEBUG_ENABLE
216  const char *debugGetTypeName() const override { return "Xor Mod Modifier"; }
217  SupportStatus debugGetSupportStatus() const override { return kSupportStatusDone; }
218 #endif
219 
220 private:
221  Common::SharedPtr<Modifier> shallowClone() const override;
222  const char *getDefaultName() const override;
223 
224  Event _enableWhen;
225  Event _disableWhen;
226 
227  int32 _shapeID;
228 };
229 
230 class XorCheckModifier : public Modifier {
231 public:
233 
234  bool load(const PlugInModifierLoaderContext &context, const Data::Obsidian::XorCheckModifier &data);
235 
236  bool readAttribute(MiniscriptThread *thread, DynamicValue &result, const Common::String &attrib) override;
237  MiniscriptInstructionOutcome writeRefAttribute(MiniscriptThread *thread, DynamicValueWriteProxy &result, const Common::String &attrib) override;
238 
239  void disable(Runtime *runtime) override {}
240 
241 #ifdef MTROPOLIS_DEBUG_ENABLE
242  const char *debugGetTypeName() const override { return "Xor Check Modifier"; }
243  SupportStatus debugGetSupportStatus() const override { return kSupportStatusDone; }
244 #endif
245 
246 private:
247  Common::SharedPtr<Modifier> shallowClone() const override;
248  const char *getDefaultName() const override;
249 
250  MiniscriptInstructionOutcome scriptSetCheckNow(MiniscriptThread *thread, const DynamicValue &value);
251 
252  static void recursiveFindXorElements(Structural *structural, Common::Array<VisualElement *> &elements);
253  static bool sliceRectX(const Common::Rect &rect, int32 x, Common::Array<Common::Rect> &outSlices);
254  static bool sliceRectY(const Common::Rect &rect, int32 y, Common::Array<Common::Rect> &outSlices);
255 
256  bool _allClear;
257 };
258 
260 public:
262 
263  void registerModifiers(IPlugInModifierRegistrar *registrar) const override;
264 
265  const Common::SharedPtr<WordGameData> &getWordGameData() const;
266 
267 private:
275 
277 };
278 
280  uint32 startAddress;
281  uint32 endAddress;
282 };
283 
285 public:
286  struct WordBucket {
287  WordBucket();
288 
289  Common::Array<char> _chars;
290  Common::Array<uint16> _wordIndexes;
291  uint32 _spacing;
292  };
293 
294  struct SortedWord {
295  SortedWord();
296 
297  const char *_chars;
298  uint _length;
299  };
300 
301  bool load(Common::SeekableReadStream *stream, const WordGameLoadBucket *buckets, uint numBuckets, uint alignment, bool backwards);
302 
303  const Common::Array<WordBucket> &getWordBuckets() const;
304  const Common::Array<SortedWord> &getSortedWords() const;
305 
306 private:
307  Common::Array<WordBucket> _buckets;
308  Common::Array<SortedWord> _sortedWords;
309 };
310 
311 } // End of namespace Obsidian
312 
313 } // End of namespace MTropolis
314 
315 #endif
Definition: managed_surface.h:51
Definition: runtime.h:816
Definition: str.h:59
Definition: array.h:52
Definition: obsidian.h:230
Definition: runtime.h:2195
Definition: obsidian_data.h:87
Definition: runtime.h:2444
Definition: rect.h:144
Definition: runtime.h:1575
Definition: obsidian.h:205
Definition: stream.h:745
Definition: runtime.h:1185
Definition: runtime.h:3035
Definition: miniscript.h:421
Definition: modifier_factory.h:57
Definition: runtime.h:544
Definition: obsidian_data.h:96
Definition: obsidian_data.h:82
Definition: modifier_factory.h:48
Definition: obsidian.h:259
Definition: runtime.h:369
Definition: obsidian.h:174
Definition: runtime.h:1180
Definition: debug.h:59
Definition: obsidian_data.h:74
Definition: rect.h:45
Definition: obsidian.h:279
Definition: obsidian_data.h:69
Definition: obsidian.h:112
Definition: actions.h:25
Definition: obsidian.h:284
Definition: ptr.h:159
Definition: obsidian_data.h:60
Definition: obsidian_data.h:42
Definition: obsidian.h:143
Definition: obsidian.h:37