summaryrefslogtreecommitdiff
path: root/src/gui/equipmentwindow.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-09-21 01:27:20 +0300
committerAndrei Karas <akaras@inbox.ru>2012-09-21 02:50:42 +0300
commitc217b7141df580b686a0eef085bd0eb0a8e6771a (patch)
tree98181b8240ebd9cfebdfe0b81dd02c64a985e68f /src/gui/equipmentwindow.cpp
parent898c74f4ded38102360624cad924ecf49af7e36f (diff)
downloadmv-c217b7141df580b686a0eef085bd0eb0a8e6771a.tar.gz
mv-c217b7141df580b686a0eef085bd0eb0a8e6771a.tar.bz2
mv-c217b7141df580b686a0eef085bd0eb0a8e6771a.tar.xz
mv-c217b7141df580b686a0eef085bd0eb0a8e6771a.zip
Add to equipment window, background image theming.
New theme file: equipment_background.xml
Diffstat (limited to 'src/gui/equipmentwindow.cpp')
-rw-r--r--src/gui/equipmentwindow.cpp44
1 files changed, 24 insertions, 20 deletions
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)
{