summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rw-r--r--src/engine.cpp48
-rw-r--r--src/game.cpp14
-rw-r--r--src/gui/menu.cpp14
-rw-r--r--src/gui/menu.h13
5 files changed, 74 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 601bab05..4087e429 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,5 @@
0.0.14 (3 July 2005)
+- Added action menu (moved trading to action menu)
- Added support for map properties (to be used for music and minimap settings)
- Added background image to minimap
- Fixed window resizing (applies to inventory window)
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());
diff --git a/src/game.cpp b/src/game.cpp
index f6a2133f..95a74568 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -61,6 +61,8 @@ Engine *engine = NULL;
OkDialog *deathNotice = NULL;
ConfirmDialog *exitConfirm = NULL;
+Being *target = NULL;
+
#define EMOTION_TIME 150
#define MAX_TIME 10000
@@ -322,10 +324,6 @@ void do_input()
// buddyWindow->setVisible(!buddyWindow->isVisible());
// used = true;
//}
- //else if (keysym.sym == SDLK_m) {
- // menu->setVisible(!menu->isVisible());
- // used = true;
- //}
}
if (event.key.keysym.sym == SDLK_ESCAPE)
@@ -416,10 +414,10 @@ void do_input()
attack(target);
}
else if (target->isPlayer()) {
- // Begin a trade
- WFIFOW(0) = net_w_value(0x00e4);
- WFIFOL(2) = net_l_value(target->id);
- WFIFOSET(6);
+ // Show menu
+ menu->setVisible(!menu->isVisible());
+ // Pass target to menu
+ menu->setBeing(target);
}
}
}
diff --git a/src/gui/menu.cpp b/src/gui/menu.cpp
index 9c648db4..d8b2e6de 100644
--- a/src/gui/menu.cpp
+++ b/src/gui/menu.cpp
@@ -23,8 +23,8 @@
#include "menu.h"
-Menu::Menu(const std::string& menulabel, std::vector<MenuItem *> items):
- Window(menulabel)
+Menu::Menu(std::vector<MenuItem *> items):
+ Window("")
{
setContentSize(52,60);
fill(items);
@@ -52,3 +52,13 @@ void Menu::fill(std::vector<MenuItem *> items)
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
index 5d905c86..040c9a9d 100644
--- a/src/gui/menu.h
+++ b/src/gui/menu.h
@@ -25,15 +25,16 @@
#define _TMW_MENU_H
#include <guichan.hpp>
-#include "menuitem.h"
#include "window.h"
+#include "menuitem.h"
+#include "../being.h"
class Menu : public Window {
public:
/**
* Constructor.
*/
- Menu(const std::string& menulabel, std::vector<MenuItem *> items);
+ Menu(std::vector<MenuItem *> items);
/**
* Destructor.
@@ -45,6 +46,14 @@ class Menu : public Window {
*/
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 */