ManaPlus
maplayer.h
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2004-2009 The Mana World Development Team
4  * Copyright (C) 2009-2010 The Mana Developers
5  * Copyright (C) 2011-2018 The ManaPlus Developers
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_MAP_MAPLAYER_H
24 #define RESOURCES_MAP_MAPLAYER_H
25 
27 
29 
30 #include "being/actor.h"
31 
33 
34 #include "utils/vector.h"
35 
36 #include "resources/map/tileinfo.h"
37 
38 class Image;
39 class MapRowVertexes;
40 class SpecialLayer;
41 
42 struct MetaTile;
43 
49 {
50  public:
51  friend class Map;
52 
58  MapLayer(const std::string &name,
59  const int x,
60  const int y,
61  const int width,
62  const int height,
63  const bool isFringeLayer,
64  const int mask,
65  const int tileCondition);
66 
68 
69 
73 
77  void setTile(const int x,
78  const int y,
79  Image *restrict const img) restrict;
80 
84  void setTile(const int index,
85  Image *restrict const img) restrict
86  { mTiles[index].image = img; }
87 
96  void draw(Graphics *restrict const graphics,
97  int startX,
98  int startY,
99  int endX,
100  int endY,
101  const int scrollX,
102  const int scrollY) const restrict A_NONNULL(2);
103 
104  void drawSDL(Graphics *restrict const graphics) const restrict2
105  A_NONNULL(2);
106 
107 #ifdef USE_OPENGL
108  void drawOGL(Graphics *restrict const graphics) const restrict2
109  A_NONNULL(2);
110 
111  void updateOGL(Graphics *restrict const graphics,
112  int startX,
113  int startY,
114  int endX,
115  int endY,
116  const int scrollX,
117  const int scrollY) restrict2 A_NONNULL(2);
118 #endif // USE_OPENGL
119 
120  void updateSDL(const Graphics *restrict const graphics,
121  int startX,
122  int startY,
123  int endX,
124  int endY,
125  const int scrollX,
126  const int scrollY) restrict2 A_NONNULL(2);
127 
128  void drawFringe(Graphics *restrict const graphics,
129  int startX,
130  int startY,
131  int endX,
132  int endY,
133  const int scrollX,
134  const int scrollY,
135  const Actors &actors) const restrict A_NONNULL(2);
136 
138  { return mIsFringeLayer; }
139 
141  { mSpecialLayer = val; }
142 
144  { mTempLayer = val; }
145 
147  { return mWidth; }
148 
150  { return mHeight; }
151 
152  void optionChanged(const std::string &restrict value)
153  restrict override final;
154 
155  void setDrawLayerFlags(const MapTypeT &restrict n) restrict;
156 
157  void setActorsFix(const int y) restrict
158  { mActorsFix = y; }
159 
160  int calcMemoryLocal() const override final;
161 
162  int calcMemoryChilds(const int level) const override final;
163 
164  std::string getCounterName() const override final
165  { return mName; }
166 
167 #ifdef UNITTESTS
168  TileInfo *getTiles() const
169  {
170  return mTiles;
171  }
172 
173  void setTileCondition(const int c)
174  {
175  mTileCondition = c;
176  }
177 #endif // UNITTESTS
178 
179 #ifndef UNITTESTS
180  protected:
181 #endif // UNITTESTS
182  static int getTileDrawWidth(const TileInfo *restrict img,
183  const int endX,
184  int &restrict width,
185  int &restrict nextTile)
187 
188  static int getEmptyTileDrawWidth(const TileInfo *restrict img,
189  const int endX,
190  int &restrict nextTile)
192 
193  void updateConditionTiles(const MetaTile *restrict const metaTiles,
194  const int width,
195  const int height) restrict A_NONNULL(2);
196 
197  void updateCache(const int width,
198  const int height) restrict;
199 
200  void drawSpecialLayer(Graphics *const graphics,
201  const int y,
202  const int startX,
203  const int endX,
204  const int scrollX,
205  const int scrollY) const restrict;
206 
207  private:
208  const int mX;
209  const int mY;
210  const int mPixelX;
211  const int mPixelY;
212  const int mWidth;
213  const int mHeight;
214  TileInfo *restrict const mTiles;
216  const SpecialLayer *restrict mSpecialLayer;
217  const SpecialLayer *restrict mTempLayer;
218  const std::string mName;
219  typedef STD_VECTOR<MapRowVertexes*> MapRows;
220  MapRows mTempRows;
221  int mMask;
224  const bool mIsFringeLayer;
227 };
228 
229 #endif // RESOURCES_MAP_MAPLAYER_H
#define A_DELETE_COPY(func)
Definition: localconsts.h:52
const bool mIsFringeLayer
Definition: maplayer.h:224
std::string getCounterName() const
Definition: maplayer.h:164
MapType ::T MapTypeT
Definition: maptype.h:38
static int getEmptyTileDrawWidth(const TileInfo *img, const int endX, int &nextTile)
Definition: maplayer.cpp:748
int getHeight() const
Definition: maplayer.h:149
const int mY
Definition: maplayer.h:209
Image * image
Definition: tileinfo.h:42
int calcMemoryLocal() const
Definition: maplayer.cpp:838
TileInfo *const mTiles
Definition: maplayer.h:214
int getWidth() const
Definition: maplayer.h:146
const SpecialLayer * mSpecialLayer
Definition: maplayer.h:216
#define A_WARN_UNUSED
Definition: localconsts.h:152
#define final
Definition: localconsts.h:45
bool mSpecialFlag
Definition: maplayer.h:226
const int mX
Definition: maplayer.h:208
const int mPixelX
Definition: maplayer.h:210
std::list< Actor * > Actors
Definition: actor.h:35
const SpecialLayer * mTempLayer
Definition: maplayer.h:217
void setDrawLayerFlags(const MapTypeT &n)
Definition: maplayer.cpp:768
#define A_NONNULL(...)
Definition: localconsts.h:159
std::vector< MapRowVertexes * > MapRows
Definition: maplayer.h:219
void drawFringe(Graphics *const graphics, int startX, int startY, int endX, int endY, const int scrollX, const int scrollY, const Actors &actors) const
Definition: maplayer.cpp:431
~MapLayer()
Definition: maplayer.cpp:81
bool mHighlightAttackRange
Definition: maplayer.h:225
void drawSpecialLayer(Graphics *const graphics, const int y, const int startX, const int endX, const int scrollX, const int scrollY) const
Definition: maplayer.cpp:376
void setActorsFix(const int y)
Definition: maplayer.h:157
void setTile(const int x, const int y, Image *const img)
Definition: maplayer.cpp:99
int mActorsFix
Definition: maplayer.h:223
const std::string mName
Definition: maplayer.h:218
void setTempLayer(const SpecialLayer *const val)
Definition: maplayer.h:143
const int mPixelY
Definition: maplayer.h:211
int mTileCondition
Definition: maplayer.h:222
void updateOGL(Graphics *const graphics, int startX, int startY, int endX, int endY, const int scrollX, const int scrollY)
Definition: maplayer.cpp:271
MapTypeT mDrawLayerFlags
Definition: maplayer.h:215
Definition: map.h:71
static int getTileDrawWidth(const TileInfo *img, const int endX, int &width, int &nextTile)
Definition: maplayer.cpp:705
void setSpecialLayer(const SpecialLayer *const val)
Definition: maplayer.h:140
void drawSDL(Graphics *const graphics) const
Definition: maplayer.cpp:185
Definition: image.h:61
const int mWidth
Definition: maplayer.h:212
void updateSDL(const Graphics *const graphics, int startX, int startY, int endX, int endY, const int scrollX, const int scrollY)
Definition: maplayer.cpp:206
MapLayer(const std::string &name, const int x, const int y, const int width, const int height, const bool isFringeLayer, const int mask, const int tileCondition)
Definition: maplayer.cpp:49
#define restrict
Definition: localconsts.h:156
void optionChanged(const std::string &value)
Definition: maplayer.cpp:90
#define override
Definition: localconsts.h:46
void draw(Graphics *const graphics, int startX, int startY, int endX, int endY, const int scrollX, const int scrollY) const
Definition: maplayer.cpp:106
const int mHeight
Definition: maplayer.h:213
void updateCache(const int width, const int height)
Definition: maplayer.cpp:804
void drawOGL(Graphics *const graphics) const
Definition: maplayer.cpp:355
void updateConditionTiles(const MetaTile *const metaTiles, const int width, const int height)
Definition: maplayer.cpp:776
int mMask
Definition: maplayer.h:221
int calcMemoryChilds(const int level) const
Definition: maplayer.cpp:845
#define noexcept2
Definition: localconsts.h:49
#define restrict2
Definition: localconsts.h:157
bool isFringeLayer() const
Definition: maplayer.h:137
MapRows mTempRows
Definition: maplayer.h:220