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