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/itemshortcutcontainer.cpp | |
parent | e56ea6cbf7726b258a4eb6b51a0574cddd862558 (diff) | |
download | manaverse-81d317cf80f4c333396c708bbefca16be2362c8c.tar.gz manaverse-81d317cf80f4c333396c708bbefca16be2362c8c.tar.bz2 manaverse-81d317cf80f4c333396c708bbefca16be2362c8c.tar.xz manaverse-81d317cf80f4c333396c708bbefca16be2362c8c.zip |
Improve containders text draw speed.
Diffstat (limited to 'src/gui/widgets/itemshortcutcontainer.cpp')
-rw-r--r-- | src/gui/widgets/itemshortcutcontainer.cpp | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp index 2e3d60d65..eaffa8fad 100644 --- a/src/gui/widgets/itemshortcutcontainer.cpp +++ b/src/gui/widgets/itemshortcutcontainer.cpp @@ -41,6 +41,8 @@ #include "resources/image.h" +#include <guichan/font.hpp> + #include "debug.h" ItemShortcutContainer::ItemShortcutContainer(const unsigned number) : @@ -116,7 +118,8 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics) } Graphics *const g = static_cast<Graphics*>(graphics); - graphics->setFont(getFont()); + gcn::Font *const font = getFont(); + graphics->setFont(font); drawBackground(g); const Inventory *const inv = PlayerInfo::getInventory(); @@ -136,7 +139,7 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics) Input::KEY_SHORTCUT_1 + i); graphics->setColor(mForegroundColor); - g->drawText(key, itemX + 2, itemY + 2, gcn::Graphics::LEFT); + font->drawString(g, key, itemX + 2, itemY + 2); const int itemId = selShortcut->getItem(i); const unsigned char itemColor = selShortcut->getItemColor(i); @@ -168,8 +171,9 @@ void ItemShortcutContainer::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); } } } @@ -190,8 +194,8 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics) } } - g->drawText(spell->getSymbol(), itemX + 2, - itemY + mBoxHeight / 2, gcn::Graphics::LEFT); + font->drawString(g, spell->getSymbol(), + itemX + 2, itemY + mBoxHeight / 2); } } else if (skillDialog) @@ -208,8 +212,8 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics) g->drawImage(image, itemX, itemY); } - g->drawText(skill->data->shortName, itemX + 2, - itemY + mBoxHeight / 2, gcn::Graphics::LEFT); + font->drawString(g, skill->data->shortName, itemX + 2, + itemY + mBoxHeight / 2); } } } @@ -222,11 +226,12 @@ void ItemShortcutContainer::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 - font->getWidth(str)) / 2, + tPosY + mBoxHeight - 14); } } BLOCK_END("ItemShortcutContainer::draw") |