GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/windows/equipmentwindow.h Lines: 0 2 0.0 %
Date: 2017-11-29 Branches: 0 2 0.0 %

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