summaryrefslogtreecommitdiff
path: root/src/gui/minimap.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-02-29 04:27:38 +0300
committerAndrei Karas <akaras@inbox.ru>2012-02-29 04:27:38 +0300
commit8e6dd0db3a9e1bfb15068098029c25c334ca8f67 (patch)
tree0f31545099368d6edd5917bb0b72a997893cb833 /src/gui/minimap.cpp
parentea92940149eb3f4e2590cfbd07f240000acbd460 (diff)
downloadmanaplus-8e6dd0db3a9e1bfb15068098029c25c334ca8f67.tar.gz
manaplus-8e6dd0db3a9e1bfb15068098029c25c334ca8f67.tar.bz2
manaplus-8e6dd0db3a9e1bfb15068098029c25c334ca8f67.tar.xz
manaplus-8e6dd0db3a9e1bfb15068098029c25c334ca8f67.zip
Allow use context menu in minimap.
Diffstat (limited to 'src/gui/minimap.cpp')
-rw-r--r--src/gui/minimap.cpp26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp
index b4747b7c0..b76e71069 100644
--- a/src/gui/minimap.cpp
+++ b/src/gui/minimap.cpp
@@ -401,17 +401,29 @@ void Minimap::mouseReleased(gcn::MouseEvent &event)
{
gcn::Window::mouseReleased(event);
- if (!player_node)
+ if (!player_node || !viewport)
return;
if (event.getButton() == gcn::MouseEvent::LEFT)
{
- const gcn::Rectangle a = getChildrenArea();
- const int x = event.getX() - a.x;
- const int y = event.getY() - a.y;
+ int x = event.getX();
+ int y = event.getY();
+ screenToMap(x, y);
- player_node->navigateTo((x - mMapOriginX + mWidthProportion)
- / mWidthProportion, (y - mMapOriginY + mHeightProportion)
- / mHeightProportion);
+ player_node->navigateTo(x, y);
}
+ else if (event.getButton() == gcn::MouseEvent::RIGHT)
+ {
+ int x = event.getX();
+ int y = event.getY();
+ screenToMap(x, y);
+ viewport->showMapPopup(x, y);
+ }
+}
+
+void Minimap::screenToMap(int &x, int &y)
+{
+ const gcn::Rectangle a = getChildrenArea();
+ x = (x - a.x - mMapOriginX + mWidthProportion) / mWidthProportion;
+ y = (y - a.y - mMapOriginY + mHeightProportion) / mHeightProportion;
}