summaryrefslogtreecommitdiff
path: root/src/gui/widgets/avatar.cpp
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-03-29 20:35:19 -0600
committerJared Adams <jaxad0127@gmail.com>2009-03-29 20:36:58 -0600
commitbbf4d657e77fd39887b9941af1fe75a5ec27d988 (patch)
treed03c2973cff4d11e2eddbb856483369255ee40af /src/gui/widgets/avatar.cpp
parent985e65f31b9cc06f13b733ddd5c7a9daa1331e21 (diff)
downloadmana-client-bbf4d657e77fd39887b9941af1fe75a5ec27d988.tar.gz
mana-client-bbf4d657e77fd39887b9941af1fe75a5ec27d988.tar.bz2
mana-client-bbf4d657e77fd39887b9941af1fe75a5ec27d988.tar.xz
mana-client-bbf4d657e77fd39887b9941af1fe75a5ec27d988.zip
Fix up eAthena party handling some more
Diffstat (limited to 'src/gui/widgets/avatar.cpp')
-rw-r--r--src/gui/widgets/avatar.cpp48
1 files changed, 36 insertions, 12 deletions
diff --git a/src/gui/widgets/avatar.cpp b/src/gui/widgets/avatar.cpp
index a36c0302..2603e3ae 100644
--- a/src/gui/widgets/avatar.cpp
+++ b/src/gui/widgets/avatar.cpp
@@ -28,28 +28,52 @@
#include <guichan/widgets/label.hpp>
+namespace {
+ Image *avatarStatusOffline;
+ Image *avatarStatusOnline;
+ int avatarCount = 0;
+}
+
Avatar::Avatar(const std::string &name):
mName(name)
{
+ setOpaque(false);
setSize(110, 12);
+
+ if (avatarCount == 0)
+ {
+ ResourceManager *resman = ResourceManager::getInstance();
+ avatarStatusOffline = resman->getImage("graphics/gui/circle-gray.png");
+ avatarStatusOnline = resman->getImage("graphics/gui/circle-green.png");
+ }
+ avatarCount++;
+ avatarStatusOffline->incRef();
+ avatarStatusOnline->incRef();
+
+ mStatus = new Icon(avatarStatusOffline);
+ mStatus->setSize(12, 12);
+ add(mStatus, 1, 0);
+
mLabel = new gcn::Label(name);
mLabel->setSize(85, 12);
- mLabel->setPosition(25, 0);
- ResourceManager *resman = ResourceManager::getInstance();
- mStatusOffline = resman->getImage("graphics/gui/circle-gray.png");
- mStatusOnline = resman->getImage("graphics/gui/circle-green.png");
- mStatus = new Icon(mStatusOffline);
- mStatus->setSize(25, 12);
- mStatus->setPosition(0, 0);
+ add(mLabel, 14, 0);
}
-void Avatar::setOnline(bool online)
+Avatar::~Avatar()
{
- mStatus->setImage(online ? mStatusOnline : mStatusOffline);
+ avatarCount--;
+
+ avatarStatusOffline->decRef();
+ avatarStatusOnline->decRef();
}
-void Avatar::draw(gcn::Graphics *g)
+void Avatar::setName(const std::string &name)
+{
+ mName = name;
+ mLabel->setCaption(name);
+}
+
+void Avatar::setOnline(bool online)
{
- mLabel->draw(g);
- mStatus->draw(g);
+ mStatus->setImage(online ? avatarStatusOnline : avatarStatusOffline);
}