From 354ca55186072cd152f3b13d58985b87e55d8e42 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Mon, 26 Jan 2009 20:57:29 -0700 Subject: Cleaned up inventory includes, as well as adding right click popup menus to the item shortcut container. Signed-off-by: Ira Rice --- src/gui/itemshortcutcontainer.cpp | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'src/gui/itemshortcutcontainer.cpp') 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 +#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) -- cgit v1.2.3-70-g09d2