summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMateusz Kaduk <mateusz.kaduk@gmail.com>2005-06-18 13:36:54 +0000
committerMateusz Kaduk <mateusz.kaduk@gmail.com>2005-06-18 13:36:54 +0000
commit6040daae3201e4a4cc55c2754c73225752fd4c5f (patch)
tree7f1c15a6bd50b6c1773077e28f736c11178c79d8 /src
parent275b80eca0ecc71262b4ca8aeba6e7501f711d43 (diff)
downloadmana-6040daae3201e4a4cc55c2754c73225752fd4c5f.tar.gz
mana-6040daae3201e4a4cc55c2754c73225752fd4c5f.tar.bz2
mana-6040daae3201e4a4cc55c2754c73225752fd4c5f.tar.xz
mana-6040daae3201e4a4cc55c2754c73225752fd4c5f.zip
Showing buddyWindow
Diffstat (limited to 'src')
-rw-r--r--src/gui/buddywindow.cpp37
-rw-r--r--src/gui/buddywindow.h4
-rw-r--r--src/gui/menu.cpp64
-rw-r--r--src/gui/menu.h59
-rw-r--r--src/gui/menuitem.cpp115
-rw-r--r--src/gui/menuitem.h53
-rw-r--r--src/gui/popupmenu.cpp6
7 files changed, 42 insertions, 296 deletions
diff --git a/src/gui/buddywindow.cpp b/src/gui/buddywindow.cpp
index b57b32dd..d5e9e7a0 100644
--- a/src/gui/buddywindow.cpp
+++ b/src/gui/buddywindow.cpp
@@ -22,28 +22,45 @@
*/
#include "buddywindow.h"
-#include "menu.h"
BuddyWindow::BuddyWindow():
Window("Buddys")
{
- setContentSize(80, 200);
+ setContentSize(120, 200);
listbox = new gcn::ListBox();
listbox->setListModel(dynamic_cast<ListModel*>(this));
scrollArea = new ScrollArea(listbox);
scrollArea->setDimension(gcn::Rectangle(
- 2, 0, 76, 180));
+ 2, 0, 116, 180));
add(scrollArea);
- addBuddy("Usiu"); // for testing
+ talk = new Button("Talk");
+ talk->setPosition(1,180);
+ talk->addActionListener(this);
+ talk->setEventId("Talk");
+ remove = new Button("Remove");
+ remove->addActionListener(this);
+ remove->setEventId("Remove");
+ remove->setPosition(talk->getWidth()+2,180);
+ cancel = new Button("Cancel");
+ cancel->addActionListener(this);
+ cancel->setEventId("Cancel");
+ cancel->setPosition(talk->getWidth()+remove->getWidth()+2,180);
+
+ add(talk);
+ add(remove);
+ add(cancel);
}
BuddyWindow::~BuddyWindow()
{
delete listbox;
delete scrollArea;
+ delete talk;
+ delete remove;
+ delete cancel;
}
void BuddyWindow::draw(gcn::Graphics *graphics)
@@ -54,5 +71,17 @@ void BuddyWindow::draw(gcn::Graphics *graphics)
void BuddyWindow::action(const std::string& eventId)
{
+ if(eventId.compare("Cancel")) {
+ setVisible(false);
+ }
+ /*
+ else if(eventId.compare("Remove")) {
+ int selected = listbox->getSelected();
+ std::string who = this->getElementAt(selected);
+ removeBuddy(who);
+ } else if(eventId.compare("Talk")) {
+ // TODO
+ }
+ */
}
diff --git a/src/gui/buddywindow.h b/src/gui/buddywindow.h
index a884ba6f..a4221700 100644
--- a/src/gui/buddywindow.h
+++ b/src/gui/buddywindow.h
@@ -27,6 +27,7 @@
#include <guichan.hpp>
#include "window.h"
#include "scrollarea.h"
+#include "button.h"
#include "../resources/buddylist.h"
/**
@@ -61,6 +62,9 @@ class BuddyWindow : public Window, public BuddyList,
private:
gcn::ListBox *listbox;
ScrollArea *scrollArea;
+ Button *talk;
+ Button *remove;
+ Button *cancel;
};
#endif /* _TMW_BUDDYWINDOW_H */
diff --git a/src/gui/menu.cpp b/src/gui/menu.cpp
deleted file mode 100644
index d8b2e6de..00000000
--- a/src/gui/menu.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * The Mana World
- * Copyright 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * The Mana World is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * The Mana World is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * 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$
- */
-
-#include "menu.h"
-
-Menu::Menu(std::vector<MenuItem *> items):
- Window("")
-{
- setContentSize(52,60);
- fill(items);
-}
-
-Menu::~Menu()
-{
-}
-
-void Menu::fill(std::vector<MenuItem *> items)
-{
- int i=0;
-
- for(std::vector<MenuItem *>::iterator item = items.begin();
- item != items.end(); ++item)
- {
- MenuItem *optr;
- optr = *item;
- optr->setSize(50,10);
- optr->setPosition(0,i);
- i=i+10;
- add(*item);
- }
-
- resizeToContent();
-}
-
-void Menu::setBeing(Being *target)
-{
- where = target;
-}
-
-Being * Menu::getBeing()
-{
- return where;
-}
-
diff --git a/src/gui/menu.h b/src/gui/menu.h
deleted file mode 100644
index 040c9a9d..00000000
--- a/src/gui/menu.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * The Mana World
- * Copyright 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * The Mana World is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * The Mana World is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * 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$
- */
-
-#ifndef _TMW_MENU_H
-#define _TMW_MENU_H
-
-#include <guichan.hpp>
-#include "window.h"
-#include "menuitem.h"
-#include "../being.h"
-
-class Menu : public Window {
- public:
- /**
- * Constructor.
- */
- Menu(std::vector<MenuItem *> items);
-
- /**
- * Destructor.
- */
- ~Menu();
-
- /**
- * Fill menu with menuitems
- */
- void fill(std::vector<MenuItem *> items);
-
- /**
- * Set/get begin
- */
- void setBeing(Being *target);
- Being * getBeing(void);
-
- private:
- Being *where; // Where to display
-};
-
-#endif /* _TMW_MENU_H */
diff --git a/src/gui/menuitem.cpp b/src/gui/menuitem.cpp
deleted file mode 100644
index 490e2f61..00000000
--- a/src/gui/menuitem.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * The Mana World
- * Copyright 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * The Mana World is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * The Mana World is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * 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$
- */
-
-#include "menuitem.h"
-#include "../resources/resourcemanager.h"
-#include <guichan/mouseinput.hpp>
-
-MenuItem::MenuItem(const std::string& label):
- gcn::Button(label)
-{
- setBorderSize(0);
-
- // Load graphic
- Image *item[4];
-
- ResourceManager *resman = ResourceManager::getInstance();
-
- item[0] = resman->getImage("graphics/gui/menuitemN.png");
- item[1] = resman->getImage("graphics/gui/menuitemF.png");
- item[2] = resman->getImage("graphics/gui/menuitemP.png");
- item[3] = resman->getImage("graphics/gui/menuitemD.png");
-
- int bgridx[4] = {0, 9, 16, 25};
- int bgridy[4] = {0, 4, 19, 24};
- int a, x, y;
-
- for (int mode = 0; mode < 4; mode++) {
- a = 0;
- for (y = 0; y < 3; y++) {
- for (x = 0; x < 3; x++) {
- menuitem[mode].grid[a] = item[mode]->getSubImage(
- bgridx[x], bgridy[y],
- bgridx[x + 1] - bgridx[x] + 1,
- bgridy[y + 1] - bgridy[y] + 1);
- a++;
- }
- }
- }
- addMouseListener(this);
-}
-
-MenuItem::~MenuItem()
-{
-}
-
-void MenuItem::draw(gcn::Graphics* graphics)
-{
- int mode;
-
- if (!isEnabled()) {
- mode = 3;
- }
- else if (isPressed()) {
- mode = 2;
- }
- else if (hasMouse()) {
- mode = 1;
- }
- else {
- mode = 0;
- }
-
- int x, y;
- getAbsolutePosition(x, y);
-
- ((Graphics*)graphics)->drawImageRect(x, y, getWidth(), getHeight(),
- menuitem[mode]);
- graphics->setColor(getForegroundColor());
-
- int textX;
- int textY = getHeight() / 2 - getFont()->getHeight() / 2;
-
- switch (getAlignment()) {
- case gcn::Graphics::LEFT:
- textX = 4;
- break;
- case gcn::Graphics::CENTER:
- textX = getWidth() / 2;
- break;
- case gcn::Graphics::RIGHT:
- textX = getWidth() - 4;
- break;
- default:
- throw GCN_EXCEPTION("Button::draw. Uknown alignment.");
- }
-
- graphics->setFont(getFont());
-
- if (isPressed()) {
- graphics->drawText(getCaption(), textX + 1, textY + 1, getAlignment());
- }
- else {
- graphics->drawText(getCaption(), textX, textY, getAlignment());
- }
-}
diff --git a/src/gui/menuitem.h b/src/gui/menuitem.h
deleted file mode 100644
index d83a9095..00000000
--- a/src/gui/menuitem.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * The Mana World
- * Copyright 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * The Mana World is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * The Mana World is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * 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$
- */
-
-#ifndef _TMW_MENUITEM_H
-#define _TMW_MENUITEM_H
-
-#include <guichan.hpp>
-#include "../resources/image.h"
-#include "../graphics.h"
-
-class MenuItem : public gcn::Button
-{
- public:
- /**
- * Constructor.
- */
- MenuItem(const std::string& label);
-
- /**
- * Destructor.
- */
- ~MenuItem();
-
- /**
- * Draws the MenuItem.
- */
- void draw(gcn::Graphics* graphics);
-
- private:
- ImageRect menuitem[4];
-};
-
-#endif /* _TMW_MENUITEM_H */
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index c56bdfc8..205a768f 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -174,8 +174,12 @@ void PopupMenu::handleLink(const std::string& link)
}
// Add Buddy action
- else if (link == "buddy")
+ else if ((link == "buddy") && being && being->isPlayer())
{
+ if(!buddyWindow->isVisible())
+ buddyWindow->setVisible(true);
+
+ buddyWindow->addBuddy(being->name);
}
// Pick Up Floor Item action