summaryrefslogtreecommitdiff
path: root/src/gui/minimap.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2008-12-08 13:56:04 +0100
committerIra Rice <irarice@gmail.com>2008-12-08 09:43:13 -0700
commit224fc155978ebbce35ee42560edab628121d7d2e (patch)
tree53c82dc985ee0f3e65194dfe42819972e60e3e6d /src/gui/minimap.cpp
parent16d8375be2074e21ec3681c5d9b4f984e1db5687 (diff)
downloadmana-client-224fc155978ebbce35ee42560edab628121d7d2e.tar.gz
mana-client-224fc155978ebbce35ee42560edab628121d7d2e.tar.bz2
mana-client-224fc155978ebbce35ee42560edab628121d7d2e.tar.xz
mana-client-224fc155978ebbce35ee42560edab628121d7d2e.zip
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.
Diffstat (limited to 'src/gui/minimap.cpp')
-rw-r--r--src/gui/minimap.cpp12
1 files changed, 12 insertions, 0 deletions
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*>(graphics)->