summaryrefslogtreecommitdiff
path: root/src
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
parent6a9729dea9113d85b7c8224ff0aa56495c80ef73 (diff)
downloadplus-e0415e24477d07ecd90ec17667fba127deed91bd.tar.gz
plus-e0415e24477d07ecd90ec17667fba127deed91bd.tar.bz2
plus-e0415e24477d07ecd90ec17667fba127deed91bd.tar.xz
plus-e0415e24477d07ecd90ec17667fba127deed91bd.zip
Add option to autoresize minimaps.
New option: misc \ maps \ resize minimaps.
Diffstat (limited to 'src')
-rw-r--r--src/defaults.cpp1
-rw-r--r--src/gui/minimap.cpp33
-rw-r--r--src/gui/minimap.h5
-rw-r--r--src/gui/setup_other.cpp3
4 files changed, 32 insertions, 10 deletions
diff --git a/src/defaults.cpp b/src/defaults.cpp
index 4fb00525f..f482a4cef 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -304,6 +304,7 @@ DefaultsData* getConfigDefaults()
AddDEF("screenActionButton2", Input::KEY_PICKUP);
AddDEF("screenActionButton3", Input::KEY_PATHFIND);
AddDEF("screenButtonsFormat", 0);
+ AddDEF("autoresizeminimaps", false);
return configData;
}
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");
+}
diff --git a/src/gui/minimap.h b/src/gui/minimap.h
index 2fe1458ab..6efe8a786 100644
--- a/src/gui/minimap.h
+++ b/src/gui/minimap.h
@@ -38,7 +38,7 @@ class TextPopup;
*
* \ingroup Interface
*/
-class Minimap final : public Window
+class Minimap final : public Window, public ConfigListener
{
public:
Minimap();
@@ -70,6 +70,8 @@ class Minimap final : public Window
void screenToMap(int &x, int &y);
+ void optionChanged(const std::string &name);
+
private:
Image *mMapImage;
float mWidthProportion;
@@ -79,6 +81,7 @@ class Minimap final : public Window
int mMapOriginX;
int mMapOriginY;
TextPopup *mTextPopup;
+ bool mAutoResize;
};
extern Minimap *minimap;
diff --git a/src/gui/setup_other.cpp b/src/gui/setup_other.cpp
index ce0464055..965382f71 100644
--- a/src/gui/setup_other.cpp
+++ b/src/gui/setup_other.cpp
@@ -120,6 +120,9 @@ Setup_Other::Setup_Other(const Widget2 *const widget) :
new SetupItemIntTextField(_("Scroll radius"), "", "ScrollRadius",
this, "ScrollRadiusEvent", 0, 32);
+ new SetupItemCheckBox(_("Auto resize minimaps"), "", "autoresizeminimaps",
+ this, "autoresizeminimapsEvent");
+
new SetupItemLabel(_("Moving"), "", this);