summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-12-01 20:29:04 +0300
committerAndrei Karas <akaras@inbox.ru>2012-12-01 22:58:18 +0300
commit96007521ba20250db0ed05e4d6117077690637db (patch)
tree8731f51b493944dd537532db568d80f3f8d8b927 /src
parentd418537e26ec75bc656518dab293ff6313998682 (diff)
downloadmanaverse-96007521ba20250db0ed05e4d6117077690637db.tar.gz
manaverse-96007521ba20250db0ed05e4d6117077690637db.tar.bz2
manaverse-96007521ba20250db0ed05e4d6117077690637db.tar.xz
manaverse-96007521ba20250db0ed05e4d6117077690637db.zip
add batch draw to equipment window.
Diffstat (limited to 'src')
-rw-r--r--src/gui/equipmentwindow.cpp49
-rw-r--r--src/gui/equipmentwindow.h1
-rw-r--r--src/gui/widgets/window.cpp7
-rw-r--r--src/gui/widgets/window.h1
4 files changed, 47 insertions, 11 deletions
diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp
index e05e1cc50..ef22dc4c5 100644
--- a/src/gui/equipmentwindow.cpp
+++ b/src/gui/equipmentwindow.cpp
@@ -23,6 +23,7 @@
#include "gui/equipmentwindow.h"
#include "being.h"
+#include "graphicsvertexes.h"
#include "inventory.h"
#include "item.h"
#include "localplayer.h"
@@ -64,6 +65,7 @@ EquipmentWindow::EquipmentWindow(Equipment *const equipment,
mHighlightColor(getThemeColor(Theme::HIGHLIGHT)),
mBorderColor(getThemeColor(Theme::BORDER)),
mLabelsColor(getThemeColor(Theme::LABEL)),
+ mVertexes(new ImageCollection),
mItemPadding(getOption("itemPadding")),
mBoxSize(getOption("boxSize")),
mMinX(180),
@@ -145,21 +147,48 @@ 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;
const int fontHeight = getFont()->getHeight();
- for (std::vector<EquipmentBox*>::const_iterator it = mBoxes.begin(),
- it_end = mBoxes.end(); it != it_end; ++ it, ++ i)
+ if (openGLMode != 2)
{
- const EquipmentBox *const box = *it;
- if (!box)
- continue;
- if (i == mSelected)
- g->drawImage(mSlotHighlightedBackground, box->x, box->y);
- else
- g->drawImage(mSlotBackground, box->x, box->y);
+ if (mLastRedraw)
+ {
+ mVertexes->clear();
+ 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;
+ if (i == mSelected)
+ {
+ g->calcTile(mVertexes, mSlotHighlightedBackground,
+ box->x, box->y);
+ }
+ else
+ {
+ g->calcTile(mVertexes, mSlotBackground, box->x, box->y);
+ }
+ }
+ }
+ g->drawTile(mVertexes);
+ }
+ else
+ {
+ 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;
+ if (i == mSelected)
+ g->drawImage(mSlotHighlightedBackground, box->x, box->y);
+ else
+ g->drawImage(mSlotBackground, box->x, box->y);
+ }
}
if (!mEquipment)
diff --git a/src/gui/equipmentwindow.h b/src/gui/equipmentwindow.h
index d79ff950f..0d4935256 100644
--- a/src/gui/equipmentwindow.h
+++ b/src/gui/equipmentwindow.h
@@ -139,6 +139,7 @@ class EquipmentWindow final : public Window, public gcn::ActionListener
gcn::Color mLabelsColor;
Image *mSlotBackground;
Image *mSlotHighlightedBackground;
+ ImageCollection *mVertexes;
int mItemPadding;
int mBoxSize;
int mButtonPadding;
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index ba6d982c8..8c1f63e29 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -54,6 +54,7 @@ Window::Window(const std::string &caption, const bool modal,
mDefaultY(0),
mDefaultWidth(0),
mDefaultHeight(0),
+ mLastRedraw(true),
mGrip(nullptr),
mParent(parent),
mLayout(nullptr),
@@ -200,6 +201,7 @@ void Window::draw(gcn::Graphics *graphics)
}
if (mRedraw)
{
+ mLastRedraw = true;
mRedraw = false;
update = true;
mVertexes->clear();
@@ -229,7 +231,10 @@ void Window::draw(gcn::Graphics *graphics)
g->calcTile(mVertexes, mGrip, mGripRect.x, mGripRect.y);
}
-
+ else
+ {
+ mLastRedraw = false;
+ }
g->drawTile(mVertexes);
}
else
diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h
index 7b05c65f6..f8ebcd598 100644
--- a/src/gui/widgets/window.h
+++ b/src/gui/widgets/window.h
@@ -433,6 +433,7 @@ class Window : public gcn::Window,
int mDefaultY; /**< Default window Y position */
int mDefaultWidth; /**< Default window width */
int mDefaultHeight; /**< Default window height */
+ bool mLastRedraw;
private:
enum ResizeHandles