From c676f4b880ed0abd644085e587e98e3f6ba1c16b Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 13 Jul 2016 18:04:01 +0300 Subject: Show particles amount in being popup. --- src/being/actorsprite.h | 6 ++++++ src/gui/popups/beingpopup.cpp | 8 +++++++- src/particle/particlelist.cpp | 7 ++++++- src/particle/particlelist.h | 4 ++++ src/particle/particlevector.h | 3 +++ 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/being/actorsprite.h b/src/being/actorsprite.h index 1a32ceaf9..6f5c020c2 100644 --- a/src/being/actorsprite.h +++ b/src/being/actorsprite.h @@ -184,6 +184,12 @@ class ActorSprite notfinal : public CompoundSprite, public Actor virtual void stopCast(const bool b A_UNUSED) { } + size_t getParticlesCount() const + { + return mStatusParticleEffects.size() + + mChildParticleEffects.size(); + } + protected: /** * A status effect block is a 16 bit mask of status effects. We assign diff --git a/src/gui/popups/beingpopup.cpp b/src/gui/popups/beingpopup.cpp index 8fed0d4b6..396f323a7 100644 --- a/src/gui/popups/beingpopup.cpp +++ b/src/gui/popups/beingpopup.cpp @@ -72,7 +72,7 @@ void BeingPopup::postInit() void BeingPopup::addLabels(const int fontHeight) { - for (int f = 0; f < 8; f ++) + for (int f = 0; f < 9; f ++) { Label *const label = new Label(this, "A"); label->setPosition(0, fontHeight * (f + 1)); @@ -257,6 +257,12 @@ void BeingPopup::show(const int x, const int y, Being *const b) } #endif } + ptr = mLabels[num]; + // TRANSLATORS: being popup label + ptr->setCaption(strprintf(_("Particles: %u"), + CAST_U32(b->getParticlesCount()))); + ptr->adjustSize(); + num ++; const size_t sz = mLabels.size(); for (size_t f = num; f < sz; f ++) diff --git a/src/particle/particlelist.cpp b/src/particle/particlelist.cpp index 5e3dc4b5b..0d2a2f195 100644 --- a/src/particle/particlelist.cpp +++ b/src/particle/particlelist.cpp @@ -32,7 +32,8 @@ typedef std::list::const_iterator ParticleListCIter; ParticleList::ParticleList(ParticleContainer *const parent, const bool delParent) : ParticleContainer(parent, delParent), - mElements() + mElements(), + mSize(0U) {} ParticleList::~ParticleList() @@ -46,6 +47,7 @@ void ParticleList::addLocally(Particle *const particle) // The effect may not die without the beings permission or we segfault particle->disableAutoDelete(); mElements.push_back(particle); + mSize ++; } } @@ -60,6 +62,7 @@ void ParticleList::removeLocally(const Particle *const particle) p->kill(); p->prepareToDie(); it = mElements.erase(it); + mSize --; } else { @@ -74,6 +77,7 @@ void ParticleList::clearLocally() (*it)->kill(); mElements.clear(); + mSize = 0U; } void ParticleList::moveTo(const float x, const float y) @@ -89,6 +93,7 @@ void ParticleList::moveTo(const float x, const float y) { p->kill(); it = mElements.erase(it); + mSize --; } else { diff --git a/src/particle/particlelist.h b/src/particle/particlelist.h index 3da542b37..6d27903cd 100644 --- a/src/particle/particlelist.h +++ b/src/particle/particlelist.h @@ -58,8 +58,12 @@ class ParticleList final : public ParticleContainer void moveTo(const float x, const float y) override final; + size_t size() const + { return mSize; } + protected: std::list mElements; /**< Contained particle effects */ + size_t mSize; }; #endif // PARTICLE_PARTICLELIST_H diff --git a/src/particle/particlevector.h b/src/particle/particlevector.h index 8804991be..68589e4e1 100644 --- a/src/particle/particlevector.h +++ b/src/particle/particlevector.h @@ -59,6 +59,9 @@ class ParticleVector final : public ParticleContainer void moveTo(const float x, const float y) override final; + size_t size() const + { return mIndexedElements.size(); } + protected: std::vector mIndexedElements; }; -- cgit v1.2.3-60-g2f50