From 224fc155978ebbce35ee42560edab628121d7d2e Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Mon, 8 Dec 2008 13:56:04 +0100 Subject: Don't scroll past the edges of the minimap When centering the minimap on the player, it would often happen that the minimap scrolled past its edge. Based on a patch by QOAL. --- src/gui/minimap.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/gui/minimap.cpp') diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index 8339e478..bb51d64a 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -84,6 +84,18 @@ void Minimap::draw(gcn::Graphics *graphics) { 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(); + + if (mapOriginX < minOriginX) + mapOriginX = minOriginX; + if (mapOriginY < minOriginY) + mapOriginY = minOriginY; + if (mapOriginX > a.x) + mapOriginX = a.x; + if (mapOriginY > a.y) + mapOriginY = a.y; } static_cast(graphics)-> -- cgit v1.2.3-70-g09d2