3
* Copyright (C) 2004-2009 The Mana World Development Team
4
* Copyright (C) 2009-2010 The Mana Developers
5
* Copyright (C) 2011-2013 The ManaPlus Developers
7
* This file is part of The ManaPlus Client.
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
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.
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/>.
23
#include "gui/widgets/skillinfo.h"
25
#include "playerinfo.h"
27
#include "gui/widgets/skillmodel.h"
31
SkillInfo::SkillInfo() :
46
dataMap[0] = new SkillData();
50
SkillInfo::~SkillInfo()
52
FOR_EACH (SkillDataMapIter, it, dataMap)
57
void SkillInfo::update()
59
const int baseLevel = PlayerInfo::getSkillLevel(id);
60
const std::pair<int, int> exp = PlayerInfo::getStatExperience(id);
62
if (!modifiable && baseLevel == 0 && exp.second == 0)
68
model->updateVisibilities();
73
const bool updateVisibility = !visible;
82
// TRANSLATORS: skills dialog. skill level
83
skillLevel = strprintf(_("Lvl: %d"), baseLevel);
91
skillExp = strprintf("%d / %d", exp.first, exp.second);
92
progress = static_cast<float>(exp.first)
93
/ static_cast<float>(exp.second);
101
color = Theme::getProgressColor(Theme::PROG_EXP, progress);
103
if (updateVisibility && model)
104
model->updateVisibilities();
106
data = getData(level);
112
void SkillInfo::addData(const int level1, SkillData *const data1)
114
dataMap[level1] = data1;
117
SkillData *SkillInfo::getData(const int level1) const
119
SkillDataMapCIter it = dataMap.find(level1);
120
if (it == dataMap.end())
125
SkillData *SkillInfo::getData1(const int lev) const
127
SkillDataMapCIter it = dataMap.find(lev);
128
if (it == dataMap.end())
129
return (*dataMap.begin()).second;