summaryrefslogtreecommitdiff
path: root/src/gui/minimap.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2009-04-26 22:28:40 +0200
committerBjørn Lindeijer <bjorn@lindeijer.nl>2009-04-26 22:42:26 +0200
commit739e1ef748cf61935d3d15ef5319576f81d3a615 (patch)
tree925274893a87ad73d6e934ba7c3b07eed3c6a5ab /src/gui/minimap.cpp
parent9e5bdec034d81a9afec170988ea0a6d0a40e9e77 (diff)
downloadmana-739e1ef748cf61935d3d15ef5319576f81d3a615.tar.gz
mana-739e1ef748cf61935d3d15ef5319576f81d3a615.tar.bz2
mana-739e1ef748cf61935d3d15ef5319576f81d3a615.tar.xz
mana-739e1ef748cf61935d3d15ef5319576f81d3a615.zip
Moved minimap title setting into the Minimap class
Also cleaned up some debug log statements, fixed initialization order, removed an unused member variable and added some documentation.
Diffstat (limited to 'src/gui/minimap.cpp')
-rw-r--r--src/gui/minimap.cpp36
1 files changed, 21 insertions, 15 deletions
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp
index 019ffe6b..174151c6 100644
--- a/src/gui/minimap.cpp
+++ b/src/gui/minimap.cpp
@@ -39,10 +39,10 @@
bool Minimap::mShow = true;
Minimap::Minimap():
- Window(_("MiniMap")),
- mMapImage(NULL),
- mHeightProportion(0.5),
- mWidthProportion(0.5)
+ Window(_("Map")),
+ mMapImage(0),
+ mWidthProportion(0.5),
+ mHeightProportion(0.5)
{
setWindowName("MiniMap");
mShow = config.getValue(getWindowName() + "Show", true);
@@ -55,8 +55,6 @@ Minimap::Minimap():
setSticky(false);
loadWindowState();
-
- //Debug
}
Minimap::~Minimap()
@@ -69,13 +67,24 @@ Minimap::~Minimap()
void Minimap::setMap(Map *map)
{
+ // Set the title for the Minimap
+ std::string caption;
+
+ if (map->hasProperty("name"))
+ caption = map->getProperty("name");
+ else if (map->hasProperty("mapname"))
+ caption = map->getProperty("mapname");
+ else
+ caption = _("Map");
+
+ minimap->setCaption(caption);
+
+ // Adapt the image
if (mMapImage)
mMapImage->decRef();
- mMap = map;
-
ResourceManager *resman = ResourceManager::getInstance();
- mMapImage = resman->getImage(mMap->getProperty("minimap"));
+ mMapImage = resman->getImage(map->getProperty("minimap"));
if (mMapImage)
{
@@ -90,12 +99,9 @@ void Minimap::setMap(Map *map)
setMinWidth(mapWidth > titleWidth ? mapWidth : titleWidth);
setMinHeight(mapHeight);
- mWidthProportion = (float) mMapImage->getWidth() / (float) mMap->getWidth();
- mHeightProportion = (float) mMapImage->getHeight() / (float) mMap->getHeight();
-
- logger->log("Minimap width : %d ; %d ; %f", mMapImage->getWidth(), mMap->getWidth(), mWidthProportion);
- logger->log("Minimap height : %d ; %d ; %f", mMapImage->getHeight(), mMap->getHeight(), mHeightProportion);
-
+ mWidthProportion = (float) mMapImage->getWidth() / map->getWidth();
+ mHeightProportion = (float) mMapImage->getHeight() / map->getHeight();
+
setMaxWidth(mMapImage->getWidth() > titleWidth ?
mMapImage->getWidth() + offsetX : titleWidth);
setMaxHeight(mMapImage->getHeight() + offsetY);