summaryrefslogtreecommitdiff
path: root/src
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
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')
-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)