summaryrefslogtreecommitdiff
path: root/src/player.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2008-05-14 18:57:32 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2008-05-14 18:57:32 +0000
commit2d648c5dc29a1ceae154194c23c799c7076894b4 (patch)
treef6c31a30260b80713257be211b139263b3291098 /src/player.cpp
parent41906acb990895831e3b2c39102f41c9b580ae10 (diff)
downloadmana-2d648c5dc29a1ceae154194c23c799c7076894b4.tar.gz
mana-2d648c5dc29a1ceae154194c23c799c7076894b4.tar.bz2
mana-2d648c5dc29a1ceae154194c23c799c7076894b4.tar.xz
mana-2d648c5dc29a1ceae154194c23c799c7076894b4.zip
Added ability to define friends, players you want to ignore or disregard and
configure whether trading is allowed. Based on new popup code, configuration improvements to store hierarchical data and a table model.
Diffstat (limited to 'src/player.cpp')
-rw-r--r--src/player.cpp31
1 files changed, 27 insertions, 4 deletions
diff --git a/src/player.cpp b/src/player.cpp
index 3d8a8b6e..d0c6bdc6 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -36,7 +36,8 @@
#include "gui/gui.h"
Player::Player(int id, int job, Map *map):
- Being(id, job, map)
+ Being(id, job, map),
+ mDrawStrategy(NULL)
{
}
@@ -74,15 +75,37 @@ Player::getType() const
return PLAYER;
}
+
+void
+Player::setNameDrawStrategy(PlayerNameDrawStrategy *draw_strategy)
+{
+ if (mDrawStrategy)
+ delete mDrawStrategy;
+ mDrawStrategy = draw_strategy;
+}
+
+class
+DefaultPlayerNameDrawStrategy : public PlayerNameDrawStrategy
+{
+public:
+ virtual void draw(Player *player, Graphics *graphics, int px, int py)
+ {
+ graphics->setFont(speechFont);
+ graphics->setColor(gcn::Color(255, 255, 255));
+ graphics->drawText(player->getName(), px + 15, py + 30, gcn::Graphics::CENTER);
+ }
+};
+
void
Player::drawName(Graphics *graphics, int offsetX, int offsetY)
{
int px = mPx + offsetX;
int py = mPy + offsetY;
- graphics->setFont(speechFont);
- graphics->setColor(gcn::Color(255, 255, 255));
- graphics->drawText(mName, px + 15, py + 30, gcn::Graphics::CENTER);
+ if (mDrawStrategy)
+ mDrawStrategy->draw(this, graphics, px, py);
+ else
+ DefaultPlayerNameDrawStrategy().draw(this, graphics, px, py);
}
void Player::setGender(int gender)