diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-12-27 01:09:30 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-12-27 23:15:05 +0300 |
commit | 81d317cf80f4c333396c708bbefca16be2362c8c (patch) | |
tree | 1bd2818130625873c50ecbda9b3e826e51c809bb /src/gui/widgets/dropshortcutcontainer.cpp | |
parent | e56ea6cbf7726b258a4eb6b51a0574cddd862558 (diff) | |
download | mv-81d317cf80f4c333396c708bbefca16be2362c8c.tar.gz mv-81d317cf80f4c333396c708bbefca16be2362c8c.tar.bz2 mv-81d317cf80f4c333396c708bbefca16be2362c8c.tar.xz mv-81d317cf80f4c333396c708bbefca16be2362c8c.zip |
Improve containders text draw speed.
Diffstat (limited to 'src/gui/widgets/dropshortcutcontainer.cpp')
-rw-r--r-- | src/gui/widgets/dropshortcutcontainer.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/gui/widgets/dropshortcutcontainer.cpp b/src/gui/widgets/dropshortcutcontainer.cpp index a1c7d2742..6f20be38a 100644 --- a/src/gui/widgets/dropshortcutcontainer.cpp +++ b/src/gui/widgets/dropshortcutcontainer.cpp @@ -35,6 +35,8 @@ #include "resources/image.h" #include "resources/resourcemanager.h" +#include <guichan/font.hpp> + #include "debug.h" DropShortcutContainer::DropShortcutContainer(): @@ -110,6 +112,8 @@ void DropShortcutContainer::draw(gcn::Graphics *graphics) return; } + gcn::Font *const font = getFont(); + for (unsigned i = 0; i < mMaxItems; i++) { const int itemX = (i % mGridWidth) * mBoxWidth; @@ -140,8 +144,9 @@ void DropShortcutContainer::draw(gcn::Graphics *graphics) g->setColor(mEquipedColor); else g->setColor(mUnEquipedColor); - g->drawText(caption, itemX + mBoxWidth / 2, - itemY + mBoxHeight - 14, gcn::Graphics::CENTER); + font->drawString(g, caption, + itemX + (mBoxWidth - font->getWidth(caption)) / 2, + itemY + mBoxHeight - 14); } } } @@ -154,11 +159,12 @@ void DropShortcutContainer::draw(gcn::Graphics *graphics) { const int tPosX = mCursorPosX - (image->mBounds.w / 2); const int tPosY = mCursorPosY - (image->mBounds.h / 2); + const std::string str = toString(mItemMoved->getQuantity()); g->drawImage(image, tPosX, tPosY); - g->drawText(toString(mItemMoved->getQuantity()), - tPosX + mBoxWidth / 2, tPosY + mBoxHeight - 14, - gcn::Graphics::CENTER); + font->drawString(g, str, + tPosX + (mBoxWidth / 2 - font->getWidth(str)) / 2, + tPosY + mBoxHeight - 14); } } BLOCK_END("DropShortcutContainer::draw") |