diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-05-25 18:28:08 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-05-25 18:28:08 +0300 |
commit | 2f8d0391e93f723bd2d5836222aebf61b3962cdf (patch) | |
tree | c32b715e2a1bb644516627a0b429e2c8466b7f97 /src/gui | |
parent | c8b08540989f3b16973a395e9e163a225ee47055 (diff) | |
download | plus-2f8d0391e93f723bd2d5836222aebf61b3962cdf.tar.gz plus-2f8d0391e93f723bd2d5836222aebf61b3962cdf.tar.bz2 plus-2f8d0391e93f723bd2d5836222aebf61b3962cdf.tar.xz plus-2f8d0391e93f723bd2d5836222aebf61b3962cdf.zip |
Add safeDraw method into equipmentwindow.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/windows/equipmentwindow.cpp | 125 | ||||
-rw-r--r-- | src/gui/windows/equipmentwindow.h | 2 |
2 files changed, 91 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); } } diff --git a/src/gui/windows/equipmentwindow.h b/src/gui/windows/equipmentwindow.h index a8073b3c4..6ad9b2fd2 100644 --- a/src/gui/windows/equipmentwindow.h +++ b/src/gui/windows/equipmentwindow.h @@ -72,6 +72,8 @@ class EquipmentWindow final : public Window, */ void draw(Graphics *graphics) override final; + void safeDraw(Graphics *graphics) override final; + void action(const ActionEvent &event) override final; void mousePressed(MouseEvent& event) override final; |