From 2d648c5dc29a1ceae154194c23c799c7076894b4 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Wed, 14 May 2008 18:57:32 +0000 Subject: 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. --- src/player.cpp | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'src/player.cpp') 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) -- cgit v1.2.3-70-g09d2