ScummVM API documentation
layer.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 STARK_RESOURCES_LAYER_H
23 #define STARK_RESOURCES_LAYER_H
24 
25 #include "common/array.h"
26 #include "common/str.h"
27 
28 #include "engines/stark/gfx/renderentry.h"
29 #include "engines/stark/resources/object.h"
30 
31 namespace Stark {
32 
33 namespace Formats {
34 class XRCReadStream;
35 }
36 
37 namespace Resources {
38 
39 class Item;
40 
46 class Layer : public Object {
47 public:
48  static const Type::ResourceType TYPE = Type::kLayer;
49 
50  enum SubType {
51  kLayer2D = 1,
52  kLayer3D = 2
53  };
54 
56  static Object *construct(Object *parent, byte subType, uint16 index, const Common::String &name);
57 
58  Layer(Object *parent, byte subType, uint16 index, const Common::String &name);
59  virtual ~Layer();
60 
61  // Resource API
62  void readData(Formats::XRCReadStream *stream) override;
63  void saveLoad(ResourceSerializer *serializer) override;
64  void saveLoadCurrent(ResourceSerializer *serializer) override;
65 
67  virtual Gfx::RenderEntryArray listRenderEntries() = 0;
68 
70  Gfx::LightEntryArray listLightEntries();
71 
73  void setScrollPosition(const Common::Point &position);
74 
76  Common::Point getScroll() const;
77 
79  void setScroll(const Common::Point &scroll);
80 
82  void enable(bool enabled);
83 
85  bool isEnabled() const;
86 
87 protected:
88  void printData() override;
89 
90  Common::Point _scroll;
91  float _scrollScale; // Used for the parallax effect
92  bool _enabled;
93 };
94 
100 class Layer2D : public Layer {
101 public:
102  Layer2D(Object *parent, byte subType, uint16 index, const Common::String &name);
103  virtual ~Layer2D();
104 
105  // Resource API
106  void readData(Formats::XRCReadStream *stream) override;
107  void onEnterLocation() override;
108  void onExitLocation() override;
109 
110  // Layer API
111  Gfx::RenderEntryArray listRenderEntries() override;
112 
113 protected:
114  void printData() override;
115 
116  Common::Array<uint32> _itemIndices;
117  Common::Array<Item *> _items;
118 };
119 
125 class Layer3D : public Layer {
126 public:
127  Layer3D(Object *parent, byte subType, uint16 index, const Common::String &name);
128  virtual ~Layer3D();
129 
130  // Resource API
131  void readData(Formats::XRCReadStream *stream) override;
132  void onAllLoaded() override;
133  void onEnterLocation() override;
134 
135  // Layer API
136  Gfx::RenderEntryArray listRenderEntries() override;
137 
139  Gfx::RenderEntry *getBackgroundRenderEntry();
140 
141 protected:
142  void printData() override;
143 
144  bool _shouldRenderShadows;
145  uint32 _maxShadowLength;
146  float _nearClipPlane;
147  float _farClipPlane;
148 
149  Item *_backgroundItem;
150  Common::Array<Item *> _items;
151 };
152 
153 } // End of namespace Resources
154 } // End of namespace Stark
155 
156 #endif // STARK_RESOURCES_LAYER_H
Definition: layer.h:46
Definition: str.h:59
Definition: layer.h:125
Definition: array.h:52
Definition: item.h:62
Definition: layer.h:100
Definition: console.h:27
Definition: object.h:143
Definition: rect.h:45
Definition: xrc.h:45
Definition: renderentry.h:67
Definition: stateprovider.h:51