summaryrefslogtreecommitdiff
path: root/src/gui/windows/equipmentwindow.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-05-25 18:28:08 +0300
committerAndrei Karas <akaras@inbox.ru>2015-05-25 18:28:08 +0300
commit2f8d0391e93f723bd2d5836222aebf61b3962cdf (patch)
treec32b715e2a1bb644516627a0b429e2c8466b7f97 /src/gui/windows/equipmentwindow.cpp
parentc8b08540989f3b16973a395e9e163a225ee47055 (diff)
downloadmv-2f8d0391e93f723bd2d5836222aebf61b3962cdf.tar.gz
mv-2f8d0391e93f723bd2d5836222aebf61b3962cdf.tar.bz2
mv-2f8d0391e93f723bd2d5836222aebf61b3962cdf.tar.xz
mv-2f8d0391e93f723bd2d5836222aebf61b3962cdf.zip
Add safeDraw method into equipmentwindow.
Diffstat (limited to 'src/gui/windows/equipmentwindow.cpp')
-rw-r--r--src/gui/windows/equipmentwindow.cpp125
1 files changed, 89 insertions, 36 deletions
diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp
index 8da2e3071..c856433ba 100644
--- a/src/gui/windows/equipmentwindow.cpp
+++ b/src/gui/windows/equipmentwindow.cpp
@@ -187,54 +187,107 @@ void EquipmentWindow::draw(Graphics *graphics)
const int fontHeight = font->getHeight();
const std::vector<EquipmentBox*> &boxes = mPages[mSelectedTab]->boxes;
- if (isBatchDrawRenders(openGLMode))
+ if (mLastRedraw)
{
- if (mLastRedraw)
- {
- mVertexes->clear();
- FOR_EACH (std::vector<EquipmentBox*>::const_iterator, it, boxes)
- {
- const EquipmentBox *const box = *it;
- if (!box)
- {
- i ++;
- continue;
- }
- if (i == mSelected)
- {
- graphics->calcTileCollection(mVertexes,
- mSlotHighlightedBackground,
- box->x, box->y);
- }
- else
- {
- graphics->calcTileCollection(mVertexes,
- mSlotBackground,
- box->x, box->y);
- }
- i ++;
- }
- graphics->finalize(mVertexes);
- }
- graphics->drawTileCollection(mVertexes);
- }
- else
- {
- for (std::vector<EquipmentBox*>::const_iterator it = boxes.begin(),
- it_end = boxes.end(); it != it_end; ++ it, ++ i)
+ mVertexes->clear();
+ FOR_EACH (std::vector<EquipmentBox*>::const_iterator, it, boxes)
{
const EquipmentBox *const box = *it;
if (!box)
+ {
+ i ++;
continue;
+ }
if (i == mSelected)
{
- graphics->drawImage(mSlotHighlightedBackground,
+ graphics->calcTileCollection(mVertexes,
+ mSlotHighlightedBackground,
box->x, box->y);
}
else
{
- graphics->drawImage(mSlotBackground, box->x, box->y);
+ graphics->calcTileCollection(mVertexes,
+ mSlotBackground,
+ box->x, box->y);
}
+ i ++;
+ }
+ graphics->finalize(mVertexes);
+ }
+ graphics->drawTileCollection(mVertexes);
+
+ if (!mEquipment)
+ {
+ BLOCK_END("EquipmentWindow::draw")
+ return;
+ }
+
+ i = 0;
+ const int projSlot = inventoryHandler->getProjectileSlot();
+ for (std::vector<EquipmentBox*>::const_iterator it = boxes.begin(),
+ it_end = boxes.end(); it != it_end; ++ it, ++ i)
+ {
+ const EquipmentBox *const box = *it;
+ if (!box)
+ continue;
+ const Item *const item = mEquipment->getEquipment(i);
+ if (item)
+ {
+ // Draw Item.
+ Image *const image = item->getImage();
+ if (image)
+ {
+ image->setAlpha(1.0F); // Ensure the image is drawn
+ // with maximum opacity
+ graphics->drawImage(image, box->x + mItemPadding,
+ box->y + mItemPadding);
+ if (i == projSlot)
+ {
+ const std::string str = toString(item->getQuantity());
+ font->drawString(graphics,
+ mLabelsColor,
+ mLabelsColor2,
+ str,
+ box->x + (mBoxSize - font->getWidth(str)) / 2,
+ box->y - fontHeight);
+ }
+ }
+ }
+ else if (box->image)
+ {
+ graphics->drawImage(box->image,
+ box->x + mItemPadding,
+ box->y + mItemPadding);
+ }
+ }
+ BLOCK_END("EquipmentWindow::draw")
+}
+
+void EquipmentWindow::safeDraw(Graphics *graphics)
+{
+ BLOCK_START("EquipmentWindow::draw")
+ // Draw window graphics
+ Window::draw(graphics);
+
+ int i = 0;
+ Font *const font = getFont();
+ const int fontHeight = font->getHeight();
+ const std::vector<EquipmentBox*> &boxes = mPages[mSelectedTab]->boxes;
+
+ for (std::vector<EquipmentBox*>::const_iterator it = boxes.begin(),
+ it_end = boxes.end(); it != it_end; ++ it, ++ i)
+ {
+ const EquipmentBox *const box = *it;
+ if (!box)
+ continue;
+ if (i == mSelected)
+ {
+ graphics->drawImage(mSlotHighlightedBackground,
+ box->x, box->y);
+ }
+ else
+ {
+ graphics->drawImage(mSlotBackground, box->x, box->y);
}
}