1 |
|
|
/* |
2 |
|
|
* The ManaPlus Client |
3 |
|
|
* Copyright (C) 2009-2010 The Mana Developers |
4 |
|
|
* Copyright (C) 2011-2019 The ManaPlus Developers |
5 |
|
|
* Copyright (C) 2019-2021 Andrei Karas |
6 |
|
|
* |
7 |
|
|
* This file is part of The ManaPlus Client. |
8 |
|
|
* |
9 |
|
|
* This program is free software; you can redistribute it and/or modify |
10 |
|
|
* it under the terms of the GNU General Public License as published by |
11 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
12 |
|
|
* any later version. |
13 |
|
|
* |
14 |
|
|
* This program is distributed in the hope that it will be useful, |
15 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 |
|
|
* GNU General Public License for more details. |
18 |
|
|
* |
19 |
|
|
* You should have received a copy of the GNU General Public License |
20 |
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
21 |
|
|
*/ |
22 |
|
|
|
23 |
|
|
#ifndef RESOURCES_AMBIENTLAYER_H |
24 |
|
|
#define RESOURCES_AMBIENTLAYER_H |
25 |
|
|
|
26 |
|
|
#include "resources/memorycounter.h" |
27 |
|
|
|
28 |
|
|
#include "localconsts.h" |
29 |
|
|
|
30 |
|
|
class Graphics; |
31 |
|
|
class Image; |
32 |
|
|
class Map; |
33 |
|
|
|
34 |
|
|
class AmbientLayer final : public MemoryCounter |
35 |
|
|
{ |
36 |
|
|
public: |
37 |
|
|
friend class Map; |
38 |
|
|
|
39 |
|
|
/** |
40 |
|
|
* Constructor. |
41 |
|
|
* |
42 |
|
|
* @param img the image this overlay displays |
43 |
|
|
* @param parallax scroll factor based on camera position |
44 |
|
|
* @param speedX scrolling speed in x-direction |
45 |
|
|
* @param speedY scrolling speed in y-direction |
46 |
|
|
* @param keepRatio rescale the image to keep |
47 |
|
|
* the same ratio than in 800x600 resolution mode. |
48 |
|
|
*/ |
49 |
|
|
AmbientLayer(const std::string &name, |
50 |
|
|
Image *const img, |
51 |
|
|
const float parallax, |
52 |
|
|
const float parallaxY, |
53 |
|
|
const float posX, |
54 |
|
|
const float posY, |
55 |
|
|
const float speedX, |
56 |
|
|
const float speedY, |
57 |
|
|
const bool keepRatio, |
58 |
|
|
const int mask); |
59 |
|
|
|
60 |
|
|
A_DELETE_COPY(AmbientLayer) |
61 |
|
|
|
62 |
|
|
~AmbientLayer() override final; |
63 |
|
|
|
64 |
|
|
void update(const int timePassed, |
65 |
|
|
const float dx, |
66 |
|
|
const float dy); |
67 |
|
|
|
68 |
|
|
void draw(Graphics *const graphics, |
69 |
|
|
const int x, |
70 |
|
|
const int y) const A_NONNULL(2); |
71 |
|
|
|
72 |
|
|
int calcMemoryLocal() const override; |
73 |
|
|
|
74 |
|
|
std::string getCounterName() const override final |
75 |
|
|
{ return mName; } |
76 |
|
|
|
77 |
|
|
private: |
78 |
|
|
const std::string mName; |
79 |
|
|
Image *mImage; |
80 |
|
|
float mParallaxX; |
81 |
|
|
float mParallaxY; |
82 |
|
|
float mPosX; /**< Current layer X position. */ |
83 |
|
|
float mPosY; /**< Current layer Y position. */ |
84 |
|
|
float mSpeedX; /**< Scrolling speed in X direction. */ |
85 |
|
|
float mSpeedY; /**< Scrolling speed in Y direction. */ |
86 |
|
|
int mMask; |
87 |
|
|
bool mKeepRatio; /**< Keep overlay ratio on every resolution */ |
88 |
|
|
}; |
89 |
|
|
|
90 |
|
|
#endif // RESOURCES_AMBIENTLAYER_H |