From d129ce9776a6fd0e165b676a3addd14186c5d85d Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Mon, 8 Dec 2008 14:13:32 +0100 Subject: 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. --- src/gui/minimap.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'src') 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)-> drawImage(mMapImage, mapOriginX, mapOriginY); @@ -124,4 +126,6 @@ void Minimap::draw(gcn::Graphics *graphics) being->mY / 2 + mapOriginY - offset, dotSize, dotSize)); } + + graphics->popClipArea(); } -- cgit v1.2.3-70-g09d2