diff options
author | Joshua Langley <joshlangley[at]optusnet.com.au> | 2007-08-14 05:59:52 +0000 |
---|---|---|
committer | Joshua Langley <joshlangley[at]optusnet.com.au> | 2007-08-14 05:59:52 +0000 |
commit | 0601642d8b3aa2c7aa365e27aa3ef2459553c3fd (patch) | |
tree | e2c4a93c3aca4b35b69857b17b722c3260b4c3d1 /src/gui/itemcontainer.h | |
parent | 68f069fea3182c6d5720df03f1d63de38f14c31d (diff) | |
download | mana-client-0601642d8b3aa2c7aa365e27aa3ef2459553c3fd.tar.gz mana-client-0601642d8b3aa2c7aa365e27aa3ef2459553c3fd.tar.bz2 mana-client-0601642d8b3aa2c7aa365e27aa3ef2459553c3fd.tar.xz mana-client-0601642d8b3aa2c7aa365e27aa3ef2459553c3fd.zip |
mantis_id:129 - Inventory Window Slots Added.
Diffstat (limited to 'src/gui/itemcontainer.h')
-rw-r--r-- | src/gui/itemcontainer.h | 71 |
1 files changed, 58 insertions, 13 deletions
diff --git a/src/gui/itemcontainer.h b/src/gui/itemcontainer.h index 8c548fcd..38dc9f6e 100644 --- a/src/gui/itemcontainer.h +++ b/src/gui/itemcontainer.h @@ -24,7 +24,9 @@ #ifndef _TMW_ITEMCONTAINER_H__ #define _TMW_ITEMCONTAINER_H__ +#include <guichan/keylistener.hpp> #include <guichan/mouselistener.hpp> + #include <guichan/widget.hpp> #include <list> @@ -39,13 +41,18 @@ class SelectionListener; * * \ingroup GUI */ -class ItemContainer : public gcn::Widget, public gcn::MouseListener +class ItemContainer : public gcn::Widget, + public gcn::KeyListener, + public gcn::MouseListener { public: /** * Constructor. Initializes the graphic. + * @param inventory + * @param gridColumns Amount of columns in grid. + * @param gridRows Amount of rows in grid. */ - ItemContainer(Inventory *inventory); + ItemContainer(Inventory *inventory, int gridColumns, int gridRows); /** * Destructor. @@ -53,20 +60,19 @@ class ItemContainer : public gcn::Widget, public gcn::MouseListener virtual ~ItemContainer(); /** - * Handles the logic of the ItemContainer + * Draws the items. */ - void logic(); + void draw(gcn::Graphics *graphics); /** - * Draws the items. + * Handles the key presses. */ - void draw(gcn::Graphics *graphics); + void keyPressed(gcn::KeyEvent &event); /** - * Sets the width of the container. This is used to determine the new - * height of the container. + * Handles the key releases. */ - void setWidth(int width); + void keyReleased(gcn::KeyEvent &event); /** * Handles mouse click. @@ -74,9 +80,20 @@ class ItemContainer : public gcn::Widget, public gcn::MouseListener void mousePressed(gcn::MouseEvent &event); /** + * Handles mouse dragged. + */ + void mouseDragged(gcn::MouseEvent &event); + + /** + * Handles mouse released. + */ + void mouseReleased(gcn::MouseEvent &event); + + /** * Returns the selected item. */ - Item* getItem(); + Item* getItem() const + { return mSelectedItem; } /** * Sets selected item to NULL. @@ -101,8 +118,26 @@ class ItemContainer : public gcn::Widget, public gcn::MouseListener mListeners.remove(listener); } + enum { + MOVE_SELECTED_LEFT, // 0 + MOVE_SELECTED_RIGHT, // 1 + MOVE_SELECTED_UP, // 2 + MOVE_SELECTED_DOWN // 3 + }; private: /** + * Execute all the functionality associated with the action key. + */ + void keyAction(); + + /** + * Moves the highlight in the direction specified. + * + * @param direction The move direction of the highlighter. + */ + void moveHighlight(int direction); + + /** * Sets the currently selected item. */ void setSelectedItem(Item *item); @@ -112,11 +147,21 @@ class ItemContainer : public gcn::Widget, public gcn::MouseListener */ void fireSelectionChangedEvent(); + /** + * Gets the slot index based on the cursor position. + * + * @param posX The X Coordinate position. + * @param posY The Y Coordinate position. + * @return The slot index on success, -1 on failure. + */ + int getSlotIndex(const int posX, const int posY) const; + Inventory *mInventory; + int mGridColumns, mGridRows; Image *mSelImg; - Item *mSelectedItem; - - int mMaxItems; + Item *mSelectedItem, *mHighlightedItem; + bool mDragged, mSwapItems; + int mDragPosX, mDragPosY; std::list<SelectionListener*> mListeners; }; |