summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-08-01 16:33:36 +0300
committerAndrei Karas <akaras@inbox.ru>2017-08-01 19:20:50 +0300
commit30586d87976c755a6a3922ff275d2cc36faa3255 (patch)
tree4528134e9ecd414aab4679db4d5b1a00797f0087
parent547fb04145d2ab1e5c68a47b1e673aa352d41da6 (diff)
downloadplus-30586d87976c755a6a3922ff275d2cc36faa3255.tar.gz
plus-30586d87976c755a6a3922ff275d2cc36faa3255.tar.bz2
plus-30586d87976c755a6a3922ff275d2cc36faa3255.tar.xz
plus-30586d87976c755a6a3922ff275d2cc36faa3255.zip
Add default icons for unknown skills by types.
-rw-r--r--src/defaults.cpp8
-rw-r--r--src/gui/windows/skilldialog.cpp41
-rw-r--r--src/gui/windows/skilldialog.h3
3 files changed, 50 insertions, 2 deletions
diff --git a/src/defaults.cpp b/src/defaults.cpp
index ab377d31f..8f443d892 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -689,6 +689,14 @@ DefaultsData* getPathsDefaults()
AddDEF("languageIcons", "graphics/badges/flags");
AddDEF("palettesDir", "");
AddDEF("defaultPaletteFile", "palette.gpl");
+ AddDEF("unknownSkillIcon", "graphics/sprites/error.png");
+ AddDEF("attackSkillIcon", "graphics/sprites/error.png");
+ AddDEF("groundSkillIcon", "graphics/sprites/error.png");
+ AddDEF("selfSkillIcon", "graphics/sprites/error.png");
+ AddDEF("unusedSkillIcon", "graphics/sprites/error.png");
+ AddDEF("supportSkillIcon", "graphics/sprites/error.png");
+ AddDEF("trapSkillIcon", "graphics/sprites/error.png");
+ AddDEF("missingSkillIcon", "graphics/sprites/error.png");
AddDEF("overweightPercent", 50);
AddDEF("playerNameOffset", 64);
diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp
index ae6b72a35..a0401012d 100644
--- a/src/gui/windows/skilldialog.cpp
+++ b/src/gui/windows/skilldialog.cpp
@@ -508,7 +508,10 @@ void SkillDialog::loadSkillData(XmlNodeConstPtr node,
strprintf(_("Skill %u"), skill->id));
data->name = name;
const std::string icon = XML::getProperty(node, "icon", "");
- data->setIcon(icon);
+ if (icon.empty())
+ data->setIcon(paths.getStringValue("missingSkillIcon"));
+ else
+ data->setIcon(icon);
if (skill->id < SKILL_VAR_MIN_ID)
{
data->dispName = strprintf("%s, %u",
@@ -614,6 +617,40 @@ bool SkillDialog::updateSkill(const int id,
return false;
}
+std::string SkillDialog::getDefaultSkillIcon(const SkillType::SkillType type)
+{
+ std::string icon;
+ switch (type)
+ {
+ case SkillType::Attack:
+ icon = paths.getStringValue("attackSkillIcon");
+ break;
+ case SkillType::Ground:
+ icon = paths.getStringValue("groundSkillIcon");
+ break;
+ case SkillType::Self:
+ icon = paths.getStringValue("selfSkillIcon");
+ break;
+ case SkillType::Unused:
+ icon = paths.getStringValue("unusedSkillIcon");
+ break;
+ case SkillType::Support:
+ icon = paths.getStringValue("supportSkillIcon");
+ break;
+ case SkillType::TargetTrap:
+ icon = paths.getStringValue("trapSkillIcon");
+ break;
+ case SkillType::Unknown:
+ icon = paths.getStringValue("unknownSkillIcon");
+ break;
+ default:
+ break;
+ }
+ if (icon.empty())
+ return paths.getStringValue("missingSkillIcon");
+ return icon;
+}
+
void SkillDialog::addSkill(const SkillOwner::Type owner,
const int id,
const std::string &name,
@@ -641,7 +678,7 @@ void SkillDialog::addSkill(const SkillOwner::Type owner,
data->dispName = strprintf("%s, %u", name.c_str(), skill->id);
}
data->description.clear();
- data->setIcon("");
+ data->setIcon(getDefaultSkillIcon(type));
data->shortName = toString(skill->id);
skill->modifiable = modifiable;
skill->visible = Visible_false;
diff --git a/src/gui/windows/skilldialog.h b/src/gui/windows/skilldialog.h
index ab65f9f1b..2273125f0 100644
--- a/src/gui/windows/skilldialog.h
+++ b/src/gui/windows/skilldialog.h
@@ -207,6 +207,9 @@ class SkillDialog final : public Window,
int offsetX,
int offsetY);
+ static std::string getDefaultSkillIcon(const SkillType::SkillType
+ type);
+
void addSkillDuration(SkillInfo *const skill);
SkillInfo *loadSkill(XmlNodeConstPtr node,