From c217b7141df580b686a0eef085bd0eb0a8e6771a Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 21 Sep 2012 01:27:20 +0300 Subject: Add to equipment window, background image theming. New theme file: equipment_background.xml --- data/graphics/gui/CMakeLists.txt | 1 + data/graphics/gui/Makefile.am | 1 + data/graphics/gui/equipment_background.xml | 6 ++++ data/graphics/gui/window.png | Bin 18045 -> 18125 bytes src/gui/equipmentwindow.cpp | 44 ++++++++++++++++------------- src/gui/equipmentwindow.h | 2 ++ 6 files changed, 34 insertions(+), 20 deletions(-) create mode 100644 data/graphics/gui/equipment_background.xml diff --git a/data/graphics/gui/CMakeLists.txt b/data/graphics/gui/CMakeLists.txt index 46a1db548..4d8560b61 100644 --- a/data/graphics/gui/CMakeLists.txt +++ b/data/graphics/gui/CMakeLists.txt @@ -17,6 +17,7 @@ SET (FILES dropdown_background.xml dropdown_pressed.xml emote_selection.xml + equipment_background.xml equipment_playerbox.xml equipmentbox.png incomplete_icon.xml diff --git a/data/graphics/gui/Makefile.am b/data/graphics/gui/Makefile.am index bae374b8e..96e653059 100644 --- a/data/graphics/gui/Makefile.am +++ b/data/graphics/gui/Makefile.am @@ -20,6 +20,7 @@ gui_DATA = \ dropdown_background.xml \ dropdown_pressed.xml \ emote_selection.xml \ + equipment_background.xml \ equipment_playerbox.xml \ equipmentbox.png \ incomplete_icon.xml \ diff --git a/data/graphics/gui/equipment_background.xml b/data/graphics/gui/equipment_background.xml new file mode 100644 index 000000000..c2d4189f2 --- /dev/null +++ b/data/graphics/gui/equipment_background.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/data/graphics/gui/window.png b/data/graphics/gui/window.png index 1f18b40a9..20f5bf829 100644 Binary files a/data/graphics/gui/window.png and b/data/graphics/gui/window.png differ diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp index 1265d2119..a69343b77 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -65,7 +65,10 @@ EquipmentWindow::EquipmentWindow(Equipment *const equipment, mSelected(-1), mForing(foring), mImageSet(nullptr), - mBeing(being) + mBeing(being), + mHighlightColor(Theme::getThemeColor(Theme::HIGHLIGHT)), + mBorderColor(Theme::getThemeColor(Theme::BORDER)), + mLabelsColor(Theme::getThemeColor(Theme::LABEL)) { if (setupWindow) setupWindow->registerWindowForReset(this); @@ -99,12 +102,13 @@ EquipmentWindow::EquipmentWindow(Equipment *const equipment, area.height - mUnequip->getHeight() - buttonPadding); mUnequip->setEnabled(false); + ImageRect rect; + Theme::instance()->loadRect(rect, "equipment_background.xml", "", 0, 1); + mSlotBackground = rect.grid[0]; + mSlotHighlightedBackground = rect.grid[1]; add(mPlayerBox); add(mUnequip); - mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT); - mBorderColor = Theme::getThemeColor(Theme::BORDER); - mLabelsColor = Theme::getThemeColor(Theme::LABEL); } EquipmentWindow::~EquipmentWindow() @@ -125,15 +129,17 @@ EquipmentWindow::~EquipmentWindow() mImageSet->decRef(); mImageSet = nullptr; } + if (mSlotBackground) + mSlotBackground->decRef(); + if (mSlotHighlightedBackground) + mSlotHighlightedBackground->decRef(); } void EquipmentWindow::draw(gcn::Graphics *graphics) { // Draw window graphics Window::draw(graphics); - Graphics *const g = static_cast(graphics); - Window::drawChildren(graphics); int i = 0; @@ -146,23 +152,21 @@ void EquipmentWindow::draw(gcn::Graphics *graphics) if (!box) continue; if (i == mSelected) - { - mHighlightColor.a = getGuiAlpha(); - // Set color to the highlight color - g->setColor(mHighlightColor); - g->fillRectangle(gcn::Rectangle(box->x, box->y, - BOX_WIDTH, BOX_HEIGHT)); - } + g->drawImage(mSlotHighlightedBackground, box->x, box->y); + else + g->drawImage(mSlotBackground, box->x, box->y); + } - // Set color black - g->setColor(mBorderColor); - // Draw box border - g->drawRectangle(gcn::Rectangle(box->x, box->y, - BOX_WIDTH, BOX_HEIGHT)); + if (!mEquipment) + return; - if (!mEquipment) + i = 0; + for (std::vector::const_iterator it = mBoxes.begin(), + it_end = mBoxes.end(); it != it_end; ++ it, ++ i) + { + const EquipmentBox *const box = *it; + if (!box) continue; - const Item *const item = mEquipment->getEquipment(i); if (item) { diff --git a/src/gui/equipmentwindow.h b/src/gui/equipmentwindow.h index c30d04504..a2f87ca3c 100644 --- a/src/gui/equipmentwindow.h +++ b/src/gui/equipmentwindow.h @@ -136,6 +136,8 @@ class EquipmentWindow : public Window, public gcn::ActionListener gcn::Color mHighlightColor; gcn::Color mBorderColor; gcn::Color mLabelsColor; + Image *mSlotBackground; + Image *mSlotHighlightedBackground; }; extern EquipmentWindow *equipmentWindow; -- cgit v1.2.3-70-g09d2