diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-03-27 18:54:04 +0100 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-03-27 18:57:04 +0100 |
commit | 4b70908a529317ce4e57448fe4f4a59e75416537 (patch) | |
tree | a041eeed198708bf5f558f595f716c7814961daf /src/gui/itemcontainer.h | |
parent | 372f6493d07cbffb601ecb775ebecd51267725cf (diff) | |
download | mana-client-4b70908a529317ce4e57448fe4f4a59e75416537.tar.gz mana-client-4b70908a529317ce4e57448fe4f4a59e75416537.tar.bz2 mana-client-4b70908a529317ce4e57448fe4f4a59e75416537.tar.xz mana-client-4b70908a529317ce4e57448fe4f4a59e75416537.zip |
Fixed inventory window. Not resizable though.
Resizing of the inventory window may come back later. Also did some more
code cleanups, moving defines to enums, getting rid of eAthena-specific
offset handling (to be done in the network layer), etc.
Mantis-issue: 666
Diffstat (limited to 'src/gui/itemcontainer.h')
-rw-r--r-- | src/gui/itemcontainer.h | 57 |
1 files changed, 24 insertions, 33 deletions
diff --git a/src/gui/itemcontainer.h b/src/gui/itemcontainer.h index 38eaba01..a28ca392 100644 --- a/src/gui/itemcontainer.h +++ b/src/gui/itemcontainer.h @@ -22,12 +22,12 @@ #ifndef ITEMCONTAINER_H #define ITEMCONTAINER_H -#include <list> - #include <guichan/keylistener.hpp> #include <guichan/mouselistener.hpp> #include <guichan/widget.hpp> +#include <list> + class Image; class Inventory; class Item; @@ -49,13 +49,13 @@ class ItemContainer : public gcn::Widget, public: /** * Constructor. Initializes the graphic. + * * @param inventory * @param gridColumns Amount of columns in grid. * @param gridRows Amount of rows in grid. * @param offset Index offset */ - ItemContainer(Inventory *inventory, int gridColumns, int gridRows, - int offset = 0); + ItemContainer(Inventory *inventory, int gridColumns, int gridRows); /** * Destructor. @@ -67,35 +67,16 @@ class ItemContainer : public gcn::Widget, */ void draw(gcn::Graphics *graphics); - /** - * Handles the key presses. - */ void keyPressed(gcn::KeyEvent &event); - - /** - * Handles the key releases. - */ void keyReleased(gcn::KeyEvent &event); - - /** - * Handles mouse click. - */ 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* getSelectedItem() const + Item *getSelectedItem() const { return mSelectedItem; } /** @@ -121,13 +102,24 @@ class ItemContainer : public gcn::Widget, mSelectionListeners.remove(listener); } - enum { - MOVE_SELECTED_LEFT, // 0 - MOVE_SELECTED_RIGHT, // 1 - MOVE_SELECTED_UP, // 2 - MOVE_SELECTED_DOWN // 3 - }; private: + enum Direction + { + Left, + Right, + Up, + Down + }; + + enum SelectionState + { + SEL_NONE = 0, + SEL_SELECTED, + SEL_SELECTING, + SEL_DESELECTING, + SEL_DRAGGING + }; + /** * Execute all the functionality associated with the action key. */ @@ -141,7 +133,7 @@ class ItemContainer : public gcn::Widget, * * @param direction The move direction of the highlighter. */ - void moveHighlight(int direction); + void moveHighlight(Direction direction); /** * Sets the currently selected item. @@ -174,10 +166,9 @@ class ItemContainer : public gcn::Widget, Inventory *mInventory; int mGridColumns, mGridRows; - int mOffset; Image *mSelImg; Item *mSelectedItem, *mHighlightedItem; - int mSelectionStatus; + SelectionState mSelectionStatus; bool mSwapItems; bool mDescItems; int mDragPosX, mDragPosY; |