ManaPlus
Public Types | Public Member Functions | Static Public Member Functions | Data Fields | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes
CompoundSprite Class Reference

#include <compoundsprite.h>

Inheritance diagram for CompoundSprite:
Sprite ActorSprite Being FloorItem LocalPlayer

Public Types

typedef std::vector< Sprite * >::iterator SpriteIterator
 
typedef std::vector< Sprite * >::const_iterator SpriteConstIterator
 

Public Member Functions

 CompoundSprite ()
 
 ~CompoundSprite ()
 
bool reset ()
 
bool play (const std::string &action)
 
bool update (const int time)
 
void drawSimple (Graphics *const graphics, const int posX, const int posY) const
 
int getWidth () const
 
int getHeight () const
 
const ImagegetImage () const
 
bool setSpriteDirection (const SpriteDirection::Type direction)
 
int getNumberOfLayers () const
 
unsigned int getCurrentFrame () const
 
unsigned int getFrameCount () const
 
void addSprite (Sprite *const sprite)
 
void setSprite (const size_t layer, Sprite *const sprite)
 
void removeSprite (const int layer)
 
void clear ()
 
void ensureSize (const size_t layerCount)
 
void drawSprites (Graphics *const graphics, const int posX, const int posY) const
 
virtual void drawSpritesSDL (Graphics *const graphics, const int posX, const int posY) const
 
void setAlpha (float alpha)
 
bool updateNumber (const unsigned num)
 
int getLastTime () const
 
int getStartTime () const
 
- Public Member Functions inherited from Sprite
virtual ~Sprite ()
 
virtual void draw (Graphics *const graphics, const int posX, const int posY) const =0
 
virtual float getAlpha () const
 
virtual const void * getHash () const
 
virtual const void * getHash2 () const
 

Static Public Member Functions

static void setEnableDelay (bool b)
 

Data Fields

std::vector< Sprite * > mSprites
 

Protected Types

typedef std::list< CompoundItem * > ImagesCache
 

Protected Member Functions

void redraw () const
 
void updateImages () const
 
bool updateFromCache () const
 
void initCurrentCacheItem () const
 
- Protected Member Functions inherited from Sprite
 Sprite ()
 

Protected Attributes

ImagesCache imagesCache
 
CompoundItemmCacheItem
 
ImagemImage
 
ImagemAlphaImage
 
int mOffsetX
 
int mOffsetY
 
int mStartTime
 
int mLastTime
 
int mNextRedrawTime
 
bool mNeedsRedraw
 
bool mEnableAlphaFix
 
bool mDisableAdvBeingCaching
 
bool mDisableBeingCaching
 
- Protected Attributes inherited from Sprite
float mAlpha
 

Static Protected Attributes

static bool mEnableDelay = true
 

Detailed Description

Definition at line 37 of file compoundsprite.h.

Member Typedef Documentation

◆ ImagesCache

typedef std::list<CompoundItem*> CompoundSprite::ImagesCache
protected

Definition at line 122 of file compoundsprite.h.

◆ SpriteConstIterator

typedef std::vector<Sprite*>::const_iterator CompoundSprite::SpriteConstIterator

Definition at line 41 of file compoundsprite.h.

◆ SpriteIterator

typedef std::vector<Sprite*>::iterator CompoundSprite::SpriteIterator

Definition at line 40 of file compoundsprite.h.

Constructor & Destructor Documentation

◆ CompoundSprite()

CompoundSprite::CompoundSprite ( )

Definition at line 72 of file compoundsprite.cpp.

72  :
73  Sprite(),
74  mSprites(),
75  imagesCache(),
76  mCacheItem(nullptr),
77  mImage(nullptr),
78  mAlphaImage(nullptr),
79  mOffsetX(0),
80  mOffsetY(0),
81  mStartTime(0),
82  mLastTime(0),
83 #ifndef USE_SDL2
84  mNextRedrawTime(0),
85 #endif // USE_SDL2
86  mNeedsRedraw(false),
87  mEnableAlphaFix(config.getBoolValue("enableAlphaFix")),
88  mDisableAdvBeingCaching(config.getBoolValue("disableAdvBeingCaching")),
89  mDisableBeingCaching(config.getBoolValue("disableBeingCaching"))
90 {
91  mAlpha = 1.0F;
92 }
std::vector< Sprite * > mSprites
CompoundItem * mCacheItem
ImagesCache imagesCache
bool mDisableAdvBeingCaching
bool getBoolValue(const std::string &key) const
Sprite()
Definition: sprite.h:125
float mAlpha
Definition: sprite.h:130
Configuration config

References Sprite::mAlpha.

◆ ~CompoundSprite()

CompoundSprite::~CompoundSprite ( )

Definition at line 94 of file compoundsprite.cpp.

95 {
96  clear();
97  mImage = nullptr;
98  mAlphaImage = nullptr;
99 }

References clear(), mAlphaImage, and mImage.

Member Function Documentation

◆ addSprite()

void CompoundSprite::addSprite ( Sprite *const  sprite)

Definition at line 271 of file compoundsprite.cpp.

272 {
273  mSprites.push_back(sprite);
274  mNeedsRedraw = true;
275 }

References mNeedsRedraw, and mSprites.

Referenced by ActorSprite::setupSpriteDisplay().

◆ clear()

void CompoundSprite::clear ( )

Definition at line 298 of file compoundsprite.cpp.

299 {
300  // Skip if it won't change anything
301  if (!mSprites.empty())
302  {
304  mSprites.clear();
305  }
306  mNeedsRedraw = true;
308  imagesCache.clear();
310  mLastTime = 0;
311 }
#define delete2(var)
Definition: delete2.h:25
void delete_all(Container &c)
Definition: dtor.h:56

References delete2, delete_all(), imagesCache, mCacheItem, mLastTime, mNeedsRedraw, and mSprites.

Referenced by ActorSprite::setupSpriteDisplay(), and ~CompoundSprite().

◆ drawSimple()

void CompoundSprite::drawSimple ( Graphics *const  graphics,
const int  posX,
const int  posY 
) const

Definition at line 149 of file compoundsprite.cpp.

152 {
153  FUNC_BLOCK("CompoundSprite::draw", 1)
154  if (mNeedsRedraw)
155  updateImages();
156 
157  if (mSprites.empty()) // Nothing to draw
158  return;
159 
160  if (mAlpha == 1.0F && (mImage != nullptr))
161  {
162  graphics->drawImage(mImage, posX + mOffsetX, posY + mOffsetY);
163  }
164  else if ((mAlpha != 0.0F) && (mAlphaImage != nullptr))
165  {
166  mAlphaImage->setAlpha(mAlpha);
167  graphics->drawImage(mAlphaImage,
168  posX + mOffsetX, posY + mOffsetY);
169  }
170  else
171  {
172  CompoundSprite::drawSprites(graphics, posX, posY);
173  }
174 }
void updateImages() const
void drawSprites(Graphics *const graphics, const int posX, const int posY) const
virtual void drawImage(const Image *const image, int dstX, int dstY)=0
if(!vert) return
#define FUNC_BLOCK(name, id)
Definition: perfomance.h:81
std::string empty
Definition: podict.cpp:26

References Graphics::drawImage(), drawSprites(), FUNC_BLOCK, Sprite::mAlpha, mAlphaImage, mImage, mNeedsRedraw, mOffsetX, mOffsetY, mSprites, and updateImages().

Referenced by FloorItem::draw(), Being::drawElementalSpriteAt(), Being::drawHomunculusSpriteAt(), Being::drawMercenarySpriteAt(), Being::drawMonsterSpriteAt(), Being::drawOtherSpriteAt(), and Being::drawPortalSpriteAt().

◆ drawSprites()

void CompoundSprite::drawSprites ( Graphics *const  graphics,
const int  posX,
const int  posY 
) const

Definition at line 176 of file compoundsprite.cpp.

179 {
181  {
182  if (*it != nullptr)
183  {
184  (*it)->setAlpha(mAlpha);
185  (*it)->draw(graphics, posX, posY);
186  }
187  }
188 }
std::vector< Sprite * >::const_iterator SpriteConstIterator
#define FOR_EACH(type, iter, array)
Definition: foreach.h:25

References FOR_EACH, Sprite::mAlpha, and mSprites.

Referenced by drawSimple().

◆ drawSpritesSDL()

void CompoundSprite::drawSpritesSDL ( Graphics *const  graphics,
const int  posX,
const int  posY 
) const
virtual

Reimplemented in Being.

Definition at line 190 of file compoundsprite.cpp.

193 {
195  {
196  if (*it != nullptr)
197  (*it)->draw(graphics, posX, posY);
198  }
199 }

References FOR_EACH, and mSprites.

Referenced by redraw().

◆ ensureSize()

void CompoundSprite::ensureSize ( const size_t  layerCount)

Definition at line 313 of file compoundsprite.cpp.

314 {
315  // Skip if it won't change anything
316  if (mSprites.size() >= layerCount)
317  return;
318 
319 // resize(layerCount, nullptr);
320  mSprites.resize(layerCount);
321 }

References mSprites.

◆ getCurrentFrame()

unsigned int CompoundSprite::getCurrentFrame ( ) const
virtual

Returns the current frame number for the sprite.

Implements Sprite.

Definition at line 251 of file compoundsprite.cpp.

252 {
254  {
255  if (*it != nullptr)
256  return (*it)->getCurrentFrame();
257  }
258  return 0;
259 }

References FOR_EACH, and mSprites.

◆ getFrameCount()

unsigned int CompoundSprite::getFrameCount ( ) const
virtual

Returns the frame count for the sprite.

Implements Sprite.

Definition at line 261 of file compoundsprite.cpp.

262 {
264  {
265  if (*it != nullptr)
266  return (*it)->getFrameCount();
267  }
268  return 0;
269 }

References FOR_EACH, and mSprites.

Referenced by Being::logic().

◆ getHeight()

int CompoundSprite::getHeight ( ) const
virtual

Gets the height in pixels of the first sprite in the list.

Implements Sprite.

Definition at line 213 of file compoundsprite.cpp.

214 {
216  {
217  const Sprite *const base = *it;
218  if (base != nullptr)
219  return base->getHeight();
220  }
221 
222  return 0;
223 }
Definition: sprite.h:34

References anonymous_namespace{stringutils.cpp}::base, FOR_EACH, and mSprites.

Referenced by ActorSprite::getHeight(), and Being::getHeight().

◆ getImage()

const Image * CompoundSprite::getImage ( ) const
virtual

Returns a reference to the current image being drawn.

Implements Sprite.

Definition at line 225 of file compoundsprite.cpp.

226 {
227  return mImage;
228 }

References mImage.

◆ getLastTime()

int CompoundSprite::getLastTime ( ) const
inline

Definition at line 105 of file compoundsprite.h.

106  { return mLastTime; }

References mLastTime.

◆ getNumberOfLayers()

int CompoundSprite::getNumberOfLayers ( ) const

Definition at line 244 of file compoundsprite.cpp.

245 {
246  if ((mImage != nullptr) || (mAlphaImage != nullptr))
247  return 1;
248  return CAST_S32(mSprites.size());
249 }
#define CAST_S32
Definition: cast.h:30

References CAST_S32, mAlphaImage, mImage, and mSprites.

Referenced by Being::drawPlayerSprites(), Being::getNumberOfLayers(), and Being::searchSlotValue().

◆ getStartTime()

int CompoundSprite::getStartTime ( ) const
inline

Definition at line 108 of file compoundsprite.h.

109  { return mStartTime; }

References mStartTime.

◆ getWidth()

int CompoundSprite::getWidth ( ) const
virtual

Gets the width in pixels of the first sprite in the list.

Implements Sprite.

Definition at line 201 of file compoundsprite.cpp.

202 {
204  {
205  const Sprite *const base = *it;
206  if (base != nullptr)
207  return base->getWidth();
208  }
209 
210  return 0;
211 }

References anonymous_namespace{stringutils.cpp}::base, FOR_EACH, and mSprites.

Referenced by ActorSprite::getWidth(), and Being::getWidth().

◆ initCurrentCacheItem()

void CompoundSprite::initCurrentCacheItem ( ) const
protected

Definition at line 525 of file compoundsprite.cpp.

526 {
527  delete mCacheItem;
528  mCacheItem = new CompoundItem;
531 // mCacheItem->alpha = mAlpha;
532 
534  {
535  if (*it != nullptr)
536  mCacheItem->data.push_back((*it)->getHash());
537  else
538  mCacheItem->data.push_back(nullptr);
539  }
540 }
VectorPointers data
Definition: compounditem.h:42
Image * alphaImage
Definition: compounditem.h:44
Image * image
Definition: compounditem.h:43

References CompoundItem::alphaImage, CompoundItem::data, FOR_EACH, CompoundItem::image, mAlphaImage, mCacheItem, mImage, and mSprites.

Referenced by updateImages().

◆ play()

bool CompoundSprite::play ( const std::string &  action)
virtual

Plays an action using the current direction.

Returns
true if the sprite changed, false otherwise

Implements Sprite.

Definition at line 115 of file compoundsprite.cpp.

116 {
117  bool ret = false;
118  bool ret2 = true;
120  {
121  if (*it != nullptr)
122  {
123  const bool tmpVal = (*it)->play(action);
124  ret |= tmpVal;
125  ret2 &= tmpVal;
126  }
127  }
128  mNeedsRedraw |= ret;
129  if (ret2)
130  mLastTime = 0;
131  return ret;
132 }
std::vector< Sprite * >::iterator SpriteIterator

References FOR_EACH, mLastTime, mNeedsRedraw, and mSprites.

◆ redraw()

void CompoundSprite::redraw ( ) const
protected

< Surface is in video memory

< Surface is in video memory

Definition at line 323 of file compoundsprite.cpp.

324 {
325 #ifndef USE_SDL2
326 
327 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
328  const uint32_t rmask = 0xff000000U;
329  const uint32_t gmask = 0x00ff0000U;
330  const uint32_t bmask = 0x0000ff00U;
331  const uint32_t amask = 0x000000ffU;
332 #else // SDL_BYTEORDER == SDL_BIG_ENDIAN
333  const uint32_t rmask = 0x000000ffU;
334  const uint32_t gmask = 0x0000ff00U;
335  const uint32_t bmask = 0x00ff0000U;
336  const uint32_t amask = 0xff000000U;
337 #endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
338 
339  SDL_Surface *const surface = MSDL_CreateRGBSurface(SDL_HWSURFACE,
340  BUFFER_WIDTH, BUFFER_HEIGHT, 32, rmask, gmask, bmask, amask);
341 
342  if (surface == nullptr)
343  return;
344 
345  SurfaceGraphics *graphics = new SurfaceGraphics;
346  graphics->setBlitMode(BlitMode::BLIT_GFX);
347  graphics->setTarget(surface);
348  graphics->beginDraw();
349 
350  int tileX = mapTileSize / 2;
351  int tileY = mapTileSize;
352 
353  const Game *const game = Game::instance();
354  if (game != nullptr)
355  {
356  const Map *const map = game->getCurrentMap();
357  if (map != nullptr)
358  {
359  tileX = map->getTileWidth() / 2;
360  tileY = map->getTileWidth();
361  }
362  }
363 
364  const int posX = BUFFER_WIDTH / 2 - tileX;
365  const int posY = BUFFER_HEIGHT - tileY;
366 
367  mOffsetX = tileX - BUFFER_WIDTH / 2;
368  mOffsetY = tileY - BUFFER_HEIGHT;
369 
370  drawSpritesSDL(graphics, posX, posY);
371 
372  delete2(graphics)
373 
374  SDL_SetAlpha(surface, 0, SDL_ALPHA_OPAQUE);
375 
376  delete mAlphaImage;
377 
379  {
380  SDL_Surface *const surfaceA = MSDL_CreateRGBSurface(SDL_HWSURFACE,
381  BUFFER_WIDTH, BUFFER_HEIGHT, 32, rmask, gmask, bmask, amask);
382  SDL_BlitSurface(surface, nullptr, surfaceA, nullptr);
383  mAlphaImage = imageHelper->loadSurface(surfaceA);
384  MSDL_FreeSurface(surfaceA);
385  }
386  else
387  {
388  mAlphaImage = nullptr;
389  }
390 
391  delete mImage;
392  mImage = imageHelper->loadSurface(surface);
393  MSDL_FreeSurface(surface);
394 #endif // USE_SDL2
395 }
virtual void drawSpritesSDL(Graphics *const graphics, const int posX, const int posY) const
Definition: game.h:64
Map * getCurrentMap() const
Definition: game.h:107
static Game * instance()
Definition: game.h:82
virtual Image * loadSurface(SDL_Surface *const)
Definition: imagehelper.h:73
static bool mEnableAlpha
Definition: imagehelper.h:117
Definition: map.h:75
int getTileWidth() const
Definition: map.h:178
void setTarget(SDL_Surface *const target)
void setBlitMode(const BlitModeT mode)
static const int BUFFER_HEIGHT
static const int BUFFER_WIDTH
static const int mapTileSize
Definition: map.h:27
#define MSDL_CreateRGBSurface(flags, w, h, d, r, g, b, a)
Definition: debug.h:55
#define MSDL_FreeSurface(surface)
Definition: debug.h:54
ImageHelper * imageHelper
Definition: imagehelper.cpp:44
@ BLIT_GFX
Definition: blitmode.h:32

References SurfaceGraphics::beginDraw(), BlitMode::BLIT_GFX, BUFFER_HEIGHT, BUFFER_WIDTH, delete2, drawSpritesSDL(), Game::getCurrentMap(), Map::getTileWidth(), imageHelper, Game::instance(), ImageHelper::loadSurface(), mAlphaImage, mapTileSize, ImageHelper::mEnableAlpha, mImage, mOffsetX, mOffsetY, MSDL_CreateRGBSurface, MSDL_FreeSurface, SurfaceGraphics::setBlitMode(), and SurfaceGraphics::setTarget().

Referenced by updateImages().

◆ removeSprite()

void CompoundSprite::removeSprite ( const int  layer)

Definition at line 288 of file compoundsprite.cpp.

289 {
290  // Skip if it won't change anything
291  if (mSprites[layer] == nullptr)
292  return;
293 
294  delete2(mSprites[layer])
295  mNeedsRedraw = true;
296 }

References delete2, mNeedsRedraw, and mSprites.

◆ reset()

bool CompoundSprite::reset ( )
virtual

Resets the sprite.

Returns
true if the sprite changed, false otherwise

Implements Sprite.

Definition at line 101 of file compoundsprite.cpp.

102 {
103  bool ret = false;
105  {
106  if (*it != nullptr)
107  ret |= (*it)->reset();
108  }
109  if (ret)
110  mLastTime = 0;
111  mNeedsRedraw |= ret;
112  return ret;
113 }

References FOR_EACH, mLastTime, mNeedsRedraw, and mSprites.

Referenced by Ea::PlayerRecv::processPlayerWarp().

◆ setAlpha()

void CompoundSprite::setAlpha ( float  alpha)
virtual

Sets the alpha value of the animated sprite

Reimplemented from Sprite.

Definition at line 397 of file compoundsprite.cpp.

398 {
399  if (alpha != mAlpha)
400  {
401  if (mEnableAlphaFix &&
402 #ifdef USE_OPENGL
404 #endif // USE_OPENGL
405  mSprites.size() > 3U)
406  {
408  {
409  if (*it != nullptr)
410  (*it)->setAlpha(alpha);
411  }
412  }
413  mAlpha = alpha;
414  }
415 }
virtual RenderType useOpenGL() const
Definition: imagehelper.h:107
@ RENDER_SOFTWARE
Definition: rendertype.h:27

References FOR_EACH, imageHelper, Sprite::mAlpha, mEnableAlphaFix, mSprites, RENDER_SOFTWARE, and ImageHelper::useOpenGL().

Referenced by ActorSprite::setAlpha().

◆ setEnableDelay()

static void CompoundSprite::setEnableDelay ( bool  b)
inlinestatic

Definition at line 102 of file compoundsprite.h.

103  { mEnableDelay = b; }
static bool mEnableDelay

References mEnableDelay.

Referenced by Game::Game().

◆ setSprite()

void CompoundSprite::setSprite ( const size_t  layer,
Sprite *const  sprite 
)

Definition at line 277 of file compoundsprite.cpp.

278 {
279  // Skip if it won't change anything
280  if (mSprites[layer] == sprite)
281  return;
282 
283  delete mSprites[layer];
284  mSprites[layer] = sprite;
285  mNeedsRedraw = true;
286 }

References mNeedsRedraw, and mSprites.

Referenced by Being::setGender(), Being::setHairTempSprite(), Being::setSpriteCards(), Being::setSpriteColor(), Being::setSpriteColorId(), Being::setSpriteId(), and Being::setTempSprite().

◆ setSpriteDirection()

bool CompoundSprite::setSpriteDirection ( const SpriteDirection::Type  direction)
virtual

Sets the direction.

Returns
true if the sprite changed, false otherwise

Implements Sprite.

Definition at line 230 of file compoundsprite.cpp.

231 {
232  bool ret = false;
234  {
235  if (*it != nullptr)
236  ret |= (*it)->setSpriteDirection(direction);
237  }
238  if (ret)
239  mLastTime = 0;
240  mNeedsRedraw |= ret;
241  return ret;
242 }

References FOR_EACH, mLastTime, mNeedsRedraw, and mSprites.

Referenced by Being::setDirection().

◆ update()

bool CompoundSprite::update ( const int  time)
virtual

Inform the animation of the passed time so that it can output the correct animation frame.

Returns
true if the sprite changed, false otherwise

Implements Sprite.

Definition at line 134 of file compoundsprite.cpp.

135 {
136  bool ret = false;
137  if (A_UNLIKELY(mLastTime == 0))
138  mStartTime = time;
139  mLastTime = time;
141  {
142  if (*it != nullptr)
143  ret |= (*it)->update(time);
144  }
145  mNeedsRedraw |= ret;
146  return ret;
147 }
#define A_UNLIKELY(x)
Definition: likely.h:30

References A_UNLIKELY, FOR_EACH, mLastTime, mNeedsRedraw, mSprites, and mStartTime.

Referenced by ActorSprite::logic().

◆ updateFromCache()

bool CompoundSprite::updateFromCache ( ) const
protected

Definition at line 456 of file compoundsprite.cpp.

457 {
458 #ifndef USE_SDL2
459 // static int hits = 0;
460 // static int miss = 0;
461 
462  if ((mCacheItem != nullptr) && (mCacheItem->image != nullptr))
463  {
464  imagesCache.push_front(mCacheItem);
465  mCacheItem = nullptr;
466  if (imagesCache.size() > cache_max_size)
467  {
468  for (unsigned f = 0; f < cache_clean_part; f ++)
469  {
470  CompoundItem *item = imagesCache.back();
471  imagesCache.pop_back();
472  delete item;
473  }
474  }
475  }
476 
477 // logger->log("cache size: %d, hit %d, miss %d",
478 // (int)imagesCache.size(), hits, miss);
479 
480  const size_t sz = mSprites.size();
481  FOR_EACH (ImagesCache::iterator, it, imagesCache)
482  {
483  CompoundItem *const ic = *it;
484  if ((ic != nullptr) && ic->data.size() == sz)
485  {
486  bool fail(false);
487  VectorPointers::const_iterator it2 = ic->data.begin();
488  const VectorPointers::const_iterator it2_end = ic->data.end();
489 
490  for (SpriteConstIterator it1 = mSprites.begin(),
491  it1_end = mSprites.end();
492  it1 != it1_end && it2 != it2_end;
493  ++ it1, ++ it2)
494  {
495  const void *ptr1 = nullptr;
496  const void *ptr2 = nullptr;
497  if (*it1 != nullptr)
498  ptr1 = (*it1)->getHash();
499  if (*it2 != nullptr)
500  ptr2 = *it2;
501  if (ptr1 != ptr2)
502  {
503  fail = true;
504  break;
505  }
506  }
507  if (!fail)
508  {
509 // hits ++;
510  mImage = (*it)->image;
511  mAlphaImage = (*it)->alphaImage;
512  imagesCache.erase(it);
513  mCacheItem = ic;
514  return true;
515  }
516  }
517  }
518  mImage = nullptr;
519  mAlphaImage = nullptr;
520 // miss++;
521 #endif // USE_SDL2
522  return false;
523 }
static const unsigned cache_clean_part
static const unsigned cache_max_size

References cache_clean_part, cache_max_size, CompoundItem::data, FOR_EACH, CompoundItem::image, imagesCache, mAlphaImage, mCacheItem, mImage, and mSprites.

Referenced by updateImages().

◆ updateImages()

void CompoundSprite::updateImages ( ) const
protected

Definition at line 417 of file compoundsprite.cpp.

418 {
419 #ifndef USE_SDL2
420 #ifdef USE_OPENGL
422  return;
423 #endif // USE_OPENGL
424 
425  if (mEnableDelay)
426  {
428  return;
430  }
431  mNeedsRedraw = false;
432 
434  {
435  if (mSprites.size() <= 3U)
436  return;
437 
439  {
440  if (updateFromCache())
441  return;
442 
443  redraw();
444 
445  if (mImage != nullptr)
447  }
448  else
449  {
450  redraw();
451  }
452  }
453 #endif // USE_SDL2
454 }
void redraw() const
bool updateFromCache() const
void initCurrentCacheItem() const
volatile int tick_time
Definition: timer.cpp:53
int get_elapsed_time1(const int startTime)
Definition: timer.cpp:105

References get_elapsed_time1(), imageHelper, initCurrentCacheItem(), mDisableAdvBeingCaching, mDisableBeingCaching, mEnableDelay, mImage, mNeedsRedraw, mNextRedrawTime, mSprites, redraw(), RENDER_SOFTWARE, tick_time, updateFromCache(), and ImageHelper::useOpenGL().

Referenced by Being::drawCompound(), and drawSimple().

◆ updateNumber()

bool CompoundSprite::updateNumber ( const unsigned  num)
virtual

Implements Sprite.

Definition at line 542 of file compoundsprite.cpp.

543 {
544  bool res(false);
546  {
547  if (*it != nullptr)
548  {
549  if ((*it)->updateNumber(num))
550  res = true;
551  }
552  }
553  return res;
554 }

References FOR_EACH, and mSprites.

Referenced by Being::updatePercentHP().

Field Documentation

◆ imagesCache

ImagesCache CompoundSprite::imagesCache
mutableprotected

Definition at line 123 of file compoundsprite.h.

Referenced by clear(), and updateFromCache().

◆ mAlphaImage

Image* CompoundSprite::mAlphaImage
mutableprotected

◆ mCacheItem

CompoundItem* CompoundSprite::mCacheItem
mutableprotected

Definition at line 124 of file compoundsprite.h.

Referenced by clear(), initCurrentCacheItem(), and updateFromCache().

◆ mDisableAdvBeingCaching

bool CompoundSprite::mDisableAdvBeingCaching
protected

Definition at line 140 of file compoundsprite.h.

Referenced by updateImages().

◆ mDisableBeingCaching

bool CompoundSprite::mDisableBeingCaching
protected

Definition at line 141 of file compoundsprite.h.

Referenced by updateImages().

◆ mEnableAlphaFix

bool CompoundSprite::mEnableAlphaFix
protected

Definition at line 139 of file compoundsprite.h.

Referenced by setAlpha().

◆ mEnableDelay

bool CompoundSprite::mEnableDelay = true
staticprotected

Definition at line 137 of file compoundsprite.h.

Referenced by setEnableDelay(), and updateImages().

◆ mImage

Image* CompoundSprite::mImage
mutableprotected

◆ mLastTime

int CompoundSprite::mLastTime
protected

Definition at line 132 of file compoundsprite.h.

Referenced by clear(), getLastTime(), play(), reset(), setSpriteDirection(), and update().

◆ mNeedsRedraw

bool CompoundSprite::mNeedsRedraw
mutableprotected

◆ mNextRedrawTime

int CompoundSprite::mNextRedrawTime
mutableprotected

Definition at line 134 of file compoundsprite.h.

Referenced by updateImages().

◆ mOffsetX

int CompoundSprite::mOffsetX
mutableprotected

Definition at line 129 of file compoundsprite.h.

Referenced by Being::drawCompound(), drawSimple(), and redraw().

◆ mOffsetY

int CompoundSprite::mOffsetY
mutableprotected

Definition at line 130 of file compoundsprite.h.

Referenced by Being::drawCompound(), drawSimple(), and redraw().

◆ mSprites

std::vector<Sprite*> CompoundSprite::mSprites

◆ mStartTime

int CompoundSprite::mStartTime
protected

Definition at line 131 of file compoundsprite.h.

Referenced by getStartTime(), and update().


The documentation for this class was generated from the following files: