ManaPlus
equipmentwindow.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-2018 The ManaPlus Developers
6  *
7  * This file is part of The ManaPlus Client.
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #ifndef GUI_WINDOWS_EQUIPMENTWINDOW_H
24 #define GUI_WINDOWS_EQUIPMENTWINDOW_H
25 
26 #include "equipment.h"
27 #include "localconsts.h"
28 
29 #include "gui/widgets/window.h"
30 
31 #include "utils/stringmap.h"
32 #include "utils/xml.h"
33 
35 
36 class Being;
37 class Button;
38 class Image;
39 class ImageSet;
40 class Item;
41 class PlayerBox;
42 class TabStrip;
43 
44 struct EquipmentPage;
45 
51 class EquipmentWindow final : public Window,
52  public ActionListener
53 {
54  public:
58  EquipmentWindow(Equipment *const equipment,
59  Being *const being,
60  const bool foring);
61 
63 
64 
67  ~EquipmentWindow() override final;
68 
69  void postInit() override final;
70 
74  void draw(Graphics *const graphics) override final A_NONNULL(2);
75 
76  void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
77 
78  void action(const ActionEvent &event) override final;
79 
80  void mousePressed(MouseEvent& event) override final;
81 
82  const Item* getEquipment(const int i) const A_WARN_UNUSED
83  {
84  return mEquipment != nullptr ?
85  mEquipment->getEquipment(i) : nullptr;
86  }
87 
88  void setBeing(Being *const being);
89 
90  void updateBeing(Being *const being);
91 
92  void resetBeing(const Being *const being);
93 
94  void mouseExited(MouseEvent &event) override final;
95 
96  void mouseMoved(MouseEvent &event) override final;
97 
98  void mouseReleased(MouseEvent &event) override final;
99 
100  void recalcSize();
101 
102  static void prepareSlotNames();
103 
104  private:
105  const Item *getItem(const int x, const int y) const A_WARN_UNUSED;
106 
107  void setSelected(const int index);
108 
109  void fillBoxes();
110 
111  void fillDefault();
112 
113  void updatePage();
114 
115  int addPage(const std::string &name);
116 
117  void addDefaultPage();
118 
119  void addBox(const int idx, int x, int y, const int imageIndex);
120 
121  void loadWindow(XmlNodeConstPtrConst windowNode);
122 
123  void loadPage(XmlNodeConstPtr node);
124 
125  void loadPlayerBox(XmlNodeConstPtr playerBoxNode, const int page);
126 
127  void loadSlot(XmlNodeConstPtr slotNode,
128  const ImageSet *const imageset,
129  const int page);
130 
131  static int parseSlotName(const std::string &name) A_WARN_UNUSED;
132 
134 
136 
139 
145  STD_VECTOR<EquipmentPage*> mPages;
151  int mSelected;
153  int mBoxSize;
155  int mMinX;
156  int mMinY;
157  int mMaxX;
158  int mMaxY;
161  bool mForing;
163 };
164 
167 
168 #endif // GUI_WINDOWS_EQUIPMENTWINDOW_H
#define A_DELETE_COPY(func)
Definition: localconsts.h:52
std::map< std::string, int > StringIntMap
Definition: stringmap.h:27
void setBeing(Being *const being)
#define A_NONNULLPOINTER
Definition: localconsts.h:294
ImageSet * mImageSet
void safeDraw(Graphics *const graphics)
void mousePressed(MouseEvent &event)
const Item * getItem(const int x, const int y) const
ImageCollection * mVertexes
#define A_WARN_UNUSED
Definition: localconsts.h:172
Definition: window.h:98
Definition: button.h:94
#define final
Definition: localconsts.h:45
void loadPlayerBox(const xmlNodePtr playerBoxNode, const int page)
static void prepareSlotNames()
void mouseReleased(MouseEvent &event)
#define A_NONNULL(...)
Definition: localconsts.h:179
EquipmentWindow * equipmentWindow
const Item * getEquipment(const int index) const
Definition: equipment.h:68
std::vector< EquipmentPage * > mPages
void addBox(const int idx, int x, int y, const int imageIndex)
const Item * getEquipment(const int i) const
Definition: item.h:48
EquipmentWindow * beingEquipmentWindow
static StringIntMap mSlotNames
void loadWindow(const xmlNode *const windowNode)
void resetBeing(const Being *const being)
Equipment * mEquipment
void loadSlot(const xmlNodePtr slotNode, const ImageSet *const imageset, const int page)
void draw(Graphics *const graphics)
EquipmentWindow(Equipment *const equipment, Being *const being, const bool foring)
Image * mSlotHighlightedBackground
static int parseSlotName(const std::string &name)
Definition: image.h:61
void mouseExited(MouseEvent &event)
int addPage(const std::string &name)
void mouseMoved(MouseEvent &event)
Definition: color.h:74
void action(const ActionEvent &event)
void setSelected(const int index)
void loadPage(const xmlNodePtr node)
Definition: being.h:93
void updateBeing(Being *const being)
PlayerBox * mPlayerBox