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-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 
31 
35 
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 
56 class SkillDialog final : public Window,
57  public ActionListener
58 {
59  public:
60  SkillDialog();
61 
63 
64  ~SkillDialog() override final;
65 
66  void postInit() override final;
67 
71  void action(const ActionEvent &event) override final;
72 
76  std::string update(const int id);
77 
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 
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;
228  STD_VECTOR<SkillInfo*> mDurations;
230  std::list<Tab*> mDeleteTabs;
236 };
237 
238 extern SkillDialog *skillDialog;
239 
240 #endif // GUI_WINDOWS_SKILLDIALOG_H
bool AutoTarget
Definition: autotarget.h:30
CastType ::T CastTypeT
Definition: casttype.h:34
Definition: being.h:96
Definition: button.h:102
Definition: event.h:79
Definition: label.h:91
static void useSkillDefault(const SkillInfo *const info, const AutoTarget autoTarget, int level, const bool withText, const std::string &text, int offsetX, int offsetY)
void setSkillDuration(const SkillOwner::Type owner, const int id, const int duration)
void selectSkillLevel(const int skillId, const int level)
SkillData * getSkillData(const int id) const
void setSkillOffsetY(const int skillId, const int offset)
SkillModel * mDefaultModel
Definition: skilldialog.h:234
void updateQuest(const int var, const int val1, const int val2, const int val3, const int time1)
SkillMap mSkills
Definition: skilldialog.h:227
void slowLogic()
std::vector< SkillInfo * > mDurations
Definition: skilldialog.h:228
void selectSkillCastType(const int skillId, const CastTypeT type)
void clearSkills()
SkillInfo * loadSkill(const xmlNodePtr node, SkillModel *const model)
void addDefaultTab()
bool hasSkills() const
Definition: skilldialog.h:119
SkillTab * mDefaultTab
Definition: skilldialog.h:235
void postInit()
Label * mPointsLabel
Definition: skilldialog.h:231
SkillInfo * getSkill(const int id) const
bool updateSkill(const int id, const int range, const Modifiable modifiable, const SkillType::SkillType type, const int sp)
std::list< Tab * > mDeleteTabs
Definition: skilldialog.h:230
SkillInfo * getSkillByItem(const int itemId) const
void updateTabSelection()
void widgetResized(const Event &event)
void playRemoveEffect(const int id) const
void updateModelsHidden()
void action(const ActionEvent &event)
void removeSkill(const int id)
void playCastingDstTileEffect(const int id, const int level, const int x, const int y, const int delay) const
void playUpdateEffect(const int id) const
void loadSkills()
static void loadSkillData(const xmlNodePtr node, SkillInfo *const skill)
void updateModels()
Button * mUseButton
Definition: skilldialog.h:232
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)
std::map< int, SkillInfo * > SkillMap
Definition: skilldialog.h:226
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)
void addSkillDuration(SkillInfo *const skill)
Button * mIncreaseButton
Definition: skilldialog.h:233
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)
TabbedArea * mTabs
Definition: skilldialog.h:229
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)
void useItem(const int itemId, const AutoTarget autoTarget, const int level, const std::string &data) const
void setSkillOffsetX(const int skillId, const int offset)
SkillData * getSkillDataByLevel(const int id, const int level) const
static std::string getDefaultSkillIcon(const SkillType::SkillType type)
void loadXmlFile(const std::string &fileName, const SkipError skipError)
void hideSkills(const SkillOwner::Type owner)
Definition: tab.h:88
Definition: window.h:102
#define A_WARN_UNUSED
Definition: localconsts.h:161
#define A_NONNULLPOINTER
Definition: localconsts.h:266
#define noexcept2
Definition: localconsts.h:50
#define final
Definition: localconsts.h:46
#define A_DELETE_COPY(func)
Definition: localconsts.h:53
uint32_t data
bool Modifiable
Definition: modifiable.h:30
bool info(InputEvent &event)
Definition: commands.cpp:57
bool skill(InputEvent &event)
Definition: commands.cpp:97
SkillDialog * skillDialog
Definition: skilldialog.cpp:66
bool SkipError
Definition: skiperror.h:30
std::string fileName
Definition: testmain.cpp:39