diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/engine.cpp | 6 | ||||
-rw-r--r-- | src/gui/minimap.cpp | 15 | ||||
-rw-r--r-- | src/gui/minimap.h | 6 |
3 files changed, 22 insertions, 5 deletions
diff --git a/src/engine.cpp b/src/engine.cpp index 42054ffb..e4361f96 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -107,6 +107,12 @@ void Engine::changeMap(const std::string &mapPath) minimap->setCaption("Unknown"); logger->log("WARNING: Map file '%s' defines a minimap image but does not define a 'mapname' property", map_path.c_str()); } + // How many pixels equal one tile. .5 (which is the TMW default) is 2 tiles to a pixel, + // while 1 is 1 tile to 1 pixel + if (newMap->hasProperty("minimapproportion")) + { + minimap->setProportion(atof(newMap->getProperty("minimapproportion").c_str())); + } } minimap->setMapImage(mapImage); beingManager->setMap(newMap); diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index 9f4df73c..1f3a903c 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -32,7 +32,8 @@ Minimap::Minimap(): Window("Map"), - mMapImage(NULL) + mMapImage(NULL), + mProportion(0.5) { setWindowName("MiniMap"); } @@ -57,9 +58,13 @@ void Minimap::setMapImage(Image *img) if (mMapImage) { mMapImage->setAlpha(0.7); - setDefaultSize(5, 25, img->getWidth(), img->getHeight()); + setDefaultSize(5, 25, mMapImage->getWidth(), mMapImage->getHeight()); loadWindowState(); } + else + { + setVisible(false); + } } void Minimap::draw(gcn::Graphics *graphics) @@ -103,11 +108,11 @@ void Minimap::draw(gcn::Graphics *graphics) continue; } - int offset = (dotSize - 1); + int offset = (dotSize - 1) * mProportion; graphics->fillRectangle(gcn::Rectangle( - being->mX + getPadding() - offset, - being->mY + getTitleBarHeight() - offset, + (being->mX * mProportion) + getPadding() - offset, + (being->mY * mProportion) + getTitleBarHeight() - offset, dotSize, dotSize)); } } diff --git a/src/gui/minimap.h b/src/gui/minimap.h index 0ec13e67..a3b14729 100644 --- a/src/gui/minimap.h +++ b/src/gui/minimap.h @@ -54,12 +54,18 @@ class Minimap : public Window void setMapImage(Image *img); /** + * Sets the map proportion (1 means 1 tile to one pixel, .5 means 2 tiles to 1 pixel, etc.) + */ + void setProportion(float proportion) { mProportion = proportion; } + + /** * Draws the minimap. */ void draw(gcn::Graphics *graphics); private: Image *mMapImage; + float mProportion; }; extern Minimap *minimap; |