From 914d3de7c324cb1ec456892702689718352a7842 Mon Sep 17 00:00:00 2001 From: Yohann Ferreira Date: Fri, 17 Jun 2011 16:46:06 +0200 Subject: First pass on removing tile hard coded values. Every files has been checked against the hard coded 32 values except the map.cpp file. I also added convenience functions in the Game class, centralized the default item icon size, and removed two unused defines in being.cpp. --- src/gui/minimap.cpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'src/gui/minimap.cpp') 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(); -- cgit v1.2.3-70-g09d2