summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-05-25 01:58:52 +0300
committerAndrei Karas <akaras@inbox.ru>2015-05-25 01:58:52 +0300
commite3682e2cdcb59c36792f6f9c39569e0af01088f0 (patch)
treeb4d7a665652e4a8c00f28d557f96b120abc62002
parent1b3a9751ae558e45c614f04525d5ff65e3c0fc1e (diff)
downloadplus-e3682e2cdcb59c36792f6f9c39569e0af01088f0.tar.gz
plus-e3682e2cdcb59c36792f6f9c39569e0af01088f0.tar.bz2
plus-e3682e2cdcb59c36792f6f9c39569e0af01088f0.tar.xz
plus-e3682e2cdcb59c36792f6f9c39569e0af01088f0.zip
Dont set global color variables before drawing text.
This allow not set actual OpenGL color on each call because it useless for drawing text.
-rw-r--r--src/actions/actions.cpp6
-rw-r--r--src/being/being.cpp4
-rw-r--r--src/flooritem.cpp10
-rw-r--r--src/game.cpp12
-rw-r--r--src/gui/fonts/font.cpp6
-rw-r--r--src/gui/fonts/font.h2
-rw-r--r--src/gui/gui.cpp6
-rw-r--r--src/gui/viewport.cpp7
-rw-r--r--src/gui/widgets/avatarlistbox.cpp30
-rw-r--r--src/gui/widgets/browserbox.cpp17
-rw-r--r--src/gui/widgets/button.cpp1
-rw-r--r--src/gui/widgets/colorpage.cpp17
-rw-r--r--src/gui/widgets/dropdown.cpp18
-rw-r--r--src/gui/widgets/emoteshortcutcontainer.cpp7
-rw-r--r--src/gui/widgets/extendedlistbox.cpp22
-rw-r--r--src/gui/widgets/itemcontainer.cpp20
-rw-r--r--src/gui/widgets/itemshortcutcontainer.cpp36
-rw-r--r--src/gui/widgets/label.cpp1
-rw-r--r--src/gui/widgets/listbox.cpp28
-rw-r--r--src/gui/widgets/progressbar.cpp9
-rw-r--r--src/gui/widgets/serverslistbox.h25
-rw-r--r--src/gui/widgets/shoplistbox.cpp18
-rw-r--r--src/gui/widgets/skilllistbox.h23
-rw-r--r--src/gui/widgets/spellshortcutcontainer.cpp5
-rw-r--r--src/gui/widgets/textbox.cpp6
-rw-r--r--src/gui/widgets/textfield.cpp7
-rw-r--r--src/gui/widgets/textpreview.cpp23
-rw-r--r--src/gui/widgets/virtshortcutcontainer.cpp21
-rw-r--r--src/gui/widgets/window.cpp7
-rw-r--r--src/gui/windows/equipmentwindow.cpp3
-rw-r--r--src/particle/textparticle.cpp15
-rw-r--r--src/resources/map/mapitem.cpp8
-rw-r--r--src/test/testlauncher.cpp5
-rw-r--r--src/text.cpp15
-rw-r--r--src/touchmanager.cpp10
35 files changed, 319 insertions, 131 deletions
diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp
index eb05e5811..caef71b01 100644
--- a/src/actions/actions.cpp
+++ b/src/actions/actions.cpp
@@ -1372,15 +1372,17 @@ impHandler0(testSdlFont)
nullGraphics->beginDraw();
clock_gettime(CLOCK_MONOTONIC, &time1);
+ Color color(0, 0, 0, 255);
+
for (int f = 0; f < 500; f ++)
{
FOR_EACH (std::vector<std::string>::const_iterator, it, data)
{
width += font->getWidth(*it);
- font->drawString(nullGraphics, *it, 10, 10);
+ font->drawString(nullGraphics, color, color, *it, 10, 10);
}
FOR_EACH (std::vector<std::string>::const_iterator, it, data)
- font->drawString(nullGraphics, *it, 10, 10);
+ font->drawString(nullGraphics, color, color, *it, 10, 10);
font->doClean();
}
diff --git a/src/being/being.cpp b/src/being/being.cpp
index c11da7493..206151533 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -2560,8 +2560,8 @@ void Being::drawSpriteAt(Graphics *const graphics,
Font *const font = gui->getFont();
if (font)
{
- graphics->setColor(userPalette->getColor(UserPalette::BEING));
- font->drawString(graphics, mName, x, y);
+ const Color &color = userPalette->getColor(UserPalette::BEING);
+ font->drawString(graphics, color, color, mName, x, y);
}
}
}
diff --git a/src/flooritem.cpp b/src/flooritem.cpp
index c28b0a239..0de19f886 100644
--- a/src/flooritem.cpp
+++ b/src/flooritem.cpp
@@ -162,10 +162,12 @@ void FloorItem::draw(Graphics *const graphics,
{
if (font && mAmount > 1)
{
-// graphics->setColor(Color(255, 255, 255, 100));
- graphics->setColor(userPalette->getColor(
- UserPalette::FLOOR_ITEM_TEXT));
- font->drawString(graphics, toString(mAmount), x, y);
+ const Color &color = userPalette->getColor(
+ UserPalette::FLOOR_ITEM_TEXT);
+ font->drawString(graphics,
+ color, color,
+ toString(mAmount),
+ x, y);
}
}
BLOCK_END("FloorItem::draw")
diff --git a/src/game.cpp b/src/game.cpp
index 7026051da..41f6ff760 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -491,9 +491,15 @@ void Game::addWatermark()
{
if (!boldFont || !config.getBoolValue("addwatermark"))
return;
- mainGraphics->setColorAll(theme->getColor(Theme::TEXT, 255),
- theme->getColor(Theme::TEXT_OUTLINE, 255));
- boldFont->drawString(mainGraphics, settings.serverName, 100, 50);
+
+ const Color &color1 = theme->getColor(Theme::TEXT, 255);
+ const Color &color2 = theme->getColor(Theme::TEXT_OUTLINE, 255);
+
+ boldFont->drawString(mainGraphics,
+ color1,
+ color2,
+ settings.serverName,
+ 100, 50);
}
bool Game::createScreenshot()
diff --git a/src/gui/fonts/font.cpp b/src/gui/fonts/font.cpp
index 31ca8552a..2e894a380 100644
--- a/src/gui/fonts/font.cpp
+++ b/src/gui/fonts/font.cpp
@@ -202,6 +202,8 @@ void Font::clear()
}
void Font::drawString(Graphics *const graphics,
+ Color col,
+ const Color &col2,
const std::string &text,
const int x, const int y)
{
@@ -212,8 +214,8 @@ void Font::drawString(Graphics *const graphics,
return;
}
- Color col = graphics->getColor();
- const Color &col2 = graphics->getColor2();
+// Color col = graphics->getColor();
+// const Color &col2 = graphics->getColor2();
const float alpha = static_cast<float>(col.a) / 255.0F;
/* The alpha value is ignored at string generation so avoid caching the
diff --git a/src/gui/fonts/font.h b/src/gui/fonts/font.h
index a112673a1..3da6d9c7d 100644
--- a/src/gui/fonts/font.h
+++ b/src/gui/fonts/font.h
@@ -107,6 +107,8 @@ class Font final
* @see Font::drawString
*/
void drawString(Graphics *const graphics,
+ Color col,
+ const Color &col2,
const std::string &text,
const int x, const int y);
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 66d72af7b..d54a924f1 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -471,8 +471,10 @@ void Gui::draw()
{
const int posX = mouseX - mGuiFont->getWidth(str) / 2;
const int posY = mouseY + (image ? image->mBounds.h / 2 : 0);
- mGraphics->setColorAll(mForegroundColor, mForegroundColor2);
- mGuiFont->drawString(mGraphics, str, posX, posY);
+ mGuiFont->drawString(mGraphics,
+ mForegroundColor, mForegroundColor2,
+ str,
+ posX, posY);
}
}
if (image)
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 5bee2f8ff..473f6614e 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -357,8 +357,11 @@ void Viewport::drawPath(Graphics *const graphics,
if (mMap)
{
const std::string str = toString(cnt);
- font->drawString(graphics, str, squareX + 4
- - font->getWidth(str) / 2, squareY + 12);
+ font->drawString(graphics,
+ color, color,
+ str,
+ squareX + 4 - font->getWidth(str) / 2,
+ squareY + 12);
}
cnt ++;
}
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp
index 33d1b9331..d93787d18 100644
--- a/src/gui/widgets/avatarlistbox.cpp
+++ b/src/gui/widgets/avatarlistbox.cpp
@@ -307,32 +307,46 @@ void AvatarListBox::draw(Graphics *graphics)
}
}
- graphics->setColor(mForegroundColor);
-
// Draw Name
if (a->getDisplayBold())
{
if (type == MapItemType::SEPARATOR)
{
- boldFont->drawString(graphics, text,
- mImagePadding + mPadding, y + mPadding);
+ boldFont->drawString(graphics,
+ mForegroundColor,
+ mForegroundColor,
+ text,
+ mImagePadding + mPadding,
+ y + mPadding);
}
else
{
- boldFont->drawString(graphics, text,
- 15 + mImagePadding + mPadding, y + mPadding);
+ boldFont->drawString(graphics,
+ mForegroundColor,
+ mForegroundColor,
+ text,
+ 15 + mImagePadding + mPadding,
+ y + mPadding);
}
}
else
{
if (type == MapItemType::SEPARATOR)
{
- font->drawString(graphics, text, mImagePadding + mPadding,
+ font->drawString(graphics,
+ mForegroundColor,
+ mForegroundColor,
+ text,
+ mImagePadding + mPadding,
y + mPadding);
}
else
{
- font->drawString(graphics, text, 15 + mImagePadding + mPadding,
+ font->drawString(graphics,
+ mForegroundColor,
+ mForegroundColor,
+ text,
+ 15 + mImagePadding + mPadding,
y + mPadding);
}
}
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index fdb528cea..47f9821b7 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -523,11 +523,22 @@ void BrowserBox::draw(Graphics *graphics)
break;
if (!part.mType)
{
- graphics->setColorAll(part.mColor, part.mColor2);
if (part.mBold)
- boldFont->drawString(graphics, part.mText, part.mX, part.mY);
+ {
+ boldFont->drawString(graphics,
+ part.mColor,
+ part.mColor2,
+ part.mText,
+ part.mX, part.mY);
+ }
else
- font->drawString(graphics, part.mText, part.mX, part.mY);
+ {
+ font->drawString(graphics,
+ part.mColor,
+ part.mColor2,
+ part.mText,
+ part.mX, part.mY);
+ }
}
else if (part.mImage)
{
diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp
index e6f5b501d..dab8dc2d9 100644
--- a/src/gui/widgets/button.cpp
+++ b/src/gui/widgets/button.cpp
@@ -646,7 +646,6 @@ void Button::draw(Graphics *graphics)
if (image)
graphics->drawImage(image, textX, textY);
-// font->drawString(graphics, mCaption, textX, textY);
BLOCK_END("Button::draw")
}
diff --git a/src/gui/widgets/colorpage.cpp b/src/gui/widgets/colorpage.cpp
index 04af4dc2c..7ecb323b4 100644
--- a/src/gui/widgets/colorpage.cpp
+++ b/src/gui/widgets/colorpage.cpp
@@ -57,7 +57,6 @@ void ColorPage::draw(Graphics *graphics)
mListModel);
mHighlightColor.a = static_cast<int>(mAlpha * 255.0F);
- graphics->setColor(mHighlightColor);
updateAlpha();
Font *const font = getFont();
@@ -66,27 +65,33 @@ void ColorPage::draw(Graphics *graphics)
if (mSelected >= 0)
{
+ graphics->setColor(mHighlightColor);
graphics->fillRectangle(Rect(mPadding,
rowHeight * mSelected + mPadding,
mDimension.width - 2 * mPadding, rowHeight));
const ColorPair *const colors = model->getColorAt(mSelected);
- graphics->setColorAll(*colors->color1, *colors->color2);
const std::string str = mListModel->getElementAt(mSelected);
- font->drawString(graphics, str, (width - font->getWidth(str)) / 2,
+ font->drawString(graphics,
+ *colors->color1,
+ *colors->color2,
+ str,
+ (width - font->getWidth(str)) / 2,
mSelected * rowHeight + mPadding);
}
- graphics->setColorAll(mForegroundColor, mForegroundColor2);
const int sz = mListModel->getNumberOfElements();
for (int i = 0, y = mPadding; i < sz; ++i, y += rowHeight)
{
if (i != mSelected)
{
const ColorPair *const colors = model->getColorAt(i);
- graphics->setColorAll(*colors->color1, *colors->color2);
const std::string str = mListModel->getElementAt(i);
- font->drawString(graphics, str, (width - font->getWidth(str)) / 2,
+ font->drawString(graphics,
+ *colors->color1,
+ *colors->color2,
+ str,
+ (width - font->getWidth(str)) / 2,
y);
}
}
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index a4afdb6d1..81729c58d 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -231,7 +231,6 @@ void DropDown::draw(Graphics* graphics)
if (model && mPopup->getSelected() >= 0)
{
Font *const font = getFont();
- graphics->setColorAll(mForegroundColor, mForegroundColor2);
if (mExtended)
{
const int sel = mPopup->getSelected();
@@ -240,7 +239,10 @@ void DropDown::draw(Graphics* graphics)
const Image *const image = model2->getImageAt(sel);
if (!image)
{
- font->drawString(graphics, model->getElementAt(sel),
+ font->drawString(graphics,
+ mForegroundColor,
+ mForegroundColor2,
+ model->getElementAt(sel),
mPadding, mPadding);
}
else
@@ -248,14 +250,20 @@ void DropDown::draw(Graphics* graphics)
graphics->drawImage(image,
mImagePadding,
(mDimension.height - image->getHeight()) / 2 + mPadding);
- font->drawString(graphics, model->getElementAt(sel),
+ font->drawString(graphics,
+ mForegroundColor,
+ mForegroundColor2,
+ model->getElementAt(sel),
image->getWidth() + mImagePadding + mSpacing, mPadding);
}
}
else
{
- font->drawString(graphics, model->getElementAt(
- mPopup->getSelected()), mPadding, mPadding);
+ font->drawString(graphics,
+ mForegroundColor,
+ mForegroundColor2,
+ model->getElementAt(mPopup->getSelected()),
+ mPadding, mPadding);
}
}
diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp
index 9b58d10d5..0896188d9 100644
--- a/src/gui/widgets/emoteshortcutcontainer.cpp
+++ b/src/gui/widgets/emoteshortcutcontainer.cpp
@@ -108,7 +108,6 @@ void EmoteShortcutContainer::draw(Graphics *graphics)
}
}
}
- graphics->setColorAll(mForegroundColor, mForegroundColor2);
for (unsigned i = 0; i < mMaxItems; i++)
{
const int emoteX = (i % mGridWidth) * mBoxWidth;
@@ -118,7 +117,11 @@ void EmoteShortcutContainer::draw(Graphics *graphics)
const std::string key = inputManager.getKeyValueString(
InputAction::EMOTE_1 + i);
- font->drawString(graphics, key, emoteX + 2, emoteY + 2);
+ font->drawString(graphics,
+ mForegroundColor,
+ mForegroundColor2,
+ key,
+ emoteX + 2, emoteY + 2);
}
BLOCK_END("EmoteShortcutContainer::draw")
diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp
index 41400c1a6..6dabc0584 100644
--- a/src/gui/widgets/extendedlistbox.cpp
+++ b/src/gui/widgets/extendedlistbox.cpp
@@ -152,8 +152,6 @@ void ExtendedListBox::draw(Graphics *graphics)
}
}
- graphics->setColorAll(mForegroundColor, mForegroundColor2);
-
for (size_t f = 0; f < itemsSz; ++f)
{
const ExtendedListBoxItem &item = mListItems[f];
@@ -162,17 +160,20 @@ void ExtendedListBox::draw(Graphics *graphics)
const Image *const image = model->getImageAt(row1);
if (!image || !item.image)
{
- font->drawString(graphics, item.text, mPadding, y1 + textPos);
+ font->drawString(graphics,
+ mForegroundColor, mForegroundColor2,
+ item.text,
+ mPadding, y1 + textPos);
}
else
{
- font->drawString(graphics, item.text,
+ font->drawString(graphics,
+ mForegroundColor, mForegroundColor2,
+ item.text,
image->getWidth() + mImagePadding + mSpacing, y1 + textPos);
}
}
- graphics->setColorAll(mForegroundSelectedColor, mForegroundSelectedColor2);
-
for (size_t f = 0; f < selSz; ++f)
{
const ExtendedListBoxItem &item = mSelectedItems[f];
@@ -181,11 +182,16 @@ void ExtendedListBox::draw(Graphics *graphics)
const Image *const image = model->getImageAt(row1);
if (!image || !item.image)
{
- font->drawString(graphics, item.text, mPadding, y1 + textPos);
+ font->drawString(graphics,
+ mForegroundSelectedColor, mForegroundSelectedColor2,
+ item.text,
+ mPadding, y1 + textPos);
}
else
{
- font->drawString(graphics, item.text,
+ font->drawString(graphics,
+ mForegroundSelectedColor, mForegroundSelectedColor2,
+ item.text,
image->getWidth() + mImagePadding + mSpacing, y1 + textPos);
}
}
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index 4849591a6..7fbe9970c 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -319,13 +319,21 @@ void ItemContainer::draw(Graphics *graphics)
}
if (item->isEquipped() == Equipped_true)
- graphics->setColorAll(mEquipedColor, mEquipedColor2);
+ {
+ font->drawString(graphics,
+ mEquipedColor, mEquipedColor2,
+ caption,
+ itemX + (mBoxWidth - font->getWidth(caption)) / 2,
+ itemY + mEquippedTextPadding);
+ }
else
- graphics->setColorAll(mUnEquipedColor, mUnEquipedColor2);
-
- font->drawString(graphics, caption,
- itemX + (mBoxWidth - font->getWidth(caption)) / 2,
- itemY + mEquippedTextPadding);
+ {
+ font->drawString(graphics,
+ mUnEquipedColor, mUnEquipedColor2,
+ 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 775062ce1..cc835903d 100644
--- a/src/gui/widgets/itemshortcutcontainer.cpp
+++ b/src/gui/widgets/itemshortcutcontainer.cpp
@@ -115,8 +115,11 @@ void ItemShortcutContainer::draw(Graphics *graphics)
// Draw item keyboard shortcut.
const std::string key = inputManager.getKeyValueString(
InputAction::SHORTCUT_1 + i);
- graphics->setColorAll(mForegroundColor, mForegroundColor);
- font->drawString(graphics, key, itemX + 2, itemY + 2);
+ font->drawString(graphics,
+ mForegroundColor,
+ mForegroundColor,
+ key,
+ itemX + 2, itemY + 2);
const int itemId = selShortcut->getItem(i);
const unsigned char itemColor = selShortcut->getItemColor(i);
@@ -144,16 +147,22 @@ void ItemShortcutContainer::draw(Graphics *graphics)
graphics->drawImage(image, itemX, itemY);
if (item->isEquipped() == Equipped_true)
{
- graphics->setColorAll(mEquipedColor, mEquipedColor2);
+ font->drawString(graphics,
+ mEquipedColor,
+ mEquipedColor2,
+ caption,
+ itemX + (mBoxWidth - font->getWidth(caption)) / 2,
+ itemY + mBoxHeight - 14);
}
else
{
- graphics->setColorAll(mUnEquipedColor,
- mUnEquipedColor2);
+ font->drawString(graphics,
+ mUnEquipedColor,
+ mUnEquipedColor2,
+ caption,
+ itemX + (mBoxWidth - font->getWidth(caption)) / 2,
+ itemY + mBoxHeight - 14);
}
- font->drawString(graphics, caption,
- itemX + (mBoxWidth - font->getWidth(caption)) / 2,
- itemY + mBoxHeight - 14);
}
}
}
@@ -174,7 +183,10 @@ void ItemShortcutContainer::draw(Graphics *graphics)
}
}
- font->drawString(graphics, spell->getSymbol(),
+ font->drawString(graphics,
+ mForegroundColor,
+ mForegroundColor,
+ spell->getSymbol(),
itemX + 2, itemY + mBoxHeight / 2);
}
}
@@ -192,7 +204,11 @@ void ItemShortcutContainer::draw(Graphics *graphics)
graphics->drawImage(image, itemX, itemY);
}
- font->drawString(graphics, skill->data->shortName, itemX + 2,
+ font->drawString(graphics,
+ mForegroundColor,
+ mForegroundColor,
+ skill->data->shortName,
+ itemX + 2,
itemY + mBoxHeight / 2);
}
}
diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp
index c08e15409..a5cabc365 100644
--- a/src/gui/widgets/label.cpp
+++ b/src/gui/widgets/label.cpp
@@ -184,7 +184,6 @@ void Label::draw(Graphics* graphics)
const Image *const image = mTextChunk.img;
if (image)
graphics->drawImage(image, textX, textY);
-// font->drawString(graphics, mCaption, textX, textY);
BLOCK_END("Label::draw")
}
diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp
index 63595cfb3..d4b6f7a76 100644
--- a/src/gui/widgets/listbox.cpp
+++ b/src/gui/widgets/listbox.cpp
@@ -175,15 +175,15 @@ void ListBox::draw(Graphics *graphics)
rowHeight * mSelected + mPadding,
mDimension.width - 2 * mPadding, rowHeight));
- graphics->setColorAll(mForegroundSelectedColor,
- mForegroundSelectedColor2);
const std::string str = mListModel->getElementAt(mSelected);
- font->drawString(graphics, str,
+ font->drawString(graphics,
+ mForegroundSelectedColor,
+ mForegroundSelectedColor2,
+ str,
(width - font->getWidth(str)) / 2,
mSelected * rowHeight + mPadding + mItemPadding);
}
// Draw the list elements
- graphics->setColorAll(mForegroundColor, mForegroundColor2);
const int sz = mListModel->getNumberOfElements();
for (int i = 0, y = mPadding + mItemPadding;
i < sz; ++i, y += rowHeight)
@@ -191,7 +191,10 @@ void ListBox::draw(Graphics *graphics)
if (i != mSelected)
{
const std::string str = mListModel->getElementAt(i);
- font->drawString(graphics, str,
+ font->drawString(graphics,
+ mForegroundColor,
+ mForegroundColor2,
+ str,
(width - font->getWidth(str)) / 2, y);
}
}
@@ -205,14 +208,15 @@ void ListBox::draw(Graphics *graphics)
rowHeight * mSelected + mPadding,
mDimension.width - 2 * mPadding, rowHeight));
- graphics->setColorAll(mForegroundSelectedColor,
- mForegroundSelectedColor2);
const std::string str = mListModel->getElementAt(mSelected);
- font->drawString(graphics, str, mPadding,
+ font->drawString(graphics,
+ mForegroundSelectedColor,
+ mForegroundSelectedColor2,
+ str,
+ mPadding,
mSelected * rowHeight + mPadding + mItemPadding);
}
// Draw the list elements
- graphics->setColorAll(mForegroundColor, mForegroundColor2);
const int sz = mListModel->getNumberOfElements();
for (int i = 0, y = mPadding + mItemPadding; i < sz;
++i, y += rowHeight)
@@ -220,7 +224,11 @@ void ListBox::draw(Graphics *graphics)
if (i != mSelected)
{
const std::string str = mListModel->getElementAt(i);
- font->drawString(graphics, str, mPadding, y);
+ font->drawString(graphics,
+ mForegroundColor,
+ mForegroundColor2,
+ str,
+ mPadding, y);
}
}
}
diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp
index 2692363f4..9acb8386c 100644
--- a/src/gui/widgets/progressbar.cpp
+++ b/src/gui/widgets/progressbar.cpp
@@ -278,9 +278,12 @@ void ProgressBar::render(Graphics *graphics)
const int textX = mDimension.width / 2;
const int textY = (mDimension.height - font->getHeight()) / 2;
- graphics->setColorAll(mForegroundColor, mForegroundColor2);
- font->drawString(graphics, mText, textX
- - font->getWidth(mText) / 2, textY);
+ font->drawString(graphics,
+ mForegroundColor,
+ mForegroundColor2,
+ mText,
+ textX - font->getWidth(mText) / 2,
+ textY);
graphics->setColor(oldColor);
}
diff --git a/src/gui/widgets/serverslistbox.h b/src/gui/widgets/serverslistbox.h
index a16547cd1..cd94e10bc 100644
--- a/src/gui/widgets/serverslistbox.h
+++ b/src/gui/widgets/serverslistbox.h
@@ -80,14 +80,17 @@ class ServersListBox final : public ListBox
{
const ServerInfo &info = model->getServer(i);
+ const Color *color1;
+ const Color *color2;
if (mSelected == i)
{
- graphics->setColorAll(mForegroundSelectedColor,
- mForegroundSelectedColor2);
+ color1 = &mForegroundSelectedColor;
+ color2 = &mForegroundSelectedColor2;
}
else
{
- graphics->setColorAll(mForegroundColor, mForegroundColor2);
+ color1 = &mForegroundColor;
+ color2 = &mForegroundColor2;
}
int top;
@@ -97,6 +100,8 @@ class ServersListBox final : public ListBox
{
x += font1->getWidth(info.name) + 15;
font1->drawString(graphics,
+ *color1,
+ *color2,
info.name,
mPadding,
y + mPadding);
@@ -110,21 +115,27 @@ class ServersListBox final : public ListBox
if (!info.description.empty())
{
font2->drawString(graphics,
+ *color1,
+ *color2,
info.description,
x,
y + mPadding);
}
font2->drawString(graphics,
+ *color1,
+ *color2,
model->getElementAt(i),
mPadding,
top);
if (info.version.first > 0)
{
- graphics->setColorAll(mNotSupportedColor,
- mNotSupportedColor2);
- font2->drawString(graphics, info.version.second,
- width - info.version.first - mPadding, top);
+ font2->drawString(graphics,
+ mNotSupportedColor,
+ mNotSupportedColor2,
+ info.version.second,
+ width - info.version.first - mPadding,
+ top);
}
}
}
diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp
index b4799a218..b29951a73 100644
--- a/src/gui/widgets/shoplistbox.cpp
+++ b/src/gui/widgets/shoplistbox.cpp
@@ -155,16 +155,22 @@ void ShopListBox::draw(Graphics *graphics)
}
if (mSelected == i)
{
- graphics->setColorAll(mForegroundSelectedColor,
- mForegroundSelectedColor2);
+ font->drawString(graphics,
+ mForegroundSelectedColor,
+ mForegroundSelectedColor2,
+ mListModel->getElementAt(i),
+ ITEM_ICON_SIZE + mPadding,
+ y + (ITEM_ICON_SIZE - fontHeigh) / 2 + mPadding);
}
else
{
- graphics->setColorAll(mForegroundColor, mForegroundColor2);
+ font->drawString(graphics,
+ mForegroundColor,
+ mForegroundColor2,
+ mListModel->getElementAt(i),
+ ITEM_ICON_SIZE + mPadding,
+ y + (ITEM_ICON_SIZE - fontHeigh) / 2 + mPadding);
}
- font->drawString(graphics, mListModel->getElementAt(i),
- ITEM_ICON_SIZE + mPadding,
- y + (ITEM_ICON_SIZE - fontHeigh) / 2 + mPadding);
}
BLOCK_END("ShopListBox::draw")
}
diff --git a/src/gui/widgets/skilllistbox.h b/src/gui/widgets/skilllistbox.h
index 344bffa59..e012aabd3 100644
--- a/src/gui/widgets/skilllistbox.h
+++ b/src/gui/widgets/skilllistbox.h
@@ -133,7 +133,6 @@ class SkillListBox final : public ListBox
}
}
- graphics->setColorAll(mTextColor, mTextColor2);
for (int i = 0, y = 1 + mPadding;
i < model->getNumberOfElements();
++i, y += getRowHeight())
@@ -144,11 +143,19 @@ class SkillListBox final : public ListBox
const SkillData *const data = e->data;
const std::string &description = data->description;
graphics->drawImage(data->icon, mPadding, y);
- font->drawString(graphics, data->name, mTextPadding, y);
+ font->drawString(graphics,
+ mTextColor,
+ mTextColor2,
+ data->name,
+ mTextPadding, y);
if (!description.empty())
{
- font->drawString(graphics, description,
- mTextPadding, y + space);
+ font->drawString(graphics,
+ mTextColor,
+ mTextColor2,
+ description,
+ mTextPadding,
+ y + space);
}
if (e->skillLevelWidth < 0)
@@ -157,8 +164,12 @@ class SkillListBox final : public ListBox
e->skillLevelWidth = font->getWidth(e->skillLevel) + 1;
}
- font->drawString(graphics, e->skillLevel, width2
- - e->skillLevelWidth, y);
+ font->drawString(graphics,
+ mTextColor,
+ mTextColor2,
+ e->skillLevel,
+ width2 - e->skillLevelWidth,
+ y);
}
}
}
diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp
index a22cb7f6e..ca2059ad5 100644
--- a/src/gui/widgets/spellshortcutcontainer.cpp
+++ b/src/gui/widgets/spellshortcutcontainer.cpp
@@ -110,7 +110,10 @@ void SpellShortcutContainer::draw(Graphics *graphics)
}
}
- font->drawString(graphics, spell->getSymbol(),
+ font->drawString(graphics,
+ mForegroundColor,
+ mForegroundColor2,
+ spell->getSymbol(),
itemX + 2, itemY + mBoxHeight / 2);
}
}
diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp
index fbefb2478..82713ec86 100644
--- a/src/gui/widgets/textbox.cpp
+++ b/src/gui/widgets/textbox.cpp
@@ -456,13 +456,15 @@ void TextBox::draw(Graphics* graphics)
mCaretRow * font->getHeight());
}
- graphics->setColorAll(mForegroundColor, mForegroundColor2);
const int fontHeight = font->getHeight();
for (size_t i = 0, sz = mTextRows.size(); i < sz; i++)
{
// Move the text one pixel so we can have a caret before a letter.
- font->drawString(graphics, mTextRows[i], 1,
+ font->drawString(graphics,
+ mForegroundColor,
+ mForegroundColor2,
+ mTextRows[i], 1,
static_cast<int>(i * static_cast<size_t>(fontHeight)));
}
BLOCK_END("TextBox::draw")
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index 8f615fc70..603485f65 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -198,8 +198,11 @@ void TextField::draw(Graphics *graphics)
font->getWidth(mText.substr(0, mCaretPosition)) - mXScroll);
}
- graphics->setColorAll(mForegroundColor, mForegroundColor2);
- font->drawString(graphics, mText, mPadding - mXScroll, mPadding);
+ font->drawString(graphics,
+ mForegroundColor,
+ mForegroundColor2,
+ mText,
+ mPadding - mXScroll, mPadding);
BLOCK_END("TextField::draw")
}
diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp
index acb5e3e12..5c829ecd7 100644
--- a/src/gui/widgets/textpreview.cpp
+++ b/src/gui/widgets/textpreview.cpp
@@ -114,14 +114,27 @@ void TextPreview::draw(Graphics* graphics)
graphics->fillRectangle(Rect(mPadding, mPadding, x, y));
}
- graphics->setColorAll(Color(mTextColor->r,
- mTextColor->g, mTextColor->b, alpha),
- Color(mTextColor2->r, mTextColor2->g, mTextColor2->b, alpha));
+ Color color1(mTextColor->r, mTextColor->g, mTextColor->b, alpha);
if (mOutline && mTextColor != mTextColor2)
- graphics->setColor2(getThemeColor(Theme::OUTLINE, 255));
+ {
+ const Color &color2 = getThemeColor(Theme::OUTLINE, 255);
+ mFont->drawString(graphics,
+ color1,
+ color2,
+ mText,
+ mPadding + 1, mPadding + 1);
+ }
+ else
+ {
+ Color color2(mTextColor2->r, mTextColor2->g, mTextColor2->b, alpha);
+ mFont->drawString(graphics,
+ color1,
+ color2,
+ mText,
+ mPadding + 1, mPadding + 1);
+ }
- mFont->drawString(graphics, mText, mPadding + 1, mPadding + 1);
BLOCK_END("TextPreview::draw")
}
diff --git a/src/gui/widgets/virtshortcutcontainer.cpp b/src/gui/widgets/virtshortcutcontainer.cpp
index 4b03d8890..c4a85a0ed 100644
--- a/src/gui/widgets/virtshortcutcontainer.cpp
+++ b/src/gui/widgets/virtshortcutcontainer.cpp
@@ -121,12 +121,23 @@ void VirtShortcutContainer::draw(Graphics *graphics)
image->setAlpha(1.0F);
graphics->drawImage(image, itemX, itemY);
if (item->isEquipped() == Equipped_true)
- graphics->setColorAll(mEquipedColor, mEquipedColor2);
+ {
+ font->drawString(graphics,
+ mEquipedColor,
+ mEquipedColor2,
+ caption,
+ itemX + (mBoxWidth - font->getWidth(caption)) / 2,
+ itemY + mBoxHeight - 14);
+ }
else
- graphics->setColorAll(mUnEquipedColor, mUnEquipedColor2);
- font->drawString(graphics, caption,
- itemX + (mBoxWidth - font->getWidth(caption)) / 2,
- itemY + mBoxHeight - 14);
+ {
+ font->drawString(graphics,
+ mUnEquipedColor,
+ mUnEquipedColor2,
+ caption,
+ itemX + (mBoxWidth - font->getWidth(caption)) / 2,
+ itemY + mBoxHeight - 14);
+ }
}
}
}
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index 657fbcd88..0898549ec 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -374,7 +374,6 @@ void Window::draw(Graphics *graphics)
// Draw title
if (mShowTitle)
{
- graphics->setColorAll(mForegroundColor, mForegroundColor2);
int x;
switch (mCaptionAlign)
{
@@ -389,7 +388,11 @@ void Window::draw(Graphics *graphics)
x = mCaptionOffsetX - mCaptionFont->getWidth(mCaption);
break;
}
- mCaptionFont->drawString(graphics, mCaption, x, mCaptionOffsetY);
+ mCaptionFont->drawString(graphics,
+ mForegroundColor,
+ mForegroundColor2,
+ mCaption,
+ x, mCaptionOffsetY);
}
if (update)
diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp
index 8843976e1..8da2e3071 100644
--- a/src/gui/windows/equipmentwindow.cpp
+++ b/src/gui/windows/equipmentwindow.cpp
@@ -265,9 +265,10 @@ void EquipmentWindow::draw(Graphics *graphics)
box->y + mItemPadding);
if (i == projSlot)
{
- graphics->setColorAll(mLabelsColor, mLabelsColor2);
const std::string str = toString(item->getQuantity());
font->drawString(graphics,
+ mLabelsColor,
+ mLabelsColor2,
str,
box->x + (mBoxSize - font->getWidth(str)) / 2,
box->y - fontHeight);
diff --git a/src/particle/textparticle.cpp b/src/particle/textparticle.cpp
index ab07c33a5..aa506e75f 100644
--- a/src/particle/textparticle.cpp
+++ b/src/particle/textparticle.cpp
@@ -77,10 +77,19 @@ void TextParticle::draw(Graphics *const graphics,
graphics->setColor(color);
if (mOutline)
{
- graphics->setColor2(theme->getColor(
- Theme::OUTLINE, static_cast<int>(alpha)));
+ const Color &color2 = theme->getColor(Theme::OUTLINE,
+ static_cast<int>(alpha));
+ mTextFont->drawString(graphics,
+ color, color2,
+ mText,
+ screenX - mTextWidth, screenY);
+ }
+ else
+ {
+ mTextFont->drawString(graphics,
+ color, color,
+ mText, screenX - mTextWidth, screenY);
}
- mTextFont->drawString(graphics, mText, screenX - mTextWidth, screenY);
BLOCK_END("TextParticle::draw")
return;
}
diff --git a/src/resources/map/mapitem.cpp b/src/resources/map/mapitem.cpp
index 146003040..3037dfb4a 100644
--- a/src/resources/map/mapitem.cpp
+++ b/src/resources/map/mapitem.cpp
@@ -165,8 +165,12 @@ void MapItem::draw(Graphics *const graphics, const int x, const int y,
Font *const font = gui->getFont();
if (font)
{
- graphics->setColor(userPalette->getColor(UserPalette::BEING));
- font->drawString(graphics, mName, x, y);
+ const Color &color = userPalette->getColor(UserPalette::BEING);
+ font->drawString(graphics,
+ color,
+ color,
+ mName,
+ x, y);
}
}
BLOCK_END("MapItem::draw")
diff --git a/src/test/testlauncher.cpp b/src/test/testlauncher.cpp
index f8f9be812..a2738c8ba 100644
--- a/src/test/testlauncher.cpp
+++ b/src/test/testlauncher.cpp
@@ -611,9 +611,10 @@ int TestLauncher::testDraw()
mainGraphics->fillRectangle(Rect(200, 100, 300, 300));
mainGraphics->popClipArea();
- mainGraphics->setColorAll(Color(0xFFU, 0x00U, 0x00U, 0xB0U),
- Color(0x00U, 0xFFU, 0x00U, 0xB0U));
+ Color color(0xFFU, 0x00U, 0x00U, 0xB0U);
+ Color color2(0x00U, 0xFFU, 0x00U, 0xB0U);
boldFont->drawString(mainGraphics,
+ color, color2,
"test test test test test test test test ", 300, 100);
mainGraphics->drawTileCollection(col2);
diff --git a/src/text.cpp b/src/text.cpp
index 8cb3705a7..fac2dba04 100644
--- a/src/text.cpp
+++ b/src/text.cpp
@@ -145,11 +145,18 @@ void Text::draw(Graphics *const graphics, const int xOff, const int yOff)
mBubble);
}
- graphics->setColor(*mColor);
if (!mIsSpeech)
- graphics->setColor2(mOutlineColor);
-
- mFont->drawString(graphics, mText, mX - xOff, mY - yOff);
+ {
+ mFont->drawString(graphics,
+ *mColor, mOutlineColor,
+ mText, mX - xOff, mY - yOff);
+ }
+ else
+ {
+ mFont->drawString(graphics,
+ *mColor, *mColor,
+ mText, mX - xOff, mY - yOff);
+ }
BLOCK_END("Text::draw")
}
diff --git a/src/touchmanager.cpp b/src/touchmanager.cpp
index d9cd14087..efa4758b1 100644
--- a/src/touchmanager.cpp
+++ b/src/touchmanager.cpp
@@ -247,8 +247,9 @@ void TouchManager::draw()
return;
Font *const font = boldFont;
- mainGraphics->setColorAll(theme->getColor(Theme::TEXT, 255),
- theme->getColor(Theme::TEXT_OUTLINE, 255));
+ const Color &color1 = theme->getColor(Theme::TEXT, 255);
+ const Color &color2 = theme->getColor(Theme::TEXT_OUTLINE, 255);
+
FOR_EACH (TouchItemVectorCIter, it, mObjects)
{
const TouchItem *const item = *it;
@@ -259,7 +260,10 @@ void TouchManager::draw()
/ 2 + item->x;
const int textY = (item->rect.height - font->getHeight())
/ 2 + item->y;
- font->drawString(mainGraphics, str, textX, textY);
+ font->drawString(mainGraphics,
+ color1,
+ color2,
+ str, textX, textY);
}
}
}