ManaPlus
inventorywindow.h
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2004-2009 The Mana World Development Team
4  * Copyright (C) 2009-2010 The Mana Developers
5  * Copyright (C) 2011-2019 The ManaPlus Developers
6  * Copyright (C) 2019-2021 Andrei Karas
7  *
8  * This file is part of The ManaPlus Client.
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  */
23 
24 #ifndef GUI_WINDOWS_INVENTORYWINDOW_H
25 #define GUI_WINDOWS_INVENTORYWINDOW_H
26 
28 
29 #include "gui/widgets/window.h"
30 
34 #include "listeners/keylistener.h"
36 
37 class Button;
38 class DropDown;
39 class InventoryWindow;
40 class Item;
41 class ItemContainer;
42 class LayoutCell;
43 class ProgressBar;
44 class SortListModelInv;
45 class TabStrip;
46 class TextField;
47 
51 
57 class InventoryWindow final : public Window,
58  public ActionListener,
59  public KeyListener,
60  public SelectionListener,
61  public InventoryListener,
62  public AttributeListener
63 {
64  public:
68  explicit InventoryWindow(Inventory *const inventory);
69 
71 
72 
75  ~InventoryWindow() override final;
76 
77  void postInit() override final;
78 
79  void storeSortOrder() const;
80 
84  void action(const ActionEvent &event) override final;
85 
90 
94  void unselectItem();
95 
99  void widgetHidden(const Event &event) override final;
100 
104  void mouseClicked(MouseEvent &event) override final;
105 
109  void keyPressed(KeyEvent &event) override final;
110 
114  void keyReleased(KeyEvent &event) override final;
115 
119  void valueChanged(const SelectionEvent &event) override final;
120 
125  void close() override final;
126 
127  void slotsChanged(const Inventory *const inventory) override final;
128 
130  {
131  return mInventory != nullptr ?
132  mInventory->isMainInventory() : false;
133  }
134 
139  { return storageWindow != nullptr; }
140 
141  void updateDropButton();
142 
143  void updateButtons(const Item *item);
144 
145  bool isInputFocused() const A_WARN_UNUSED;
146 
147  void widgetResized(const Event &event) override final;
148 
149  void mouseMoved(MouseEvent &event) override final;
150 
151  void mouseExited(MouseEvent &event) override final;
152 
153  void setVisible(Visible visible) override final;
154 
155  void unsetInventory();
156 
157  void attributeChanged(const AttributesT id,
158  const int64_t oldVal,
159  const int64_t newVal) override final;
160 
161  void combineItems(const int index1,
162  const int index2);
163 
164  void moveItemToCraft(const int craftSlot);
165 
166  static bool isAnyInputFocused();
167 
169 
170  static void nextTab();
171 
172  static void prevTab();
173 
174  private:
178  void updateWeight();
179 
180  typedef std::list<InventoryWindow*> WindowList;
182 
185 
195 
206 
207  bool mSplit;
209 };
210 
211 #endif // GUI_WINDOWS_INVENTORYWINDOW_H
Attributes ::T AttributesT
Definition: attributes.h:118
Definition: button.h:102
Definition: event.h:79
void mouseExited(MouseEvent &event)
Button * mRetrieveButton
void moveItemToCraft(const int craftSlot)
void action(const ActionEvent &event)
TabStrip * mFilter
TextField * mNameFilter
static WindowList invInstances
ProgressBar * mSlotsBar
void storeSortOrder() const
Button * mInvCloseButton
void combineItems(const int index1, const int index2)
ItemContainer * mItems
static void nextTab()
void attributeChanged(const AttributesT id, const int64_t oldVal, const int64_t newVal)
Button * mOutfitButton
InventoryWindow(Inventory *const inventory)
bool isMainInventory() const
LayoutCell * mFilterCell
bool isInputFocused() const
static bool isAnyInputFocused()
static void prevTab()
void widgetResized(const Event &event)
void keyReleased(KeyEvent &event)
LayoutCell * mSortDropDownCell
void valueChanged(const SelectionEvent &event)
Inventory * mInventory
static bool isStorageActive()
DropDown * mSortDropDown
LayoutCell * mNameFilterCell
LayoutCell * mSlotsBarCell
void slotsChanged(const Inventory *const inventory)
Button * mEquipmentButton
SortListModelInv * mSortModel
void mouseClicked(MouseEvent &event)
static InventoryWindow * getFirstVisible()
std::list< InventoryWindow * > WindowList
void keyPressed(KeyEvent &event)
void setVisible(Visible visible)
void mouseMoved(MouseEvent &event)
void widgetHidden(const Event &event)
ProgressBar * mWeightBar
Item * getSelectedItem() const
void updateButtons(const Item *item)
bool isMainInventory() const
Definition: inventory.h:179
Definition: item.h:50
Definition: window.h:102
InventoryWindow * inventoryWindow
InventoryWindow * cartWindow
InventoryWindow * storageWindow
#define override
Definition: localconsts.h:47
#define A_WARN_UNUSED
Definition: localconsts.h:161
#define A_NONNULLPOINTER
Definition: localconsts.h:266
#define final
Definition: localconsts.h:46
#define A_DELETE_COPY(func)
Definition: localconsts.h:53
bool Visible
Definition: visible.h:30