ScummVM API documentation
room.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 TWP_ROOM_H
23 #define TWP_ROOM_H
24 
25 #include "common/array.h"
26 #include "common/rect.h"
27 #include "common/stream.h"
28 #include "common/ptr.h"
29 #include "math/vector2d.h"
30 #include "twp/squirrel/squirrel.h"
31 #include "twp/font.h"
32 #include "twp/motor.h"
33 #include "twp/scenegraph.h"
34 #include "twp/graph.h"
35 
36 #define FULLSCREENCLOSEUP 1
37 #define FULLSCREENROOM 2
38 
39 namespace Twp {
40 
41 enum class RoomEffect {
42  None = 0,
43  Sepia = 1,
44  Ega = 2,
45  Vhs = 3,
46  Ghost = 4,
47  BlackAndWhite = 5
48 };
49 
50 class Node;
51 class Object;
52 
53 class Layer {
54 public:
55  Layer(const Common::String &name, const Math::Vector2d &parallax, int zsort);
56  Layer(const Common::StringArray &names, const Math::Vector2d &parallax, int zsort);
57 
58 public:
61  Math::Vector2d _parallax;
62  int _zsort = 0;
64 };
65 
66 struct ScalingValue {
67  float scale;
68  int y;
69 };
70 
71 struct Scaling {
73  Common::String trigger;
74 
75  float getScaling(float yPos);
76 };
77 
78 struct Light {
79  Color color;
80  Math::Vector2d pos;
81  float brightness = 0.f; // light brightness 1.0f...100.f
82  float coneDirection = 0.f; // cone direction 0...360.f
83  float coneAngle = 0.f; // cone angle 0...360.f
84  float coneFalloff = 0.f; // cone falloff 0.f...1.0f
85  float cutOffRadius = 0.f; // cutoff radius
86  float halfRadius = 0.f; // cone half radius 0.0f...1.0f
87  bool on = false;
88  int id = 0;
89 };
90 
91 struct Lights {
92  int _numLights = 0; // Number of lights
93  Light _lights[50];
94  Color _ambientLight; // Ambient light color
95 };
96 
99 
101  Scaling *_scaling = nullptr;
102 };
103 
104 class PathFinder;
105 class Scene;
106 class Room {
107 public:
108  Room(const Common::String &name, HSQOBJECT &table);
109  ~Room();
110 
111  static void load(Common::SharedPtr<Room> room, Common::SeekableReadStream &s);
112 
113  void update(float elapsedSec);
114 
115  Common::SharedPtr<Object> createObject(const Common::String &sheet, const Common::Array<Common::String> &frames);
116  Common::SharedPtr<Object> createTextObject(const Common::String &fontName, const Common::String &text, TextHAlignment hAlign = thLeft, TextVAlignment vAlign = tvCenter, float maxWidth = 0.0f);
117 
118  Math::Vector2d getScreenSize();
119 
120  Common::SharedPtr<Layer> layer(int zsort);
121  Common::SharedPtr<Object> getObj(const Common::String &key);
122 
123  Light *createLight(const Color &color, const Math::Vector2d &pos);
124  float getScaling(float yPos);
125  void objectParallaxLayer(Common::SharedPtr<Object> obj, int zsort);
126  void setOverlay(const Color &color);
127  Color getOverlay() const;
128 
129  void walkboxHidden(const Common::String &name, bool hidden);
130  Common::Array<Math::Vector2d> calculatePath(const Math::Vector2d &frm, const Math::Vector2d &to);
131 
132 public:
133  Common::String _name; // Name of the room
134  Common::String _sheet; // Name of the spritesheet to use
135  Math::Vector2d _roomSize; // Size of the room
136  int _fullscreen = 0; // Indicates if a room is a closeup room (fullscreen=1) or not (fullscreen=2), just a guess
137  int _height = 0; // Height of the room (what else ?)
138  Common::Array<Common::SharedPtr<Layer> > _layers; // Parallax layers of a room
139  Common::Array<Walkbox> _walkboxes; // Represents the areas where an actor can or cannot walk
140  Common::Array<Walkbox> _mergedPolygon;
141  Common::Array<Scaling> _scalings; // Defines the scaling of the actor in the room
142  Scaling _scaling; // Defines the scaling of the actor in the room
143  HSQOBJECT _table; // Squirrel table representing this room
144  bool _entering = false; // Indicates whether or not an actor is entering this room
145  Lights _lights; // Lights of the room
146  Common::Array<Common::SharedPtr<Object> > _triggers; // Triggers currently enabled in the room
147  Common::Array<ScalingTrigger> _scalingTriggers; // Scaling Triggers of the room
148  bool _pseudo = false;
150  OverlayNode _overlayNode; // Represents an overlay
151  RoomEffect _effect = RoomEffect::None;
152  Common::SharedPtr<Motor> _overlayTo;
153  Common::SharedPtr<Motor> _rotateTo;
154  float _rotation = 0.f;
155  PathFinder _pathFinder;
156 };
157 
158 } // namespace Twp
159 
160 #endif
Definition: room.h:53
Definition: scenegraph.h:281
Definition: room.h:91
Definition: str.h:59
Definition: graph.h:111
Definition: room.h:71
Definition: stream.h:745
Definition: gfx.h:35
Graphics::Surface * scale(const Graphics::Surface &srcImage, int xSize, int ySize)
Definition: scenegraph.h:217
Definition: squirrel.h:153
Definition: room.h:106
Definition: room.h:97
Definition: room.h:78
Definition: ptr.h:159
Definition: room.h:66
Definition: lobject.h:332
Definition: achievements_tables.h:27