summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2018-02-13 05:24:46 +0300
committerAndrei Karas <akaras@inbox.ru>2018-02-13 05:24:46 +0300
commit869cb1c660310140f02a0b3804e02a2f3c4a0326 (patch)
tree2f0df222ebf1292d17aba1f8b0fe66866a18b330 /src
parent3a4d8f947b0358c636f983b4248777e8371678dd (diff)
downloadplus-869cb1c660310140f02a0b3804e02a2f3c4a0326.tar.gz
plus-869cb1c660310140f02a0b3804e02a2f3c4a0326.tar.bz2
plus-869cb1c660310140f02a0b3804e02a2f3c4a0326.tar.xz
plus-869cb1c660310140f02a0b3804e02a2f3c4a0326.zip
Add support for show clan badge.
But for now clan unset for players.
Diffstat (limited to 'src')
-rw-r--r--src/being/being.cpp28
-rw-r--r--src/being/being.h9
-rw-r--r--src/enums/being/badgeindex.h1
-rw-r--r--src/resources/db/badgesdb.cpp11
-rw-r--r--src/resources/db/badgesdb.h2
5 files changed, 51 insertions, 0 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp
index da67becda..bb921f92f 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -173,6 +173,7 @@ Being::Being(const BeingId id,
mRaceName(),
mPartyName(),
mGuildName(),
+ mClanName(),
mSpeech(),
mDispName(nullptr),
mNameColor(nullptr),
@@ -1201,6 +1202,33 @@ void Being::setGuildName(const std::string &restrict name) restrict2
}
}
+void Being::showClanBadge(const bool show) restrict2
+{
+ delete2(mBadges[BadgeIndex::Clan]);
+ if (show &&
+ !mClanName.empty() &&
+ mShowBadges != BadgeDrawType::Hide)
+ {
+ const std::string badge = BadgesDB::getClanBadge(mClanName);
+ if (!badge.empty())
+ {
+ mBadges[BadgeIndex::Clan] = AnimatedSprite::load(
+ paths.getStringValue("badges") + badge,
+ 0);
+ }
+ }
+}
+
+void Being::setClanName(const std::string &restrict name) restrict2
+{
+ if (mClanName != name)
+ {
+ mClanName = name;
+ showClanBadge(!mClanName.empty());
+ updateBadgesCount();
+ }
+}
+
void Being::setGuildPos(const std::string &restrict pos A_UNUSED) restrict2
{
}
diff --git a/src/being/being.h b/src/being/being.h
index 4e672ef52..fe8bb4c6a 100644
--- a/src/being/being.h
+++ b/src/being/being.h
@@ -259,6 +259,10 @@ class Being notfinal : public ActorSprite,
A_WARN_UNUSED
{ return mGuildName; }
+ const std::string &getClanName() const restrict2 noexcept2
+ A_WARN_UNUSED
+ { return mClanName; }
+
/**
* Sets the name of the primary guild the being is in. Shown in
* BeingPopup (eventually).
@@ -267,6 +271,8 @@ class Being notfinal : public ActorSprite,
void setGuildPos(const std::string &restrict pos) restrict2;
+ void setClanName(const std::string &restrict name) restrict2;
+
/**
* Adds a guild to the being.
*/
@@ -1055,6 +1061,8 @@ class Being notfinal : public ActorSprite,
void showGuildBadge(const bool show) restrict2;
+ void showClanBadge(const bool show) restrict2;
+
void showGmBadge(const bool show) restrict2;
void showPartyBadge(const bool show) restrict2;
@@ -1178,6 +1186,7 @@ class Being notfinal : public ActorSprite,
std::string mRaceName;
std::string mPartyName;
std::string mGuildName;
+ std::string mClanName;
std::string mSpeech;
/**
diff --git a/src/enums/being/badgeindex.h b/src/enums/being/badgeindex.h
index dd50625fd..1455120b1 100644
--- a/src/enums/being/badgeindex.h
+++ b/src/enums/being/badgeindex.h
@@ -34,6 +34,7 @@ enum2Start(BadgeIndex)
Guild = 6,
Party = 7,
Name = 8,
+ Clan = 9,
BadgeIndexSize
}
diff --git a/src/resources/db/badgesdb.cpp b/src/resources/db/badgesdb.cpp
index aff03fc4f..4a9ded0d8 100644
--- a/src/resources/db/badgesdb.cpp
+++ b/src/resources/db/badgesdb.cpp
@@ -35,6 +35,7 @@ namespace
BadgesInfos mGuilds;
BadgesInfos mNames;
BadgesInfos mParties;
+ BadgesInfos mClans;
bool mLoaded = false;
} // namespace
@@ -78,12 +79,14 @@ void BadgesDB::load()
loadDB("guild", mGuilds);
loadDB("name", mNames);
loadDB("party", mParties);
+ loadDB("clan", mClans);
}
void BadgesDB::unload()
{
logger->log1("Unloading Badges database...");
mParties.clear();
+ mClans.clear();
mGuilds.clear();
mNames.clear();
mLoaded = false;
@@ -112,3 +115,11 @@ const std::string BadgesDB::getGuildBadge(const std::string &name)
return std::string();
return (*it).second;
}
+
+const std::string BadgesDB::getClanBadge(const std::string &name)
+{
+ const BadgesInfosIter it = mClans.find(name);
+ if (it == mClans.end())
+ return std::string();
+ return (*it).second;
+}
diff --git a/src/resources/db/badgesdb.h b/src/resources/db/badgesdb.h
index 6c5a94fab..78db3c113 100644
--- a/src/resources/db/badgesdb.h
+++ b/src/resources/db/badgesdb.h
@@ -40,6 +40,8 @@ namespace BadgesDB
const std::string getNameBadge(const std::string &name);
const std::string getPartyBadge(const std::string &name);
+
+ const std::string getClanBadge(const std::string &name);
} // namespace BadgesDB
#endif // RESOURCES_DB_BADGESDB_H