ManaPlus
Public Member Functions | Data Fields
SkillInfo Struct Reference

#include <skillinfo.h>

Public Member Functions

 SkillInfo ()
 
 ~SkillInfo ()
 
void update ()
 
SkillDatagetData (const int level) const
 
SkillDatagetData1 (const int level) const
 
void addData (const int level, SkillData *const data)
 
bool isUsable () const
 
std::string toDataStr () const
 

Data Fields

std::string skillLevel
 
std::string skillEffect
 
std::string useButton
 
std::string errorText
 
std::string castingAction
 
std::string castingRideAction
 
std::string castingSkyAction
 
std::string castingWaterAction
 
SkillDataMap dataMap
 
SkillModelmodel
 
SkillTabtab
 
SkillDatadata
 
int level
 
int customSelectedLevel
 
int customOffsetX
 
int customOffsetY
 
int skillLevelWidth
 
unsigned int id
 
int range
 
int sp
 
int duration
 
int durationTime
 
int cooldown
 
int x
 
int y
 
SkillType::SkillType type
 
SkillOwner::Type owner
 
CastTypeT customCastType
 
Modifiable modifiable
 
Visible visible
 
Visible alwaysVisible
 
bool useTextParameter
 

Detailed Description

Definition at line 49 of file skillinfo.h.

Constructor & Destructor Documentation

◆ SkillInfo()

SkillInfo::SkillInfo ( )

Definition at line 37 of file skillinfo.cpp.

References data, and dataMap.

37  :
38  skillLevel(),
39  skillEffect(),
40  useButton(),
41  errorText(),
42  castingAction(),
46  dataMap(),
47  model(nullptr),
48  tab(nullptr),
49  data(nullptr),
50  level(0),
52  customOffsetX(0),
53  customOffsetY(0),
54  skillLevelWidth(0),
55  id(0),
56  range(0),
57  sp(0),
58  duration(0),
59  durationTime(0),
60  cooldown(0),
61  x(0),
62  y(0),
69  useTextParameter(false)
70 {
71  dataMap[0] = new SkillData;
72  data = dataMap[0];
73 }
unsigned int id
Definition: skillinfo.h:68
std::string useButton
Definition: skillinfo.h:53
std::string skillEffect
Definition: skillinfo.h:52
bool useTextParameter
Definition: skillinfo.h:82
SkillTab * tab
Definition: skillinfo.h:61
int cooldown
Definition: skillinfo.h:73
CastTypeT customCastType
Definition: skillinfo.h:78
std::string castingWaterAction
Definition: skillinfo.h:58
std::string castingRideAction
Definition: skillinfo.h:56
SkillOwner::Type owner
Definition: skillinfo.h:77
int customOffsetY
Definition: skillinfo.h:66
std::string errorText
Definition: skillinfo.h:54
SkillData * data
Definition: skillinfo.h:62
std::string castingAction
Definition: skillinfo.h:55
int duration
Definition: skillinfo.h:71
Modifiable modifiable
Definition: skillinfo.h:79
const bool Visible_false
Definition: visible.h:29
int customOffsetX
Definition: skillinfo.h:65
int level
Definition: skillinfo.h:63
int range
Definition: skillinfo.h:69
int sp
Definition: skillinfo.h:70
int customSelectedLevel
Definition: skillinfo.h:64
const bool Modifiable_false
Definition: modifiable.h:29
Visible alwaysVisible
Definition: skillinfo.h:81
std::string castingSkyAction
Definition: skillinfo.h:57
std::string skillLevel
Definition: skillinfo.h:51
int skillLevelWidth
Definition: skillinfo.h:67
Visible visible
Definition: skillinfo.h:80
SkillDataMap dataMap
Definition: skillinfo.h:59
SkillType::SkillType type
Definition: skillinfo.h:76
int durationTime
Definition: skillinfo.h:72
SkillModel * model
Definition: skillinfo.h:60

◆ ~SkillInfo()

SkillInfo::~SkillInfo ( )

Definition at line 75 of file skillinfo.cpp.

References dataMap, and FOR_EACH.

76 {
78  delete (*it).second;
79  dataMap.clear();
80 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
SkillDataMap::iterator SkillDataMapIter
Definition: skillinfo.h:46
SkillDataMap dataMap
Definition: skillinfo.h:59

Member Function Documentation

◆ addData()

void SkillInfo::addData ( const int  level,
SkillData *const  data 
)

Definition at line 177 of file skillinfo.cpp.

References dataMap.

Referenced by SkillDialog::loadSkillData().

178 {
179  dataMap[level1] = data1;
180 }
SkillDataMap dataMap
Definition: skillinfo.h:59

◆ getData()

SkillData * SkillInfo::getData ( const int  level) const

Definition at line 182 of file skillinfo.cpp.

References dataMap.

Referenced by SkillDialog::loadSkillData(), and update().

183 {
184  const SkillDataMapCIter it = dataMap.find(level1);
185  if (it == dataMap.end())
186  return nullptr;
187  return (*it).second;
188 }
SkillDataMap::const_iterator SkillDataMapCIter
Definition: skillinfo.h:47
SkillDataMap dataMap
Definition: skillinfo.h:59

◆ getData1()

SkillData * SkillInfo::getData1 ( const int  level) const

Definition at line 190 of file skillinfo.cpp.

References dataMap.

Referenced by SkillDialog::getSkillDataByLevel(), SkillDialog::useSkill(), SkillDialog::useSkillDefault(), SkillDialog::useSkillPosition(), and SkillDialog::useSkillTarget().

191 {
192  const SkillDataMapCIter it = dataMap.find(lev);
193  if (it == dataMap.end())
194  return (*dataMap.begin()).second;
195  return (*it).second;
196 }
SkillDataMap::const_iterator SkillDataMapCIter
Definition: skillinfo.h:47
SkillDataMap dataMap
Definition: skillinfo.h:59

◆ isUsable()

bool SkillInfo::isUsable ( ) const
inline

Definition at line 95 of file skillinfo.h.

References A_WARN_UNUSED, SkillType::Attack, SkillType::Self, SkillType::Support, and toDataStr().

96  {
97  return type == SkillType::Attack
98  || type == SkillType::Self
100  }
SkillType::SkillType type
Definition: skillinfo.h:76

◆ toDataStr()

std::string SkillInfo::toDataStr ( ) const

Definition at line 198 of file skillinfo.cpp.

References CAST_S32, customCastType, customOffsetX, customOffsetY, and strprintf().

Referenced by isUsable(), SkillListBox::mouseDragged(), SkillRectangleListBox::mouseDragged(), and SkillDialog::update().

199 {
200  return strprintf("%d %d %d",
203  customOffsetY);
204 }
CastTypeT customCastType
Definition: skillinfo.h:78
int customOffsetY
Definition: skillinfo.h:66
#define CAST_S32
Definition: cast.h:29
std::string strprintf(const char *const format,...)
Definition: stringutils.cpp:99
int customOffsetX
Definition: skillinfo.h:65

◆ update()

void SkillInfo::update ( )

Definition at line 82 of file skillinfo.cpp.

References _, CAST_S32, customSelectedLevel, data, dataMap, getData(), PlayerInfo::getSkillLevel(), ServerCommandType::item, level, model, modifiable, Modifiable_false, SkillTypeEntry::name, range, skillEffect, skillLevel, skillLevelWidth, skillTypeList, skillTypeListSize, sp, strprintf(), Catch::toString(), SkillTypeEntry::type, type, SkillType::Unknown, SkillModel::updateVisibilities(), visible, Visible_false, and Visible_true.

Referenced by SkillDialog::addSkill(), SkillDialog::loadSkill(), SkillDialog::removeSkill(), SkillDialog::selectSkillCastType(), SkillDialog::selectSkillLevel(), SkillDialog::setSkillOffsetX(), SkillDialog::setSkillOffsetY(), SkillDialog::update(), SkillDialog::updateQuest(), and SkillDialog::updateSkill().

83 {
84  const int baseLevel = PlayerInfo::getSkillLevel(id);
85  if (modifiable == Modifiable_false && baseLevel == 0)
86  {
87  if (visible == Visible_true)
88  {
90  if (model != nullptr)
92  }
93  return;
94  }
95 
96  const bool updateVisibility = (visible == Visible_false);
98 
99  if (baseLevel == 0)
100  {
101  skillLevel.clear();
102  }
103  else
104  {
105  if (customSelectedLevel == 0)
106  {
107  // TRANSLATORS: skill level
108  skillLevel = strprintf(_("Lvl: %d"), baseLevel);
109  }
110  else
111  {
112  // TRANSLATORS: skill level
113  skillLevel = strprintf(_("Lvl: %d / %d"),
115  baseLevel);
116  }
117  }
118 
119  // TRANSLATORS: skill type
120  const char *const typeStr = _("Type: %s");
121 
122  if (type == SkillType::Unknown)
123  {
124  // TRANSLATORS: Skill type
125  skillEffect = strprintf(typeStr, _("Unknown"));
126  }
127  else
128  {
129  skillEffect.clear();
130  for (size_t f = 0; f < skillTypeListSize; f ++)
131  {
132  const SkillTypeEntry &item = skillTypeList[f];
133  if ((item.type & type) != 0)
134  {
135  if (!skillEffect.empty())
136  skillEffect.append(", ");
137  skillEffect.append(strprintf(typeStr, item.name));
138  }
139  }
140  }
141  if (skillEffect.empty())
142  {
143  // TRANSLATORS: Skill type
144  skillEffect = strprintf(typeStr, _("Unknown:"));
145  skillEffect.append(" ").append(toString(CAST_S32(type)));
146  }
147 
148  if (sp != 0)
149  {
150  // TRANSLATORS: skill mana
151  skillEffect.append(strprintf(_(" / Mana: -%d"), sp));
152  }
153 
154  if (range > 0)
155  {
156  if (!skillEffect.empty())
157  skillEffect.append(" / ");
158  // TRANSLATORS: skill range
159  skillEffect.append(strprintf(_("Range: %d"), range));
160  }
161 
162  level = baseLevel;
165 
166  skillLevelWidth = -1;
167 
168  if (updateVisibility && (model != nullptr))
170 
171  data = getData(level);
172  if (data == nullptr)
173  data = dataMap[0];
174 }
#define _(s)
Definition: gettext.h:34
const bool Visible_true
Definition: visible.h:29
std::string skillEffect
Definition: skillinfo.h:52
SkillData * getData(const int level) const
Definition: skillinfo.cpp:182
const char *const name
void updateVisibilities()
Definition: skillmodel.cpp:53
SkillData * data
Definition: skillinfo.h:62
Modifiable modifiable
Definition: skillinfo.h:79
#define CAST_S32
Definition: cast.h:29
std::string strprintf(const char *const format,...)
Definition: stringutils.cpp:99
const bool Visible_false
Definition: visible.h:29
int level
Definition: skillinfo.h:63
int range
Definition: skillinfo.h:69
int sp
Definition: skillinfo.h:70
int customSelectedLevel
Definition: skillinfo.h:64
const bool Modifiable_false
Definition: modifiable.h:29
const size_t skillTypeListSize
Definition: skilltypelist.h:30
std::string skillLevel
Definition: skillinfo.h:51
std::string toString(T const &value)
converts any type to a string
Definition: catch.hpp:1774
SkillTypeEntry skillTypeList[skillTypeListSize]
Definition: skilltypelist.h:32
int getSkillLevel(const int id)
Definition: playerinfo.cpp:118
int skillLevelWidth
Definition: skillinfo.h:67
Visible visible
Definition: skillinfo.h:80
SkillDataMap dataMap
Definition: skillinfo.h:59
SkillType::SkillType type
Definition: skillinfo.h:76
const SkillType::SkillType type
SkillModel * model
Definition: skillinfo.h:60

Field Documentation

◆ alwaysVisible

Visible SkillInfo::alwaysVisible

◆ castingAction

std::string SkillInfo::castingAction

Definition at line 55 of file skillinfo.h.

Referenced by SkillDialog::loadSkill().

◆ castingRideAction

std::string SkillInfo::castingRideAction

Definition at line 56 of file skillinfo.h.

Referenced by SkillDialog::loadSkill().

◆ castingSkyAction

std::string SkillInfo::castingSkyAction

Definition at line 57 of file skillinfo.h.

Referenced by SkillDialog::loadSkill().

◆ castingWaterAction

std::string SkillInfo::castingWaterAction

Definition at line 58 of file skillinfo.h.

Referenced by SkillDialog::loadSkill().

◆ cooldown

int SkillInfo::cooldown

Definition at line 73 of file skillinfo.h.

Referenced by SkillListBox::draw(), and SkillDialog::slowLogic().

◆ customCastType

CastTypeT SkillInfo::customCastType

◆ customOffsetX

int SkillInfo::customOffsetX

◆ customOffsetY

int SkillInfo::customOffsetY

◆ customSelectedLevel

int SkillInfo::customSelectedLevel

◆ data

SkillData* SkillInfo::data

◆ dataMap

SkillDataMap SkillInfo::dataMap

Definition at line 59 of file skillinfo.h.

Referenced by addData(), getData(), getData1(), SkillInfo(), update(), and ~SkillInfo().

◆ duration

int SkillInfo::duration

Definition at line 71 of file skillinfo.h.

Referenced by SkillDialog::setSkillDuration(), and SkillDialog::slowLogic().

◆ durationTime

int SkillInfo::durationTime

Definition at line 72 of file skillinfo.h.

Referenced by SkillDialog::setSkillDuration(), and SkillDialog::slowLogic().

◆ errorText

std::string SkillInfo::errorText

◆ id

unsigned int SkillInfo::id

◆ level

int SkillInfo::level

◆ model

SkillModel* SkillInfo::model

◆ modifiable

Modifiable SkillInfo::modifiable

◆ owner

SkillOwner::Type SkillInfo::owner

◆ range

int SkillInfo::range

Definition at line 69 of file skillinfo.h.

Referenced by SkillDialog::addSkill(), update(), and SkillDialog::updateSkill().

◆ skillEffect

std::string SkillInfo::skillEffect

Definition at line 52 of file skillinfo.h.

Referenced by SkillPopup::show(), and update().

◆ skillLevel

std::string SkillInfo::skillLevel

◆ skillLevelWidth

int SkillInfo::skillLevelWidth

◆ sp

int SkillInfo::sp

Definition at line 70 of file skillinfo.h.

Referenced by SkillDialog::addSkill(), update(), and SkillDialog::updateSkill().

◆ tab

SkillTab* SkillInfo::tab

◆ type

SkillType::SkillType SkillInfo::type

◆ useButton

std::string SkillInfo::useButton

Definition at line 53 of file skillinfo.h.

Referenced by SkillDialog::addSkill(), and SkillDialog::loadSkill().

◆ useTextParameter

bool SkillInfo::useTextParameter

◆ visible

Visible SkillInfo::visible

◆ x

int SkillInfo::x

◆ y

int SkillInfo::y

The documentation for this struct was generated from the following files: