ScummVM API documentation
view.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 MOHAWK_VIEW_H
23 #define MOHAWK_VIEW_H
24 
25 #include "mohawk/mohawk.h"
26 #include "common/rect.h"
27 
28 namespace Mohawk {
29 
30 class GraphicsManager;
31 
32 class Feature;
33 class View;
34 
35 enum : uint {
36  kFeatureObjectMask = 0xff, // both (sort of)
37  kFeatureOldSortForeground = 0x1000, // old
38  kFeatureOldDropSpot = 0x2000, // old
39  kFeatureOldNoClip = 0x4000, // old
40  kFeatureNewSortForeground = 0x4000, // new
41  kFeatureSortBackground = 0x8000, // both
42  kFeatureOldReset = 0x10000, // old
43  kFeatureOldDisable = 0x20000, // old
44  kFeatureOldAlternateScripts = 0x40000, // old
45  kFeatureOldDisableOnReset = 0x80000, // old
46  kFeatureDisableOnEnd = 0x100000, // both
47  kFeatureNewDisable = 0x200000, // new
48  kFeatureNewDisableOnReset = 0x400000, // new
49  kFeatureOldAdjustByPos = 0x800000, // old
50  kFeatureNewNoLoop = 0x800000, // new
51  kFeatureOldDisabled = 0x1000000, // old
52  kFeatureOldRandom = 0x2000000, // old
53  kFeatureNewClip = 0x2000000, // new
54  kFeatureSortStatic = 0x4000000, // both
55  kFeatureInternalRegion = 0x8000000, // both
56  kFeatureSortCheckRight = 0x10000000, // both
57  kFeatureSortCheckTop = 0x20000000, // both
58  kFeatureSortCheckLeft = 0x40000000, // both
59  kFeatureNewInternalTiming = 0x80000000 // new
60 };
61 
62 class Module {
63 public:
64  Module();
65  virtual ~Module();
66 
67  virtual void init() = 0;
68  virtual void shutdown() = 0;
69  virtual void update() = 0;
70 
71  typedef void (Module::*HotspotProc)(uint);
72  typedef void (Module::*FeatureProc)(Feature *);
73  typedef bool (Module::*BooleanProc)(Feature *);
74  typedef void (Module::*PickupProc)(Feature *, Common::Point, uint32, Common::Rect *);
75 };
76 
77 // This is memcpy()ed around, beware.
78 #define FEATURE_BITMAP_ITEMS 48 // this is 24 in old
79 struct FeatureData {
80  uint16 bitmapIds[FEATURE_BITMAP_ITEMS];
81  Common::Point bitmapPos[FEATURE_BITMAP_ITEMS];
82 
83  uint16 unknown192; // old?
84 
85  uint16 scrbIndex;
86  uint16 compoundSHAPIndex;
87  uint16 endFrame; // old?
88  uint16 currFrame; // old?
89  uint32 currOffset;
90 
91  Common::Rect bounds;
92 
93  Common::Point currentPos;
94  Common::Point nextPos;
95 
96  uint16 unknown220; // old?
97 
98  uint16 syncChannel;
99  uint16 enabled;
100  byte paused; // new
101  byte hidden; // new
102 
103  uint16 useClipRect;
104  Common::Rect clipRect;
105 };
106 
107 class Feature {
108 public:
109  Feature(View *view);
110  virtual ~Feature();
111 
112  virtual void resetFrame() = 0;
113 
114  virtual void setNodeDefaults(Feature *prev, Feature *next);
115  virtual void resetFeatureScript(uint16 enabled, uint16 scrbId);
116  virtual void resetFeature(bool notifyDone, Module::FeatureProc doneProc, uint16 scrbId);
117 
118  void hide(bool clip);
119  void show();
120 
121  void moveAndUpdate(Common::Point newPos);
122 
123  void defaultDraw();
124 
125  Feature *_next, *_prev;
126 
127  Module::FeatureProc _drawProc;
128  Module::FeatureProc _moveProc;
129  Module::FeatureProc _doneProc;
130  Module::FeatureProc _frameProc;
131  Module::BooleanProc _timeProc;
132 
133  uint16 _region; // TODO
134  uint16 _id;
135  uint16 _scrbId;
136  uint16 _storedScrbId; // old
137  uint32 _flags;
138  uint32 _nextTime;
139  uint32 _delayTime;
140  bool _dirty; // byte in old
141  bool _needsReset;
142  bool _justReset; // old
143  bool _done; // new
144 
145  FeatureData _data;
146 
147 protected:
148  View *_view;
149 
150  virtual void resetScript() = 0;
151  virtual void finishResetFeatureScript() = 0;
152 };
153 
154 class OldFeature : public Feature {
155 public:
156  OldFeature(View *view);
157  ~OldFeature() override;
158 
159  void resetFrame() override;
160  void resetFeatureScript(uint16 enabled, uint16 scrbId) override;
161 
162 protected:
163  void resetScript() override;
164  void finishResetFeatureScript() override;
165 };
166 
167 class NewFeature : public Feature {
168 public:
169  NewFeature(View *view);
170  ~NewFeature() override;
171 
172  void resetFrame() override;
173  void resetFeatureScript(uint16 enabled, uint16 scrbId) override;
174 
175  uint32 _unknown168;
176 
177  // Drag/drop variables.
178  Module::PickupProc _pickupProc;
179  Module::FeatureProc _dropProc;
180  Module::FeatureProc _dragMoveProc;
181  Module::FeatureProc _oldMoveProc;
182  uint32 _dragFlags;
183  uint32 _oldFlags;
184  Common::Point _oldPos;
185  Common::Point _posDiff;
186  Common::Point _currDragPos;
187 
188 protected:
189  void resetScript() override;
190  void finishResetFeatureScript() override;
191 };
192 
193 class View {
194 public:
195  View(MohawkEngine *vm);
196  virtual ~View();
197 
198  virtual void idleView();
199 
200  void setModule(Module *module);
201  Module *getCurrentModule() { return _currentModule; }
202  GraphicsManager *getGfx() { return _gfx; }
203 
204  Common::Array<uint16> getSHPL(uint16 id);
205  void installBG(uint16 id);
206  void setColors(Common::SeekableReadStream *tpalStream);
207  void copyFadeColors(uint start, uint count);
208 
209  uint16 getCompoundSHAPId(uint16 shapIndex);
210 
211  void installGroupOfSCRBs(bool main, uint base, uint size, uint count = 0);
212  virtual void freeScripts();
213  void installFeatureShapes(bool regs, uint groupId, uint16 resourceBase);
214  void freeFeatureShapes();
215 
216  uint16 getGroupFromBaseId(uint16 baseId);
217  void getnthScriptSetGroup(uint16 &scrbIndex, uint16 &shapIndex, uint16 scrbId);
218  Common::SeekableReadStream *getSCRB(uint16 index, uint16 id = 0xffff);
219 
220  Feature *getFeaturePtr(uint16 id);
221  uint16 getNewFeatureId();
222  void removeFeature(Feature *feature, bool free);
223  void insertUnderCursor(Feature *feature);
224  Feature *pointOnFeature(bool topdown, uint32 flags, Common::Point pos);
225  void sortView();
226 
227  uint32 _lastIdleTime;
228 
229  virtual uint32 getTime() = 0;
230 
231  bool _needsUpdate;
232 
233 protected:
234  MohawkEngine *_vm;
235  GraphicsManager *_gfx;
236  void setGraphicsManager(GraphicsManager *gfx) { _gfx = gfx; } // TODO
237  Module *_currentModule;
238 
239  uint16 _backgroundId;
240 
241  Feature *_rootNode, *_cursorNode;
242 
243  uint16 _numSCRBGroups;
244  uint16 _SCRBGroupBases[14];
245  uint16 _SCRBGroupSizes[14];
246  Common::Array<uint16> _SCRBEntries;
247  //uint16 _numCompoundSHAPGroups;
248  uint16 _compoundSHAPGroups[14];
249 
250  Feature *sortOneList(Feature *root);
251  Feature *mergeLists(Feature *root, Feature *mergeRoot);
252 
253  virtual void finishDraw() { }
254 };
255 
256 } // End of namespace Mohawk
257 
258 #endif
Definition: view.h:107
Definition: view.h:79
Definition: view.h:154
Definition: view.h:62
Definition: rect.h:144
Definition: stream.h:745
Definition: graphics.h:68
Definition: rect.h:45
Definition: mohawk.h:54
Definition: graphics.h:37
Definition: view.h:193
Definition: view.h:167
Definition: bitmap.h:32