GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/windows/skilldialog.h Lines: 0 1 0.0 %
Date: 2018-07-14 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-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_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() override final;
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 updateModelsHidden();
85
86
        void loadXmlFile(const std::string &fileName,
87
                         const SkipError skipError);
88
89
        void clearSkills();
90
91
        void hideSkills(const SkillOwner::Type owner);
92
93
        void loadSkills();
94
95
        bool updateSkill(const int id,
96
                         const int range,
97
                         const Modifiable modifiable,
98
                         const SkillType::SkillType type,
99
                         const int sp);
100
101
        void addSkill(const SkillOwner::Type owner,
102
                      const int id,
103
                      const std::string &name,
104
                      const int level,
105
                      const int range,
106
                      const Modifiable modifiable,
107
                      const SkillType::SkillType type,
108
                      const int sp);
109
110
        SkillInfo* getSkill(const int id) const A_WARN_UNUSED;
111
112
        SkillInfo* getSkillByItem(const int itemId) const A_WARN_UNUSED;
113
114
        void setSkillDuration(const SkillOwner::Type owner,
115
                              const int id,
116
                              const int duration);
117
118
        bool hasSkills() const noexcept2 A_WARN_UNUSED
119
        { return !mSkills.empty(); }
120
121
        void widgetResized(const Event &event) override final;
122
123
        void useItem(const int itemId,
124
                     const AutoTarget autoTarget,
125
                     const int level,
126
                     const std::string &data) const;
127
128
        void updateTabSelection();
129
130
        void updateQuest(const int var,
131
                         const int val1,
132
                         const int val2,
133
                         const int val3,
134
                         const int time1);
135
136
        void playUpdateEffect(const int id) const;
137
138
        void playRemoveEffect(const int id) const;
139
140
        void playCastingDstTileEffect(const int id,
141
                                      const int level,
142
                                      const int x,
143
                                      const int y,
144
                                      const int delay) const;
145
146
        void slowLogic();
147
148
        void removeSkill(const int id);
149
150
        static void useSkill(const int skillId,
151
                             const AutoTarget autoTarget,
152
                             int level,
153
                             const bool withText,
154
                             const std::string &text,
155
                             CastTypeT castType,
156
                             const int offsetX,
157
                             const int offsetY);
158
159
        static void useSkill(const SkillInfo *const info,
160
                             const AutoTarget autoTarget,
161
                             int level,
162
                             const bool withText,
163
                             const std::string &text,
164
                             const CastTypeT castType,
165
                             const int offsetX,
166
                             const int offsetY);
167
168
        SkillData *getSkillData(const int id) const;
169
170
        SkillData *getSkillDataByLevel(const int id,
171
                                       const int level) const;
172
173
        void selectSkillLevel(const int skillId,
174
                              const int level);
175
176
        void selectSkillCastType(const int skillId,
177
                                 const CastTypeT type);
178
179
        void setSkillOffsetX(const int skillId,
180
                             const int offset);
181
182
        void setSkillOffsetY(const int skillId,
183
                             const int offset);
184
185
    private:
186
        static void useSkillDefault(const SkillInfo *const info,
187
                                    const AutoTarget autoTarget,
188
                                    int level,
189
                                    const bool withText,
190
                                    const std::string &text,
191
                                    int offsetX,
192
                                    int offsetY);
193
194
        static void useSkillTarget(const SkillInfo *const info,
195
                                   const AutoTarget autoTarget,
196
                                   int level,
197
                                   const bool withText,
198
                                   const std::string &text,
199
                                   const Being *being,
200
                                   int offsetX,
201
                                   int offsetY);
202
203
        static void useSkillPosition(const SkillInfo *const info,
204
                                     int level,
205
                                     const bool withText,
206
                                     const std::string &text,
207
                                     const int x,
208
                                     const int y,
209
                                     int offsetX,
210
                                     int offsetY);
211
212
        static std::string getDefaultSkillIcon(const SkillType::SkillType
213
                                               type);
214
215
        void addSkillDuration(SkillInfo *const skill);
216
217
        SkillInfo *loadSkill(XmlNodeConstPtr node,
218
                             SkillModel *const model);
219
220
        void loadSkillData(XmlNodeConstPtr node,
221
                           SkillInfo *const skill);
222
223
        void addDefaultTab();
224
225
        typedef std::map<int, SkillInfo*> SkillMap;
226
        SkillMap mSkills;
227
        STD_VECTOR<SkillInfo*> mDurations;
228
        TabbedArea *mTabs A_NONNULLPOINTER;
229
        std::list<Tab*> mDeleteTabs;
230
        Label *mPointsLabel A_NONNULLPOINTER;
231
        Button *mUseButton A_NONNULLPOINTER;
232
        Button *mIncreaseButton A_NONNULLPOINTER;
233
        SkillModel *mDefaultModel;
234
        SkillTab *mDefaultTab;
235
};
236
237
extern SkillDialog *skillDialog;
238
239
#endif  // GUI_WINDOWS_SKILLDIALOG_H