summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-10-16 01:58:12 +0300
committerAndrei Karas <akaras@inbox.ru>2016-10-16 01:58:12 +0300
commit036df13f60e4d5c4e30d92c09fa376c147a68e9c (patch)
treea976693604fb050bb0f81681621e797a8162f6c6 /src
parentbdc9cb6d5886af2bf068bfb5ea37f724f0cecae6 (diff)
downloadmanaplus-036df13f60e4d5c4e30d92c09fa376c147a68e9c.tar.gz
manaplus-036df13f60e4d5c4e30d92c09fa376c147a68e9c.tar.bz2
manaplus-036df13f60e4d5c4e30d92c09fa376c147a68e9c.tar.xz
manaplus-036df13f60e4d5c4e30d92c09fa376c147a68e9c.zip
Add option to show player name only for selected player.s20161017
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/being/being.cpp16
-rw-r--r--src/being/localplayer.cpp56
-rw-r--r--src/being/localplayer.h2
-rw-r--r--src/defaults.cpp4
-rw-r--r--src/enums/being/visiblename.h34
-rw-r--r--src/gui/widgets/tabs/setup_players.cpp22
-rw-r--r--src/gui/widgets/tabs/setup_players.h1
9 files changed, 119 insertions, 18 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d02f7d049..55fd86d09 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1197,6 +1197,7 @@ SET(SRCS
enums/being/relation.h
enums/being/targetcursorsize.h
enums/being/targetcursortype.h
+ enums/being/visiblename.h
listeners/playerrelationslistener.h
listeners/renamelistener.cpp
listeners/renamelistener.h
diff --git a/src/Makefile.am b/src/Makefile.am
index ac3eb779f..cf2f1ce76 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -657,6 +657,7 @@ SRC += events/actionevent.h \
enums/being/relation.h \
enums/being/targetcursorsize.h \
enums/being/targetcursortype.h \
+ enums/being/visiblename.h \
position.cpp \
position.h \
render/safeopenglgraphics.cpp\
diff --git a/src/being/being.cpp b/src/being/being.cpp
index 5ad4a1006..c401f9d0b 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -275,7 +275,7 @@ Being::Being(const BeingId id,
setMap(map);
setSubtype(subtype, 0);
- bool showName1 = false;
+ VisibleName::Type showName1 = VisibleName::Hide;
switch (mType)
{
@@ -284,11 +284,12 @@ Being::Being(const BeingId id,
case ActorType::Pet:
case ActorType::Homunculus:
case ActorType::Elemental:
- showName1 = config.getBoolValue("visiblenames");
+ showName1 = static_cast<VisibleName::Type>(
+ config.getIntValue("visiblenames"));
break;
case ActorType::Portal:
case ActorType::SkillUnit:
- showName1 = false;
+ showName1 = VisibleName::Hide;
break;
default:
case ActorType::Unknown:
@@ -306,10 +307,11 @@ Being::Being(const BeingId id,
reReadConfig();
- if (mType == ActorType::Npc)
+ if (mType == ActorType::Npc ||
+ showName1 == VisibleName::Show)
+ {
setShowName(true);
- else if (showName1)
- setShowName(showName1);
+ }
updateColors();
updatePercentHP();
@@ -2398,7 +2400,7 @@ void Being::updateCoords() restrict2
void Being::optionChanged(const std::string &restrict value) restrict2
{
if (mType == ActorType::Player && value == "visiblenames")
- setShowName(config.getBoolValue("visiblenames"));
+ setShowName(config.getIntValue("visiblenames") == VisibleName::Show);
}
void Being::flashName(const int time) restrict2
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp
index 23186dc2c..9af1371bf 100644
--- a/src/being/localplayer.cpp
+++ b/src/being/localplayer.cpp
@@ -166,6 +166,8 @@ LocalPlayer::LocalPlayer(const BeingId id,
mBlockAdvert(false),
mTargetDeadPlayers(config.getBoolValue("targetDeadPlayers")),
mServerAttack(fromBool(config.getBoolValue("serverAttack"), Keep)),
+ mVisibleNames(static_cast<VisibleName::Type>(
+ config.getIntValue("visiblenames"))),
mEnableAdvert(config.getBoolValue("enableAdvert")),
mTradebot(config.getBoolValue("tradebot")),
mTargetOnlyReachable(config.getBoolValue("targetOnlyReachable")),
@@ -216,6 +218,7 @@ LocalPlayer::LocalPlayer(const BeingId id,
config.addListener("tradebot", this);
config.addListener("targetOnlyReachable", this);
config.addListener("showserverpos", this);
+ config.addListener("visiblenames", this);
setShowName(config.getBoolValue("showownname"));
}
@@ -553,21 +556,27 @@ void LocalPlayer::setTarget(Being *const target)
oldTarget = mTarget;
}
- if (mTarget && mTarget->getType() == ActorType::Monster)
- mTarget->setShowName(false);
+ if (mTarget)
+ {
+ if (mTarget->getType() == ActorType::Monster)
+ mTarget->setShowName(false);
+ }
mTarget = target;
if (oldTarget)
oldTarget->updateName();
- if (mTarget)
+ if (target)
{
- mLastTargetX = mTarget->mX;
- mLastTargetY = mTarget->mY;
- mTarget->updateName();
+ mLastTargetX = target->mX;
+ mLastTargetY = target->mY;
+ target->updateName();
+ if (mVisibleNames == VisibleName::ShowOnSelection)
+ target->setShowName(true);
}
-
+ if (oldTarget && mVisibleNames == VisibleName::ShowOnSelection)
+ oldTarget->setShowName(false);
if (target && target->getType() == ActorType::Monster)
target->setShowName(true);
}
@@ -1073,33 +1082,66 @@ void LocalPlayer::addMessageToQueue(const std::string &message,
void LocalPlayer::optionChanged(const std::string &value)
{
if (value == "showownname")
+ {
setShowName(config.getBoolValue("showownname"));
+ }
else if (value == "targetDeadPlayers")
+ {
mTargetDeadPlayers = config.getBoolValue("targetDeadPlayers");
+ }
else if (value == "enableBuggyServers")
+ {
mIsServerBuggy = serverConfig.getBoolValue("enableBuggyServers");
+ }
else if (value == "syncPlayerMove")
+ {
mSyncPlayerMove = config.getBoolValue("syncPlayerMove");
+ }
else if (value == "syncPlayerMoveDistance")
+ {
mSyncPlayerMoveDistance = config.getIntValue("syncPlayerMoveDistance");
+ }
else if (value == "drawPath")
+ {
mDrawPath = config.getBoolValue("drawPath");
+ }
else if (value == "serverAttack")
+ {
mServerAttack = fromBool(config.getBoolValue("serverAttack"), Keep);
+ }
else if (value == "attackMoving")
+ {
mAttackMoving = config.getBoolValue("attackMoving");
+ }
else if (value == "attackNext")
+ {
mAttackNext = config.getBoolValue("attackNext");
+ }
else if (value == "showJobExp")
+ {
mShowJobExp = config.getBoolValue("showJobExp");
+ }
else if (value == "enableAdvert")
+ {
mEnableAdvert = config.getBoolValue("enableAdvert");
+ }
else if (value == "tradebot")
+ {
mTradebot = config.getBoolValue("tradebot");
+ }
else if (value == "targetOnlyReachable")
+ {
mTargetOnlyReachable = config.getBoolValue("targetOnlyReachable");
+ }
else if (value == "showserverpos")
+ {
mShowServerPos = config.getBoolValue("showserverpos");
+ }
+ else if (value == "visiblenames")
+ {
+ mVisibleNames = static_cast<VisibleName::Type>(
+ config.getIntValue("visiblenames"));
+ }
}
void LocalPlayer::addJobMessage(const int change)
diff --git a/src/being/localplayer.h b/src/being/localplayer.h
index 7a3985a32..3a7f4605d 100644
--- a/src/being/localplayer.h
+++ b/src/being/localplayer.h
@@ -26,6 +26,7 @@
#include "being/being.h"
#include "enums/being/pickup.h"
+#include "enums/being/visiblename.h"
#include "enums/simpletypes/allowsort.h"
#include "enums/simpletypes/keep.h"
@@ -514,6 +515,7 @@ class LocalPlayer final : public Being,
bool mBlockAdvert;
bool mTargetDeadPlayers;
Keep mServerAttack;
+ VisibleName::Type mVisibleNames;
bool mEnableAdvert;
bool mTradebot;
bool mTargetOnlyReachable;
diff --git a/src/defaults.cpp b/src/defaults.cpp
index 48febf17f..aa357648c 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -30,6 +30,8 @@
#include "enums/screendensity.h"
+#include "enums/being/visiblename.h"
+
#include "enums/input/inputaction.h"
#include "render/graphics.h"
@@ -82,7 +84,7 @@ DefaultsData* getConfigDefaults()
AddDEF("OverlayDetail", 2);
AddDEF("speechBubbleAlpha", 1.0F);
AddDEF("MostUsedServerName0", "server.themanaworld.org");
- AddDEF("visiblenames", true);
+ AddDEF("visiblenames", VisibleName::Show);
AddDEF("speech", CAST_S32(BeingSpeech::NO_NAME_IN_BUBBLE));
AddDEF("showgender", true);
AddDEF("showlevel", false);
diff --git a/src/enums/being/visiblename.h b/src/enums/being/visiblename.h
new file mode 100644
index 000000000..70b607502
--- /dev/null
+++ b/src/enums/being/visiblename.h
@@ -0,0 +1,34 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2011-2016 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_VISIBLENAME_H
+#define ENUMS_BEING_VISIBLENAME_H
+
+namespace VisibleName
+{
+ enum Type
+ {
+ Hide = 0,
+ Show = 1,
+ ShowOnSelection = 2
+ };
+} // namespace BeingDirection
+
+#endif // ENUMS_BEING_VISIBLENAME_H
diff --git a/src/gui/widgets/tabs/setup_players.cpp b/src/gui/widgets/tabs/setup_players.cpp
index 0ed677af0..4f6daa272 100644
--- a/src/gui/widgets/tabs/setup_players.cpp
+++ b/src/gui/widgets/tabs/setup_players.cpp
@@ -51,9 +51,22 @@ static const char *const badgesList[] =
N_("show at bottom"),
};
+static const int visibleNamesListSize = 3;
+
+static const char *const visibleNamesList[] =
+{
+ // TRANSLATORS: visible name type
+ N_("hide"),
+ // TRANSLATORS: visible name type
+ N_("show"),
+ // TRANSLATORS: visible name type
+ N_("show on selection")
+};
+
Setup_Players::Setup_Players(const Widget2 *const widget) :
SetupTabScroll(widget),
- mBadgesList(new NamesModel)
+ mBadgesList(new NamesModel),
+ mVisibleNamesList(new NamesModel)
{
// TRANSLATORS: settings tab name
setName(_("Players"));
@@ -82,9 +95,12 @@ Setup_Players::Setup_Players(const Widget2 *const widget) :
new SetupItemCheckBox(_("Target dead players"), "",
"targetDeadPlayers", this, "targetDeadPlayersEvent");
+ mVisibleNamesList->fillFromArray(&visibleNamesList[0],
+ visibleNamesListSize);
// TRANSLATORS: settings option
- new SetupItemCheckBox(_("Visible names"), "",
- "visiblenames", this, "visiblenamesEvent");
+ new SetupItemDropDown(_("Show player names"), "",
+ "visiblenames", this, "visiblenamesEvent",
+ mVisibleNamesList, 150);
// TRANSLATORS: settings option
new SetupItemCheckBox(_("Auto move names"), "",
diff --git a/src/gui/widgets/tabs/setup_players.h b/src/gui/widgets/tabs/setup_players.h
index c2fe43ba6..efc8e6ecd 100644
--- a/src/gui/widgets/tabs/setup_players.h
+++ b/src/gui/widgets/tabs/setup_players.h
@@ -42,6 +42,7 @@ class Setup_Players final : public SetupTabScroll
private:
NamesModel *mBadgesList;
+ NamesModel *mVisibleNamesList;
};
#endif // GUI_WIDGETS_TABS_SETUP_PLAYERS_H