ScummVM API documentation
renderobject.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 NANCY_RENDEROBJECT_H
23 #define NANCY_RENDEROBJECT_H
24 
25 #include "common/path.h"
26 #include "graphics/managed_surface.h"
27 
28 namespace Nancy {
29 
30 class NancyEngine;
31 class GraphicsManager;
32 
33 // Loosely equivalent to the original engine's ZRenderStructs.
34 // A subclass of this will be automatically updated and drawn from the graphics manager,
35 // but initialization needs to be done manually.
36 class RenderObject {
37  friend class GraphicsManager;
38 public:
39  RenderObject(uint16 zOrder);
40  RenderObject(uint16 zOrder, Graphics::ManagedSurface &surface, const Common::Rect &srcBounds, const Common::Rect &destBounds);
41 
42  virtual ~RenderObject();
43 
44  virtual void init(); // Does not get called automatically
45  virtual void registerGraphics(); // Does not get called automatically
46  virtual void updateGraphics() {}
47 
48  void moveTo(const Common::Point &position);
49  void moveTo(const Common::Rect &bounds);
50  void setVisible(bool visible);
51  void setTransparent(bool isTransparent);
52  bool isVisible() const { return _isVisible; }
53 
54  // Only used by The Vampire Diaries
55  void grabPalette(byte *colors, uint paletteStart = 0, uint paletteSize = 256);
56  void setPalette(const Common::Path &paletteName, uint paletteStart = 0, uint paletteSize = 256);
57  void setPalette(const byte *colors, uint paletteStart = 0, uint paletteSize = 256);
58 
59  bool hasMoved() const { return _previousScreenPosition != _screenPosition; }
60  Common::Rect getScreenPosition() const;
61  Common::Rect getPreviousScreenPosition() const;
62 
63  // Given a screen-space rect, convert it to the _drawSurface's local space
64  Common::Rect convertToLocal(const Common::Rect &screen) const;
65  // Given a local (to the _drawSurface) space rect, convert it to screen space
66  Common::Rect convertToScreen(const Common::Rect &rect) const;
67 
68  Common::Rect getBounds() const { return Common::Rect(_screenPosition.width(), _screenPosition.height()); }
69  uint16 getZOrder() const { return _z; }
70 
71  Graphics::ManagedSurface _drawSurface;
72 
73 protected:
74  // Needed for proper handling of objects inside the viewport
75  virtual bool isViewportRelative() const { return false; }
76 
77  bool _needsRedraw;
78  bool _isVisible;
79  bool _hasMoved;
80  uint16 _z;
81  Common::Rect _previousScreenPosition;
82  Common::Rect _screenPosition;
83 };
84 
85 } // End of namespace Nancy
86 
87 #endif // NANCY_RENDEROBJECT_H
Definition: managed_surface.h:51
virtual void setPalette(const byte *colors, uint start, uint num)=0
Definition: graphics.h:37
Definition: rect.h:144
Definition: path.h:52
Definition: renderobject.h:36
int16 width() const
Definition: rect.h:191
virtual void grabPalette(byte *colors, uint start, uint num) const =0
Definition: rect.h:45
Definition: graphics.h:37
int16 height() const
Definition: rect.h:192
Definition: actionmanager.h:32