diff options
author | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-06-17 16:46:06 +0200 |
---|---|---|
committer | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-06-17 16:46:06 +0200 |
commit | 914d3de7c324cb1ec456892702689718352a7842 (patch) | |
tree | eb05c251adb6f012a40f3d7de4eb42ab854b7d94 /src/gui/minimap.cpp | |
parent | faf0a45d6b8b85acd2836cf5e8e7f7c5b161931d (diff) | |
download | mana-914d3de7c324cb1ec456892702689718352a7842.tar.gz mana-914d3de7c324cb1ec456892702689718352a7842.tar.bz2 mana-914d3de7c324cb1ec456892702689718352a7842.tar.xz mana-914d3de7c324cb1ec456892702689718352a7842.zip |
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.
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(); |