summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2008-12-13 16:33:04 +0100
committerBjørn Lindeijer <bjorn@lindeijer.nl>2008-12-13 16:34:01 +0100
commit291a1d63d407a46d3ad9152bbddc6e3d9a93b413 (patch)
treee8bf26cc0a66945248ba7f6d56c9d0a5bb302a03 /src
parentbc7ce889e154a121fdbd0a8126c35194ee3a7b52 (diff)
downloadmana-291a1d63d407a46d3ad9152bbddc6e3d9a93b413.tar.gz
mana-291a1d63d407a46d3ad9152bbddc6e3d9a93b413.tar.bz2
mana-291a1d63d407a46d3ad9152bbddc6e3d9a93b413.tar.xz
mana-291a1d63d407a46d3ad9152bbddc6e3d9a93b413.zip
Center large minimaps on player
Based on a patch by QOAL. (cherry picked from eAthena client) Conflicts: src/gui/minimap.cpp
Diffstat (limited to 'src')
-rw-r--r--src/gui/minimap.cpp41
1 files changed, 21 insertions, 20 deletions
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp
index 501530f1..02d20d8e 100644
--- a/src/gui/minimap.cpp
+++ b/src/gui/minimap.cpp
@@ -44,49 +44,50 @@ Minimap::Minimap():
Minimap::~Minimap()
{
if (mMapImage)
- {
mMapImage->decRef();
- }
}
void Minimap::setMapImage(Image *img)
{
if (mMapImage)
- {
mMapImage->decRef();
- }
mMapImage = img;
- if (mMapImage)
- {
+ if (mMapImage) {
mMapImage->setAlpha(0.7);
- setSize( mMapImage->getWidth() + 6, mMapImage->getHeight() + 23 );
- setVisible(true);
+ setContentSize(mMapImage->getWidth(), mMapImage->getHeight());
}
- else
- {
- setVisible(false);
- }
-
}
void Minimap::draw(gcn::Graphics *graphics)
{
Window::draw(graphics);
+ const gcn::Rectangle a = getChildrenArea();
+
+ int mapOriginX = a.x;
+ int mapOriginY = a.y;
+
if (mMapImage)
{
- static_cast<Graphics*>(graphics)->drawImage(
- mMapImage, getPadding(), getTitleBarHeight());
+ if (mMapImage->getWidth() > a.width ||
+ mMapImage->getHeight() > a.height)
+ {
+ const Vector &pos = player_node->getPosition();
+ mapOriginX += (a.width - (int) (pos.x / 32)) / 2;
+ mapOriginY += (a.height - (int) (pos.y / 32)) / 2;
+ }
+ static_cast<Graphics*>(graphics)->
+ drawImage(mMapImage, mapOriginX, mapOriginY);
}
- Beings &beings = beingManager->getAll();
- BeingIterator bi;
+ const Beings &beings = beingManager->getAll();
+ Beings::const_iterator bi;
for (bi = beings.begin(); bi != beings.end(); bi++)
{
- Being *being = (*bi);
+ const Being *being = (*bi);
int dotSize = 2;
switch (being->getType()) {
@@ -116,8 +117,8 @@ void Minimap::draw(gcn::Graphics *graphics)
const Vector &pos = being->getPosition();
graphics->fillRectangle(gcn::Rectangle(
- (int) pos.x / 64 + getPadding() - offset,
- (int) pos.y / 64 + getTitleBarHeight() - offset,
+ (int) pos.x / 64 + mapOriginX - offset,
+ (int) pos.x / 64 + mapOriginY - offset,
dotSize, dotSize));
}
}