From 332f02da85370a6a2cd5ddc53e252fe2ae3eb53b 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 bb51d64a..578e2ce6 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -74,28 +74,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) / 2) - (player_node->mX * mProportion); - mapOriginY += ((a.height) / 2) - (player_node->mY * mProportion); + mapOriginX = ((a.width) / 2) - (player_node->mX * mProportion); + mapOriginY = ((a.height) / 2) - (player_node->mY * mProportion); - 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)-> @@ -140,4 +142,6 @@ void Minimap::draw(gcn::Graphics *graphics) (int) (being->mY * mProportion) + mapOriginY - offset, dotSize, dotSize)); } + + graphics->popClipArea(); } -- cgit v1.2.3-70-g09d2