summaryrefslogtreecommitdiff
path: root/src/gui/guildlistbox.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/guildlistbox.cpp')
-rw-r--r--src/gui/guildlistbox.cpp35
1 files changed, 26 insertions, 9 deletions
diff --git a/src/gui/guildlistbox.cpp b/src/gui/guildlistbox.cpp
index 11661235..1c14fd55 100644
--- a/src/gui/guildlistbox.cpp
+++ b/src/gui/guildlistbox.cpp
@@ -1,6 +1,6 @@
/*
* The Mana World
- * Copyright 2004 The Mana World Development Team
+ * Copyright 2008 The Mana World Development Team
*
* This file is part of The Mana World.
*
@@ -18,25 +18,32 @@
* along with The Mana World; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id$
+ * $Id $
*/
#include "guildlistbox.h"
#include "../graphics.h"
+#include "../resources/image.h"
+#include "../resources/resourcemanager.h"
+
#include <guichan/font.hpp>
GuildListBox::GuildListBox():
ListBox(NULL)
{
+ onlineIcon = ResourceManager::getInstance()->getImage("graphics/gui/circle-green.png");
+ offlineIcon = ResourceManager::getInstance()->getImage("graphics/gui/circle-gray.png");
}
-void GuildListBox::draw(gcn::Graphics *graphics)
+void GuildListBox::draw(gcn::Graphics *gcnGraphics)
{
if (!mListModel)
return;
+ Graphics *graphics = static_cast<Graphics*>(gcnGraphics);
+
graphics->setColor(gcn::Color(110, 160, 255));
graphics->setFont(getFont());
@@ -48,17 +55,22 @@ void GuildListBox::draw(gcn::Graphics *graphics)
getWidth(), fontHeight));
}
- // TODO: Add online status image
-
// Draw the list elements
for (int i = 0, y = 0;
i < mListModel->getNumberOfElements();
++i, y += fontHeight)
{
- graphics->drawText(mListModel->getElementAt(i), 1, y);
+ // Draw online status
+ bool online = mUsers[mListModel->getElementAt(i)];
+ Image *icon = online ? onlineIcon : offlineIcon;
+ if (icon)
+ graphics->drawImage(icon, 1, y);
+ // Draw Name
+ graphics->setColor(gcn::Color(0, 0, 0));
+ graphics->drawText(mListModel->getElementAt(i), 33, y);
}
}
-
+/*
void GuildListBox::setSelected(int selected)
{
if (!mListModel)
@@ -84,14 +96,19 @@ void GuildListBox::setSelected(int selected)
distributeValueChangedEvent();
}
-
+*/
void GuildListBox::mousePressed(gcn::MouseEvent &event)
{
if (event.getButton() == gcn::MouseEvent::LEFT)
{
- // TODO: Add guild functions, ie private messaging
int y = event.getY();
setSelected(y / getFont()->getHeight());
distributeActionEvent();
}
+ // TODO: Add guild functions, ie private messaging
+}
+
+void GuildListBox::setOnlineStatus(const std::string &user, bool online)
+{
+ mUsers[user] = online;
}