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 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;
229  std::list<Tab*> mDeleteTabs;
235 };
236 
237 extern SkillDialog *skillDialog;
238 
239 #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:265
Definition: tab.h:84
void updateTabSelection()
void setSkillOffsetX(const int skillId, const int offset)
Label * mPointsLabel
Definition: skilldialog.h:230
std::string fileName
Definition: testmain.cpp:38
SkillDialog * skillDialog
Definition: skilldialog.cpp:65
TabbedArea * mTabs
Definition: skilldialog.h:228
void loadXmlFile(const std::string &fileName, const SkipError skipError)
SkillTab * mDefaultTab
Definition: skilldialog.h:234
bool updateSkill(const int id, const int range, const Modifiable modifiable, const SkillType::SkillType type, const int sp)
Button * mIncreaseButton
Definition: skilldialog.h:232
#define A_WARN_UNUSED
Definition: localconsts.h:160
Definition: window.h:98
void removeSkill(const int id)
Definition: button.h:96
#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
void updateModelsHidden()
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:231
void clearSkills()
SkillModel * mDefaultModel
Definition: skilldialog.h:233
std::list< Tab * > mDeleteTabs
Definition: skilldialog.h:229
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:118
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:225
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:226
std::vector< SkillInfo * > mDurations
Definition: skilldialog.h:227
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