diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-09-21 01:27:20 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-09-21 02:50:42 +0300 |
commit | c217b7141df580b686a0eef085bd0eb0a8e6771a (patch) | |
tree | 98181b8240ebd9cfebdfe0b81dd02c64a985e68f | |
parent | 898c74f4ded38102360624cad924ecf49af7e36f (diff) | |
download | manaplus-c217b7141df580b686a0eef085bd0eb0a8e6771a.tar.gz manaplus-c217b7141df580b686a0eef085bd0eb0a8e6771a.tar.bz2 manaplus-c217b7141df580b686a0eef085bd0eb0a8e6771a.tar.xz manaplus-c217b7141df580b686a0eef085bd0eb0a8e6771a.zip |
Add to equipment window, background image theming.
New theme file: equipment_background.xml
-rw-r--r-- | data/graphics/gui/CMakeLists.txt | 1 | ||||
-rw-r--r-- | data/graphics/gui/Makefile.am | 1 | ||||
-rw-r--r-- | data/graphics/gui/equipment_background.xml | 6 | ||||
-rw-r--r-- | data/graphics/gui/window.png | bin | 18045 -> 18125 bytes | |||
-rw-r--r-- | src/gui/equipmentwindow.cpp | 44 | ||||
-rw-r--r-- | src/gui/equipmentwindow.h | 2 |
6 files changed, 34 insertions, 20 deletions
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 @@ +<skinset name="Default" image="window.png"> + <widget type="Window" xpos="96" ypos="220"> + <part type="standart" xpos="0" ypos="0" width="36" height="36" /> + <part type="highlighted" xpos="36" ypos="0" width="36" height="36" /> + </widget> +</skinset> diff --git a/data/graphics/gui/window.png b/data/graphics/gui/window.png Binary files differindex 1f18b40a9..20f5bf829 100644 --- a/data/graphics/gui/window.png +++ b/data/graphics/gui/window.png 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*>(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<EquipmentBox*>::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; |