summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2008-12-08 14:13:32 +0100
committerBjørn Lindeijer <bjorn@lindeijer.nl>2008-12-08 14:13:32 +0100
commitd129ce9776a6fd0e165b676a3addd14186c5d85d (patch)
tree7ed10e82b3e0aa81e0f5543e3956cdcf14c28855 /src
parent47d3d648907ef22ee1a3493ac403b5e9ca8281b3 (diff)
downloadmana-d129ce9776a6fd0e165b676a3addd14186c5d85d.tar.gz
mana-d129ce9776a6fd0e165b676a3addd14186c5d85d.tar.bz2
mana-d129ce9776a6fd0e165b676a3addd14186c5d85d.tar.xz
mana-d129ce9776a6fd0e165b676a3addd14186c5d85d.zip
Clip the minimap image to within its window
The image wasn't clipped so it would draw beneath the map name and on top of the window border.
Diffstat (limited to 'src')
-rw-r--r--src/gui/minimap.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp
index c9bfe673..231c749f 100644
--- a/src/gui/minimap.cpp
+++ b/src/gui/minimap.cpp
@@ -60,28 +60,30 @@ void Minimap::draw(gcn::Graphics *graphics)
const gcn::Rectangle a = getChildrenArea();
- int mapOriginX = a.x;
- int mapOriginY = a.y;
+ graphics->pushClipArea(a);
+
+ int mapOriginX = 0;
+ int mapOriginY = 0;
if (mMapImage)
{
if (mMapImage->getWidth() > a.width ||
mMapImage->getHeight() > a.height)
{
- mapOriginX += (a.width - player_node->mX) / 2;
- mapOriginY += (a.height - player_node->mY) / 2;
+ mapOriginX = (a.width - player_node->mX) / 2;
+ mapOriginY = (a.height - player_node->mY) / 2;
- const int minOriginX = a.x + a.width - mMapImage->getWidth();
- const int minOriginY = a.y + a.height - mMapImage->getHeight();
+ const int minOriginX = a.width - mMapImage->getWidth();
+ const int minOriginY = a.height - mMapImage->getHeight();
if (mapOriginX < minOriginX)
mapOriginX = minOriginX;
if (mapOriginY < minOriginY)
mapOriginY = minOriginY;
- if (mapOriginX > a.x)
- mapOriginX = a.x;
- if (mapOriginY > a.y)
- mapOriginY = a.y;
+ if (mapOriginX > 0)
+ mapOriginX = 0;
+ if (mapOriginY > 0)
+ mapOriginY = 0;
}
static_cast<Graphics*>(graphics)->
drawImage(mMapImage, mapOriginX, mapOriginY);
@@ -124,4 +126,6 @@ void Minimap::draw(gcn::Graphics *graphics)
being->mY / 2 + mapOriginY - offset,
dotSize, dotSize));
}
+
+ graphics->popClipArea();
}