diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2008-12-08 13:56:04 +0100 |
---|---|---|
committer | Ira Rice <irarice@gmail.com> | 2008-12-08 09:43:13 -0700 |
commit | 224fc155978ebbce35ee42560edab628121d7d2e (patch) | |
tree | 53c82dc985ee0f3e65194dfe42819972e60e3e6d | |
parent | 16d8375be2074e21ec3681c5d9b4f984e1db5687 (diff) | |
download | mana-224fc155978ebbce35ee42560edab628121d7d2e.tar.gz mana-224fc155978ebbce35ee42560edab628121d7d2e.tar.bz2 mana-224fc155978ebbce35ee42560edab628121d7d2e.tar.xz mana-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.
-rw-r--r-- | src/gui/minimap.cpp | 12 |
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)-> |