From 0c34224ca4f6cbc21c24e2e6018ded03c6906c44 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 27 Dec 2012 00:05:12 +0300 Subject: Improve servers list draw speed. --- src/gui/serverdialog.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'src/gui') diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index 220f0c1b3..926b9332a 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -189,6 +189,12 @@ public: height)); } + gcn::Font *const font1 = boldFont; + gcn::Font *const font2 = getFont(); + const int fontHeight = font1->getHeight(); + const int pad1 = fontHeight + mPadding; + const int pad2 = height / 4 + mPadding; + const int width = getWidth(); // Draw the list elements for (int i = 0, y = 0; i < model->getNumberOfElements(); ++i, y += height) @@ -205,28 +211,24 @@ public: if (!info.name.empty()) { - graphics->setFont(boldFont); - x += boldFont->getWidth(info.name) + 15; - graphics->drawText(info.name, mPadding, y + mPadding); - top = y + boldFont->getHeight() + mPadding; + x += font1->getWidth(info.name) + 15; + font1->drawString(graphics, info.name, mPadding, y + mPadding); + top = y + pad1; } else { - top = y + height / 4 + mPadding; + top = y + pad2; } - graphics->setFont(getFont()); - if (!info.description.empty()) - graphics->drawText(info.description, x, y + mPadding); - graphics->drawText(model->getElementAt(i), mPadding, top); + font2->drawString(graphics, info.description, x, y + mPadding); + font2->drawString(graphics, model->getElementAt(i), mPadding, top); if (info.version.first > 0) { graphics->setColor(mNotSupportedColor); - - graphics->drawText(info.version.second, - getWidth() - info.version.first - mPadding, top); + font2->drawString(graphics, info.version.second, + width - info.version.first - mPadding, top); } } } -- cgit v1.2.3-70-g09d2