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_EQUIPMENTWINDOW_H |
25 |
|
|
#define GUI_WINDOWS_EQUIPMENTWINDOW_H |
26 |
|
|
|
27 |
|
|
#include "equipment.h" |
28 |
|
|
#include "localconsts.h" |
29 |
|
|
|
30 |
|
|
#include "gui/widgets/window.h" |
31 |
|
|
|
32 |
|
|
#include "utils/stringmap.h" |
33 |
|
|
#include "utils/xml.h" |
34 |
|
|
|
35 |
|
|
#include "listeners/actionlistener.h" |
36 |
|
|
|
37 |
|
|
class Being; |
38 |
|
|
class Button; |
39 |
|
|
class Image; |
40 |
|
|
class ImageSet; |
41 |
|
|
class Item; |
42 |
|
|
class PlayerBox; |
43 |
|
|
class TabStrip; |
44 |
|
|
|
45 |
|
|
struct EquipmentPage; |
46 |
|
|
|
47 |
|
|
/** |
48 |
|
|
* Equipment dialog. |
49 |
|
|
* |
50 |
|
|
* \ingroup Interface |
51 |
|
|
*/ |
52 |
|
|
class EquipmentWindow final : public Window, |
53 |
|
|
public ActionListener |
54 |
|
|
{ |
55 |
|
|
public: |
56 |
|
|
/** |
57 |
|
|
* Constructor. |
58 |
|
|
*/ |
59 |
|
|
EquipmentWindow(Equipment *const equipment, |
60 |
|
|
Being *const being, |
61 |
|
|
const bool foring); |
62 |
|
|
|
63 |
|
|
A_DELETE_COPY(EquipmentWindow) |
64 |
|
|
|
65 |
|
|
/** |
66 |
|
|
* Destructor. |
67 |
|
|
*/ |
68 |
|
|
~EquipmentWindow() override final; |
69 |
|
|
|
70 |
|
|
void postInit() override final; |
71 |
|
|
|
72 |
|
|
/** |
73 |
|
|
* Draws the equipment window. |
74 |
|
|
*/ |
75 |
|
|
void draw(Graphics *const graphics) override final A_NONNULL(2); |
76 |
|
|
|
77 |
|
|
void safeDraw(Graphics *const graphics) override final A_NONNULL(2); |
78 |
|
|
|
79 |
|
|
void action(const ActionEvent &event) override final; |
80 |
|
|
|
81 |
|
|
void mousePressed(MouseEvent& event) override final; |
82 |
|
|
|
83 |
|
|
const Item* getEquipment(const int i) const A_WARN_UNUSED |
84 |
|
|
{ |
85 |
|
|
return mEquipment != nullptr ? |
86 |
|
|
mEquipment->getEquipment(i) : nullptr; |
87 |
|
|
} |
88 |
|
|
|
89 |
|
|
void setBeing(Being *const being); |
90 |
|
|
|
91 |
|
|
void updateBeing(Being *const being); |
92 |
|
|
|
93 |
|
|
void resetBeing(const Being *const being); |
94 |
|
|
|
95 |
|
|
void mouseExited(MouseEvent &event) override final; |
96 |
|
|
|
97 |
|
|
void mouseMoved(MouseEvent &event) override final; |
98 |
|
|
|
99 |
|
|
void mouseReleased(MouseEvent &event) override final; |
100 |
|
|
|
101 |
|
|
void recalcSize(); |
102 |
|
|
|
103 |
|
|
static void prepareSlotNames(); |
104 |
|
|
|
105 |
|
|
private: |
106 |
|
|
const Item *getItem(const int x, const int y) const A_WARN_UNUSED; |
107 |
|
|
|
108 |
|
|
void setSelected(const int index); |
109 |
|
|
|
110 |
|
|
void fillBoxes(); |
111 |
|
|
|
112 |
|
|
void fillDefault(); |
113 |
|
|
|
114 |
|
|
void updatePage(); |
115 |
|
|
|
116 |
|
|
int addPage(const std::string &name); |
117 |
|
|
|
118 |
|
|
void addDefaultPage(); |
119 |
|
|
|
120 |
|
|
void addBox(const int idx, int x, int y, const int imageIndex); |
121 |
|
|
|
122 |
|
|
void loadWindow(XmlNodeConstPtrConst windowNode); |
123 |
|
|
|
124 |
|
|
void loadPage(XmlNodeConstPtr node); |
125 |
|
|
|
126 |
|
|
void loadPlayerBox(XmlNodeConstPtr playerBoxNode, const int page); |
127 |
|
|
|
128 |
|
|
void loadSlot(XmlNodeConstPtr slotNode, |
129 |
|
|
const ImageSet *const imageset, |
130 |
|
|
const int page); |
131 |
|
|
|
132 |
|
|
static int parseSlotName(const std::string &name) A_WARN_UNUSED; |
133 |
|
|
|
134 |
|
|
static StringIntMap mSlotNames; |
135 |
|
|
|
136 |
|
|
Equipment *mEquipment; |
137 |
|
|
|
138 |
|
|
PlayerBox *mPlayerBox A_NONNULLPOINTER; |
139 |
|
|
Button *mUnequip A_NONNULLPOINTER; |
140 |
|
|
|
141 |
|
|
ImageSet *mImageSet; |
142 |
|
|
Being *mBeing; |
143 |
|
|
Image *mSlotBackground; |
144 |
|
|
Image *mSlotHighlightedBackground; |
145 |
|
|
ImageCollection *mVertexes A_NONNULLPOINTER; |
146 |
|
|
STD_VECTOR<EquipmentPage*> mPages; |
147 |
|
|
TabStrip *mTabs; |
148 |
|
|
Color mHighlightColor; |
149 |
|
|
Color mBorderColor; |
150 |
|
|
Color mLabelsColor; |
151 |
|
|
Color mLabelsColor2; |
152 |
|
|
int mSelected; /**< Index of selected item. */ |
153 |
|
|
int mItemPadding; |
154 |
|
|
int mBoxSize; |
155 |
|
|
int mButtonPadding; |
156 |
|
|
int mMinX; |
157 |
|
|
int mMinY; |
158 |
|
|
int mMaxX; |
159 |
|
|
int mMaxY; |
160 |
|
|
int mYPadding; |
161 |
|
|
int mSelectedTab; |
162 |
|
|
bool mForing; |
163 |
|
|
bool mHaveDefaultPage; |
164 |
|
|
}; |
165 |
|
|
|
166 |
|
|
extern EquipmentWindow *equipmentWindow; |
167 |
|
|
extern EquipmentWindow *beingEquipmentWindow; |
168 |
|
|
|
169 |
|
|
#endif // GUI_WINDOWS_EQUIPMENTWINDOW_H |