summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-12-27 01:09:30 +0300
committerAndrei Karas <akaras@inbox.ru>2012-12-27 23:15:05 +0300
commit81d317cf80f4c333396c708bbefca16be2362c8c (patch)
tree1bd2818130625873c50ecbda9b3e826e51c809bb /src/gui
parente56ea6cbf7726b258a4eb6b51a0574cddd862558 (diff)
downloadplus-81d317cf80f4c333396c708bbefca16be2362c8c.tar.gz
plus-81d317cf80f4c333396c708bbefca16be2362c8c.tar.bz2
plus-81d317cf80f4c333396c708bbefca16be2362c8c.tar.xz
plus-81d317cf80f4c333396c708bbefca16be2362c8c.zip
Improve containders text draw speed.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/widgets/dropshortcutcontainer.cpp16
-rw-r--r--src/gui/widgets/emoteshortcutcontainer.cpp7
-rw-r--r--src/gui/widgets/itemcontainer.cpp10
-rw-r--r--src/gui/widgets/itemshortcutcontainer.cpp27
-rw-r--r--src/gui/widgets/spellshortcutcontainer.cpp10
5 files changed, 44 insertions, 26 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")
diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp
index dcd4fa08e..68296ffc8 100644
--- a/src/gui/widgets/emoteshortcutcontainer.cpp
+++ b/src/gui/widgets/emoteshortcutcontainer.cpp
@@ -39,6 +39,8 @@
#include "utils/dtor.h"
+#include <guichan/font.hpp>
+
#include "debug.h"
static const int MAX_ITEMS = 48;
@@ -110,7 +112,8 @@ void EmoteShortcutContainer::draw(gcn::Graphics *graphics)
mBackgroundImg->setAlpha(mAlpha);
Graphics *const g = static_cast<Graphics *const>(graphics);
- graphics->setFont(getFont());
+ gcn::Font *const font = getFont();
+ graphics->setFont(font);
drawBackground(g);
graphics->setColor(mForegroundColor);
@@ -123,7 +126,7 @@ void EmoteShortcutContainer::draw(gcn::Graphics *graphics)
const std::string key = inputManager.getKeyValueString(
Input::KEY_EMOTE_1 + i);
- g->drawText(key, emoteX + 2, emoteY + 2, gcn::Graphics::LEFT);
+ font->drawString(g, key, emoteX + 2, emoteY + 2);
}
const unsigned sz = static_cast<unsigned>(mEmoteImg.size());
for (unsigned i = 0; i < mMaxItems; i++)
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index 6e9ce1657..ffb6c590f 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -43,6 +43,7 @@
#include "resources/image.h"
+#include <guichan/font.hpp>
#include <guichan/mouseinput.hpp>
#include <guichan/selectionlistener.hpp>
@@ -234,8 +235,8 @@ void ItemContainer::draw(gcn::Graphics *graphics)
BLOCK_START("ItemContainer::draw")
Graphics *const g = static_cast<Graphics *const>(graphics);
-
- g->setFont(getFont());
+ gcn::Font *const font = getFont();
+ g->setFont(font);
for (int j = 0; j < mGridRows; j++)
{
@@ -315,8 +316,9 @@ void ItemContainer::draw(gcn::Graphics *graphics)
else
g->setColor(mUnEquipedColor);
- g->drawText(caption, itemX + mBoxWidth / 2,
- itemY + mEquippedTextPadding, gcn::Graphics::CENTER);
+ font->drawString(g, caption,
+ itemX + (mBoxWidth - font->getWidth(caption)) / 2,
+ itemY + mEquippedTextPadding);
}
}
BLOCK_END("ItemContainer::draw")
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")
diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp
index af9457078..ee43a5d3f 100644
--- a/src/gui/widgets/spellshortcutcontainer.cpp
+++ b/src/gui/widgets/spellshortcutcontainer.cpp
@@ -40,6 +40,8 @@
#include "utils/gettext.h"
+#include <guichan/font.hpp>
+
#include "debug.h"
SpellShortcutContainer::SpellShortcutContainer(const unsigned number) :
@@ -102,8 +104,8 @@ void SpellShortcutContainer::draw(gcn::Graphics *graphics)
}
Graphics *const g = static_cast<Graphics *const>(graphics);
-
- graphics->setFont(getFont());
+ gcn::Font *const font = getFont();
+ graphics->setFont(font);
const int selectedId = spellShortcut->getSelectedItem();
g->setColor(mForegroundColor);
@@ -139,8 +141,8 @@ void SpellShortcutContainer::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);
}
}