summaryrefslogtreecommitdiff
path: root/src/localplayer.cpp
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2009-01-09 21:24:13 -0700
committerIra Rice <irarice@gmail.com>2009-01-09 21:24:13 -0700
commit0dabbade690301ef89da2fb2562da8e48afc22d3 (patch)
treeaf73cc3f45c48dc0cf97b8c0fc3048f11eaaec03 /src/localplayer.cpp
parent43630ab7969fa26cb0a3e2773e7266f2f9647867 (diff)
downloadmana-client-0dabbade690301ef89da2fb2562da8e48afc22d3.tar.gz
mana-client-0dabbade690301ef89da2fb2562da8e48afc22d3.tar.bz2
mana-client-0dabbade690301ef89da2fb2562da8e48afc22d3.tar.xz
mana-client-0dabbade690301ef89da2fb2562da8e48afc22d3.zip
Added the ability to see your own name in game.
Signed-off-by: Ira Rice <irarice@gmail.com>
Diffstat (limited to 'src/localplayer.cpp')
-rw-r--r--src/localplayer.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 24b50d03..fb568d20 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -20,6 +20,7 @@
*/
#include <cassert>
+#include "configuration.h"
#include "equipment.h"
#include "floor_item.h"
#include "game.h"
@@ -44,6 +45,9 @@
LocalPlayer *player_node = NULL;
+static const int NAME_X_OFFSET = 15;
+static const int NAME_Y_OFFSET = 30;
+
LocalPlayer::LocalPlayer(Uint32 id, Uint16 job, Map *map):
Player(id, job, map),
mCharId(0),
@@ -68,6 +72,13 @@ LocalPlayer::LocalPlayer(Uint32 id, Uint16 job, Map *map):
mInventory(new Inventory(INVENTORY_SIZE)),
mStorage(new Inventory(STORAGE_SIZE))
{
+ // Variable to keep the local player from doing certain actions before a map
+ // is initialized. e.g. drawing a player's name using the TextManager, since
+ // it appears to be dependant upon map coordinates for updating drawing.
+ mMapInitialized = false;
+
+ mUpdateName = true;
+
initTargetCursor();
}
@@ -75,6 +86,7 @@ LocalPlayer::~LocalPlayer()
{
delete mInventory;
delete mStorage;
+ delete mName;
for (int i = Being::TC_SMALL; i < Being::NUM_TC; i++)
{
@@ -158,6 +170,38 @@ void LocalPlayer::logic()
Being::logic();
}
+void LocalPlayer::setGM()
+{
+ mIsGM = !mIsGM;
+ setName(getName());
+}
+
+void LocalPlayer::setName(const std::string &name)
+{
+ if (mName)
+ {
+ delete mName;
+ mName = 0;
+ }
+
+ if (config.getValue("showownname", false) && mMapInitialized)
+ {
+ Player::setName(name);
+ }
+ else
+ {
+ Being::setName(name);
+ }
+}
+
+void LocalPlayer::updateCoords()
+{
+ if (mName)
+ {
+ mName->adviseXY(mPx + NAME_X_OFFSET, mPy + NAME_Y_OFFSET);
+ }
+}
+
void LocalPlayer::nextStep()
{
if (mPath.empty())