diff options
author | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-06-22 18:58:47 +0200 |
---|---|---|
committer | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-06-22 18:58:47 +0200 |
commit | 852ff45c35c422b5264487669934b392a8657465 (patch) | |
tree | 380751fae34a7dcd7b31bd84e303b9086eb17485 /src/gui/minimap.cpp | |
parent | 2a11c6c5d874d661dcb7f016183c3c3e64e65f3c (diff) | |
parent | ec3c689c64922baf4a9f99bc6e9345e0a80403e8 (diff) | |
download | mana-client-852ff45c35c422b5264487669934b392a8657465.tar.gz mana-client-852ff45c35c422b5264487669934b392a8657465.tar.bz2 mana-client-852ff45c35c422b5264487669934b392a8657465.tar.xz mana-client-852ff45c35c422b5264487669934b392a8657465.zip |
Merge branch 'master' of gitorious.org:~bertram/mana/mana-any-square-tile-size
Diffstat (limited to 'src/gui/minimap.cpp')
-rw-r--r-- | src/gui/minimap.cpp | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index 993814ea..7ad034e4 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -43,6 +43,7 @@ bool Minimap::mShow = true; Minimap::Minimap(): Window(_("Map")), + mMap(0), mMapImage(0), mWidthProportion(0.5), mHeightProportion(0.5) @@ -96,6 +97,7 @@ void Minimap::setMap(Map *map) if (map) { + mMap = map; std::string tempname = "graphics/minimaps/" + map->getFilename() + ".png"; ResourceManager *resman = ResourceManager::getInstance(); @@ -159,14 +161,17 @@ void Minimap::draw(gcn::Graphics *graphics) int mapOriginX = 0; int mapOriginY = 0; - if (mMapImage) + if (mMapImage && mMap) { if (mMapImage->getWidth() > a.width || mMapImage->getHeight() > a.height) { const Vector &p = player_node->getPosition(); - mapOriginX = (int) (((a.width) / 2) - (int) (p.x * mWidthProportion) / 32); - mapOriginY = (int) (((a.height) / 2) - (int) (p.y * mHeightProportion) / 32); + mapOriginX = (int) (((a.width) / 2) - (int) (p.x * mWidthProportion) + / mMap->getTileWidth()); + mapOriginY = (int) (((a.height) / 2) + - (int) (p.y * mHeightProportion) + / mMap->getTileHeight()); const int minOriginX = a.width - mMapImage->getWidth(); const int minOriginY = a.height - mMapImage->getHeight(); @@ -230,10 +235,15 @@ void Minimap::draw(gcn::Graphics *graphics) const int offsetWidth = (int) ((dotSize - 1) * mWidthProportion); const Vector &pos = being->getPosition(); - graphics->fillRectangle(gcn::Rectangle( - (int) (pos.x * mWidthProportion) / 32 + mapOriginX - offsetWidth, - (int) (pos.y * mHeightProportion) / 32 + mapOriginY - offsetHeight, - dotSize, dotSize)); + if (mMap) + { + graphics->fillRectangle(gcn::Rectangle( + (int) (pos.x * mWidthProportion) / mMap->getTileWidth() + + mapOriginX - offsetWidth, + (int) (pos.y * mHeightProportion) / mMap->getTileHeight() + + mapOriginY - offsetHeight, + dotSize, dotSize)); + } } graphics->popClipArea(); |