diff options
author | Mateusz Kaduk <mateusz.kaduk@gmail.com> | 2005-06-16 08:30:34 +0000 |
---|---|---|
committer | Mateusz Kaduk <mateusz.kaduk@gmail.com> | 2005-06-16 08:30:34 +0000 |
commit | 8d801b2c43f7dfd0b279bb263480d38f5694ac06 (patch) | |
tree | 82b3382ad67d297373cec74a74d7db60b3dd4def /src/engine.cpp | |
parent | 06afc063b8538b90b8dd8eb662a9ae0e11812963 (diff) | |
download | mana-8d801b2c43f7dfd0b279bb263480d38f5694ac06.tar.gz mana-8d801b2c43f7dfd0b279bb263480d38f5694ac06.tar.bz2 mana-8d801b2c43f7dfd0b279bb263480d38f5694ac06.tar.xz mana-8d801b2c43f7dfd0b279bb263480d38f5694ac06.zip |
Added action menu (moved trading to menu)
Diffstat (limited to 'src/engine.cpp')
-rw-r--r-- | src/engine.cpp | 48 |
1 files changed, 44 insertions, 4 deletions
diff --git a/src/engine.cpp b/src/engine.cpp index bca79219..64015153 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -87,6 +87,37 @@ char hairtable[16][4][2] = { { { 0, 16}, {-1, 6}, {-1, 6}, { 0, 6} } // DEAD }; +/** + * Listener used for trading request + */ +class tradeItemListener : public gcn::MouseListener +{ + void mouseClick(int x, int y, int button, int count) + { + Being *target = menu->getBeing(); + + // Begin a trade + WFIFOW(0) = net_w_value(0x00e4); + WFIFOL(2) = net_l_value(target->id); + WFIFOSET(6); + std::cout << "Clicked trade" << std::endl; + menu->setVisible(!menu->isVisible()); + } +}; + +/** + * Listener used for buddy request + */ +class buddyItemListener : public gcn::MouseListener +{ + void mouseClick(int x, int y, int button, int count) + { + std::cout << "Clicked buddy" << std::endl; + //buddyWindow->setVisible(!buddyWindow->isVisible()); + menu->setVisible(!menu->isVisible()); + } +}; + int get_x_offset(Being *being) { int offset = 0; @@ -165,11 +196,20 @@ Engine::Engine(): buddyWindow = new BuddyWindow(); helpWindow = new HelpWindow(); - /* Menu items */ + /** + * Menu items + */ std::vector<MenuItem*> items; - items.push_back(new MenuItem("First")); - items.push_back(new MenuItem("Second")); - menu = new Menu("Menu", items); + + MenuItem *tradeItem = new MenuItem("Trade"); + tradeItem->addMouseListener(new tradeItemListener()); + items.push_back(tradeItem); + + MenuItem *buddyItem = new MenuItem("Buddy"); + buddyItem->addMouseListener(new buddyItemListener()); + items.push_back(buddyItem); + + menu = new Menu(items); // Initialize window posisitons chatWindow->setPosition(0, screen->h - chatWindow->getHeight()); |