summaryrefslogtreecommitdiff
path: root/src/gui/minimap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/minimap.cpp')
-rw-r--r--src/gui/minimap.cpp88
1 files changed, 14 insertions, 74 deletions
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp
index 59e385c4..cd00a5af 100644
--- a/src/gui/minimap.cpp
+++ b/src/gui/minimap.cpp
@@ -39,55 +39,23 @@
#include <guichan/font.hpp>
-bool Minimap::mShow = true;
-
Minimap::Minimap():
- Window(_("Map")),
mMap(0),
mMapImage(0),
mWidthProportion(0.5),
mHeightProportion(0.5)
{
- setWindowName("Minimap");
- mShow = config.getValue(getWindowName() + "Show", true);
- setDefaultSize(5, 25, 100, 100);
- // set this to false as the minimap window size is changed
- //depending on the map size
- setResizable(false);
- setupWindow->registerWindowForReset(this);
-
- setDefaultVisible(true);
- setSaveVisible(true);
-
- setStickyButton(true);
- setSticky(false);
-
- loadWindowState();
- setVisible(mShow, isSticky());
+ setSize(100, 100);
}
Minimap::~Minimap()
{
- config.setValue(getWindowName() + "Show", mShow);
-
if (mMapImage)
mMapImage->decRef();
}
void Minimap::setMap(Map *map)
{
- // Set the title for the Minimap
- std::string caption = "";
- std::string minimapName;
-
- if (map)
- caption = map->getName();
-
- if (caption.empty())
- caption = _("Map");
-
- minimap->setCaption(caption);
-
// Adapt the image
if (mMapImage)
{
@@ -102,7 +70,7 @@ void Minimap::setMap(Map *map)
"graphics/minimaps/" + map->getFilename() + ".png";
ResourceManager *resman = ResourceManager::getInstance();
- minimapName = map->getProperty("minimap");
+ std::string minimapName = map->getProperty("minimap");
if (minimapName.empty() && resman->exists(tempname))
minimapName = tempname;
@@ -113,68 +81,40 @@ void Minimap::setMap(Map *map)
if (mMapImage)
{
- const int offsetX = 2 * getPadding();
- const int offsetY = getTitleBarHeight() + getPadding();
- const int titleWidth = getFont()->getWidth(getCaption()) + 15;
- const int mapWidth = mMapImage->getWidth() < 100 ?
- mMapImage->getWidth() + offsetX : 100;
- const int mapHeight = mMapImage->getHeight() < 100 ?
- mMapImage->getHeight() + offsetY : 100;
-
- setMinWidth(mapWidth > titleWidth ? mapWidth : titleWidth);
- setMinHeight(mapHeight);
-
mWidthProportion = (float) mMapImage->getWidth() / map->getWidth();
mHeightProportion = (float) mMapImage->getHeight() / map->getHeight();
- setMaxWidth(mMapImage->getWidth() > titleWidth ?
- mMapImage->getWidth() + offsetX : titleWidth);
- setMaxHeight(mMapImage->getHeight() + offsetY);
-
- setDefaultSize(getX(), getY(), getWidth(), getHeight());
- resetToDefaultSize();
-
- if (mShow)
- setVisible(true);
+ setVisible(true);
}
else
{
- if (!isSticky())
- setVisible(false);
+ setVisible(true);
}
}
-void Minimap::toggle()
-{
- setVisible(!isVisible(), isSticky());
- mShow = isVisible();
-}
-
void Minimap::draw(gcn::Graphics *graphics)
{
- Window::draw(graphics);
-
- const gcn::Rectangle a = getChildrenArea();
-
- graphics->pushClipArea(a);
+ const int width = getWidth();
+ const int height = getHeight();
+ graphics->pushClipArea(gcn::Rectangle(0, 0, width, height));
int mapOriginX = 0;
int mapOriginY = 0;
if (mMapImage && mMap)
{
- if (mMapImage->getWidth() > a.width ||
- mMapImage->getHeight() > a.height)
+
+ if (mMapImage->getWidth() > width ||
+ mMapImage->getHeight() > height)
{
const Vector &p = local_player->getPosition();
- mapOriginX = (int) (((a.width) / 2) - (int) (p.x * mWidthProportion)
+ mapOriginX = (int) ((width / 2) - (int) (p.x * mWidthProportion)
/ mMap->getTileWidth());
- mapOriginY = (int) (((a.height) / 2)
- - (int) (p.y * mHeightProportion)
+ mapOriginY = (int) ((height / 2) - (int) (p.y * mHeightProportion)
/ mMap->getTileHeight());
- const int minOriginX = a.width - mMapImage->getWidth();
- const int minOriginY = a.height - mMapImage->getHeight();
+ const int minOriginX = width - mMapImage->getWidth();
+ const int minOriginY = height - mMapImage->getHeight();
if (mapOriginX < minOriginX)
mapOriginX = minOriginX;