summaryrefslogtreecommitdiff
path: root/src/being
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-07-29 02:06:59 +0300
committerAndrei Karas <akaras@inbox.ru>2015-07-29 02:07:25 +0300
commitf612e40c96f370282971d3a5795da4fb8d99bea1 (patch)
treee8741515ff407b510f15477da39eb13c356467d6 /src/being
parent0de50d314ca7705024d1035802eaea2c43eb2848 (diff)
downloadmanaverse-f612e40c96f370282971d3a5795da4fb8d99bea1.tar.gz
manaverse-f612e40c96f370282971d3a5795da4fb8d99bea1.tar.bz2
manaverse-f612e40c96f370282971d3a5795da4fb8d99bea1.tar.xz
manaverse-f612e40c96f370282971d3a5795da4fb8d99bea1.zip
Add bages db. Add badges support for parties.
Diffstat (limited to 'src/being')
-rw-r--r--src/being/being.cpp71
-rw-r--r--src/being/being.h7
2 files changed, 67 insertions, 11 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp
index 363ff6c5f..ef5412d0a 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -71,6 +71,7 @@
#include "resources/spriteaction.h"
#include "resources/db/avatardb.h"
+#include "resources/db/badgesdb.h"
#include "resources/db/emotedb.h"
#include "resources/db/homunculusdb.h"
#include "resources/db/horsedb.h"
@@ -134,6 +135,7 @@ Being::Being(const BeingId id,
mInfo(BeingInfo::unknown),
mEmotionSprite(nullptr),
mAnimationEffect(nullptr),
+ mPartyBadge(nullptr),
mTeamBadge(nullptr),
mSpriteAction(SpriteAction::STAND),
mName(),
@@ -221,6 +223,7 @@ Being::Being(const BeingId id,
mAreaSize(11),
mTeamId(0U),
mLook(0U),
+ mBadgesCount(0U),
mHairColor(0),
mErased(false),
mEnemy(false),
@@ -290,7 +293,9 @@ Being::~Being()
delete2(mText);
delete2(mEmotionSprite);
delete2(mAnimationEffect);
+ delete2(mPartyBadge);
delete2(mTeamBadge);
+ mBadgesCount = 0;
#ifdef EATHENA_SUPPORT
delete2(mChat);
#endif
@@ -1366,6 +1371,8 @@ void Being::setAction(const BeingActionT &action, const int attackId)
mEmotionSprite->play(currentAction);
if (mAnimationEffect)
mAnimationEffect->play(currentAction);
+ if (mPartyBadge)
+ mPartyBadge->play(currentAction);
if (mTeamBadge)
mTeamBadge->play(currentAction);
#ifdef EATHENA_SUPPORT
@@ -1431,6 +1438,8 @@ void Being::setDirection(const uint8_t direction)
mEmotionSprite->setSpriteDirection(dir);
if (mAnimationEffect)
mAnimationEffect->setSpriteDirection(dir);
+ if (mPartyBadge)
+ mPartyBadge->setSpriteDirection(dir);
if (mTeamBadge)
mTeamBadge->setSpriteDirection(dir);
#ifdef EATHENA_SUPPORT
@@ -1537,6 +1546,8 @@ void Being::logic()
if (mAnimationEffect->isTerminated())
delete2(mAnimationEffect)
}
+ if (mPartyBadge)
+ mPartyBadge->update(time);
if (mTeamBadge)
mTeamBadge->update(time);
@@ -1848,18 +1859,30 @@ void Being::drawEmotion(Graphics *const graphics,
mEmotionSprite->draw(graphics, px, py);
if (mAnimationEffect)
mAnimationEffect->draw(graphics, px, py);
- if (mTeamBadge && mShowBadges)
+ if (mShowBadges && mBadgesCount)
{
+ int x;
+ int y;
if (!mShowBadgesTop && mDispName && gui)
{
Font *const font = gui->getFont();
- mTeamBadge->draw(graphics,
- mDispName->getX() - offsetX + mDispName->getWidth(),
- mDispName->getY() - offsetY - font->getHeight());
+ x = mDispName->getX() - offsetX + mDispName->getWidth();
+ y = mDispName->getY() - offsetY - font->getHeight();
}
else
{
- mTeamBadge->draw(graphics, px, py);
+ x = px + 8 - mBadgesCount * 8;
+ y = py;
+ }
+ if (mTeamBadge)
+ {
+ mTeamBadge->draw(graphics, x, y);
+ x += 16;
+ }
+ if (mPartyBadge)
+ {
+ mPartyBadge->draw(graphics, x, y);
+// x += 16;
}
}
}
@@ -3710,15 +3733,45 @@ void Being::setTeamId(const uint16_t teamId)
void Being::showBadges(const bool show)
{
delete2(mTeamBadge);
- if (show && mTeamId)
+ if (show && mTeamId && mShowBadges)
{
- mTeamBadge = AnimatedSprite::load(
- paths.getStringValue("badges") +
+ const std::string name = paths.getStringValue("badges") +
paths.getStringValue(strprintf("team%dbadge",
- mTeamId)));
+ mTeamId));
+ if (!name.empty())
+ mTeamBadge = AnimatedSprite::load(name);
+ }
+ updateBadgesCount();
+}
+
+void Being::setPartyName(const std::string &name)
+{
+ if (mPartyName != name)
+ {
+ delete2(mPartyBadge);
+ mPartyName = name;
+ if (!mPartyName.empty() && mShowBadges)
+ {
+ const std::string badge = BadgesDB::getPartyBadge(mPartyName);
+ if (!badge.empty())
+ {
+ mPartyBadge = AnimatedSprite::load(
+ paths.getStringValue("badges") + badge);
+ }
+ }
+ updateBadgesCount();
}
}
+void Being::updateBadgesCount()
+{
+ mBadgesCount = 0;
+ if (mTeamBadge)
+ mBadgesCount ++;
+ if (mPartyBadge)
+ mBadgesCount ++;
+}
+
#ifdef EATHENA_SUPPORT
void Being::setChat(ChatObject *const obj)
{
diff --git a/src/being/being.h b/src/being/being.h
index e58cbcb90..2f8796ba7 100644
--- a/src/being/being.h
+++ b/src/being/being.h
@@ -227,8 +227,7 @@ class Being notfinal : public ActorSprite,
/**
* Sets the name of the party the being is in. Shown in BeingPopup.
*/
- void setPartyName(const std::string &name)
- { mPartyName = name; }
+ void setPartyName(const std::string &name);
const std::string &getPartyName() const A_WARN_UNUSED
{ return mPartyName; }
@@ -955,11 +954,14 @@ class Being notfinal : public ActorSprite,
void setDefaultNameColor(const UserColorIdT defaultColor);
+ void updateBadgesCount();
+
static int getDefaultEffectId(const AttackTypeT &type);
BeingInfo *mInfo;
AnimatedSprite *mEmotionSprite;
AnimatedSprite *mAnimationEffect;
+ AnimatedSprite *mPartyBadge;
AnimatedSprite *mTeamBadge;
std::string mSpriteAction;
@@ -1124,6 +1126,7 @@ class Being notfinal : public ActorSprite,
int mAreaSize;
uint16_t mTeamId;
uint16_t mLook;
+ uint16_t mBadgesCount;
unsigned char mHairColor;
bool mErased;
bool mEnemy;