From 269e05e71f09cac3d181f2042cde01e5541658f3 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Tue, 3 Feb 2009 12:13:16 -0700 Subject: Made highlights configurable through the color dialog. Signed-off-by: Ira Rice --- src/gui/browserbox.cpp | 17 ++++++++++++++--- src/gui/colour.cpp | 1 + src/gui/listbox.cpp | 7 ++++++- src/gui/shoplistbox.cpp | 7 ++++++- 4 files changed, 27 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/gui/browserbox.cpp b/src/gui/browserbox.cpp index 6fd0482a..cd5479c8 100644 --- a/src/gui/browserbox.cpp +++ b/src/gui/browserbox.cpp @@ -122,7 +122,18 @@ void BrowserBox::addRow(const std::string &row) //discard older rows when a row limit has been set if (mMaxRows > 0) { - while (mTextRows.size() > mMaxRows) mTextRows.pop_front(); + while (mTextRows.size() > mMaxRows) + { + mTextRows.pop_front(); + for (unsigned int i = 0; i < mLinks.size(); i++) + { + mLinks[i].y1 -= font->getHeight(); + mLinks[i].y2 -= font->getHeight(); + + if (mLinks[i].y1 < 0) + mLinks.erase(mLinks.begin() + i); + } + } } // Auto size mode @@ -238,9 +249,10 @@ void BrowserBox::draw(gcn::Graphics *graphics) if (mSelectedLink >= 0) { + bool valid; if ((mHighMode & BACKGROUND)) { - graphics->setColor(gcn::Color(HIGHLIGHT)); + graphics->setColor(gcn::Color(textColour->getColour('H', valid))); graphics->fillRectangle(gcn::Rectangle( mLinks[mSelectedLink].x1, mLinks[mSelectedLink].y1, @@ -251,7 +263,6 @@ void BrowserBox::draw(gcn::Graphics *graphics) if ((mHighMode & UNDERLINE)) { - bool valid; graphics->setColor(gcn::Color(textColour->getColour('<', valid))); graphics->drawLine( mLinks[mSelectedLink].x1, diff --git a/src/gui/colour.cpp b/src/gui/colour.cpp index e6ceeaca..075e9861 100644 --- a/src/gui/colour.cpp +++ b/src/gui/colour.cpp @@ -32,6 +32,7 @@ Colour::Colour() { addColour('C', 0x000000, _("Chat")); addColour('G', 0xff0000, _("GM")); + addColour('H', 0xebc873, _("Highlight")); addColour('Y', 0x1fa052, _("Player")); addColour('W', 0x0000ff, _("Whisper")); addColour('I', 0xf1dc27, _("Is")); diff --git a/src/gui/listbox.cpp b/src/gui/listbox.cpp index 1de57593..643d234e 100644 --- a/src/gui/listbox.cpp +++ b/src/gui/listbox.cpp @@ -24,6 +24,7 @@ #include #include +#include "colour.h" #include "listbox.h" #include "../configuration.h" @@ -43,9 +44,13 @@ void ListBox::draw(gcn::Graphics *graphics) if (config.getValue("guialpha", 0.8) != mAlpha) mAlpha = config.getValue("guialpha", 0.8); + bool valid; + const int red = (textColour->getColour('H', valid) >> 16) & 0xFF; + const int green = (textColour->getColour('H', valid) >> 8) & 0xFF; + const int blue = textColour->getColour('H', valid) & 0xFF; const int alpha = mAlpha * 255; - graphics->setColor(gcn::Color(235, 200, 115, alpha)); + graphics->setColor(gcn::Color(red, green, blue, alpha)); graphics->setFont(getFont()); const int fontHeight = getFont()->getHeight(); diff --git a/src/gui/shoplistbox.cpp b/src/gui/shoplistbox.cpp index 9db33ac6..3d17fd55 100644 --- a/src/gui/shoplistbox.cpp +++ b/src/gui/shoplistbox.cpp @@ -26,6 +26,7 @@ #include #include +#include "colour.h" #include "shoplistbox.h" #include "../configuration.h" @@ -65,6 +66,10 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics) if (config.getValue("guialpha", 0.8) != mAlpha) mAlpha = config.getValue("guialpha", 0.8); + bool valid; + const int red = (textColour->getColour('H', valid) >> 16) & 0xFF; + const int green = (textColour->getColour('H', valid) >> 8) & 0xFF; + const int blue = textColour->getColour('H', valid) & 0xFF; const int alpha = mAlpha * 255; Graphics *graphics = static_cast(gcnGraphics); @@ -80,7 +85,7 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics) if (i == mSelected) { - backgroundColor = gcn::Color(235, 200, 115, alpha); + backgroundColor = gcn::Color(red, green, blue, alpha); } else if (mShopItems && mPlayerMoney < mShopItems->at(i)->getPrice() && mPriceCheck) -- cgit v1.2.3-70-g09d2