ScummVM API documentation
elements.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 * Additional copyright for this file:
8 * Copyright (C) 1995-1997 Presto Studios, Inc.
9 *
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 *
23 */
24
25#ifndef PEGASUS_ELEMENTS_H
26#define PEGASUS_ELEMENTS_H
27
28#include "common/array.h"
29#include "common/rect.h"
30#include "common/str.h"
31#include "common/system.h"
32#include "graphics/surface.h"
33
34#include "pegasus/timers.h"
35#include "pegasus/util.h"
36
37namespace Common {
38 class MacResManager;
39}
40
41namespace Pegasus {
42
43class DisplayElement : public IDObject {
44friend class GraphicsManager;
45public:
46 DisplayElement(const DisplayElementID);
47 virtual ~DisplayElement();
48
49 void setDisplayOrder(const DisplayOrder);
50 DisplayOrder getDisplayOrder() const { return _elementOrder; }
51
52 bool validToDraw(DisplayOrder, DisplayOrder);
53
54 virtual void draw(const Common::Rect&) {}
55 bool isDisplaying() { return _elementIsDisplaying; }
56 virtual void startDisplaying();
57 virtual void stopDisplaying();
58
59 virtual void show();
60 virtual void hide();
61 bool isVisible() { return _elementIsVisible; }
62
63 // triggerRedraw only triggers a draw if the element is displaying and visible.
64 void triggerRedraw();
65 void setTriggeredElement(DisplayElement *);
66
67 virtual void setBounds(const CoordType, const CoordType, const CoordType, const CoordType);
68 virtual void setBounds(const Common::Rect &);
69 virtual void getBounds(Common::Rect &) const;
70 virtual void sizeElement(const CoordType, const CoordType);
71 virtual void moveElementTo(const CoordType, const CoordType);
72 virtual void moveElement(const CoordType, const CoordType);
73 virtual void getLocation(CoordType &, CoordType &) const;
74 virtual void getCenter(CoordType &, CoordType &) const;
75 virtual void centerElementAt(const CoordType, const CoordType);
76
77protected:
78 Common::Rect _bounds;
79 bool _elementIsVisible;
80 DisplayElement *_triggeredElement;
81
82 // Used only by PegasusEngine
83 bool _elementIsDisplaying;
84 DisplayOrder _elementOrder;
85 DisplayElement *_nextElement;
86};
87
88// I'm using the proper "highlight" instead of the evil
89// QuickDraw "hilite" :P (deal with it!)
91public:
92 DropHighlight(const DisplayElementID);
93 ~DropHighlight() override {}
94
95 void setHighlightColor(const uint32 &highlight) { _highlightColor = highlight; }
96 void getHighlightColor(uint32 &highlight) const { highlight = _highlightColor; }
97
98 void setHighlightThickness(const uint16 thickness) { _thickness = thickness; }
99 uint16 getHighlightThickness() const { return _thickness; }
100
101 void setHighlightCornerDiameter(const uint16 diameter) { _cornerDiameter = diameter; }
102 uint16 getHighlightCornerDiameter() const { return _cornerDiameter; }
103
104 void draw(const Common::Rect&) override;
105
106protected:
107 uint32 _highlightColor;
108 uint16 _thickness;
109 uint16 _cornerDiameter;
110};
111
113public:
114 Animation(const DisplayElementID id) : DisplayElement(id) {}
115};
116
117class IdlerAnimation : public Animation, public Idler {
118public:
119 IdlerAnimation(const DisplayElementID);
120
121 void startDisplaying() override;
122 void stopDisplaying() override;
123
124 TimeValue getLastTime() const { return _lastTime; }
125
126protected:
127 void useIdleTime() override;
128 virtual void timeChanged(const TimeValue);
129
130 TimeValue _lastTime;
131};
132
133// This class reads PICT resources and plays them like a movie.
134// Assumes there is a resource of type 'PFrm' describing the time values for each
135// PICT frame, as well as the total time in the movie.
136// Assumes that PICT frames begin at PICT 128
137
139public:
140 FrameSequence(const DisplayElementID);
141 ~FrameSequence() override;
142
143 void useFileName(const Common::Path &fileName);
144
145 virtual void openFrameSequence();
146 virtual void closeFrameSequence();
147 bool isSequenceOpen() const;
148
149 uint16 getNumFrames() const { return _numFrames; }
150 virtual uint16 getFrameNum() const { return _currentFrameNum; }
151 virtual void setFrameNum(const int16);
152
153protected:
154 void timeChanged(const TimeValue) override;
155 virtual void newFrame(const uint16) {}
156
157 Common::MacResManager *_resFork;
158 TimeValue _duration;
159
160 uint16 _numFrames;
161 Common::Array<TimeValue> _frameTimes;
162
163 uint16 _currentFrameNum;
164};
165
166class SpriteFrame;
167
168class Sprite : public DisplayElement {
169friend class SpriteFrame;
170public:
171 Sprite(const DisplayElementID);
172 ~Sprite() override;
173
174 virtual void addPICTResourceFrame(const ResIDType, const bool, const CoordType, const CoordType);
175 virtual uint32 addFrame(SpriteFrame *, const CoordType, const CoordType);
176 virtual void removeFrame(const uint32);
177 virtual void discardFrames();
178
179 // Setting the current frame.
180 // If the index is negative, sets the current frame to NULL and hides the sprite.
181 // If the index is larger than the number of frames in the sprite, the number
182 // is treated modulo the number of frames.
183 virtual void setCurrentFrameIndex(const int32);
184 virtual uint32 getCurrentFrameIndex() const { return _currentFrameNum; }
185
186 virtual SpriteFrame *getFrame(const int32);
187
188 void draw(const Common::Rect &) override;
189
190 uint32 getNumFrames() const { return _numFrames; }
191
192protected:
194 SpriteFrame *frame;
195 CoordType frameLeft;
196 CoordType frameTop;
197 };
198
199 uint32 _numFrames;
200 uint32 _currentFrameNum;
201 SpriteFrameRec *_currentFrame;
203};
204
206public:
207 SpriteSequence(const DisplayElementID id, const DisplayElementID spriteID);
208 ~SpriteSequence() override {}
209
210 void useTransparent(bool transparent) { _transparent = transparent; }
211
212 void openFrameSequence() override;
213 void closeFrameSequence() override;
214
215 void draw(const Common::Rect &) override;
216
217 void setBounds(const Common::Rect &) override;
218
219protected:
220 void newFrame(const uint16) override;
221
222 bool _transparent;
223 Sprite _sprite;
224};
225
227public:
228 ScreenDimmer() : DisplayElement(kScreenDimmerID) {}
229 ~ScreenDimmer() override {}
230
231 void draw(const Common::Rect &) override;
232};
233
235public:
236 SoundLevel(const DisplayElementID);
237 ~SoundLevel() override {}
238
239 void incrementLevel();
240 void decrementLevel();
241
242 uint16 getSoundLevel();
243 void setSoundLevel(uint16);
244
245 void draw(const Common::Rect &) override;
246
247protected:
248 uint16 _soundLevel;
249};
250
251} // End of namespace Pegasus
252
253#endif
Definition: macresman.h:126
Definition: path.h:52
Definition: elements.h:112
Definition: elements.h:43
Definition: elements.h:90
Definition: timers.h:208
Definition: elements.h:138
Definition: graphics.h:44
Definition: util.h:38
Definition: elements.h:117
Definition: timers.h:37
Definition: elements.h:226
Definition: elements.h:234
Definition: surface.h:115
Definition: elements.h:168
Definition: elements.h:205
Definition: algorithm.h:29
Definition: rect.h:536
Definition: elements.h:193