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.cpp32
1 files changed, 24 insertions, 8 deletions
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp
index f07cb417..8339e478 100644
--- a/src/gui/minimap.cpp
+++ b/src/gui/minimap.cpp
@@ -30,11 +30,11 @@
Minimap::Minimap():
Window("Map"),
- mMapImage(NULL)
+ mMapImage(NULL),
+ mProportion(0.5)
{
+ setCloseButton(true);
setWindowName("MiniMap");
- setDefaultSize(5, 25, 100, 100);
- loadWindowState();
}
Minimap::~Minimap()
@@ -51,7 +51,21 @@ void Minimap::setMapImage(Image *img)
mMapImage = img;
if (mMapImage)
+ {
+ int offsetX = getPadding();
+ int offsetY = getTitleBarHeight();
mMapImage->setAlpha(0.7);
+ setDefaultSize(offsetX, offsetY,
+ mMapImage->getWidth() < (100 + offsetX) ?
+ mMapImage->getWidth() : (100 + offsetX),
+ mMapImage->getHeight() < (100 + offsetY) ?
+ mMapImage->getHeight() : (100 + offsetY));
+ loadWindowState();
+ }
+ else
+ {
+ setVisible(false);
+ }
}
void Minimap::draw(gcn::Graphics *graphics)
@@ -68,9 +82,10 @@ void Minimap::draw(gcn::Graphics *graphics)
if (mMapImage->getWidth() > a.width ||
mMapImage->getHeight() > a.height)
{
- mapOriginX += (a.width - player_node->mX) / 2;
- mapOriginY += (a.height - player_node->mY) / 2;
+ mapOriginX += ((a.width) / 2) - (player_node->mX * mProportion);
+ mapOriginY += ((a.height) / 2) - (player_node->mY * mProportion);
}
+
static_cast<Graphics*>(graphics)->
drawImage(mMapImage, mapOriginX, mapOriginY);
}
@@ -106,10 +121,11 @@ void Minimap::draw(gcn::Graphics *graphics)
continue;
}
- const int offset = (dotSize - 1) / 2;
+ const int offset = (int) ((dotSize - 1) * mProportion);
+
graphics->fillRectangle(gcn::Rectangle(
- being->mX / 2 + mapOriginX - offset,
- being->mY / 2 + mapOriginY - offset,
+ (int) (being->mX * mProportion) + mapOriginX - offset,
+ (int) (being->mY * mProportion) + mapOriginY - offset,
dotSize, dotSize));
}
}