From e2e4ceb9fa8a72ad94853f74724676fff82b15c0 Mon Sep 17 00:00:00 2001 From: David Athay Date: Tue, 15 Apr 2008 15:42:04 +0000 Subject: Added online status of guild members --- src/gui/guildlistbox.cpp | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) (limited to 'src/gui/guildlistbox.cpp') 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 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(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; } -- cgit v1.2.3-70-g09d2