From c14af75fab3ddb45886a358e5056c2b0baee91e1 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 4 Jul 2016 20:04:05 +0300 Subject: Use skill type as bit mask with skill types. It rare but still possible. --- src/gui/widgets/skillinfo.cpp | 65 +++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 40 deletions(-) (limited to 'src/gui/widgets') diff --git a/src/gui/widgets/skillinfo.cpp b/src/gui/widgets/skillinfo.cpp index 4174146e2..2ce169451 100644 --- a/src/gui/widgets/skillinfo.cpp +++ b/src/gui/widgets/skillinfo.cpp @@ -31,6 +31,8 @@ #include "utils/gettext.h" #include "utils/stringutils.h" +#include "resources/skilltypelist.h" + #include "debug.h" SkillInfo::SkillInfo() : @@ -113,47 +115,30 @@ void SkillInfo::update() // TRANSLATORS: skill type const char *const typeStr = _("Type: %s"); - switch (type) + + if (type == SkillType::Unknown) + { + // TRANSLATORS: Skill type + skillEffect = strprintf(typeStr, _("Unknown")); + } + else + { + for (size_t f = 0; f < skillTypeListSize; f ++) + { + const SkillTypeEntry &item = skillTypeList[f]; + if ((item.type & type) != 0) + { + if (!skillEffect.empty()) + skillEffect.append(", "); + skillEffect.append(strprintf(typeStr, item.name)); + } + } + } + if (skillEffect.empty()) { - case SkillType::Unknown: - // TRANSLATORS: Skill type - skillEffect = strprintf(typeStr, _("Unknown")); - break; - - case SkillType::Attack: - // TRANSLATORS: Skill type - skillEffect = strprintf(typeStr, _("Attack")); - break; - - case SkillType::Ground: - // TRANSLATORS: Skill type - skillEffect = strprintf(typeStr, _("Ground")); - break; - - case SkillType::Self: - // TRANSLATORS: Skill type - skillEffect = strprintf(typeStr, _("Self")); - break; - - case SkillType::Unused: - // TRANSLATORS: Skill type - skillEffect = strprintf(typeStr, _("Unused")); - break; - - case SkillType::Support: - // TRANSLATORS: Skill type - skillEffect = strprintf(typeStr, _("Support")); - break; - - case SkillType::TargetTrap: - // TRANSLATORS: Skill type - skillEffect = strprintf(typeStr, _("Target trap")); - break; - default: - // TRANSLATORS: Skill type - skillEffect = strprintf(typeStr, _("Unknown:")); - skillEffect.append(" ").append(toString(CAST_S32(type))); - break; + // TRANSLATORS: Skill type + skillEffect = strprintf(typeStr, _("Unknown:")); + skillEffect.append(" ").append(toString(CAST_S32(type))); } if (sp) -- cgit v1.2.3-70-g09d2