GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/windows/equipmentwindow.h Lines: 0 2 0.0 %
Date: 2018-09-20 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-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
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,
59
                        Being *const being,
60
                        const bool foring);
61
62
        A_DELETE_COPY(EquipmentWindow)
63
64
        /**
65
         * Destructor.
66
         */
67
        ~EquipmentWindow() override final;
68
69
        void postInit() override final;
70
71
        /**
72
         * Draws the equipment window.
73
         */
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
133
        static StringIntMap mSlotNames;
134
135
        Equipment *mEquipment;
136
137
        PlayerBox *mPlayerBox A_NONNULLPOINTER;
138
        Button *mUnequip A_NONNULLPOINTER;
139
140
        ImageSet *mImageSet;
141
        Being *mBeing;
142
        Image *mSlotBackground;
143
        Image *mSlotHighlightedBackground;
144
        ImageCollection *mVertexes A_NONNULLPOINTER;
145
        STD_VECTOR<EquipmentPage*> mPages;
146
        TabStrip *mTabs;
147
        Color mHighlightColor;
148
        Color mBorderColor;
149
        Color mLabelsColor;
150
        Color mLabelsColor2;
151
        int mSelected; /**< Index of selected item. */
152
        int mItemPadding;
153
        int mBoxSize;
154
        int mButtonPadding;
155
        int mMinX;
156
        int mMinY;
157
        int mMaxX;
158
        int mMaxY;
159
        int mYPadding;
160
        int mSelectedTab;
161
        bool mForing;
162
        bool mHaveDefaultPage;
163
};
164
165
extern EquipmentWindow *equipmentWindow;
166
extern EquipmentWindow *beingEquipmentWindow;
167
168
#endif  // GUI_WINDOWS_EQUIPMENTWINDOW_H