summaryrefslogtreecommitdiff
path: root/src/gui/minimap.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-02-08 20:28:31 +0200
committerAndrei Karas <akaras@inbox.ru>2011-02-08 20:40:26 +0200
commite45cefb6b073447c10145b65b59f30af440ce77c (patch)
tree504a1cd3215c02fdf21345e90a695790126f1d32 /src/gui/minimap.cpp
parent5f59d91bf515f02f65e8883b310d89e518b4ea80 (diff)
downloadmanaplus-e45cefb6b073447c10145b65b59f30af440ce77c.tar.gz
manaplus-e45cefb6b073447c10145b65b59f30af440ce77c.tar.bz2
manaplus-e45cefb6b073447c10145b65b59f30af440ce77c.tar.xz
manaplus-e45cefb6b073447c10145b65b59f30af440ce77c.zip
Fixing code style and adding configuration option for extented minimaps.
Diffstat (limited to 'src/gui/minimap.cpp')
-rw-r--r--src/gui/minimap.cpp63
1 files changed, 42 insertions, 21 deletions
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp
index 9efacdce6..1dd9ba54e 100644
--- a/src/gui/minimap.cpp
+++ b/src/gui/minimap.cpp
@@ -94,31 +94,52 @@ void Minimap::setMap(Map *map)
mMapImage = 0;
}
- if (true/* TODO replace this with an option*/) {
- // should this optionally happen only if there is no resourcemanager option? i.e. a tristate always, fallback, never?
- SDL_Surface* surface = SDL_CreateRGBSurface(SDL_SWSURFACE, map->getWidth(), map->getHeight(), 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000);
- // I'm not sure if the locks are necessary since it's a SWSURFACE
- SDL_LockSurface(surface);
- int* data = (int*)surface->pixels;
- for (int y = 0; y < surface->h; y++)
- for (int x = 0; x < surface->w; x++)
- *(data++) = -map->getWalk(x,y);
- SDL_UnlockSurface(surface);
- mMapImage = Image::load(surface);
- SDL_FreeSurface(surface);
- }
- else if (map)
+ if (map)
{
- std::string tempname =
- "graphics/minimaps/" + map->getFilename() + ".png";
- ResourceManager *resman = ResourceManager::getInstance();
+ if (config.getBoolValue("showExtMinimaps"))
+ {
+ SDL_Surface* surface = SDL_CreateRGBSurface(SDL_SWSURFACE,
+ map->getWidth(), map->getHeight(), 32,
+ 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000);
+ if (!surface)
+ {
+ if (!isSticky())
+ setVisible(false);
+ return;
+ }
+
+ // I'm not sure if the locks are necessary since it's a SWSURFACE
+ SDL_LockSurface(surface);
+ int* data = (int*)surface->pixels;
+ if (!data)
+ {
+ if (!isSticky())
+ setVisible(false);
+ return;
+ }
+ for (int y = 0; y < surface->h; y ++)
+ {
+ for (int x = 0; x < surface->w; x ++)
+ *(data ++) = -map->getWalk(x,y);
+ }
+ SDL_UnlockSurface(surface);
- minimapName = map->getProperty("minimap");
+ mMapImage = Image::load(surface);
+ SDL_FreeSurface(surface);
+ }
+ else
+ {
+ std::string tempname =
+ "graphics/minimaps/" + map->getFilename() + ".png";
+ ResourceManager *resman = ResourceManager::getInstance();
+
+ minimapName = map->getProperty("minimap");
- if (minimapName.empty() && resman->exists(tempname))
- minimapName = tempname;
+ if (minimapName.empty() && resman->exists(tempname))
+ minimapName = tempname;
- mMapImage = resman->getImage(minimapName);
+ mMapImage = resman->getImage(minimapName);
+ }
}
if (mMapImage && map)