From 943166059f5e0b7403b00f5d5fc19bd72c706657 Mon Sep 17 00:00:00 2001 From: Blue Sans Douze Date: Sat, 23 Jan 2010 17:31:21 +0100 Subject: Autoload a minimap is no minimap info is given Looks for "graphics/minimap/MAPID.png" --- src/gui/minimap.cpp | 11 ++++++++++- src/map.cpp | 12 ++++++++++++ src/map.h | 5 +++++ 3 files changed, 27 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index b8f8ef57..539bfbaa 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -78,6 +78,7 @@ void Minimap::setMap(Map *map) { // Set the title for the Minimap std::string caption = ""; + std::string minimapName; if (map) caption = map->getName(); @@ -96,8 +97,16 @@ void Minimap::setMap(Map *map) if (map) { + std::string tempname = "graphics/minimaps/"+(*map->getMapId())+".png"; + ResourceManager *resman = ResourceManager::getInstance(); - mMapImage = resman->getImage(map->getProperty("minimap")); + minimapName = map->getProperty("minimap"); + if (minimapName.empty() && resman->exists(tempname)) + { + minimapName = tempname; + } + std::cout << "Minimap name : " << minimapName << std::endl; + mMapImage = resman->getImage(minimapName); } if (mMapImage) diff --git a/src/map.cpp b/src/map.cpp index 34064a64..5f411c47 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -583,6 +583,18 @@ const std::string &Map::getName() const return getProperty("mapname"); } +const std::string *Map::getMapId() const +{ + std::string fileName = getProperty("_filename"); + int lastSlash = fileName.rfind("/") + 1; + int lastDot = fileName.rfind("."); + + std::string *sub = new std::string( + fileName.substr(lastSlash, lastDot - lastSlash)); + + return sub; +} + static int const basicCost = 100; Path Map::findPath(int startX, int startY, int destX, int destY, diff --git a/src/map.h b/src/map.h index 9914b50f..82b9e842 100644 --- a/src/map.h +++ b/src/map.h @@ -266,6 +266,11 @@ class Map : public Properties const std::string &getMusicFile() const; const std::string &getName() const; + /** + * Gives the map id based on filepath (ex: 009-1) + */ + const std::string *getMapId() const; + /** * Find a path from one location to the next. */ -- cgit v1.2.3-60-g2f50