From 2d45a2ca5480ae0fdc03a807787f622444830d44 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 12 Aug 2011 03:47:28 +0300 Subject: Rename file names log and chatlog to correct logger and chatlogger. --- src/gui/outfitwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui/outfitwindow.cpp') diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp index 9dd41a643..09e75856f 100644 --- a/src/gui/outfitwindow.cpp +++ b/src/gui/outfitwindow.cpp @@ -28,7 +28,7 @@ #include "inventory.h" #include "item.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "playerinfo.h" #include "gui/chatwindow.h" -- cgit v1.2.3-70-g09d2 From 7bedfccf5982534a9cbcb2c18ca0d37df117bfc8 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 22 Aug 2011 16:28:01 +0300 Subject: Add new colors to themes: BORDER, BACKGROUND_GRAY, SCROLLBAR_GRAY. --- data/graphics/gui/colors.xml | 3 +++ data/themes/blackwood/colors.xml | 3 +++ data/themes/enchilado/colors.xml | 3 +++ data/themes/mana/colors.xml | 3 +++ data/themes/pink/colors.xml | 3 +++ data/themes/redandblack/colors.xml | 3 +++ data/themes/wood/colors.xml | 3 +++ src/gui/botcheckerwindow.cpp | 1 - src/gui/equipmentwindow.cpp | 2 +- src/gui/outfitwindow.cpp | 5 +++-- src/gui/statuswindow.cpp | 2 -- src/gui/theme.cpp | 3 +++ src/gui/theme.h | 3 +++ src/gui/widgets/desktop.cpp | 7 ++++--- src/gui/widgets/itemcontainer.cpp | 2 ++ src/gui/widgets/scrollarea.cpp | 8 ++++---- src/gui/widgets/spellshortcutcontainer.cpp | 1 - 17 files changed, 41 insertions(+), 14 deletions(-) (limited to 'src/gui/outfitwindow.cpp') diff --git a/data/graphics/gui/colors.xml b/data/graphics/gui/colors.xml index b17e4b80c..017b55400 100644 --- a/data/graphics/gui/colors.xml +++ b/data/graphics/gui/colors.xml @@ -2,6 +2,7 @@ + @@ -11,6 +12,8 @@ + + diff --git a/data/themes/blackwood/colors.xml b/data/themes/blackwood/colors.xml index b30121a6b..b85ccdfc7 100644 --- a/data/themes/blackwood/colors.xml +++ b/data/themes/blackwood/colors.xml @@ -2,6 +2,7 @@ + @@ -11,6 +12,8 @@ + + diff --git a/data/themes/enchilado/colors.xml b/data/themes/enchilado/colors.xml index 839f06772..38167192d 100644 --- a/data/themes/enchilado/colors.xml +++ b/data/themes/enchilado/colors.xml @@ -2,6 +2,7 @@ + @@ -11,6 +12,8 @@ + + diff --git a/data/themes/mana/colors.xml b/data/themes/mana/colors.xml index 9e7b73c69..96a929a5e 100644 --- a/data/themes/mana/colors.xml +++ b/data/themes/mana/colors.xml @@ -2,6 +2,7 @@ + @@ -11,6 +12,8 @@ + + diff --git a/data/themes/pink/colors.xml b/data/themes/pink/colors.xml index 2e56c6e3c..44aac3527 100644 --- a/data/themes/pink/colors.xml +++ b/data/themes/pink/colors.xml @@ -2,6 +2,7 @@ + @@ -11,6 +12,8 @@ + + diff --git a/data/themes/redandblack/colors.xml b/data/themes/redandblack/colors.xml index fc026b361..b705241fb 100644 --- a/data/themes/redandblack/colors.xml +++ b/data/themes/redandblack/colors.xml @@ -2,6 +2,7 @@ + @@ -11,6 +12,8 @@ + + diff --git a/data/themes/wood/colors.xml b/data/themes/wood/colors.xml index 67c2da3c7..1080f2022 100644 --- a/data/themes/wood/colors.xml +++ b/data/themes/wood/colors.xml @@ -2,6 +2,7 @@ + @@ -11,6 +12,8 @@ + + diff --git a/src/gui/botcheckerwindow.cpp b/src/gui/botcheckerwindow.cpp index 2851d3d1d..4a8f8cf0d 100644 --- a/src/gui/botcheckerwindow.cpp +++ b/src/gui/botcheckerwindow.cpp @@ -290,7 +290,6 @@ BotCheckerWindow::BotCheckerWindow(): } mPlayerTitleTable = new GuiTable(mPlayerTableTitleModel); - //mPlayerTitleTable->setBackgroundColor(gcn::Color(0xbf, 0xbf, 0xbf)); mPlayerTitleTable->setHeight(1); mPlayerTableTitleModel->set(0, 0, new Label(_("Name"))); diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp index ddcd6b81c..3284301ec 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -147,7 +147,7 @@ void EquipmentWindow::draw(gcn::Graphics *graphics) } // Set color black - g->setColor(Theme::getThemeColor(Theme::OUTLINE)); + g->setColor(Theme::getThemeColor(Theme::BORDER)); // Draw box border g->drawRectangle(gcn::Rectangle(box->first, box->second, BOX_WIDTH, BOX_HEIGHT)); diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp index 09e75856f..79ac88d94 100644 --- a/src/gui/outfitwindow.cpp +++ b/src/gui/outfitwindow.cpp @@ -32,6 +32,7 @@ #include "playerinfo.h" #include "gui/chatwindow.h" +#include "gui/theme.h" #include "gui/viewport.h" #include "gui/widgets/button.h" @@ -303,9 +304,9 @@ void OutfitWindow::draw(gcn::Graphics *graphics) const int itemX = 10 + ((i % mGridWidth) * mBoxWidth); const int itemY = 25 + ((i / mGridWidth) * mBoxHeight); - graphics->setColor(gcn::Color(0, 0, 0, 64)); + graphics->setColor(Theme::getThemeColor(Theme::BORDER, 64)); graphics->drawRectangle(gcn::Rectangle(itemX, itemY, 32, 32)); - graphics->setColor(gcn::Color(255, 255, 255, 32)); + graphics->setColor(Theme::getThemeColor(Theme::BACKGROUND, 32)); graphics->fillRectangle(gcn::Rectangle(itemX, itemY, 32, 32)); if (mItems[mCurrentOutfit][i] < 0) diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp index a60707f4c..7ab2afa2d 100644 --- a/src/gui/statuswindow.cpp +++ b/src/gui/statuswindow.cpp @@ -889,7 +889,6 @@ void StatusWindow::updateStatusBar(ProgressBar *bar, bool percent A_UNUSED) col.r = 100; col.g = 100; col.b = 100; -// bar->setColor(new gcn::Color(100, 100, 100)); bar->setColor(col); } else @@ -898,7 +897,6 @@ void StatusWindow::updateStatusBar(ProgressBar *bar, bool percent A_UNUSED) col.r = 255; col.g = 255; col.b = 0; -// bar->setColor(new gcn::Color(255, 255, 0)); bar->setColor(col); } } diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp index e126c0505..5fcfeade2 100644 --- a/src/gui/theme.cpp +++ b/src/gui/theme.cpp @@ -599,6 +599,7 @@ static int readColorType(const std::string &type) "TEXT", "SHADOW", "OUTLINE", + "BORDER", "PROGRESS_BAR", "BUTTON", "BUTTON_DISABLED", @@ -608,6 +609,8 @@ static int readColorType(const std::string &type) "GUILD_CHAT_TAB", "GUILD_SOCIAL_TAB", "BACKGROUND", + "BACKGROUND_GRAY", + "SCROLLBAR_GRAY", "HIGHLIGHT", "TAB_FLASH", "TAB_PLAYER_FLASH", diff --git a/src/gui/theme.h b/src/gui/theme.h index 5fe938a20..bdcdafc74 100644 --- a/src/gui/theme.h +++ b/src/gui/theme.h @@ -143,6 +143,7 @@ class Theme : public Palette, public ConfigListener TEXT = 0, SHADOW, OUTLINE, + BORDER, PROGRESS_BAR, BUTTON, BUTTON_DISABLED, @@ -152,6 +153,8 @@ class Theme : public Palette, public ConfigListener GUILD_CHAT_TAB, GUILD_SOCIAL_TAB, BACKGROUND, + BACKGROUND_GRAY, + SCROLLBAR_GRAY, HIGHLIGHT, TAB_FLASH, TAB_PLAYER_FLASH, diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp index cfb757638..40d90ba11 100644 --- a/src/gui/widgets/desktop.cpp +++ b/src/gui/widgets/desktop.cpp @@ -53,7 +53,8 @@ Desktop::Desktop() : mVersionLabel = new Label(strprintf("%s (Mana %s)", appName.c_str(), FULL_VERSION)); - mVersionLabel->setBackgroundColor(gcn::Color(255, 255, 255, 128)); + mVersionLabel->setBackgroundColor( + Theme::getThemeColor(Theme::BACKGROUND, 128)); add(mVersionLabel, 25, 2); } @@ -85,7 +86,7 @@ void Desktop::draw(gcn::Graphics *graphics) getHeight() > mWallpaper->getHeight())) { // TODO: Color from palette - g->setColor(gcn::Color(64, 64, 64)); + g->setColor(Theme::getThemeColor(Theme::BACKGROUND_GRAY)); g->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight())); } @@ -106,7 +107,7 @@ void Desktop::draw(gcn::Graphics *graphics) } // Draw a thin border under the application version... - g->setColor(gcn::Color(255, 255, 255, 128)); + g->setColor(Theme::getThemeColor(Theme::BACKGROUND, 128)); g->fillRectangle(gcn::Rectangle(mVersionLabel->getDimension())); Container::draw(graphics); diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index c2a5ec1b7..c28e4fb4c 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -213,6 +213,7 @@ void ItemContainer::draw(gcn::Graphics *graphics) } } +/* // Draw an orange box around the selected item if (isFocused() && mHighlightedIndex != -1 && mGridColumns) { @@ -221,6 +222,7 @@ void ItemContainer::draw(gcn::Graphics *graphics) g->setColor(gcn::Color(255, 128, 0)); g->drawRectangle(gcn::Rectangle(itemX, itemY, BOX_WIDTH, BOX_HEIGHT)); } +*/ } void ItemContainer::selectNone() diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index 03f5f8c4c..3e90bf4c7 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -439,17 +439,17 @@ void ScrollArea::drawRightButton(gcn::Graphics *graphics) void ScrollArea::drawVBar(gcn::Graphics *graphics) { const gcn::Rectangle dim = getVerticalBarDimension(); - graphics->setColor(gcn::Color(0, 0, 0, 32)); + graphics->setColor(Theme::getThemeColor(Theme::SCROLLBAR_GRAY, 32)); graphics->fillRectangle(dim); - graphics->setColor(gcn::Color(255, 255, 255)); + graphics->setColor(Theme::getThemeColor(Theme::BACKGROUND)); } void ScrollArea::drawHBar(gcn::Graphics *graphics) { const gcn::Rectangle dim = getHorizontalBarDimension(); - graphics->setColor(gcn::Color(0, 0, 0, 32)); + graphics->setColor(Theme::getThemeColor(Theme::SCROLLBAR_GRAY, 32)); graphics->fillRectangle(dim); - graphics->setColor(gcn::Color(255, 255, 255)); + graphics->setColor(Theme::getThemeColor(Theme::BACKGROUND)); } void ScrollArea::drawVMarker(gcn::Graphics *graphics) diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp index 8d5b563bb..7e19b0348 100644 --- a/src/gui/widgets/spellshortcutcontainer.cpp +++ b/src/gui/widgets/spellshortcutcontainer.cpp @@ -106,7 +106,6 @@ void SpellShortcutContainer::draw(gcn::Graphics *graphics) Graphics *g = static_cast(graphics); - graphics->setColor(gcn::Color(0, 0, 0, 255)); graphics->setFont(getFont()); int selectedId = spellShortcut->getSelectedItem(); -- cgit v1.2.3-70-g09d2 From 2d17967845119a77aec6388bb27c47339052704a Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 22 Aug 2011 21:16:34 +0300 Subject: Improve draw perfomance. Add new theme color DROPDOWN_SHADOW. --- data/graphics/gui/colors.xml | 1 + data/themes/blackwood/colors.xml | 1 + data/themes/enchilado/colors.xml | 1 + data/themes/mana/colors.xml | 1 + data/themes/pink/colors.xml | 1 + data/themes/redandblack/colors.xml | 1 + data/themes/wood/colors.xml | 1 + src/gui/equipmentwindow.cpp | 12 +++++---- src/gui/equipmentwindow.h | 2 ++ src/gui/outfitwindow.cpp | 7 ++++-- src/gui/outfitwindow.h | 2 ++ src/gui/serverdialog.cpp | 24 +++++++++++------- src/gui/skilldialog.cpp | 12 ++++++--- src/gui/theme.cpp | 1 + src/gui/theme.h | 1 + src/gui/widgets/avatarlistbox.cpp | 13 ++++++---- src/gui/widgets/avatarlistbox.h | 1 + src/gui/widgets/browserbox.cpp | 10 +++++--- src/gui/widgets/browserbox.h | 4 +++ src/gui/widgets/button.cpp | 7 ++++-- src/gui/widgets/button.h | 2 ++ src/gui/widgets/checkbox.cpp | 4 ++- src/gui/widgets/desktop.cpp | 8 +++--- src/gui/widgets/desktop.h | 2 ++ src/gui/widgets/dropdown.cpp | 22 ++++++++-------- src/gui/widgets/dropdown.h | 3 +++ src/gui/widgets/dropshortcutcontainer.cpp | 14 ++++------- src/gui/widgets/dropshortcutcontainer.h | 2 ++ src/gui/widgets/emoteshortcutcontainer.cpp | 14 ++--------- src/gui/widgets/guitable.cpp | 16 ++++++------ src/gui/widgets/guitable.h | 3 ++- src/gui/widgets/itemcontainer.cpp | 7 ++++-- src/gui/widgets/itemcontainer.h | 2 ++ src/gui/widgets/itemshortcutcontainer.cpp | 14 +++++------ src/gui/widgets/itemshortcutcontainer.h | 3 ++- src/gui/widgets/listbox.cpp | 8 +++--- src/gui/widgets/listbox.h | 1 + src/gui/widgets/scrollarea.cpp | 12 +++++---- src/gui/widgets/scrollarea.h | 3 +++ src/gui/widgets/shoplistbox.cpp | 40 +++++++++++++++++------------- src/gui/widgets/shoplistbox.h | 6 +++++ src/gui/widgets/spellshortcutcontainer.cpp | 3 ++- src/gui/widgets/tab.cpp | 8 +++--- src/gui/widgets/tab.h | 2 ++ src/gui/widgets/textfield.cpp | 4 ++- src/gui/widgets/window.cpp | 8 ++---- 46 files changed, 190 insertions(+), 124 deletions(-) (limited to 'src/gui/outfitwindow.cpp') diff --git a/data/graphics/gui/colors.xml b/data/graphics/gui/colors.xml index 017b55400..2091494b3 100644 --- a/data/graphics/gui/colors.xml +++ b/data/graphics/gui/colors.xml @@ -14,6 +14,7 @@ + diff --git a/data/themes/blackwood/colors.xml b/data/themes/blackwood/colors.xml index b85ccdfc7..ef06fdc9f 100644 --- a/data/themes/blackwood/colors.xml +++ b/data/themes/blackwood/colors.xml @@ -14,6 +14,7 @@ + diff --git a/data/themes/enchilado/colors.xml b/data/themes/enchilado/colors.xml index 38167192d..f4ae878e4 100644 --- a/data/themes/enchilado/colors.xml +++ b/data/themes/enchilado/colors.xml @@ -14,6 +14,7 @@ + diff --git a/data/themes/mana/colors.xml b/data/themes/mana/colors.xml index 96a929a5e..c623b8396 100644 --- a/data/themes/mana/colors.xml +++ b/data/themes/mana/colors.xml @@ -14,6 +14,7 @@ + diff --git a/data/themes/pink/colors.xml b/data/themes/pink/colors.xml index 44aac3527..6be3ab630 100644 --- a/data/themes/pink/colors.xml +++ b/data/themes/pink/colors.xml @@ -14,6 +14,7 @@ + diff --git a/data/themes/redandblack/colors.xml b/data/themes/redandblack/colors.xml index b705241fb..8fe785114 100644 --- a/data/themes/redandblack/colors.xml +++ b/data/themes/redandblack/colors.xml @@ -14,6 +14,7 @@ + diff --git a/data/themes/wood/colors.xml b/data/themes/wood/colors.xml index 1080f2022..1f1ac1776 100644 --- a/data/themes/wood/colors.xml +++ b/data/themes/wood/colors.xml @@ -14,6 +14,7 @@ + diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp index 3284301ec..3abd97c73 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -99,6 +99,9 @@ EquipmentWindow::EquipmentWindow(Equipment *equipment, Being *being, add(mPlayerBox); add(mUnequip); + mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT); + mBorderColor = Theme::getThemeColor(Theme::BORDER); + setForegroundColor(Theme::getThemeColor(Theme::TEXT)); } EquipmentWindow::~EquipmentWindow() @@ -138,16 +141,15 @@ void EquipmentWindow::draw(gcn::Graphics *graphics) continue; if (i == mSelected) { - const gcn::Color color = Theme::getThemeColor(Theme::HIGHLIGHT); - + mHighlightColor.a = getGuiAlpha(); // Set color to the highlight color - g->setColor(gcn::Color(color.r, color.g, color.b, getGuiAlpha())); + g->setColor(mHighlightColor); g->fillRectangle(gcn::Rectangle(box->first, box->second, BOX_WIDTH, BOX_HEIGHT)); } // Set color black - g->setColor(Theme::getThemeColor(Theme::BORDER)); + g->setColor(mBorderColor); // Draw box border g->drawRectangle(gcn::Rectangle(box->first, box->second, BOX_WIDTH, BOX_HEIGHT)); @@ -167,7 +169,7 @@ void EquipmentWindow::draw(gcn::Graphics *graphics) g->drawImage(image, box->first + 2, box->second + 2); if (i == EQUIP_PROJECTILE_SLOT) { - g->setColor(Theme::getThemeColor(Theme::TEXT)); + g->setColor(getForegroundColor()); graphics->drawText(toString(item->getQuantity()), box->first + (BOX_WIDTH / 2), box->second - fontHeight, diff --git a/src/gui/equipmentwindow.h b/src/gui/equipmentwindow.h index c59600dd8..cadf27620 100644 --- a/src/gui/equipmentwindow.h +++ b/src/gui/equipmentwindow.h @@ -116,6 +116,8 @@ class EquipmentWindow : public Window, public gcn::ActionListener bool mForing; Being *mBeing; std::vector*> mBoxes; + gcn::Color mHighlightColor; + gcn::Color mBorderColor; }; extern EquipmentWindow *equipmentWindow; diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp index 79ac88d94..d3bc6a302 100644 --- a/src/gui/outfitwindow.cpp +++ b/src/gui/outfitwindow.cpp @@ -78,6 +78,9 @@ OutfitWindow::OutfitWindow(): addMouseListener(this); + mBorderColor = Theme::getThemeColor(Theme::BORDER, 64); + mBackgroundColor = Theme::getThemeColor(Theme::BACKGROUND, 32); + mPreviousButton = new Button(_("<"), "previous", this); mNextButton = new Button(_(">"), "next", this); mCurrentLabel = new Label(strprintf(_("Outfit: %d"), 1)); @@ -304,9 +307,9 @@ void OutfitWindow::draw(gcn::Graphics *graphics) const int itemX = 10 + ((i % mGridWidth) * mBoxWidth); const int itemY = 25 + ((i / mGridWidth) * mBoxHeight); - graphics->setColor(Theme::getThemeColor(Theme::BORDER, 64)); + graphics->setColor(mBorderColor); graphics->drawRectangle(gcn::Rectangle(itemX, itemY, 32, 32)); - graphics->setColor(Theme::getThemeColor(Theme::BACKGROUND, 32)); + graphics->setColor(mBackgroundColor); graphics->fillRectangle(gcn::Rectangle(itemX, itemY, 32, 32)); if (mItems[mCurrentOutfit][i] < 0) diff --git a/src/gui/outfitwindow.h b/src/gui/outfitwindow.h index 60634dbdd..8dd5fd6a3 100644 --- a/src/gui/outfitwindow.h +++ b/src/gui/outfitwindow.h @@ -137,6 +137,8 @@ class OutfitWindow : public Window, gcn::ActionListener int mAwayOutfit; Image *mBackgroundImg; + gcn::Color mBorderColor; + gcn::Color mBackgroundColor; static float mAlpha; }; diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index 143d3e5a3..763c190d6 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -158,6 +158,10 @@ public: ServersListBox(ServersListModel *model): ListBox(model) { + mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT); + mTextColor = Theme::getThemeColor(Theme::TEXT); + mNotSupportedColor = Theme::getThemeColor( + Theme::SERVER_VERSION_NOT_SUPPORTED); } void draw(gcn::Graphics *graphics) @@ -169,20 +173,18 @@ public: updateAlpha(); - graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT, - static_cast(mAlpha * 255.0f))); + mHighlightColor.a = static_cast(mAlpha * 255.0f); + graphics->setColor(mHighlightColor); graphics->setFont(getFont()); const int height = getRowHeight(); - const gcn::Color unsupported = - Theme::getThemeColor(Theme::SERVER_VERSION_NOT_SUPPORTED, - static_cast(mAlpha * 255.0f)); + mNotSupportedColor.a = static_cast(mAlpha * 255.0f); // Draw filled rectangle around the selected list element if (mSelected >= 0) { - graphics->fillRectangle(gcn::Rectangle(0, height * mSelected, - getWidth(), height)); + graphics->fillRectangle(gcn::Rectangle(0, + height * mSelected, getWidth(), height)); } // Draw the list elements @@ -191,7 +193,7 @@ public: { ServerInfo info = model->getServer(i); - graphics->setColor(Theme::getThemeColor(Theme::TEXT)); + graphics->setColor(mTextColor); int top; @@ -212,7 +214,7 @@ public: if (info.version.first > 0) { - graphics->setColor(unsupported); + graphics->setColor(mNotSupportedColor); graphics->drawText(info.version.second, getWidth() - info.version.first - 2, top); @@ -224,6 +226,10 @@ public: { return 2 * getFont()->getHeight(); } +private: + gcn::Color mHighlightColor; + gcn::Color mTextColor; + gcn::Color mNotSupportedColor; }; diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp index 896f06cab..ff57195a9 100644 --- a/src/gui/skilldialog.cpp +++ b/src/gui/skilldialog.cpp @@ -152,7 +152,9 @@ public: SkillListBox(SkillModel *model): ListBox(model), mModel(model), - mPopup(new TextPopup()) + mPopup(new TextPopup()), + mHighlightColor(Theme::getThemeColor(Theme::HIGHLIGHT)), + mTextColor(Theme::getThemeColor(Theme::TEXT)) { } @@ -187,8 +189,8 @@ public: Graphics *graphics = static_cast(gcnGraphics); - graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT, - static_cast(mAlpha * 255.0f))); + mHighlightColor.a = static_cast(mAlpha * 255.0f); + graphics->setColor(mHighlightColor); graphics->setFont(getFont()); // Draw filled rectangle around the selected list element @@ -199,7 +201,7 @@ public: } // Draw the list elements - graphics->setColor(Theme::getThemeColor(Theme::TEXT)); + graphics->setColor(mTextColor); for (int i = 0, y = 1; i < model->getNumberOfElements(); ++i, y += getRowHeight()) @@ -239,6 +241,8 @@ public: private: SkillModel *mModel; TextPopup *mPopup; + gcn::Color mHighlightColor; + gcn::Color mTextColor; }; class SkillTab : public Tab diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp index 5fcfeade2..15554044d 100644 --- a/src/gui/theme.cpp +++ b/src/gui/theme.cpp @@ -611,6 +611,7 @@ static int readColorType(const std::string &type) "BACKGROUND", "BACKGROUND_GRAY", "SCROLLBAR_GRAY", + "DROPDOWN_SHADOW", "HIGHLIGHT", "TAB_FLASH", "TAB_PLAYER_FLASH", diff --git a/src/gui/theme.h b/src/gui/theme.h index bdcdafc74..4e6a64a6f 100644 --- a/src/gui/theme.h +++ b/src/gui/theme.h @@ -155,6 +155,7 @@ class Theme : public Palette, public ConfigListener BACKGROUND, BACKGROUND_GRAY, SCROLLBAR_GRAY, + DROPDOWN_SHADOW, HIGHLIGHT, TAB_FLASH, TAB_PLAYER_FLASH, diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index 0d35ad188..d4764cba5 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -66,6 +66,9 @@ AvatarListBox::AvatarListBox(AvatarListModel *model): config.addListener("showgender", this); config.addListener("showlevel", this); + + mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT); + setForegroundColor(Theme::getThemeColor(Theme::TEXT)); } AvatarListBox::~AvatarListBox() @@ -102,8 +105,8 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics) Graphics *graphics = static_cast(gcnGraphics); - graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT, - static_cast(mAlpha * 255.0f))); + mHighlightColor.a = static_cast(mAlpha * 255.0f); + graphics->setColor(mHighlightColor); graphics->setFont(getFont()); const int fontHeight = getFont()->getHeight(); @@ -113,7 +116,7 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics) const std::string name = player_node->getName(); // Draw the list elements - graphics->setColor(Theme::getThemeColor(Theme::TEXT)); + graphics->setColor(getForegroundColor()); for (int i = 0, y = 0; i < model->getNumberOfElements(); ++i, y += fontHeight) @@ -206,7 +209,7 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics) if (a->getLevel() > 1) { - graphics->setColor(Theme::getThemeColor(Theme::TEXT)); + graphics->setColor(getForegroundColor()); int minHp = 40 + ((a->getLevel() - 1) * 5); if (minHp < 0) minHp = 40; @@ -283,7 +286,7 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics) } } - graphics->setColor(Theme::getThemeColor(Theme::TEXT)); + graphics->setColor(getForegroundColor()); // Draw Name if (a->getType() == MapItem::SEPARATOR) diff --git a/src/gui/widgets/avatarlistbox.h b/src/gui/widgets/avatarlistbox.h index 2fe1dfe3d..afb4abdf5 100644 --- a/src/gui/widgets/avatarlistbox.h +++ b/src/gui/widgets/avatarlistbox.h @@ -62,6 +62,7 @@ public: private: bool mShowGender; bool mShowLevel; + gcn::Color mHighlightColor; static int instances; static Image *onlineIcon; diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index 7df70bd04..bb83c1159 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -64,6 +64,10 @@ BrowserBox::BrowserBox(unsigned int mode, bool opaque): { setFocusable(true); addMouseListener(this); + + mBackgroundColor = Theme::getThemeColor(Theme::BACKGROUND); + mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT); + mHyperLinkColor = Theme::getThemeColor(Theme::HYPERLINK); } BrowserBox::~BrowserBox() @@ -310,7 +314,7 @@ void BrowserBox::draw(gcn::Graphics *graphics) if (mOpaque) { - graphics->setColor(Theme::getThemeColor(Theme::BACKGROUND)); + graphics->setColor(mBackgroundColor); graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight())); } @@ -319,7 +323,7 @@ void BrowserBox::draw(gcn::Graphics *graphics) { if ((mHighMode & BACKGROUND)) { - graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT)); + graphics->setColor(mHighlightColor); graphics->fillRectangle(gcn::Rectangle( mLinks[mSelectedLink].x1, mLinks[mSelectedLink].y1, @@ -330,7 +334,7 @@ void BrowserBox::draw(gcn::Graphics *graphics) if ((mHighMode & UNDERLINE)) { - graphics->setColor(Theme::getThemeColor(Theme::HYPERLINK)); + graphics->setColor(mHyperLinkColor); graphics->drawLine( mLinks[mSelectedLink].x1, mLinks[mSelectedLink].y2, diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h index 6fdb40042..9969bfd3b 100644 --- a/src/gui/widgets/browserbox.h +++ b/src/gui/widgets/browserbox.h @@ -225,6 +225,10 @@ class BrowserBox : public gcn::Widget, bool mAlwaysUpdate; bool mProcessVersion; bool mEnableImages; + + gcn::Color mBackgroundColor; + gcn::Color mHighlightColor; + gcn::Color mHyperLinkColor; }; #endif diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index 41fbc1093..7c46ae9df 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -135,6 +135,9 @@ void Button::init() } updateAlpha(); } + mEnabledColor = Theme::getThemeColor(Theme::BUTTON); + mDisabledColor = Theme::getThemeColor(Theme::BUTTON_DISABLED); + mInstances++; } @@ -238,9 +241,9 @@ void Button::draw(gcn::Graphics *graphics) // drawImageRect(0, 0, getWidth(), getHeight(), button[mode]); if (mode == BUTTON_DISABLED) - graphics->setColor(Theme::getThemeColor(Theme::BUTTON_DISABLED)); + graphics->setColor(mDisabledColor); else - graphics->setColor(Theme::getThemeColor(Theme::BUTTON)); + graphics->setColor(mEnabledColor); int textX; int textY = getHeight() / 2 - getFont()->getHeight() / 2; diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h index 8c43b6ddd..1b62179b3 100644 --- a/src/gui/widgets/button.h +++ b/src/gui/widgets/button.h @@ -101,6 +101,8 @@ class Button : public gcn::Button, public gcn::WidgetListener int mMode; int mXOffset; int mYOffset; + gcn::Color mEnabledColor; + gcn::Color mDisabledColor; }; #endif diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp index 61e5d9118..65d26e196 100644 --- a/src/gui/widgets/checkbox.cpp +++ b/src/gui/widgets/checkbox.cpp @@ -86,6 +86,8 @@ CheckBox::CheckBox(const std::string &caption, bool selected, if (listener) addActionListener(listener); + + setForegroundColor(Theme::getThemeColor(Theme::TEXT)); } CheckBox::~CheckBox() @@ -114,7 +116,7 @@ void CheckBox::draw(gcn::Graphics* graphics) drawBox(graphics); graphics->setFont(getFont()); - graphics->setColor(Theme::getThemeColor(Theme::TEXT)); + graphics->setColor(getForegroundColor()); const int h = getHeight() + getHeight() / 2; diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp index 40d90ba11..46240f76d 100644 --- a/src/gui/widgets/desktop.cpp +++ b/src/gui/widgets/desktop.cpp @@ -56,6 +56,9 @@ Desktop::Desktop() : mVersionLabel->setBackgroundColor( Theme::getThemeColor(Theme::BACKGROUND, 128)); add(mVersionLabel, 25, 2); + + mBackgroundColor = Theme::getThemeColor(Theme::BACKGROUND, 128); + mBackgroundGrayColor = Theme::getThemeColor(Theme::BACKGROUND_GRAY); } Desktop::~Desktop() @@ -85,8 +88,7 @@ void Desktop::draw(gcn::Graphics *graphics) if (!mWallpaper || (getWidth() > mWallpaper->getWidth() || getHeight() > mWallpaper->getHeight())) { - // TODO: Color from palette - g->setColor(Theme::getThemeColor(Theme::BACKGROUND_GRAY)); + g->setColor(mBackgroundGrayColor); g->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight())); } @@ -107,7 +109,7 @@ void Desktop::draw(gcn::Graphics *graphics) } // Draw a thin border under the application version... - g->setColor(Theme::getThemeColor(Theme::BACKGROUND, 128)); + g->setColor(mBackgroundColor); g->fillRectangle(gcn::Rectangle(mVersionLabel->getDimension())); Container::draw(graphics); diff --git a/src/gui/widgets/desktop.h b/src/gui/widgets/desktop.h index 962cc3c01..6364ecfe9 100644 --- a/src/gui/widgets/desktop.h +++ b/src/gui/widgets/desktop.h @@ -68,6 +68,8 @@ class Desktop : public Container, gcn::WidgetListener Image *mWallpaper; gcn::Label *mVersionLabel; + gcn::Color mBackgroundColor; + gcn::Color mBackgroundGrayColor; }; #endif // DESKTOP_H diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 681d7736e..f01d3fb55 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -101,6 +101,10 @@ DropDown::DropDown(gcn::ListModel *listModel): } instances++; + + mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT); + mShadowColor = Theme::getThemeColor(Theme::DROPDOWN_SHADOW); + setForegroundColor(Theme::getThemeColor(Theme::TEXT)); } DropDown::~DropDown() @@ -163,25 +167,20 @@ void DropDown::draw(gcn::Graphics* graphics) updateAlpha(); const int alpha = static_cast(mAlpha * 255.0f); - gcn::Color faceColor = getBaseColor(); - faceColor.a = alpha; - const gcn::Color *highlightColor = &Theme::getThemeColor(Theme::HIGHLIGHT, - alpha); - gcn::Color shadowColor = faceColor - 0x303030; - shadowColor.a = alpha; + mHighlightColor.a = alpha; + mShadowColor.a = alpha; if (mListBox->getListModel() && mListBox->getSelected() >= 0) { graphics->setFont(getFont()); - graphics->setColor(Theme::getThemeColor(Theme::TEXT)); + graphics->setColor(getForegroundColor()); graphics->drawText(mListBox->getListModel()->getElementAt( mListBox->getSelected()), 1, 0); } if (isFocused()) { - if (highlightColor) - graphics->setColor(*highlightColor); + graphics->setColor(mHighlightColor); graphics->drawRectangle(gcn::Rectangle(0, 0, getWidth() - h, h)); } @@ -193,10 +192,9 @@ void DropDown::draw(gcn::Graphics* graphics) // Draw two lines separating the ListBox with selected // element view. - if (highlightColor) - graphics->setColor(*highlightColor); + graphics->setColor(mHighlightColor); graphics->drawLine(0, h, getWidth(), h); - graphics->setColor(shadowColor); + graphics->setColor(mShadowColor); graphics->drawLine(0, h + 1, getWidth(), h + 1); } } diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index d85c3166c..6a22ba497 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -87,6 +87,9 @@ class DropDown : public gcn::DropDown */ void drawButton(gcn::Graphics *graphics); + gcn::Color mShadowColor; + gcn::Color mHighlightColor; + // Add own Images. static int instances; static Image *buttons[2][2]; diff --git a/src/gui/widgets/dropshortcutcontainer.cpp b/src/gui/widgets/dropshortcutcontainer.cpp index 92f02c78f..b628cf2d4 100644 --- a/src/gui/widgets/dropshortcutcontainer.cpp +++ b/src/gui/widgets/dropshortcutcontainer.cpp @@ -73,6 +73,8 @@ DropShortcutContainer::DropShortcutContainer(): mBoxHeight = 1; mBoxWidth = 1; } + mEquipedColor = Theme::getThemeColor(Theme::ITEM_EQUIPPED); + mUnEquipedColor = Theme::getThemeColor(Theme::ITEM_NOT_EQUIPPED); } DropShortcutContainer::~DropShortcutContainer() @@ -110,12 +112,6 @@ void DropShortcutContainer::draw(gcn::Graphics *graphics) if (mBackgroundImg) g->drawImage(mBackgroundImg, itemX, itemY); -/* // Draw item keyboard shortcut. - const char *key = SDL_GetKeyName( - (SDLKey) keyboard.getKeyValue(keyboard.KEY_SHORTCUT_1 + i)); - graphics->setColor(guiPalette->getColor(Palette::TEXT)); - g->drawText(key, itemX + 2, itemY + 2, gcn::Graphics::LEFT); -*/ if (dropShortcut->getItem(i) < 0) continue; @@ -142,11 +138,11 @@ void DropShortcutContainer::draw(gcn::Graphics *graphics) image->setAlpha(1.0f); g->drawImage(image, itemX, itemY); if (item->isEquipped()) - g->setColor(Theme::getThemeColor(Theme::ITEM_EQUIPPED)); + g->setColor(mEquipedColor); else - g->setColor(Theme::getThemeColor(Theme::TEXT)); + g->setColor(mUnEquipedColor); g->drawText(caption, itemX + mBoxWidth / 2, - itemY + mBoxHeight - 14, gcn::Graphics::CENTER); + itemY + mBoxHeight - 14, gcn::Graphics::CENTER); } } } diff --git a/src/gui/widgets/dropshortcutcontainer.h b/src/gui/widgets/dropshortcutcontainer.h index 723b215cf..b2d63a7dd 100644 --- a/src/gui/widgets/dropshortcutcontainer.h +++ b/src/gui/widgets/dropshortcutcontainer.h @@ -84,6 +84,8 @@ class DropShortcutContainer : public ShortcutContainer Item *mItemMoved; ItemPopup *mItemPopup; + gcn::Color mEquipedColor; + gcn::Color mUnEquipedColor; }; #endif diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp index 5bb972adc..5aced193f 100644 --- a/src/gui/widgets/emoteshortcutcontainer.cpp +++ b/src/gui/widgets/emoteshortcutcontainer.cpp @@ -80,6 +80,7 @@ EmoteShortcutContainer::EmoteShortcutContainer(): mBoxHeight = 1; mBoxWidth = 1; } + setForegroundColor(Theme::getThemeColor(Theme::TEXT)); } EmoteShortcutContainer::~EmoteShortcutContainer() @@ -118,20 +119,9 @@ void EmoteShortcutContainer::draw(gcn::Graphics *graphics) std::string key = keyboard.getKeyValueString( keyboard.KEY_EMOTE_1 + i); - graphics->setColor(Theme::getThemeColor(Theme::TEXT)); + graphics->setColor(getForegroundColor()); g->drawText(key, emoteX + 2, emoteY + 2, gcn::Graphics::LEFT); -/* - if (emoteShortcut->getEmote(i) - && static_cast(emoteShortcut->getEmote(i)) - 1 - < mEmoteImg.size() - && mEmoteImg[emoteShortcut->getEmote(i) - 1]) - { - mEmoteImg[emoteShortcut->getEmote(i) - 1]->draw(g, emoteX + 2, - emoteY + 10); - } -*/ - if (i < mEmoteImg.size() && mEmoteImg[i] && mEmoteImg[i]->sprite) mEmoteImg[i]->sprite->draw(g, emoteX + 2, emoteY + 10); } diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp index e25e0bb8c..e02eda88c 100644 --- a/src/gui/widgets/guitable.cpp +++ b/src/gui/widgets/guitable.cpp @@ -88,17 +88,17 @@ void GuiTableActionListener::action(const gcn::ActionEvent } -GuiTable::GuiTable(TableModel *initial_model, gcn::Color background, - bool opacity) : +GuiTable::GuiTable(TableModel *initial_model, bool opacity) : mLinewiseMode(false), mWrappingEnabled(false), mOpaque(opacity), - mBackgroundColor(background), mModel(NULL), mSelectedRow(0), mSelectedColumn(0), mTopWidget(NULL) { + mBackgroundColor = Theme::getThemeColor(Theme::BACKGROUND); + mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT); setModel(initial_model); setFocusable(true); @@ -292,8 +292,8 @@ void GuiTable::draw(gcn::Graphics* graphics) if (mOpaque) { - graphics->setColor(Theme::getThemeColor(Theme::BACKGROUND, - static_cast(mAlpha * 255.0f))); + mBackgroundColor.a = static_cast(mAlpha * 255.0f); + graphics->setColor(mBackgroundColor); graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight())); } @@ -304,7 +304,7 @@ void GuiTable::draw(gcn::Graphics* graphics) first_row = 0; unsigned rows_nr = 1 + (getHeight() / getRowHeight()); // May overestimate - // by one. + // by one. unsigned max_rows_nr; if (mModel->getRows() < first_row) @@ -343,8 +343,8 @@ void GuiTable::draw(gcn::Graphics* graphics) widget->setDimension(bounds); - graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT, - static_cast(mAlpha * 255.0f))); + mHighlightColor.a = static_cast(mAlpha * 255.0f); + graphics->setColor(mHighlightColor); if (mSelectedRow > 0) { diff --git a/src/gui/widgets/guitable.h b/src/gui/widgets/guitable.h index c4fab6a0d..d248c4820 100644 --- a/src/gui/widgets/guitable.h +++ b/src/gui/widgets/guitable.h @@ -58,7 +58,6 @@ class GuiTable : public gcn::Widget, public: GuiTable(TableModel * initial_model = NULL, - gcn::Color background = 0xffffff, bool opacity = true); virtual ~GuiTable(); @@ -190,6 +189,8 @@ private: /** Vector for compactness; used as a list in practice. */ std::vector mActionListeners; + + gcn::Color mHighlightColor; }; diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index c28e4fb4c..91b674018 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -118,6 +118,9 @@ ItemContainer::ItemContainer(Inventory *inventory, bool forceQuantity): if (!mSelImg) logger->log1("Error: Unable to load selection.png"); + mEquipedColor = Theme::getThemeColor(Theme::ITEM_EQUIPPED); + mUnEquipedColor = Theme::getThemeColor(Theme::ITEM_NOT_EQUIPPED); + addKeyListener(this); addMouseListener(this); addWidgetListener(this); @@ -204,9 +207,9 @@ void ItemContainer::draw(gcn::Graphics *graphics) caption = "Eq."; if (item->isEquipped()) - g->setColor(Theme::getThemeColor(Theme::ITEM_EQUIPPED)); + g->setColor(mEquipedColor); else - g->setColor(Theme::getThemeColor(Theme::ITEM_NOT_EQUIPPED)); + g->setColor(mUnEquipedColor); g->drawText(caption, itemX + BOX_WIDTH / 2, itemY + BOX_HEIGHT - 14, gcn::Graphics::CENTER); diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h index 5fd897a29..df7de63ee 100644 --- a/src/gui/widgets/itemcontainer.h +++ b/src/gui/widgets/itemcontainer.h @@ -202,6 +202,8 @@ class ItemContainer : public gcn::Widget, typedef SelectionListenerList::iterator SelectionListenerIterator; SelectionListenerList mSelectionListeners; + gcn::Color mEquipedColor; + gcn::Color mUnEquipedColor; }; #endif diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp index 328d5ae4d..79685fe45 100644 --- a/src/gui/widgets/itemshortcutcontainer.cpp +++ b/src/gui/widgets/itemshortcutcontainer.cpp @@ -77,6 +77,9 @@ ItemShortcutContainer::ItemShortcutContainer(unsigned number): mBoxHeight = 1; mBoxWidth = 1; } + setForegroundColor(Theme::getThemeColor(Theme::TEXT)); + mEquipedColor = Theme::getThemeColor(Theme::ITEM_EQUIPPED); + mUnEquipedColor = Theme::getThemeColor(Theme::ITEM_NOT_EQUIPPED); } ItemShortcutContainer::~ItemShortcutContainer() @@ -119,7 +122,7 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics) // Draw item keyboard shortcut. std::string key = keyboard.getKeyValueString( keyboard.KEY_SHORTCUT_1 + i); - graphics->setColor(Theme::getThemeColor(Theme::TEXT)); + graphics->setColor(getForegroundColor()); g->drawText(key, itemX + 2, itemY + 2, gcn::Graphics::LEFT); @@ -154,14 +157,9 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics) image->setAlpha(1.0f); g->drawImage(image, itemX, itemY); if (item->isEquipped()) - { - g->setColor(Theme::getThemeColor( - Theme::ITEM_EQUIPPED)); - } + g->setColor(mEquipedColor); else - { - graphics->setColor(Theme::getThemeColor(Theme::TEXT)); - } + g->setColor(mUnEquipedColor); g->drawText(caption, itemX + mBoxWidth / 2, itemY + mBoxHeight - 14, gcn::Graphics::CENTER); } diff --git a/src/gui/widgets/itemshortcutcontainer.h b/src/gui/widgets/itemshortcutcontainer.h index 7eac431ec..e6b32c6f8 100644 --- a/src/gui/widgets/itemshortcutcontainer.h +++ b/src/gui/widgets/itemshortcutcontainer.h @@ -88,7 +88,8 @@ class ItemShortcutContainer : public ShortcutContainer ItemPopup *mItemPopup; SpellPopup *mSpellPopup; + gcn::Color mEquipedColor; + gcn::Color mUnEquipedColor; }; -//extern SpellManager *spellManager; #endif diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index de8707406..53299ca46 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -41,6 +41,8 @@ float ListBox::mAlpha = 1.0; ListBox::ListBox(gcn::ListModel *listModel): gcn::ListBox(listModel) { + mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT); + setForegroundColor(Theme::getThemeColor(Theme::TEXT)); } ListBox::~ListBox() @@ -63,8 +65,8 @@ void ListBox::draw(gcn::Graphics *graphics) updateAlpha(); - graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT, - static_cast(mAlpha * 255.0f))); + mHighlightColor.a = static_cast(mAlpha * 255.0f); + graphics->setColor(mHighlightColor); graphics->setFont(getFont()); const int height = getRowHeight(); @@ -77,7 +79,7 @@ void ListBox::draw(gcn::Graphics *graphics) } // Draw the list elements - graphics->setColor(Theme::getThemeColor(Theme::TEXT)); + graphics->setColor(getForegroundColor()); for (int i = 0, y = 0; i < mListModel->getNumberOfElements(); ++i, y += height) { diff --git a/src/gui/widgets/listbox.h b/src/gui/widgets/listbox.h index 5f8c20059..418b83f58 100644 --- a/src/gui/widgets/listbox.h +++ b/src/gui/widgets/listbox.h @@ -73,6 +73,7 @@ class ListBox : public gcn::ListBox void mouseDragged(gcn::MouseEvent &event); protected: + gcn::Color mHighlightColor; static float mAlpha; }; diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index 3e90bf4c7..2796d3ab2 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -73,7 +73,6 @@ ScrollArea::ScrollArea(gcn::Widget *widget): mDrawWidth(0), mDrawHeight(0) { -// addWidgetListener(this); init(); } @@ -219,6 +218,9 @@ void ScrollArea::init() } instances++; + + mGray = Theme::getThemeColor(Theme::SCROLLBAR_GRAY, 32); + mBackground = Theme::getThemeColor(Theme::BACKGROUND); } void ScrollArea::logic() @@ -439,17 +441,17 @@ void ScrollArea::drawRightButton(gcn::Graphics *graphics) void ScrollArea::drawVBar(gcn::Graphics *graphics) { const gcn::Rectangle dim = getVerticalBarDimension(); - graphics->setColor(Theme::getThemeColor(Theme::SCROLLBAR_GRAY, 32)); + graphics->setColor(mGray); graphics->fillRectangle(dim); - graphics->setColor(Theme::getThemeColor(Theme::BACKGROUND)); + graphics->setColor(mBackground); } void ScrollArea::drawHBar(gcn::Graphics *graphics) { const gcn::Rectangle dim = getHorizontalBarDimension(); - graphics->setColor(Theme::getThemeColor(Theme::SCROLLBAR_GRAY, 32)); + graphics->setColor(mGray); graphics->fillRectangle(dim); - graphics->setColor(Theme::getThemeColor(Theme::BACKGROUND)); + graphics->setColor(mBackground); } void ScrollArea::drawVMarker(gcn::Graphics *graphics) diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h index 440fcec15..095010f3c 100644 --- a/src/gui/widgets/scrollarea.h +++ b/src/gui/widgets/scrollarea.h @@ -156,6 +156,9 @@ class ScrollArea : public gcn::ScrollArea, public gcn::WidgetListener int mYOffset; int mDrawWidth; int mDrawHeight; + + gcn::Color mGray; + gcn::Color mBackground; }; #endif diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp index 2fe28181b..793491808 100644 --- a/src/gui/widgets/shoplistbox.cpp +++ b/src/gui/widgets/shoplistbox.cpp @@ -50,9 +50,7 @@ ShopListBox::ShopListBox(gcn::ListModel *listModel): mShopItems(0) { mRowHeight = getFont()->getHeight(); - mPriceCheck = true; - - mItemPopup = new ItemPopup; + init(); } ShopListBox::ShopListBox(gcn::ListModel *listModel, ShopItems *shopListModel): @@ -61,9 +59,17 @@ ShopListBox::ShopListBox(gcn::ListModel *listModel, ShopItems *shopListModel): mShopItems(shopListModel) { mRowHeight = std::max(getFont()->getHeight(), ITEM_ICON_SIZE); - mPriceCheck = true; + init(); +} +void ShopListBox::init() +{ + mPriceCheck = true; mItemPopup = new ItemPopup; + mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT); + mBackgroundColor = Theme::getThemeColor(Theme::BACKGROUND); + mWarningColor = Theme::getThemeColor(Theme::SHOP_WARNING); + setForegroundColor(Theme::getThemeColor(Theme::TEXT)); } void ShopListBox::setPlayersMoney(int money) @@ -80,8 +86,7 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics) mAlpha = Client::getGuiAlpha(); int alpha = static_cast(mAlpha * 255.0f); - const gcn::Color* highlightColor = - &Theme::getThemeColor(Theme::HIGHLIGHT, alpha); + mHighlightColor.a = alpha; Graphics *graphics = static_cast(gcnGraphics); @@ -93,29 +98,30 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics) ++i, y += mRowHeight) { gcn::Color temp; - const gcn::Color* backgroundColor = - &Theme::getThemeColor(Theme::BACKGROUND, alpha); + gcn::Color* backgroundColor = &mBackgroundColor; + mBackgroundColor.a = alpha; if (mShopItems && mShopItems->at(i) && mPlayerMoney < mShopItems->at(i)->getPrice() && mPriceCheck) { if (i != mSelected) { - backgroundColor = &Theme::getThemeColor(Theme::SHOP_WARNING, - alpha); + backgroundColor = &mWarningColor; + backgroundColor->a = alpha; } else { - temp = Theme::getThemeColor(Theme::SHOP_WARNING, alpha); - temp.r = (temp.r + highlightColor->r) / 2; - temp.g = (temp.g + highlightColor->g) / 2; - temp.b = (temp.g + highlightColor->b) / 2; + temp = mWarningColor; + temp.r = (temp.r + mHighlightColor.r) / 2; + temp.g = (temp.g + mHighlightColor.g) / 2; + temp.b = (temp.g + mHighlightColor.b) / 2; + temp.a = alpha; backgroundColor = &temp; } } else if (i == mSelected) { - backgroundColor = highlightColor; + backgroundColor = &mHighlightColor; } graphics->setColor(*backgroundColor); @@ -130,9 +136,9 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics) graphics->drawImage(icon, 1, y); } } - graphics->setColor(Theme::getThemeColor(Theme::TEXT)); + graphics->setColor(getForegroundColor()); graphics->drawText(mListModel->getElementAt(i), ITEM_ICON_SIZE + 5, - y + (ITEM_ICON_SIZE - getFont()->getHeight()) / 2); + y + (ITEM_ICON_SIZE - getFont()->getHeight()) / 2); } } diff --git a/src/gui/widgets/shoplistbox.h b/src/gui/widgets/shoplistbox.h index 917f46729..38e238f20 100644 --- a/src/gui/widgets/shoplistbox.h +++ b/src/gui/widgets/shoplistbox.h @@ -85,6 +85,8 @@ class ShopListBox : public ListBox void mouseExited(gcn::MouseEvent& mouseEvent A_UNUSED); private: + void init(); + int mPlayerMoney; /** @@ -100,6 +102,10 @@ class ShopListBox : public ListBox static float mAlpha; bool mPriceCheck; + + gcn::Color mHighlightColor; + gcn::Color mBackgroundColor; + gcn::Color mWarningColor; }; #endif // SHOPLISTBOX_H diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp index 7e19b0348..8abe727b5 100644 --- a/src/gui/widgets/spellshortcutcontainer.cpp +++ b/src/gui/widgets/spellshortcutcontainer.cpp @@ -81,6 +81,7 @@ SpellShortcutContainer::SpellShortcutContainer(unsigned number): mBoxHeight = 1; mBoxWidth = 1; } + setForegroundColor(Theme::getThemeColor(Theme::TEXT)); } SpellShortcutContainer::~SpellShortcutContainer() @@ -109,7 +110,7 @@ void SpellShortcutContainer::draw(gcn::Graphics *graphics) graphics->setFont(getFont()); int selectedId = spellShortcut->getSelectedItem(); - g->setColor(Theme::getThemeColor(Theme::TEXT)); + g->setColor(getForegroundColor()); for (unsigned i = 0; i < mMaxItems; i++) { diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp index b7d6b4458..530f1ac82 100644 --- a/src/gui/widgets/tab.cpp +++ b/src/gui/widgets/tab.cpp @@ -77,6 +77,8 @@ Tab::Tab() : gcn::Tab(), mMode(0) { init(); + mFlashColor = Theme::getThemeColor(Theme::TAB_FLASH); + mPlayerFlashColor = Theme::getThemeColor(Theme::TAB_PLAYER_FLASH); } Tab::~Tab() @@ -177,12 +179,10 @@ void Tab::draw(gcn::Graphics *graphics) switch (mFlash) { case 1: - mLabel->setForegroundColor(Theme::getThemeColor( - Theme::TAB_FLASH)); + mLabel->setForegroundColor(mFlashColor); break; case 2: - mLabel->setForegroundColor(Theme::getThemeColor( - Theme::TAB_PLAYER_FLASH)); + mLabel->setForegroundColor(mPlayerFlashColor); break; default: break; diff --git a/src/gui/widgets/tab.h b/src/gui/widgets/tab.h index 5847bd505..ba51e6c74 100644 --- a/src/gui/widgets/tab.h +++ b/src/gui/widgets/tab.h @@ -91,6 +91,8 @@ class Tab : public gcn::Tab, public gcn::WidgetListener GraphicsVertexes *mVertexes; bool mRedraw; int mMode; + gcn::Color mFlashColor; + gcn::Color mPlayerFlashColor; }; #endif diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index f80039650..2729e5407 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -59,6 +59,8 @@ TextField::TextField(const std::string &text, bool loseFocusOnTab, mLoseFocusOnTab = loseFocusOnTab; + setForegroundColor(Theme::getThemeColor(Theme::TEXT)); + if (instances == 0) { // Load the skin @@ -136,7 +138,7 @@ void TextField::draw(gcn::Graphics *graphics) mXScroll); } - graphics->setColor(Theme::getThemeColor(Theme::TEXT)); + graphics->setColor(getForegroundColor()); graphics->setFont(getFont()); graphics->drawText(mText, 1 - mXScroll, 1); } diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 9a7c689e6..cdb9d3d55 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -95,6 +95,7 @@ Window::Window(const std::string &caption, bool modal, Window *parent, addWidgetListener(this); mCaptionFont = getFont(); + setForegroundColor(Theme::getThemeColor(Theme::TEXT)); } Window::~Window() @@ -146,15 +147,10 @@ void Window::draw(gcn::Graphics *graphics) g->drawImageRect2(mVertexes, mSkin->getBorder()); -/* - g->drawImageRect(0, 0, getWidth(), - getHeight(), mSkin->getBorder()); -*/ - // Draw title if (mShowTitle) { - g->setColor(Theme::getThemeColor(Theme::TEXT)); + g->setColor(getForegroundColor()); g->setFont(mCaptionFont); g->drawText(getCaption(), 7, 5, gcn::Graphics::LEFT); } -- cgit v1.2.3-70-g09d2