GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/windows/skilldialog.h Lines: 0 1 0.0 %
Date: 2017-11-29 Branches: 0 0 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_SKILLDIALOG_H
24
#define GUI_WINDOWS_SKILLDIALOG_H
25
26
#include "gui/widgets/window.h"
27
28
#include "enums/simpletypes/autotarget.h"
29
#include "enums/simpletypes/modifiable.h"
30
31
#include "enums/resources/skill/casttype.h"
32
#include "enums/resources/skill/skillowner.h"
33
#include "enums/resources/skill/skilltype.h"
34
35
#include "listeners/actionlistener.h"
36
37
#include "utils/xml.h"
38
39
class Being;
40
class Button;
41
class Label;
42
class SkillModel;
43
class SkillTab;
44
class Tab;
45
class TabbedArea;
46
47
struct SkillData;
48
struct SkillInfo;
49
50
/**
51
 * The skill dialog.
52
 *
53
 * \ingroup Interface
54
 */
55
class SkillDialog final : public Window,
56
                          public ActionListener
57
{
58
    public:
59
        SkillDialog();
60
61
        A_DELETE_COPY(SkillDialog)
62
63
        ~SkillDialog();
64
65
        void postInit() override final;
66
67
        /**
68
         * Called when receiving actions from widget.
69
         */
70
        void action(const ActionEvent &event) override final;
71
72
        /**
73
         * Update the given skill's display
74
         */
75
        std::string update(const int id);
76
77
        /**
78
         * Update other parts of the display
79
         */
80
        void update();
81
82
        void updateModels();
83
84
        void loadXmlFile(const std::string &fileName,
85
                         const SkipError skipError);
86
87
        void clearSkills();
88
89
        void hideSkills(const SkillOwner::Type owner);
90
91
        void loadSkills();
92
93
        bool updateSkill(const int id,
94
                         const int range,
95
                         const Modifiable modifiable,
96
                         const SkillType::SkillType type,
97
                         const int sp);
98
99
        void addSkill(const SkillOwner::Type owner,
100
                      const int id,
101
                      const std::string &name,
102
                      const int level,
103
                      const int range,
104
                      const Modifiable modifiable,
105
                      const SkillType::SkillType type,
106
                      const int sp);
107
108
        SkillInfo* getSkill(const int id) const A_WARN_UNUSED;
109
110
        SkillInfo* getSkillByItem(const int itemId) const A_WARN_UNUSED;
111
112
        void setSkillDuration(const SkillOwner::Type owner,
113
                              const int id,
114
                              const int duration);
115
116
        bool hasSkills() const noexcept2 A_WARN_UNUSED
117
        { return !mSkills.empty(); }
118
119
        void widgetResized(const Event &event) override final;
120
121
        void useItem(const int itemId,
122
                     const AutoTarget autoTarget,
123
                     const int level,
124
                     const std::string &data) const;
125
126
        void updateTabSelection();
127
128
        void updateQuest(const int var,
129
                         const int val1,
130
                         const int val2,
131
                         const int val3,
132
                         const int time1);
133
134
        void playUpdateEffect(const int id) const;
135
136
        void playRemoveEffect(const int id) const;
137
138
        void playCastingDstTileEffect(const int id,
139
                                      const int level,
140
                                      const int x,
141
                                      const int y,
142
                                      const int delay) const;
143
144
        void slowLogic();
145
146
        void removeSkill(const int id);
147
148
        static void useSkill(const int skillId,
149
                             const AutoTarget autoTarget,
150
                             int level,
151
                             const bool withText,
152
                             const std::string &text,
153
                             CastTypeT castType,
154
                             const int offsetX,
155
                             const int offsetY);
156
157
        static void useSkill(const SkillInfo *const info,
158
                             const AutoTarget autoTarget,
159
                             int level,
160
                             const bool withText,
161
                             const std::string &text,
162
                             const CastTypeT castType,
163
                             const int offsetX,
164
                             const int offsetY);
165
166
        SkillData *getSkillData(const int id) const;
167
168
        SkillData *getSkillDataByLevel(const int id,
169
                                       const int level) const;
170
171
        void selectSkillLevel(const int skillId,
172
                              const int level);
173
174
        void selectSkillCastType(const int skillId,
175
                                 const CastTypeT type);
176
177
        void setSkillOffsetX(const int skillId,
178
                             const int offset);
179
180
        void setSkillOffsetY(const int skillId,
181
                             const int offset);
182
183
    private:
184
        static void useSkillDefault(const SkillInfo *const info,
185
                                    const AutoTarget autoTarget,
186
                                    int level,
187
                                    const bool withText,
188
                                    const std::string &text,
189
                                    int offsetX,
190
                                    int offsetY);
191
192
        static void useSkillTarget(const SkillInfo *const info,
193
                                   const AutoTarget autoTarget,
194
                                   int level,
195
                                   const bool withText,
196
                                   const std::string &text,
197
                                   const Being *being,
198
                                   int offsetX,
199
                                   int offsetY);
200
201
        static void useSkillPosition(const SkillInfo *const info,
202
                                     int level,
203
                                     const bool withText,
204
                                     const std::string &text,
205
                                     const int x,
206
                                     const int y,
207
                                     int offsetX,
208
                                     int offsetY);
209
210
        static std::string getDefaultSkillIcon(const SkillType::SkillType
211
                                               type);
212
213
        void addSkillDuration(SkillInfo *const skill);
214
215
        SkillInfo *loadSkill(XmlNodeConstPtr node,
216
                             SkillModel *const model);
217
218
        void loadSkillData(XmlNodeConstPtr node,
219
                           SkillInfo *const skill);
220
221
        void addDefaultTab();
222
223
        typedef std::map<int, SkillInfo*> SkillMap;
224
        SkillMap mSkills;
225
        STD_VECTOR<SkillInfo*> mDurations;
226
        TabbedArea *mTabs A_NONNULLPOINTER;
227
        std::list<Tab*> mDeleteTabs;
228
        Label *mPointsLabel A_NONNULLPOINTER;
229
        Button *mUseButton A_NONNULLPOINTER;
230
        Button *mIncreaseButton A_NONNULLPOINTER;
231
        SkillModel *mDefaultModel;
232
        SkillTab *mDefaultTab;
233
};
234
235
extern SkillDialog *skillDialog;
236
237
#endif  // GUI_WINDOWS_SKILLDIALOG_H