ManaPlus
skilldialog.h
Go to the documentation of this file.
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 
30 
34 
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 
55 class SkillDialog final : public Window,
56  public ActionListener
57 {
58  public:
59  SkillDialog();
60 
62 
63  ~SkillDialog() override final;
64 
65  void postInit() override final;
66 
70  void action(const ActionEvent &event) override final;
71 
75  std::string update(const int id);
76 
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;
227  std::list<Tab*> mDeleteTabs;
233 };
234 
235 extern SkillDialog *skillDialog;
236 
237 #endif // GUI_WINDOWS_SKILLDIALOG_H
#define A_DELETE_COPY(func)
Definition: localconsts.h:52
bool skill(InputEvent &event)
Definition: commands.cpp:96
void useItem(const int itemId, const AutoTarget autoTarget, const int level, const std::string &data) const
void updateModels()
static std::string getDefaultSkillIcon(const SkillType::SkillType type)
SkillInfo * getSkillByItem(const int itemId) const
#define A_NONNULLPOINTER
Definition: localconsts.h:294
Definition: tab.h:84
void updateTabSelection()
void setSkillOffsetX(const int skillId, const int offset)
Label * mPointsLabel
Definition: skilldialog.h:228
std::string fileName
Definition: testmain.cpp:36
SkillDialog * skillDialog
Definition: skilldialog.cpp:65
TabbedArea * mTabs
Definition: skilldialog.h:226
void loadXmlFile(const std::string &fileName, const SkipError skipError)
SkillTab * mDefaultTab
Definition: skilldialog.h:232
bool updateSkill(const int id, const int range, const Modifiable modifiable, const SkillType::SkillType type, const int sp)
Button * mIncreaseButton
Definition: skilldialog.h:230
#define A_WARN_UNUSED
Definition: localconsts.h:172
Definition: window.h:98
void removeSkill(const int id)
Definition: button.h:94
#define final
Definition: localconsts.h:45
void loadSkillData(const xmlNodePtr node, SkillInfo *const skill)
void setSkillDuration(const SkillOwner::Type owner, const int id, const int duration)
static void useSkillTarget(const SkillInfo *const info, const AutoTarget autoTarget, int level, const bool withText, const std::string &text, const Being *being, int offsetX, int offsetY)
void playCastingDstTileEffect(const int id, const int level, const int x, const int y, const int delay) const
void hideSkills(const SkillOwner::Type owner)
SkillData * getSkillDataByLevel(const int id, const int level) const
SkillInfo * getSkill(const int id) const
SkillInfo * loadSkill(const xmlNodePtr node, SkillModel *const model)
Definition: label.h:87
bool info(InputEvent &event)
Definition: commands.cpp:56
void selectSkillLevel(const int skillId, const int level)
uint32_t data
Button * mUseButton
Definition: skilldialog.h:229
void clearSkills()
SkillModel * mDefaultModel
Definition: skilldialog.h:231
std::list< Tab * > mDeleteTabs
Definition: skilldialog.h:227
void setSkillOffsetY(const int skillId, const int offset)
void playUpdateEffect(const int id) const
void widgetResized(const Event &event)
bool hasSkills() const
Definition: skilldialog.h:116
void action(const ActionEvent &event)
void addSkillDuration(SkillInfo *const skill)
void selectSkillCastType(const int skillId, const CastTypeT type)
std::map< int, SkillInfo * > SkillMap
Definition: skilldialog.h:223
static void useSkillPosition(const SkillInfo *const info, int level, const bool withText, const std::string &text, const int x, const int y, int offsetX, int offsetY)
static void useSkill(const int skillId, const AutoTarget autoTarget, int level, const bool withText, const std::string &text, CastTypeT castType, const int offsetX, const int offsetY)
void addDefaultTab()
void loadSkills()
Definition: event.h:77
void addSkill(const SkillOwner::Type owner, const int id, const std::string &name, const int level, const int range, const Modifiable modifiable, const SkillType::SkillType type, const int sp)
SkillMap mSkills
Definition: skilldialog.h:224
std::vector< SkillInfo * > mDurations
Definition: skilldialog.h:225
void postInit()
void slowLogic()
void updateQuest(const int var, const int val1, const int val2, const int val3, const int time1)
SkillData * getSkillData(const int id) const
Definition: being.h:93
void playRemoveEffect(const int id) const
static void useSkillDefault(const SkillInfo *const info, const AutoTarget autoTarget, int level, const bool withText, const std::string &text, int offsetX, int offsetY)
#define noexcept2
Definition: localconsts.h:49
CastType ::T CastTypeT
Definition: casttype.h:33