diff options
author | David Athay <ko2fan@gmail.com> | 2008-11-25 16:50:21 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-01-05 00:39:27 +0100 |
commit | 8b6bfeb0a70d4f97cc2d20ce04fc240b65082cf1 (patch) | |
tree | 7c7e0b52b72e6d09970522faecdf10163c8e080b | |
parent | 98c58bb9d3d39e4edbff05387b905a6c0fffa85d (diff) | |
download | mana-8b6bfeb0a70d4f97cc2d20ce04fc240b65082cf1.tar.gz mana-8b6bfeb0a70d4f97cc2d20ce04fc240b65082cf1.tar.bz2 mana-8b6bfeb0a70d4f97cc2d20ce04fc240b65082cf1.tar.xz mana-8b6bfeb0a70d4f97cc2d20ce04fc240b65082cf1.zip |
Add buddy window
-rw-r--r-- | src/game.cpp | 8 | ||||
-rw-r--r-- | src/gui/buddywindow.cpp | 65 | ||||
-rw-r--r-- | src/gui/buddywindow.h | 8 | ||||
-rw-r--r-- | src/gui/menuwindow.cpp | 6 |
4 files changed, 35 insertions, 52 deletions
diff --git a/src/game.cpp b/src/game.cpp index df6d5578..8ea0d420 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -44,6 +44,7 @@ #include "particle.h" #include "effectmanager.h" +#include "gui/buddywindow.h" #include "gui/buy.h" #include "gui/buysell.h" //#include "gui/chargedialog.h" @@ -125,7 +126,7 @@ Minimap *minimap; EquipmentWindow *equipmentWindow; //ChargeDialog *chargeDialog; TradeWindow *tradeWindow; -//BuddyWindow *buddyWindow; +BuddyWindow *buddyWindow; GuildWindow *guildWindow; HelpWindow *helpWindow; DebugWindow *debugWindow; @@ -213,7 +214,7 @@ void createGuiWindows() equipmentWindow = new EquipmentWindow(player_node->mEquipment.get()); //chargeDialog = new ChargeDialog(); tradeWindow = new TradeWindow; - //buddyWindow = new BuddyWindow(); + buddyWindow = new BuddyWindow(); guildWindow = new GuildWindow(); helpWindow = new HelpWindow(); debugWindow = new DebugWindow(); @@ -263,7 +264,7 @@ void destroyGuiWindows() //delete chargeDialog; //delete newSkillWindow; delete tradeWindow; - //delete buddyWindow; + delete buddyWindow; delete guildWindow; delete helpWindow; delete debugWindow; @@ -665,6 +666,7 @@ void Game::handleInput() helpWindow->setVisible(false); debugWindow->setVisible(false); guildWindow->setVisible(false); + buddyWindow->setVisible(false); } break; } diff --git a/src/gui/buddywindow.cpp b/src/gui/buddywindow.cpp index 14a941a5..0535f837 100644 --- a/src/gui/buddywindow.cpp +++ b/src/gui/buddywindow.cpp @@ -20,64 +20,41 @@ */ #include "buddywindow.h" - -#include <guichan/widgets/listbox.hpp> - -#include "button.h" #include "chat.h" -#include "scrollarea.h" +#include "icon.h" + +#include "widgets/avatar.h" -#include "../resources/buddylist.h" +#include "../resources/resourcemanager.h" +#include "../utils/gettext.h" extern ChatWindow *chatWindow; BuddyWindow::BuddyWindow(): - Window("Buddy") + Window(_("Buddy")) { + setVisible(false); setContentSize(124, 202); + setCaption(_("Buddy List")); + setResizable(true); + setCloseButton(true); - mBuddyList = new BuddyList(); - - mListbox = new gcn::ListBox(); - mListbox->setListModel(mBuddyList); - - ScrollArea *scrollArea = new ScrollArea(mListbox); - scrollArea->setDimension(gcn::Rectangle( - 7, 5, 110, 170)); - add(scrollArea); + Image *addImg = ResourceManager::getInstance()->getImage("buddyadd.png"); + Image *delImg = ResourceManager::getInstance()->getImage("buddydel.png"); - Button *talk = new Button("Talk", "Talk", this); - Button *remove = new Button("Remove", "Remove", this); - Button *cancel = new Button("Cancel", "Cancel", this); + if (addImg && delImg) + { + Icon *addBuddy = new Icon(addImg); + Icon *delBuddy = new Icon(delImg); - talk->setPosition(2,180); - remove->setPosition(talk->getWidth()+2,180); - cancel->setPosition(talk->getWidth()+remove->getWidth()+2,180); + add(addBuddy); + add(delBuddy); + } - add(talk); - add(remove); - add(cancel); + loadWindowState("Buddy"); } void BuddyWindow::action(const gcn::ActionEvent &event) { - if (event.getId() == "Talk") { - int selected = mListbox->getSelected(); - if ( selected > -1 ) - { - std::string who = mBuddyList->getElementAt(selected); - chatWindow->setInputText(who +": "); - } - } - else if (event.getId() == "Remove") { - int selected = mListbox->getSelected(); - if ( selected > -1 ) - { - std::string who = mBuddyList->getElementAt(selected); - mBuddyList->removeBuddy(who); - } - } - else if (event.getId() == "Cancel") { - setVisible(false); - } + } diff --git a/src/gui/buddywindow.h b/src/gui/buddywindow.h index 6b07f470..15594b63 100644 --- a/src/gui/buddywindow.h +++ b/src/gui/buddywindow.h @@ -23,12 +23,11 @@ #define _TMW_BUDDYWINDOW_H #include <guichan/actionlistener.hpp> +#include <guichan/actionevent.hpp> #include "window.h" -#include "../guichanfwd.h" - -class BuddyList; +class Avatar; /** * Window showing buddy list. @@ -49,8 +48,7 @@ class BuddyWindow : public Window, public gcn::ActionListener void action(const gcn::ActionEvent &event); private: - BuddyList *mBuddyList; - gcn::ListBox *mListbox; + std::list<Avatar*> mBuddyList; }; #endif /* _TMW_BUDDYWINDOW_H */ diff --git a/src/gui/menuwindow.cpp b/src/gui/menuwindow.cpp index dbbb08d2..f74dfa41 100644 --- a/src/gui/menuwindow.cpp +++ b/src/gui/menuwindow.cpp @@ -38,6 +38,7 @@ extern Window *magicDialog; extern Window *statusWindow; extern Window *guildWindow; extern Window *itemShortcutWindow; +extern Window *buddyWindow; namespace { struct MenuWindowListener : public gcn::ActionListener @@ -65,6 +66,7 @@ MenuWindow::MenuWindow(): N_("Skills"), N_("Magic"), N_("Guilds"), + N_("Buddys"), N_("Shortcut"), N_("Setup"), 0 @@ -118,6 +120,10 @@ void MenuWindowListener::action(const gcn::ActionEvent &event) { window = guildWindow; } + else if (event.getId() == "Buddys") + { + window = buddyWindow; + } else if (event.getId() == "Shortcut") { window = itemShortcutWindow; |