summaryrefslogtreecommitdiff
path: root/src/gui/minimap.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-01-27 12:40:28 +0300
committerAndrei Karas <akaras@inbox.ru>2013-01-27 12:42:03 +0300
commite0415e24477d07ecd90ec17667fba127deed91bd (patch)
treecac49e2bcd444d0a9d534c67d38e51a34588027a /src/gui/minimap.cpp
parent6a9729dea9113d85b7c8224ff0aa56495c80ef73 (diff)
downloadmanaplus-e0415e24477d07ecd90ec17667fba127deed91bd.tar.gz
manaplus-e0415e24477d07ecd90ec17667fba127deed91bd.tar.bz2
manaplus-e0415e24477d07ecd90ec17667fba127deed91bd.tar.xz
manaplus-e0415e24477d07ecd90ec17667fba127deed91bd.zip
Add option to autoresize minimaps.
New option: misc \ maps \ resize minimaps.
Diffstat (limited to 'src/gui/minimap.cpp')
-rw-r--r--src/gui/minimap.cpp33
1 files changed, 24 insertions, 9 deletions
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp
index b30703a7e..72772b880 100644
--- a/src/gui/minimap.cpp
+++ b/src/gui/minimap.cpp
@@ -52,10 +52,14 @@ Minimap::Minimap():
mCustomMapImage(false),
mMapOriginX(0),
mMapOriginY(0),
- mTextPopup(new TextPopup)
+ mTextPopup(new TextPopup),
+ mAutoResize(config.getBoolValue("autoresizeminimaps"))
{
setWindowName("Minimap");
mShow = config.getValueBool(getWindowName() + "Show", true);
+
+ config.addListener("autoresizeminimaps", this);
+
setDefaultSize(5, 25, 100, 100);
// set this to false as the minimap window size is changed
//depending on the map size
@@ -76,6 +80,7 @@ Minimap::Minimap():
Minimap::~Minimap()
{
config.setValue(getWindowName() + "Show", mShow);
+ config.removeListeners(this);
if (mMapImage)
{
@@ -174,12 +179,11 @@ void Minimap::setMap(const Map *const map)
if (mMapImage && map)
{
- const int offsetX = 2 * getPadding();
- const int offsetY = getTitleBarHeight() + getPadding();
- const int mapWidth = mMapImage->mBounds.w < 100 ?
- mMapImage->mBounds.w + offsetX : 100;
- const int mapHeight = mMapImage->mBounds.h < 100 ?
- mMapImage->mBounds.h + offsetY : 100;
+ const int width = mMapImage->mBounds.w + 2 * getPadding();
+ const int height = mMapImage->mBounds.h
+ + getTitleBarHeight() + getPadding();
+ const int mapWidth = mMapImage->mBounds.w < 100 ? width : 100;
+ const int mapHeight = mMapImage->mBounds.h < 100 ? height : 100;
setMinWidth(mapWidth);
setMinHeight(mapHeight);
@@ -189,8 +193,13 @@ void Minimap::setMap(const Map *const map)
mHeightProportion = static_cast<float>(
mMapImage->mBounds.h) / static_cast<float>(map->getHeight());
- setMaxWidth(mMapImage->mBounds.w + offsetX);
- setMaxHeight(mMapImage->mBounds.h + offsetY);
+ setMaxWidth(width);
+ setMaxHeight(height);
+ if (mAutoResize)
+ {
+ setWidth(width);
+ setHeight(height);
+ }
setDefaultSize(getX(), getY(), getWidth(), getHeight());
resetToDefaultSize();
@@ -455,3 +464,9 @@ void Minimap::screenToMap(int &x, int &y)
x = (x - a.x - mMapOriginX + mWidthProportion) / mWidthProportion;
y = (y - a.y - mMapOriginY + mHeightProportion) / mHeightProportion;
}
+
+void Minimap::optionChanged(const std::string &name)
+{
+ if (name == "autoresizeminimaps")
+ mAutoResize = config.getBoolValue("autoresizeminimaps");
+}