summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/actormanager.cpp10
-rw-r--r--src/being/being.cpp67
-rw-r--r--src/being/being.h6
-rw-r--r--src/defaults.cpp5
-rw-r--r--src/enums/being/badgedrawtype.h35
-rw-r--r--src/enums/being/visiblenamepos.h33
-rw-r--r--src/gui/widgets/tabs/setup_players.cpp21
-rw-r--r--src/gui/widgets/tabs/setup_players.h1
10 files changed, 160 insertions, 22 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 7c41804c3..5bfcfd164 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -998,6 +998,7 @@ SET(SRCS
enums/being/attributes.h
enums/being/attributesstrings.cpp
enums/being/attributesstrings.h
+ enums/being/badgedrawtype.h
enums/being/badgeindex.h
listeners/actorspritelistener.h
listeners/arrowslistener.cpp
@@ -1273,6 +1274,7 @@ SET(SRCS
enums/being/targetcursorsize.h
enums/being/targetcursortype.h
enums/being/visiblename.h
+ enums/being/visiblenamepos.h
listeners/playerrelationslistener.h
listeners/renamelistener.cpp
listeners/renamelistener.h
diff --git a/src/Makefile.am b/src/Makefile.am
index fe70cd2ef..5226f3415 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -768,6 +768,7 @@ BASE_SRC += events/actionevent.h \
enums/being/targetcursorsize.h \
enums/being/targetcursortype.h \
enums/being/visiblename.h \
+ enums/being/visiblenamepos.h \
position.cpp \
position.h \
render/safeopenglgraphics.cpp\
@@ -1055,6 +1056,7 @@ SRC = ${BASE_SRC} \
enums/being/attributes.h \
enums/being/attributesstrings.cpp \
enums/being/attributesstrings.h \
+ enums/being/badgedrawtype.h \
enums/being/badgeindex.h \
dragdrop.h \
gui/shortcut/dropshortcut.cpp \
diff --git a/src/actormanager.cpp b/src/actormanager.cpp
index ebc3dc50e..172472072 100644
--- a/src/actormanager.cpp
+++ b/src/actormanager.cpp
@@ -243,6 +243,7 @@ ActorManager::ActorManager() :
config.addListener("extMouseTargeting", this);
config.addListener("showBadges", this);
config.addListener("enableIdCollecting", this);
+ config.addListener("visiblenamespos", this);
loadAttackList();
}
@@ -1835,6 +1836,8 @@ void ActorManager::optionChanged(const std::string &name)
mExtMouseTargeting = config.getBoolValue("extMouseTargeting");
else if (name == "showBadges")
updateBadges();
+ else if (name == "visiblenamespos")
+ updateBadges();
else if (name == "enableIdCollecting")
mEnableIdCollecting = config.getBoolValue("enableIdCollecting");
}
@@ -2122,16 +2125,19 @@ Being *ActorManager::cloneBeing(const Being *const srcBeing,
void ActorManager::updateBadges() const
{
- const uint8_t showBadges = CAST_U8(
+ const BadgeDrawType::Type showBadges = static_cast<BadgeDrawType::Type>(
config.getIntValue("showBadges"));
Being::mShowBadges = showBadges;
+ Being::mVisibleNamePos = static_cast<VisibleNamePos::Type>(
+ config.getIntValue("visiblenamespos"));
+
for_actors
{
ActorSprite *const actor = *it;
if (actor->getType() == ActorType::Player)
{
Being *const being = static_cast<Being*>(actor);
- being->showBadges(showBadges != 0u);
+ being->showBadges(showBadges != BadgeDrawType::Hide);
}
}
}
diff --git a/src/being/being.cpp b/src/being/being.cpp
index 010fb3182..4621b99a2 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -142,8 +142,9 @@ bool Being::mEnableReorderSprites = true;
bool Being::mHideErased = false;
Move Being::mMoveNames = Move_false;
bool Being::mUseDiagonal = true;
-uint8_t Being::mShowBadges = 1;
+BadgeDrawType::Type Being::mShowBadges = BadgeDrawType::Top;
int Being::mAwayEffect = -1;
+VisibleNamePos::Type Being::mVisibleNamePos = VisibleNamePos::Buttom;
std::list<BeingCacheEntry*> beingInfoCache;
typedef std::map<int, Guild*>::const_iterator GuildsMapCIter;
@@ -1096,7 +1097,9 @@ void Being::handleSkill(Being *restrict const victim,
void Being::showNameBadge(const bool show) restrict2
{
delete2(mBadges[BadgeIndex::Name]);
- if (show && !mName.empty() && (mShowBadges != 0u))
+ if (show &&
+ !mName.empty() &&
+ mShowBadges != BadgeDrawType::Hide)
{
const std::string badge = BadgesDB::getNameBadge(mName);
if (!badge.empty())
@@ -1153,7 +1156,9 @@ void Being::setShowName(const bool doShowName) restrict2
void Being::showGuildBadge(const bool show) restrict2
{
delete2(mBadges[BadgeIndex::Guild]);
- if (show && !mGuildName.empty() && (mShowBadges != 0u))
+ if (show &&
+ !mGuildName.empty() &&
+ mShowBadges != BadgeDrawType::Hide)
{
const std::string badge = BadgesDB::getGuildBadge(mGuildName);
if (!badge.empty())
@@ -2264,25 +2269,36 @@ void Being::drawEmotion(Graphics *restrict const graphics,
const int py = mPixelY - offsetY - mapTileSize * 2 - mapTileSize;
if (mAnimationEffect != nullptr)
mAnimationEffect->draw(graphics, px, py);
- if ((mShowBadges != 0u) && (mBadgesCount != 0u))
+ if (mShowBadges != BadgeDrawType::Hide &&
+ mBadgesCount != 0u)
{
int x;
int y;
- if (mShowBadges == 2 && mDispName != nullptr && gui != nullptr)
+ if (mShowBadges == BadgeDrawType::Right &&
+ mDispName != nullptr &&
+ gui != nullptr)
{
const Font *restrict const font = gui->getFont();
x = mDispName->getX() - offsetX + mDispName->getWidth();
y = mDispName->getY() - offsetY - font->getHeight();
}
- else if (mShowBadges == 3 && mDispName != nullptr && gui != nullptr)
+ else if (mShowBadges == BadgeDrawType::Bottom &&
+ mDispName != nullptr &&
+ gui != nullptr)
{
x = px + 8 - mBadgesCount * 8;
- y = mDispName->getY() - offsetY;
+ if (mVisibleNamePos == VisibleNamePos::Buttom)
+ y = mDispName->getY() - offsetY;
+ else
+ y = py + getHeight() + 16;
}
else
{
x = px + 8 - mBadgesCount * 8;
- y = py;
+ if (mVisibleNamePos == VisibleNamePos::Top)
+ y = py - mDispName->getHeight();
+ else
+ y = py;
}
for_each_badges()
{
@@ -2407,8 +2423,11 @@ void Being::updateCoords() restrict2
offsetY += mInfo->getNameOffsetY();
}
// Monster names show above the sprite instead of below it
- if (mType == ActorType::Monster)
+ if (mType == ActorType::Monster ||
+ mVisibleNamePos == VisibleNamePos::Top)
+ {
offsetY += - getHeight() - mDispName->getHeight();
+ }
mDispName->adviseXY(offsetX, offsetY, mMoveNames);
}
@@ -2444,7 +2463,8 @@ std::string Being::getGenderSign() const restrict2
else if (getGender() == Gender::MALE)
str = "\u2642";
}
- if (mShowPlayersStatus && (mShowBadges == 0u))
+ if (mShowPlayersStatus &&
+ mShowBadges == BadgeDrawType::Hide)
{
if (mShop)
str.append("$");
@@ -3309,7 +3329,10 @@ void Being::reReadConfig()
mHideErased = config.getBoolValue("hideErased");
mMoveNames = fromBool(config.getBoolValue("moveNames"), Move);
mUseDiagonal = config.getBoolValue("useDiagonalSpeed");
- mShowBadges = CAST_U8(config.getIntValue("showBadges"));
+ mShowBadges = static_cast<BadgeDrawType::Type>(
+ config.getIntValue("showBadges"));
+ mVisibleNamePos = static_cast<VisibleNamePos::Type>(
+ config.getIntValue("visiblenamespos"));
mUpdateConfigTime = cur_time;
}
@@ -3502,7 +3525,7 @@ void Being::showGmBadge(const bool show) restrict2
delete2(mBadges[BadgeIndex::Gm]);
if (show &&
mIsGM &&
- mShowBadges != 0u &&
+ mShowBadges != BadgeDrawType::Hide &&
GroupDb::getShowBadge(mGroupId))
{
const std::string &gmBadge = GroupDb::getBadge(mGroupId);
@@ -5019,7 +5042,9 @@ void Being::setTeamId(const uint16_t teamId) restrict2
void Being::showTeamBadge(const bool show) restrict2
{
delete2(mBadges[BadgeIndex::Team]);
- if (show && (mTeamId != 0u) && (mShowBadges != 0u))
+ if (show &&
+ mTeamId != 0u &&
+ mShowBadges != BadgeDrawType::Hide)
{
const std::string name = paths.getStringValue("badges") +
paths.getStringValue(strprintf("team%dbadge",
@@ -5045,7 +5070,9 @@ void Being::showBadges(const bool show) restrict2
void Being::showPartyBadge(const bool show) restrict2
{
delete2(mBadges[BadgeIndex::Party]);
- if (show && !mPartyName.empty() && (mShowBadges != 0u))
+ if (show &&
+ !mPartyName.empty() &&
+ mShowBadges != BadgeDrawType::Hide)
{
const std::string badge = BadgesDB::getPartyBadge(mPartyName);
if (!badge.empty())
@@ -5070,7 +5097,9 @@ void Being::setPartyName(const std::string &restrict name) restrict2
void Being::showShopBadge(const bool show) restrict2
{
delete2(mBadges[BadgeIndex::Shop]);
- if (show && mShop && (mShowBadges != 0u))
+ if (show &&
+ mShop &&
+ mShowBadges != BadgeDrawType::Hide)
{
const std::string badge = paths.getStringValue("shopbadge");
if (!badge.empty())
@@ -5085,7 +5114,9 @@ void Being::showShopBadge(const bool show) restrict2
void Being::showInactiveBadge(const bool show) restrict2
{
delete2(mBadges[BadgeIndex::Inactive]);
- if (show && mInactive && (mShowBadges != 0u))
+ if (show &&
+ mInactive &&
+ mShowBadges != BadgeDrawType::Hide)
{
const std::string badge = paths.getStringValue("inactivebadge");
if (!badge.empty())
@@ -5100,7 +5131,9 @@ void Being::showInactiveBadge(const bool show) restrict2
void Being::showAwayBadge(const bool show) restrict2
{
delete2(mBadges[BadgeIndex::Away]);
- if (show && mAway && (mShowBadges != 0u))
+ if (show &&
+ mAway &&
+ mShowBadges != BadgeDrawType::Hide)
{
const std::string badge = paths.getStringValue("awaybadge");
if (!badge.empty())
diff --git a/src/being/being.h b/src/being/being.h
index 6f9e753d9..0f652139d 100644
--- a/src/being/being.h
+++ b/src/being/being.h
@@ -32,12 +32,15 @@
#include "enums/simpletypes/move.h"
+#include "enums/being/visiblenamepos.h"
+
#include "resources/beinginfo.h"
#include "resources/beingslot.h"
#include "being/actorsprite.h"
#include "enums/being/attacktype.h"
+#include "enums/being/badgedrawtype.h"
#include "enums/being/beingaction.h"
#include "enums/being/gender.h"
@@ -1324,8 +1327,9 @@ class Being notfinal : public ActorSprite,
static bool mHideErased;
static Move mMoveNames;
static bool mUseDiagonal;
- static uint8_t mShowBadges;
+ static BadgeDrawType::Type mShowBadges;
static int mAwayEffect;
+ static VisibleNamePos::Type mVisibleNamePos;
time_t mMoveTime;
time_t mAttackTime;
diff --git a/src/defaults.cpp b/src/defaults.cpp
index 698436614..24aa3452c 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -30,7 +30,9 @@
#include "enums/screendensity.h"
+#include "enums/being/badgedrawtype.h"
#include "enums/being/visiblename.h"
+#include "enums/being/visiblenamepos.h"
#include "enums/input/inputaction.h"
@@ -88,6 +90,7 @@ DefaultsData* getConfigDefaults()
AddDEF("speechBubbleAlpha", 1.0F);
AddDEF("MostUsedServerName0", "server.themanaworld.org");
AddDEF("visiblenames", VisibleName::Show);
+ AddDEF("visiblenamespos", VisibleNamePos::Buttom);
AddDEF("speech", CAST_S32(BeingSpeech::NO_NAME_IN_BUBBLE));
AddDEF("showgender", true);
AddDEF("showlevel", false);
@@ -394,7 +397,7 @@ DefaultsData* getConfigDefaults()
AddDEF("ignorelogpackets", "");
AddDEF("disableLoggingInGame", false);
AddDEF("sellShopName", "unnamed");
- AddDEF("showBadges", 1);
+ AddDEF("showBadges", BadgeDrawType::Top);
AddDEF("tradescreenshot", false);
AddDEF("skillAutotarget", true);
AddDEF("logPlayerActions", false);
diff --git a/src/enums/being/badgedrawtype.h b/src/enums/being/badgedrawtype.h
new file mode 100644
index 000000000..6624b9a66
--- /dev/null
+++ b/src/enums/being/badgedrawtype.h
@@ -0,0 +1,35 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2011-2017 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef ENUMS_BEING_BADGEDRAWTYPE_H
+#define ENUMS_BEING_BADGEDRAWTYPE_H
+
+namespace BadgeDrawType
+{
+ enum Type
+ {
+ Hide = 0,
+ Top = 1,
+ Right = 2,
+ Bottom = 3
+ };
+} // namespace VisibleNamePos
+
+#endif // ENUMS_BEING_BADGEDRAWTYPE_H
diff --git a/src/enums/being/visiblenamepos.h b/src/enums/being/visiblenamepos.h
new file mode 100644
index 000000000..9c5ac6bd5
--- /dev/null
+++ b/src/enums/being/visiblenamepos.h
@@ -0,0 +1,33 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2011-2017 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef ENUMS_BEING_VISIBLENAMEPOS_H
+#define ENUMS_BEING_VISIBLENAMEPOS_H
+
+namespace VisibleNamePos
+{
+ enum Type
+ {
+ Top = 0,
+ Buttom = 1
+ };
+} // namespace VisibleNamePos
+
+#endif // ENUMS_BEING_VISIBLENAMEPOS_H
diff --git a/src/gui/widgets/tabs/setup_players.cpp b/src/gui/widgets/tabs/setup_players.cpp
index 4f9d8f856..97865c91e 100644
--- a/src/gui/widgets/tabs/setup_players.cpp
+++ b/src/gui/widgets/tabs/setup_players.cpp
@@ -63,10 +63,21 @@ static const char *const visibleNamesList[] =
N_("show on selection")
};
+static const int topDownListSize = 2;
+
+static const char *const topDownList[] =
+{
+ // TRANSLATORS: show on top or down
+ N_("top"),
+ // TRANSLATORS: show on top or down
+ N_("buttom")
+};
+
Setup_Players::Setup_Players(const Widget2 *const widget) :
SetupTabScroll(widget),
mBadgesList(new NamesModel),
- mVisibleNamesList(new NamesModel)
+ mVisibleNamesList(new NamesModel),
+ mVisibleNamesPosList(new NamesModel)
{
// TRANSLATORS: settings tab name
setName(_("Players"));
@@ -102,6 +113,13 @@ Setup_Players::Setup_Players(const Widget2 *const widget) :
"visiblenames", this, "visiblenamesEvent",
mVisibleNamesList, 150);
+ mVisibleNamesPosList->fillFromArray(&topDownList[0],
+ topDownListSize);
+ // TRANSLATORS: settings option
+ new SetupItemDropDown(_("Show player names at"), "",
+ "visiblenamespos", this, "visiblenamesposEvent",
+ mVisibleNamesPosList, 150);
+
// TRANSLATORS: settings option
new SetupItemCheckBox(_("Auto move names"), "",
"moveNames", this, "moveNamesEvent");
@@ -176,6 +194,7 @@ Setup_Players::~Setup_Players()
{
delete2(mBadgesList);
delete2(mVisibleNamesList);
+ delete2(mVisibleNamesPosList);
}
void Setup_Players::externalUpdated()
diff --git a/src/gui/widgets/tabs/setup_players.h b/src/gui/widgets/tabs/setup_players.h
index 506983381..d29d41781 100644
--- a/src/gui/widgets/tabs/setup_players.h
+++ b/src/gui/widgets/tabs/setup_players.h
@@ -43,6 +43,7 @@ class Setup_Players final : public SetupTabScroll
private:
NamesModel *mBadgesList;
NamesModel *mVisibleNamesList;
+ NamesModel *mVisibleNamesPosList;
};
#endif // GUI_WIDGETS_TABS_SETUP_PLAYERS_H