summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-05-04 17:02:05 +0300
committerAndrei Karas <akaras@inbox.ru>2013-05-04 17:02:05 +0300
commit6ed69c8769cd6c8c79c77fc8116059b42f3653e7 (patch)
tree48ede1453da63c58ba02ccc35ab06c3f7a61ddca /src
parent002656b278ab1c2e09bca8f6ffd2d5c42d57b09c (diff)
downloadManaVerse-6ed69c8769cd6c8c79c77fc8116059b42f3653e7.tar.gz
ManaVerse-6ed69c8769cd6c8c79c77fc8116059b42f3653e7.tar.bz2
ManaVerse-6ed69c8769cd6c8c79c77fc8116059b42f3653e7.tar.xz
ManaVerse-6ed69c8769cd6c8c79c77fc8116059b42f3653e7.zip
add function to graphics class to set normal and outline colors at once.
Diffstat (limited to 'src')
-rw-r--r--src/graphics.h7
-rw-r--r--src/gui/equipmentwindow.cpp3
-rw-r--r--src/gui/skilldialog.cpp3
-rw-r--r--src/gui/widgets/avatarlistbox.cpp6
-rw-r--r--src/gui/widgets/browserbox.cpp3
-rw-r--r--src/gui/widgets/emoteshortcutcontainer.cpp3
-rw-r--r--src/gui/widgets/itemshortcutcontainer.cpp3
-rw-r--r--src/gui/widgets/label.cpp4
-rw-r--r--src/gui/widgets/progressbar.cpp3
-rw-r--r--src/gui/widgets/spellshortcutcontainer.cpp3
-rw-r--r--src/gui/widgets/textbox.cpp4
-rw-r--r--src/gui/widgets/textpreview.cpp10
-rw-r--r--src/gui/widgets/window.cpp3
-rw-r--r--src/mobileopenglgraphics.h7
-rw-r--r--src/normalopenglgraphics.h7
-rw-r--r--src/nullopenglgraphics.h7
-rw-r--r--src/safeopenglgraphics.h7
17 files changed, 52 insertions, 31 deletions
diff --git a/src/graphics.h b/src/graphics.h
index ff5d47580..705a98ff6 100644
--- a/src/graphics.h
+++ b/src/graphics.h
@@ -343,6 +343,13 @@ class Graphics : public gcn::SDLGraphics
void setColor2(const gcn::Color &color)
{ mColor2 = color; }
+ void setColorAll(const gcn::Color &color, const gcn::Color &color2)
+ {
+ mColor = color;
+ mColor2 = color2;
+ mAlpha = (color.a != 255);
+ }
+
const gcn::Color &getColor2() const
{ return mColor2; }
diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp
index db082e3be..a18ec0aa4 100644
--- a/src/gui/equipmentwindow.cpp
+++ b/src/gui/equipmentwindow.cpp
@@ -224,8 +224,7 @@ void EquipmentWindow::draw(gcn::Graphics *graphics)
box->y + mItemPadding);
if (i == EQUIP_PROJECTILE_SLOT)
{
- g->setColor(mLabelsColor);
- g->setColor2(mLabelsColor2);
+ g->setColorAll(mLabelsColor, mLabelsColor2);
const std::string str = toString(item->getQuantity());
font->drawString(g, str,
box->x + (mBoxSize - font->getWidth(str)) / 2,
diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp
index d5487fa66..44d9d0283 100644
--- a/src/gui/skilldialog.cpp
+++ b/src/gui/skilldialog.cpp
@@ -159,8 +159,7 @@ class SkillListBox final : public ListBox
}
// Draw the list elements
- graphics->setColor(mTextColor);
- graphics->setColor2(mTextColor2);
+ graphics->setColorAll(mTextColor, mTextColor2);
gcn::Font *const font = getFont();
const int space = font->getHeight() + mSpacing;
const int width2 = getWidth() - mPadding;
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp
index 3202a1e21..964a2ab82 100644
--- a/src/gui/widgets/avatarlistbox.cpp
+++ b/src/gui/widgets/avatarlistbox.cpp
@@ -110,8 +110,7 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics)
const std::string name = player_node->getName();
// Draw the list elements
- graphics->setColor(mForegroundColor);
- graphics->setColor2(mForegroundColor2);
+ graphics->setColorAll(mForegroundColor, mForegroundColor2);
for (int i = 0, y = 0;
i < model->getNumberOfElements();
++i, y += fontHeight)
@@ -260,8 +259,7 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics)
}
}
- graphics->setColor(mForegroundColor);
- graphics->setColor2(mForegroundColor2);
+ graphics->setColorAll(mForegroundColor, mForegroundColor2);
// Draw Name
if (a->getDisplayBold())
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index 2edd5d67b..946205660 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -430,8 +430,7 @@ void BrowserBox::draw(gcn::Graphics *graphics)
break;
if (!part.mType)
{
- graphics2->setColor(part.mColor);
- graphics2->setColor2(part.mColor2);
+ graphics2->setColorAll(part.mColor, part.mColor2);
if (part.mBold)
boldFont->drawString(graphics, part.mText, part.mX, part.mY);
else
diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp
index 9629384a4..086a19ef0 100644
--- a/src/gui/widgets/emoteshortcutcontainer.cpp
+++ b/src/gui/widgets/emoteshortcutcontainer.cpp
@@ -117,8 +117,7 @@ void EmoteShortcutContainer::draw(gcn::Graphics *graphics)
gcn::Font *const font = getFont();
drawBackground(g);
- g->setColor(mForegroundColor);
- g->setColor2(mForegroundColor2);
+ g->setColorAll(mForegroundColor, mForegroundColor2);
for (unsigned i = 0; i < mMaxItems; i++)
{
const int emoteX = (i % mGridWidth) * mBoxWidth;
diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp
index deb0c7c86..6a5392f14 100644
--- a/src/gui/widgets/itemshortcutcontainer.cpp
+++ b/src/gui/widgets/itemshortcutcontainer.cpp
@@ -138,8 +138,7 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics)
// Draw item keyboard shortcut.
std::string key = inputManager.getKeyValueString(
Input::KEY_SHORTCUT_1 + i);
- g->setColor(mForegroundColor);
- g->setColor2(mForegroundColor);
+ g->setColorAll(mForegroundColor, mForegroundColor);
font->drawString(g, key, itemX + 2, itemY + 2);
diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp
index 4240ff2ad..854b0f33c 100644
--- a/src/gui/widgets/label.cpp
+++ b/src/gui/widgets/label.cpp
@@ -95,8 +95,8 @@ void Label::draw(gcn::Graphics* graphics)
break;
}
- graphics->setColor(mForegroundColor);
- static_cast<Graphics*>(graphics)->setColor2(mForegroundColor2);
+ static_cast<Graphics*>(graphics)->setColorAll(
+ mForegroundColor, mForegroundColor2);
font->drawString(graphics, mCaption, textX, textY);
BLOCK_END("Label::draw")
}
diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp
index 175bb7318..7d0041706 100644
--- a/src/gui/widgets/progressbar.cpp
+++ b/src/gui/widgets/progressbar.cpp
@@ -218,8 +218,7 @@ void ProgressBar::render(Graphics *graphics)
const int textX = mDimension.width / 2;
const int textY = (mDimension.height - font->getHeight()) / 2;
- graphics->setColor(mForegroundColor);
- graphics->setColor2(mOutlineColor);
+ graphics->setColorAll(mForegroundColor, mOutlineColor);
font->drawString(graphics, mText, textX
- font->getWidth(mText) / 2, textY);
diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp
index 262f49f58..f03f1d4ca 100644
--- a/src/gui/widgets/spellshortcutcontainer.cpp
+++ b/src/gui/widgets/spellshortcutcontainer.cpp
@@ -109,8 +109,7 @@ void SpellShortcutContainer::draw(gcn::Graphics *graphics)
gcn::Font *const font = getFont();
const int selectedId = spellShortcut->getSelectedItem();
- g->setColor(mForegroundColor);
- g->setColor2(mForegroundColor2);
+ g->setColorAll(mForegroundColor, mForegroundColor2);
drawBackground(g);
for (unsigned i = 0; i < mMaxItems; i++)
diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp
index b0281e9bd..386a89bad 100644
--- a/src/gui/widgets/textbox.cpp
+++ b/src/gui/widgets/textbox.cpp
@@ -362,8 +362,8 @@ void TextBox::draw(gcn::Graphics* graphics)
mCaretRow * getFont()->getHeight());
}
- graphics->setColor(mForegroundColor);
- static_cast<Graphics*>(graphics)->setColor2(mForegroundColor2);
+ static_cast<Graphics*>(graphics)->setColorAll(
+ mForegroundColor, mForegroundColor2);
gcn::Font *const font = getFont();
const int fontHeight = font->getHeight();
diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp
index ceede7133..bea96e72a 100644
--- a/src/gui/widgets/textpreview.cpp
+++ b/src/gui/widgets/textpreview.cpp
@@ -114,16 +114,12 @@ void TextPreview::draw(gcn::Graphics* graphics)
}
}
- g->setColor(gcn::Color(mTextColor->r, mTextColor->g,
- mTextColor->b, alpha));
- g->setColor2(gcn::Color(mTextColor2->r, mTextColor2->g,
- mTextColor2->b, alpha));
+ g->setColorAll(gcn::Color(mTextColor->r, mTextColor->g, mTextColor->b,
+ alpha), gcn::Color(mTextColor2->r, mTextColor2->g, mTextColor2->b,
+ alpha));
if (mOutline && mTextColor != mTextColor2)
- {
- Graphics *const g = static_cast<Graphics *const>(graphics);
g->setColor2(Theme::getThemeColor(Theme::OUTLINE));
- }
mFont->drawString(graphics, mText, mPadding + 1, mPadding + 1);
BLOCK_END("TextPreview::draw")
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index 1b9b955f0..d266d3ce8 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -283,8 +283,7 @@ void Window::draw(gcn::Graphics *graphics)
// Draw title
if (mShowTitle)
{
- g->setColor(mForegroundColor);
- g->setColor2(mForegroundColor2);
+ g->setColorAll(mForegroundColor, mForegroundColor2);
int x;
switch (static_cast<gcn::Graphics::Alignment>(mCaptionAlign))
{
diff --git a/src/mobileopenglgraphics.h b/src/mobileopenglgraphics.h
index 9c813dee2..60d7fdf27 100644
--- a/src/mobileopenglgraphics.h
+++ b/src/mobileopenglgraphics.h
@@ -132,6 +132,13 @@ class MobileOpenGLGraphics final : public Graphics
mColorAlpha = (color.a != 255);
}
+ void setColorAll(const gcn::Color &color, const gcn::Color &color2)
+ {
+ mColor = color;
+ mColor2 = color2;
+ mColorAlpha = (color.a != 255);
+ }
+
void drawPoint(int x, int y);
void drawLine(int x1, int y1, int x2, int y2);
diff --git a/src/normalopenglgraphics.h b/src/normalopenglgraphics.h
index f33b1fb97..86a380ac8 100644
--- a/src/normalopenglgraphics.h
+++ b/src/normalopenglgraphics.h
@@ -132,6 +132,13 @@ class NormalOpenGLGraphics final : public Graphics
mColorAlpha = (color.a != 255);
}
+ void setColorAll(const gcn::Color &color, const gcn::Color &color2)
+ {
+ mColor = color;
+ mColor2 = color2;
+ mColorAlpha = (color.a != 255);
+ }
+
void drawPoint(int x, int y);
void drawLine(int x1, int y1, int x2, int y2);
diff --git a/src/nullopenglgraphics.h b/src/nullopenglgraphics.h
index 61ec8e0f3..23d272e70 100644
--- a/src/nullopenglgraphics.h
+++ b/src/nullopenglgraphics.h
@@ -132,6 +132,13 @@ class NullOpenGLGraphics final : public Graphics
mColorAlpha = (color.a != 255);
}
+ void setColorAll(const gcn::Color &color, const gcn::Color &color2)
+ {
+ mColor = color;
+ mColor2 = color2;
+ mColorAlpha = (color.a != 255);
+ }
+
void drawPoint(int x, int y);
void drawLine(int x1, int y1, int x2, int y2);
diff --git a/src/safeopenglgraphics.h b/src/safeopenglgraphics.h
index d9b7af5bd..61a34e07c 100644
--- a/src/safeopenglgraphics.h
+++ b/src/safeopenglgraphics.h
@@ -108,6 +108,13 @@ class SafeOpenGLGraphics final : public Graphics
mColorAlpha = (color.a != 255);
}
+ void setColorAll(const gcn::Color &color, const gcn::Color &color2)
+ {
+ mColor = color;
+ mColor2 = color2;
+ mColorAlpha = (color.a != 255);
+ }
+
void drawPoint(int x, int y);
void drawLine(int x1, int y1, int x2, int y2);