summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/inventorywindow.cpp1
-rw-r--r--src/gui/inventorywindow.h4
-rw-r--r--src/gui/itemshortcutcontainer.cpp33
3 files changed, 30 insertions, 8 deletions
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index fe3300dc..e0e496f7 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -33,6 +33,7 @@
#include "itemcontainer.h"
#include "progressbar.h"
#include "scrollarea.h"
+#include "textbox.h"
#include "viewport.h"
#include "widgets/layout.h"
diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h
index 93b9c572..2c19ce26 100644
--- a/src/gui/inventorywindow.h
+++ b/src/gui/inventorywindow.h
@@ -25,7 +25,6 @@
#include <guichan/actionlistener.hpp>
#include <guichan/selectionlistener.hpp>
-#include "textbox.h"
#include "window.h"
#include "../guichanfwd.h"
@@ -34,6 +33,7 @@
class Item;
class ItemContainer;
class ProgressBar;
+class TextBox;
/**
* Inventory dialog.
@@ -41,7 +41,7 @@ class ProgressBar;
* \ingroup Interface
*/
class InventoryWindow : public Window, gcn::ActionListener,
- gcn::SelectionListener
+ gcn::SelectionListener
{
public:
/**
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)