summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-12-26 22:02:38 +0300
committerAndrei Karas <akaras@inbox.ru>2012-12-27 23:15:05 +0300
commitee5cd2f31dcea97654288ec6c6a5c291fc11ddcb (patch)
tree3dccf0736dffa111eaa2a4a120e16cbe2d39a112 /src/gui
parent58ddd6adb93ea973e7081bfdd4e87460a1b67cae (diff)
downloadmv-ee5cd2f31dcea97654288ec6c6a5c291fc11ddcb.tar.gz
mv-ee5cd2f31dcea97654288ec6c6a5c291fc11ddcb.tar.bz2
mv-ee5cd2f31dcea97654288ec6c6a5c291fc11ddcb.tar.xz
mv-ee5cd2f31dcea97654288ec6c6a5c291fc11ddcb.zip
Improves skill info draw speed.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/skilldialog.cpp42
-rw-r--r--src/gui/skilldialog.h4
2 files changed, 21 insertions, 25 deletions
diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp
index 219223240..deefdbd77 100644
--- a/src/gui/skilldialog.cpp
+++ b/src/gui/skilldialog.cpp
@@ -154,7 +154,8 @@ class SkillListBox final : public ListBox
// Draw the list elements
graphics->setColor(mTextColor);
- const int space = graphics->getFont()->getHeight() + mSpacing;
+ gcn::Font *const font = getFont();
+ const int space = font->getHeight() + mSpacing;
const int width2 = getWidth() - mPadding;
for (int i = 0, y = 1;
i < model->getNumberOfElements();
@@ -163,8 +164,25 @@ class SkillListBox final : public ListBox
SkillInfo *const e = model->getSkillAt(i);
if (e)
{
- e->draw(graphics, mPadding, mTextPadding,
- space, y, width2);
+ const SkillData *const data = e->data;
+ const int yPad = y + mPadding;
+ const std::string &description = data->description;
+ graphics->drawImage(data->icon, mPadding, yPad);
+ font->drawString(graphics, data->name, mTextPadding, yPad);
+ if (!description.empty())
+ {
+ font->drawString(graphics, description,
+ mTextPadding, yPad + space);
+ }
+
+ if (e->skillLevelWidth < 0)
+ {
+ // Add one for padding
+ e->skillLevelWidth = font->getWidth(e->skillLevel) + 1;
+ }
+
+ font->drawString(graphics, e->skillLevel, width2
+ - e->skillLevelWidth, yPad);
}
}
}
@@ -695,24 +713,6 @@ void SkillInfo::update()
data = dataMap[0];
}
-void SkillInfo::draw(Graphics *const graphics, const int padding,
- const int paddingText, const int spacingText,
- const int y, const int width)
-{
- const int yPad = y + padding;
- graphics->drawImage(data->icon, padding, yPad);
- graphics->drawText(data->name, paddingText, yPad);
- if (!data->description.empty())
- graphics->drawText(data->description, paddingText, yPad + spacingText);
-
- if (skillLevelWidth < 0)
- {
- // Add one for padding
- skillLevelWidth = graphics->getFont()->getWidth(skillLevel) + 1;
- }
-
- graphics->drawText(skillLevel, width - skillLevelWidth, yPad);
-}
void SkillInfo::addData(const int level1, SkillData *const data1)
{
diff --git a/src/gui/skilldialog.h b/src/gui/skilldialog.h
index 7ca8b942a..fe1cbbbde 100644
--- a/src/gui/skilldialog.h
+++ b/src/gui/skilldialog.h
@@ -86,10 +86,6 @@ struct SkillInfo final
void update();
- void draw(Graphics *const graphics, const int padding,
- const int paddingText, const int spacingText,
- const int y, const int width);
-
SkillData *getData(const int level);
SkillData *getData1(const int level);