summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2008-12-08 13:56:04 +0100
committerBjørn Lindeijer <bjorn@lindeijer.nl>2008-12-08 13:56:04 +0100
commit47d3d648907ef22ee1a3493ac403b5e9ca8281b3 (patch)
tree3ee109c623c8d9bb27b31931bc32f89f6bce2020 /src/gui
parente5671f8bdc30ac567a535f698c8dcaedd4441340 (diff)
downloadmana-47d3d648907ef22ee1a3493ac403b5e9ca8281b3.tar.gz
mana-47d3d648907ef22ee1a3493ac403b5e9ca8281b3.tar.bz2
mana-47d3d648907ef22ee1a3493ac403b5e9ca8281b3.tar.xz
mana-47d3d648907ef22ee1a3493ac403b5e9ca8281b3.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')
-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 f07cb417..c9bfe673 100644
--- a/src/gui/minimap.cpp
+++ b/src/gui/minimap.cpp
@@ -70,6 +70,18 @@ void Minimap::draw(gcn::Graphics *graphics)
{
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();
+
+ 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)->
drawImage(mMapImage, mapOriginX, mapOriginY);