ScummVM API documentation
screen.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 SCREEN_H
23#define SCREEN_H
24
25#include "agds/screenLoadingType.h"
26#include "common/array.h"
27#include "common/ptr.h"
28#include "common/rect.h"
29#include "common/scummsys.h"
30#include "common/str.h"
31
32namespace Graphics {
33struct Surface;
34}
35
36namespace AGDS {
37
38class AGDSEngine;
39class Animation;
40using AnimationPtr = Common::SharedPtr<Animation>;
41class Object;
42using ObjectPtr = Common::SharedPtr<Object>;
43struct Region;
44using RegionPtr = Common::SharedPtr<Region>;
45struct Patch;
46using PatchPtr = Common::SharedPtr<Patch>;
47
49 AnimationPtr animation;
50 bool removed = false;
51 ScreenAnimationDesc(const AnimationPtr &a) : animation(a) {
52 }
53};
54
55class Screen {
56 static int ObjectZCompare(const ObjectPtr &a, const ObjectPtr &b);
57 static int AnimationZCompare(const ScreenAnimationDesc &a, const ScreenAnimationDesc &b);
58
61
62 AGDSEngine *_engine;
63 ObjectPtr _object;
64 Object *_background;
65 Common::Point _scroll;
66 Common::String _name;
67 ScreenLoadingType _loadingType;
68 Common::String _previousScreen;
69 Children _children;
70 Animations _animations;
71 RegionPtr _region;
72 bool _applyingPatch;
73 int _characterNear, _characterFar;
74 int _fade;
75
76public:
77 struct KeyHandler {
78 ObjectPtr object;
79 uint ip;
80
81 KeyHandler() : object(), ip() {}
82 KeyHandler(Object *o, uint i) : object(o), ip(i) {}
83 };
84
85 Screen(AGDSEngine *engine, ObjectPtr object, ScreenLoadingType loadingType, const Common::String &prevScreen);
86 ~Screen();
87
88 int fade() const {
89 return _fade;
90 }
91
92 void fade(int fade) {
93 _fade = fade;
94 }
95
96 void setCharacterNearFar(int near, int far) {
97 _characterNear = near;
98 _characterFar = far;
99 }
100
101 float getZScale(int y) const;
102
103 bool applyingPatch() const {
104 return _applyingPatch;
105 }
106
107 ObjectPtr getObject() {
108 return _object;
109 }
110
111 const Common::String &getName() const {
112 return _name;
113 }
114
115 const Common::String &getPreviousScreenName() const {
116 return _previousScreen;
117 }
118
119 ScreenLoadingType loadingType() const {
120 return _loadingType;
121 }
122
123 const RegionPtr &region() const {
124 return _region;
125 }
126
127 void region(RegionPtr region) {
128 _region = region;
129 }
130
131 const Children &children() const {
132 return _children;
133 }
134
135 const Animations &animations() const {
136 return _animations;
137 }
138 void scrollTo(Common::Point scroll);
139 Common::Point scrollPosition() const {
140 return _scroll;
141 }
142
143 bool add(ObjectPtr object);
144 void add(AnimationPtr animation);
145 bool remove(const AnimationPtr &animation);
146
147 void update(const ObjectPtr &object) {
148 bool found = remove(object);
149 if (found)
150 add(object);
151 }
152
153 void setBackground(Object *object) {
154 _background = object;
155 }
156
157 bool remove(const Common::String &name);
158 bool remove(const ObjectPtr &object);
159
160 void tick();
161 void paint(Graphics::Surface &backbuffer) const;
163 ObjectPtr find(const Common::String &name);
164 KeyHandler findKeyHandler(const Common::String &keyName);
165 AnimationPtr findAnimationByPhaseVar(const Common::String &phaseVar);
166
167 void load(const PatchPtr &patch);
168 void save(const PatchPtr &patch);
169};
170
171} // End of namespace AGDS
172
173#endif /* AGDS_SCREEN_H */
Definition: agds.h:82
Definition: object.h:46
Definition: screen.h:55
Definition: str.h:59
Definition: formatinfo.h:28
Definition: screen.h:77
Definition: screen.h:48
Definition: rect.h:144
Definition: surface.h:67