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 50 of file skillinfo.h.

Constructor & Destructor Documentation

◆ SkillInfo()

SkillInfo::SkillInfo ( )

Definition at line 38 of file skillinfo.cpp.

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

References data, and dataMap.

◆ ~SkillInfo()

SkillInfo::~SkillInfo ( )

Definition at line 76 of file skillinfo.cpp.

77 {
79  delete (*it).second;
80  dataMap.clear();
81 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:25
SkillDataMap::iterator SkillDataMapIter
Definition: skillinfo.h:47

References dataMap, and FOR_EACH.

Member Function Documentation

◆ addData()

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

Definition at line 178 of file skillinfo.cpp.

179 {
180  dataMap[level1] = data1;
181 }

References dataMap.

◆ getData()

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

Definition at line 183 of file skillinfo.cpp.

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

References dataMap.

Referenced by update().

◆ getData1()

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

Definition at line 191 of file skillinfo.cpp.

192 {
193  const SkillDataMapCIter it = dataMap.find(lev);
194  if (it == dataMap.end())
195  return (*dataMap.begin()).second;
196  return (*it).second;
197 }

References dataMap.

◆ isUsable()

bool SkillInfo::isUsable ( ) const
inline

Definition at line 96 of file skillinfo.h.

97  {
98  return type == SkillType::Attack
99  || type == SkillType::Self
100  || type == SkillType::Support;
101  }

References SkillType::Attack, SkillType::Self, SkillType::Support, and type.

◆ toDataStr()

std::string SkillInfo::toDataStr ( ) const

Definition at line 199 of file skillinfo.cpp.

200 {
201  return strprintf("%d %d %d",
204  customOffsetY);
205 }
#define CAST_S32
Definition: cast.h:30
std::string strprintf(const char *const format,...)

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

◆ update()

void SkillInfo::update ( )

Definition at line 83 of file skillinfo.cpp.

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

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

Field Documentation

◆ alwaysVisible

Visible SkillInfo::alwaysVisible

Definition at line 82 of file skillinfo.h.

◆ castingAction

std::string SkillInfo::castingAction

Definition at line 56 of file skillinfo.h.

◆ castingRideAction

std::string SkillInfo::castingRideAction

Definition at line 57 of file skillinfo.h.

◆ castingSkyAction

std::string SkillInfo::castingSkyAction

Definition at line 58 of file skillinfo.h.

◆ castingWaterAction

std::string SkillInfo::castingWaterAction

Definition at line 59 of file skillinfo.h.

◆ cooldown

int SkillInfo::cooldown

Definition at line 74 of file skillinfo.h.

Referenced by SkillListBox::draw().

◆ customCastType

CastTypeT SkillInfo::customCastType

Definition at line 79 of file skillinfo.h.

Referenced by toDataStr().

◆ customOffsetX

int SkillInfo::customOffsetX

Definition at line 66 of file skillinfo.h.

Referenced by toDataStr().

◆ customOffsetY

int SkillInfo::customOffsetY

Definition at line 67 of file skillinfo.h.

Referenced by toDataStr().

◆ customSelectedLevel

int SkillInfo::customSelectedLevel

Definition at line 65 of file skillinfo.h.

Referenced by update().

◆ data

SkillData* SkillInfo::data

Definition at line 63 of file skillinfo.h.

Referenced by SkillListBox::draw(), SkillRectangleListBox::draw(), SkillInfo(), and update().

◆ dataMap

SkillDataMap SkillInfo::dataMap

Definition at line 60 of file skillinfo.h.

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

◆ duration

int SkillInfo::duration

Definition at line 72 of file skillinfo.h.

◆ durationTime

int SkillInfo::durationTime

Definition at line 73 of file skillinfo.h.

◆ errorText

std::string SkillInfo::errorText

Definition at line 55 of file skillinfo.h.

◆ id

unsigned int SkillInfo::id

Definition at line 69 of file skillinfo.h.

◆ level

int SkillInfo::level

Definition at line 64 of file skillinfo.h.

Referenced by update().

◆ model

SkillModel* SkillInfo::model

Definition at line 61 of file skillinfo.h.

Referenced by update().

◆ modifiable

Modifiable SkillInfo::modifiable

Definition at line 80 of file skillinfo.h.

Referenced by update().

◆ owner

SkillOwner::Type SkillInfo::owner

Definition at line 78 of file skillinfo.h.

◆ range

int SkillInfo::range

Definition at line 70 of file skillinfo.h.

Referenced by update().

◆ skillEffect

std::string SkillInfo::skillEffect

Definition at line 53 of file skillinfo.h.

Referenced by update().

◆ skillLevel

std::string SkillInfo::skillLevel

Definition at line 52 of file skillinfo.h.

Referenced by SkillListBox::draw(), SkillRectangleListBox::draw(), and update().

◆ skillLevelWidth

int SkillInfo::skillLevelWidth

Definition at line 68 of file skillinfo.h.

Referenced by SkillListBox::draw(), SkillRectangleListBox::draw(), and update().

◆ sp

int SkillInfo::sp

Definition at line 71 of file skillinfo.h.

Referenced by update().

◆ tab

SkillTab* SkillInfo::tab

Definition at line 62 of file skillinfo.h.

◆ type

SkillType::SkillType SkillInfo::type

Definition at line 77 of file skillinfo.h.

Referenced by isUsable(), and update().

◆ useButton

std::string SkillInfo::useButton

Definition at line 54 of file skillinfo.h.

◆ useTextParameter

bool SkillInfo::useTextParameter

Definition at line 83 of file skillinfo.h.

◆ visible

Visible SkillInfo::visible

Definition at line 81 of file skillinfo.h.

Referenced by update().

◆ x

int SkillInfo::x

◆ y

int SkillInfo::y

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