summaryrefslogtreecommitdiff
path: root/src
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
parentea92940149eb3f4e2590cfbd07f240000acbd460 (diff)
downloadmv-8e6dd0db3a9e1bfb15068098029c25c334ca8f67.tar.gz
mv-8e6dd0db3a9e1bfb15068098029c25c334ca8f67.tar.bz2
mv-8e6dd0db3a9e1bfb15068098029c25c334ca8f67.tar.xz
mv-8e6dd0db3a9e1bfb15068098029c25c334ca8f67.zip
Allow use context menu in minimap.
Diffstat (limited to 'src')
-rw-r--r--src/gui/minimap.cpp26
-rw-r--r--src/gui/minimap.h2
-rw-r--r--src/gui/popupmenu.cpp37
-rw-r--r--src/gui/popupmenu.h2
-rw-r--r--src/gui/viewport.cpp5
-rw-r--r--src/gui/viewport.h2
6 files changed, 67 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;
}
diff --git a/src/gui/minimap.h b/src/gui/minimap.h
index 8b7da5849..12835edd5 100644
--- a/src/gui/minimap.h
+++ b/src/gui/minimap.h
@@ -60,6 +60,8 @@ class Minimap : public Window
void mouseReleased(gcn::MouseEvent &event);
+ void screenToMap(int &x, int &y);
+
private:
Image *mMapImage;
float mWidthProportion;
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index 933d2c7cd..5e5f310dc 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -579,6 +579,25 @@ void PopupMenu::showPopup(int x, int y, MapItem *mapItem)
showPopup(x, y);
}
+void PopupMenu::showMapPopup(int x, int y, int x2, int y2)
+{
+ mX = x2;
+ mY = y2;
+
+ mBrowserBox->clearRows();
+
+ mBrowserBox->addRow(_("Map Item"));
+
+ if (player_node && player_node->isGM())
+ mBrowserBox->addRow("warp map", _("Warp"));
+ mBrowserBox->addRow("move", _("Move"));
+ mBrowserBox->addRow("movecamera", _("Move camera"));
+ mBrowserBox->addRow("##3---");
+ mBrowserBox->addRow("cancel", _("Cancel"));
+
+ showPopup(x, y);
+}
+
void PopupMenu::showOutfitsPopup(int x, int y)
{
mX = x;
@@ -1161,6 +1180,16 @@ void PopupMenu::handleLink(const std::string &link,
}
}
}
+ else if (link == "move" && (mX || mY))
+ {
+ if (player_node)
+ player_node->navigateTo(mX, mY);
+ }
+ else if (link == "movecamera" && (mX || mY))
+ {
+ if (viewport)
+ viewport->moveCameraToPosition(mX * 32, mY * 32);
+ }
else if (link == "split" && mItem)
{
ItemAmountWindow::showWindow(ItemAmountWindow::ItemSplit,
@@ -1304,6 +1333,14 @@ void PopupMenu::handleLink(const std::string &link,
mMapItem->getX(), mMapItem->getY());
}
}
+ else if (link == "warp map" && (mX || mY))
+ {
+ if (Game::instance())
+ {
+ Net::getAdminHandler()->warp(Game::instance()->getCurrentMapName(),
+ mX, mY);
+ }
+ }
else if (link == "remove map" && mMapItem)
{
if (viewport)
diff --git a/src/gui/popupmenu.h b/src/gui/popupmenu.h
index 8b9107300..f616e46ee 100644
--- a/src/gui/popupmenu.h
+++ b/src/gui/popupmenu.h
@@ -142,6 +142,8 @@ class PopupMenu : public Popup, public LinkHandler
void showUndressPopup(int x, int y, Being *being, Item *item);
+ void showMapPopup(int x, int y, int x2, int y2);
+
/**
* Shows the related popup menu when right click on the chat
* at the specified mouse coordinates.
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 0c0f0d3d9..17f40121e 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -706,6 +706,11 @@ void Viewport::showUndressPopup(int x, int y, Being *being, Item *item)
mPopupMenu->showUndressPopup(x, y, being, item);
}
+void Viewport::showMapPopup(int x, int y)
+{
+ mPopupMenu->showMapPopup(getMouseX(), getMouseY(), x, y);
+}
+
void Viewport::closePopupMenu()
{
if (mPopupMenu)
diff --git a/src/gui/viewport.h b/src/gui/viewport.h
index ccb8124ba..ae6ff3d49 100644
--- a/src/gui/viewport.h
+++ b/src/gui/viewport.h
@@ -173,6 +173,8 @@ class Viewport : public WindowContainer, public gcn::MouseListener,
void showUndressPopup(int x, int y, Being *being, Item *item);
+ void showMapPopup(int x, int y);
+
/**
* Closes the popup menu. Needed for when the player dies or switching
* maps.