summaryrefslogtreecommitdiff
path: root/src/gui/itemshortcutcontainer.cpp
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2009-01-26 20:57:29 -0700
committerIra Rice <irarice@gmail.com>2009-01-26 20:57:29 -0700
commit354ca55186072cd152f3b13d58985b87e55d8e42 (patch)
tree06b9a90ce70aa50c430e3b77e04820201fe147e8 /src/gui/itemshortcutcontainer.cpp
parentebc287a74689cfd283bd3a87d8969f3e689b6aa6 (diff)
downloadmana-354ca55186072cd152f3b13d58985b87e55d8e42.tar.gz
mana-354ca55186072cd152f3b13d58985b87e55d8e42.tar.bz2
mana-354ca55186072cd152f3b13d58985b87e55d8e42.tar.xz
mana-354ca55186072cd152f3b13d58985b87e55d8e42.zip
Cleaned up inventory includes, as well as adding right click popup menus
to the item shortcut container. Signed-off-by: Ira Rice <irarice@gmail.com>
Diffstat (limited to 'src/gui/itemshortcutcontainer.cpp')
-rw-r--r--src/gui/itemshortcutcontainer.cpp33
1 files changed, 27 insertions, 6 deletions
diff --git a/src/gui/itemshortcutcontainer.cpp b/src/gui/itemshortcutcontainer.cpp
index 8803ab15..83d8c9fb 100644
--- a/src/gui/itemshortcutcontainer.cpp
+++ b/src/gui/itemshortcutcontainer.cpp
@@ -20,8 +20,10 @@
*/
#include <SDL_mouse.h>
+#include "gui.h"
#include "itemshortcutcontainer.h"
#include "itempopup.h"
+#include "viewport.h"
#include "../configuration.h"
#include "../graphics.h"
@@ -172,14 +174,33 @@ void ItemShortcutContainer::mousePressed(gcn::MouseEvent &event)
if (index == -1)
return;
- // Stores the selected item if theirs one.
- if (itemShortcut->isItemSelected())
+ if (event.getButton() == gcn::MouseEvent::LEFT)
{
- itemShortcut->setItem(index);
- itemShortcut->setItemSelected(-1);
+
+ // Stores the selected item if theirs one.
+ if (itemShortcut->isItemSelected())
+ {
+ itemShortcut->setItem(index);
+ itemShortcut->setItemSelected(-1);
+ }
+ else if (itemShortcut->getItem(index))
+ mItemClicked = true;
+ }
+ else if (event.getButton() == gcn::MouseEvent::RIGHT)
+ {
+ Item *item = player_node->getInventory()->
+ findItem(itemShortcut->getItem(index));
+
+ if (!item)
+ return;
+
+ /* Convert relative to the window coordinates to absolute screen
+ * coordinates.
+ */
+ int mx, my;
+ SDL_GetMouseState(&mx, &my);
+ viewport->showPopup(mx, my, item);
}
- else if (itemShortcut->getItem(index))
- mItemClicked = true;
}
void ItemShortcutContainer::mouseReleased(gcn::MouseEvent &event)