summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/actionmanager.cpp9
-rw-r--r--src/being/localplayer.cpp6
-rw-r--r--src/client.cpp4
-rw-r--r--src/game.cpp11
-rw-r--r--src/gui/popupmanager.cpp315
-rw-r--r--src/gui/popupmanager.h192
-rw-r--r--src/gui/viewport.cpp206
-rw-r--r--src/gui/viewport.h99
-rw-r--r--src/gui/widgets/avatarlistbox.cpp13
-rw-r--r--src/gui/widgets/dropshortcutcontainer.cpp5
-rw-r--r--src/gui/widgets/itemlinkhandler.cpp5
-rw-r--r--src/gui/widgets/itemshortcutcontainer.cpp5
-rw-r--r--src/gui/widgets/popup.cpp11
-rw-r--r--src/gui/widgets/shoplistbox.cpp4
-rw-r--r--src/gui/widgets/spellshortcutcontainer.cpp5
-rw-r--r--src/gui/widgets/textfield.cpp23
-rw-r--r--src/gui/widgets/window.cpp12
-rw-r--r--src/gui/windowmenu.cpp8
-rw-r--r--src/gui/windows/chatwindow.cpp6
-rw-r--r--src/gui/windows/equipmentwindow.cpp8
-rw-r--r--src/gui/windows/inventorywindow.cpp6
-rw-r--r--src/gui/windows/minimap.cpp5
-rw-r--r--src/gui/windows/ministatuswindow.cpp9
-rw-r--r--src/gui/windows/npcdialog.cpp5
-rw-r--r--src/gui/windows/outfitwindow.cpp6
-rw-r--r--src/gui/windows/whoisonline.cpp10
-rw-r--r--src/listeners/playerdeathlistener.h6
29 files changed, 621 insertions, 377 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 60a529421..3482b6d87 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -383,6 +383,8 @@ SET(SRCS
gui/onlineplayer.h
gui/palette.cpp
gui/palette.h
+ gui/popupmanager.cpp
+ gui/popupmanager.h
gui/popups/popupmenu.cpp
gui/popups/popupmenu.h
gui/windows/questswindow.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index 3d028b119..01580c643 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -510,6 +510,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
gui/onlineplayer.h \
gui/palette.cpp \
gui/palette.h \
+ gui/popupmanager.cpp \
+ gui/popupmanager.h \
gui/popups/popupmenu.cpp \
gui/popups/popupmenu.h \
gui/windows/questswindow.cpp \
diff --git a/src/actionmanager.cpp b/src/actionmanager.cpp
index 39884f8c2..004c997f9 100644
--- a/src/actionmanager.cpp
+++ b/src/actionmanager.cpp
@@ -38,6 +38,7 @@
#include "gui/dialogsmanager.h"
#include "gui/gui.h"
+#include "gui/popupmanager.h"
#include "gui/sdlinput.h"
#include "gui/viewport.h"
@@ -363,9 +364,9 @@ impHandler0(quit)
{
if (!Game::instance())
return false;
- if (viewport && viewport->isPopupMenuVisible())
+ if (popupManager && popupManager->isPopupMenuVisible())
{
- viewport->closePopupMenu();
+ popupManager->closePopupMenu();
return true;
}
else if (!quitDialog)
@@ -1121,9 +1122,9 @@ impHandler0(showKeyboard)
impHandler0(showWindows)
{
- if (viewport)
+ if (popupManager)
{
- viewport->showWindowsPopup();
+ popupManager->showWindowsPopup();
return true;
}
return false;
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp
index e906ea5ab..ba0467bfb 100644
--- a/src/being/localplayer.cpp
+++ b/src/being/localplayer.cpp
@@ -48,7 +48,7 @@
#include "input/keyboardconfig.h"
#include "gui/gui.h"
-#include "gui/viewport.h"
+#include "gui/popupmanager.h"
#include "gui/windows/chatwindow.h"
#include "gui/windows/ministatuswindow.h"
@@ -2641,8 +2641,8 @@ void LocalPlayer::updateCoords()
{
if (socialWindow)
socialWindow->updatePortals();
- if (viewport)
- viewport->hideBeingPopup();
+ if (popupManager)
+ popupManager->hideBeingPopup();
updateMusic();
}
diff --git a/src/client.cpp b/src/client.cpp
index 9f860b669..6f6c78f7c 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -54,6 +54,7 @@
#include "gui/dialogsmanager.h"
#include "gui/gui.h"
#include "gui/skin.h"
+#include "gui/popupmanager.h"
#include "gui/theme.h"
#include "gui/windowmanager.h"
@@ -381,6 +382,8 @@ void Client::gameInit()
gui = new Gui();
gui->postInit(mainGraphics);
+ popupManager = new PopupManager;
+
initSoundManager();
eventsManager.init();
@@ -645,6 +648,7 @@ void Client::gameClear()
logger->log1("Quitting2");
delete2(mCurrentDialog);
+ delete2(popupManager);
delete2(gui);
if (Net::getInventoryHandler())
diff --git a/src/game.cpp b/src/game.cpp
index f5b146a99..4e2977232 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -53,6 +53,7 @@
#include "gui/chatconsts.h"
#include "gui/dialogsmanager.h"
#include "gui/gui.h"
+#include "gui/popupmanager.h"
#include "gui/viewport.h"
#include "gui/windowmanager.h"
#include "gui/windowmenu.h"
@@ -965,8 +966,11 @@ void Game::changeMap(const std::string &mapPath)
ResourceManager *const resman = ResourceManager::getInstance();
resman->cleanProtected();
- if (viewport)
- viewport->clearPopup();
+ if (popupManager)
+ {
+ popupManager->clearPopup();
+ popupManager->closePopupMenu();
+ }
// Clean up floor items, beings and particles
if (actorManager)
@@ -975,10 +979,7 @@ void Game::changeMap(const std::string &mapPath)
// Close the popup menu on map change so that invalid options can't be
// executed.
if (viewport)
- {
- viewport->closePopupMenu();
viewport->cleanHoverItems();
- }
// Unset the map of the player so that its particles are cleared before
// being deleted in the next step
diff --git a/src/gui/popupmanager.cpp b/src/gui/popupmanager.cpp
new file mode 100644
index 000000000..b5abb4f04
--- /dev/null
+++ b/src/gui/popupmanager.cpp
@@ -0,0 +1,315 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2004-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "gui/popupmanager.h"
+
+#include "actormanager.h"
+#include "configuration.h"
+#include "game.h"
+#include "settings.h"
+#include "sdlshared.h"
+#include "textmanager.h"
+
+#include "resources/mapitemtype.h"
+
+#include "resources/map/map.h"
+#include "resources/map/mapitem.h"
+#include "resources/map/maptype.h"
+#include "resources/map/speciallayer.h"
+
+#include "being/localplayer.h"
+#include "being/playerinfo.h"
+
+#include "input/inputmanager.h"
+
+#include "gui/gui.h"
+#include "gui/viewport.h"
+
+#include "gui/fonts/font.h"
+
+#include "gui/popups/beingpopup.h"
+#include "gui/popups/popupmenu.h"
+#include "gui/popups/textpopup.h"
+
+#include "gui/windows/ministatuswindow.h"
+
+#include "utils/delete2.h"
+
+#include "debug.h"
+
+PopupManager *popupManager = nullptr;
+
+PopupManager::PopupManager() :
+ mPopupMenu(new PopupMenu),
+ mBeingPopup(new BeingPopup),
+ mTextPopup(new TextPopup)
+{
+ mBeingPopup->postInit();
+ mPopupMenu->postInit();
+ mTextPopup->postInit();
+}
+
+PopupManager::~PopupManager()
+{
+ delete2(mPopupMenu);
+ delete2(mBeingPopup);
+ delete2(mTextPopup);
+}
+
+void PopupManager::showPopup(Window *const parent,
+ const int x, const int y,
+ Item *const item,
+ const bool isInventory)
+{
+ mPopupMenu->showPopup(parent, x, y, item, isInventory);
+}
+
+void PopupManager::showPopup(MapItem *const item)
+{
+ mPopupMenu->showPopup(viewport->getMouseX(), viewport->getMouseY(), item);
+}
+
+void PopupManager::showPopup(Window *const parent,
+ Item *const item,
+ const bool isInventory)
+{
+ mPopupMenu->showPopup(parent, viewport->getMouseX(), viewport->getMouseY(),
+ item, isInventory);
+}
+
+void PopupManager::showPopup(const int x, const int y,
+ const std::vector<ActorSprite*> &beings)
+{
+ mPopupMenu->showPopup(x, y, beings);
+}
+
+void PopupManager::showPopup(const int x, const int y,
+ const FloorItem *const floorItem)
+{
+ mPopupMenu->showPopup(x, y, floorItem);
+}
+
+void PopupManager::showPopup(const int x, const int y, MapItem *const mapItem)
+{
+ mPopupMenu->showPopup(x, y, mapItem);
+}
+
+void PopupManager::showItemPopup(Item *const item)
+{
+ mPopupMenu->showItemPopup(viewport->getMouseX(), viewport->getMouseY(),
+ item);
+}
+
+void PopupManager::showItemPopup(const int itemId,
+ const unsigned char color)
+{
+ mPopupMenu->showItemPopup(viewport->getMouseX(), viewport->getMouseY(),
+ itemId, color);
+}
+
+void PopupManager::showDropPopup(Item *const item)
+{
+ mPopupMenu->showDropPopup(viewport->getMouseX(), viewport->getMouseY(),
+ item);
+}
+
+void PopupManager::showOutfitsPopup(const int x, const int y)
+{
+ mPopupMenu->showOutfitsPopup(x, y);
+}
+
+void PopupManager::showOutfitsPopup()
+{
+ mPopupMenu->showOutfitsPopup(viewport->getMouseX(), viewport->getMouseY());
+}
+
+void PopupManager::showSpellPopup(TextCommand *const cmd)
+{
+ mPopupMenu->showSpellPopup(viewport->getMouseX(), viewport->getMouseY(),
+ cmd);
+}
+
+void PopupManager::showChatPopup(const int x, const int y,
+ ChatTab *const tab)
+{
+ mPopupMenu->showChatPopup(x, y, tab);
+}
+
+void PopupManager::showChatPopup(ChatTab *const tab)
+{
+ mPopupMenu->showChatPopup(viewport->getMouseX(), viewport->getMouseY(),
+ tab);
+}
+
+void PopupManager::showPopup(const int x, const int y,
+ const Being *const being)
+{
+ mPopupMenu->showPopup(x, y, being);
+}
+
+void PopupManager::showPopup(const Being *const being)
+{
+ mPopupMenu->showPopup(viewport->getMouseX(), viewport->getMouseY(), being);
+}
+
+void PopupManager::showPlayerPopup(const std::string &nick)
+{
+ mPopupMenu->showPlayerPopup(viewport->getMouseX(), viewport->getMouseY(),
+ nick);
+}
+
+void PopupManager::showPopup(const int x, const int y,
+ Button *const button)
+{
+ mPopupMenu->showPopup(x, y, button);
+}
+
+void PopupManager::showPopup(const int x, const int y,
+ const ProgressBar *const bar)
+{
+ mPopupMenu->showPopup(x, y, bar);
+}
+
+void PopupManager::showAttackMonsterPopup(const std::string &name,
+ const int type)
+{
+ mPopupMenu->showAttackMonsterPopup(viewport->getMouseX(),
+ viewport->getMouseY(),
+ name,
+ type);
+}
+
+void PopupManager::showPickupItemPopup(const std::string &name)
+{
+ mPopupMenu->showPickupItemPopup(viewport->getMouseX(), viewport->getMouseY(),
+ name);
+}
+
+void PopupManager::showUndressPopup(const int x, const int y,
+ const Being *const being,
+ Item *const item)
+{
+ mPopupMenu->showUndressPopup(x, y, being, item);
+}
+
+void PopupManager::showMapPopup(const int x, const int y)
+{
+ mPopupMenu->showMapPopup(viewport->getMouseX(), viewport->getMouseY(),
+ x, y);
+}
+
+void PopupManager::showMapPopup(const int x1, const int y1,
+ const int x2, const int y2)
+{
+ mPopupMenu->showMapPopup(x1, y1, x2, y2);
+}
+
+void PopupManager::showTextFieldPopup(TextField *const input)
+{
+ mPopupMenu->showTextFieldPopup(viewport->getMouseX(),
+ viewport->getMouseY(),
+ input);
+}
+
+void PopupManager::showLinkPopup(const std::string &link)
+{
+ mPopupMenu->showLinkPopup(viewport->getMouseX(),
+ viewport->getMouseY(),
+ link);
+}
+
+void PopupManager::showWindowsPopup()
+{
+ mPopupMenu->showWindowsPopup(viewport->getMouseX(), viewport->getMouseY());
+}
+
+void PopupManager::showNpcDialogPopup(const int npcId)
+{
+ mPopupMenu->showNpcDialogPopup(npcId,
+ viewport->getMouseX(),
+ viewport->getMouseY());
+}
+
+void PopupManager::showWindowPopup(Window *const window)
+{
+ mPopupMenu->showWindowPopup(window, viewport->getMouseX(),
+ viewport->getMouseY());
+}
+
+void PopupManager::closePopupMenu()
+{
+ if (mPopupMenu)
+ mPopupMenu->handleLink("cancel", nullptr);
+}
+
+void PopupManager::hideBeingPopup()
+{
+ if (mBeingPopup)
+ mBeingPopup->setVisible(false);
+}
+
+void PopupManager::hideTextPopup()
+{
+ if (mTextPopup)
+ mTextPopup->setVisible(false);
+}
+
+void PopupManager::hidePopupMenu()
+{
+ if (mPopupMenu)
+ mPopupMenu->setVisible(false);
+}
+
+bool PopupManager::isPopupMenuVisible() const
+{
+ return mPopupMenu ? mPopupMenu->isPopupVisible() : false;
+}
+
+void PopupManager::clearPopup()
+{
+ if (mPopupMenu)
+ mPopupMenu->clear();
+}
+
+void PopupManager::showBeingPopup(const int x, const int y,
+ Being *const b)
+{
+ if (mBeingPopup)
+ mBeingPopup->show(x, y, b);
+}
+
+void PopupManager::showTextPopup(const int x, const int y,
+ const std::string &text)
+{
+ if (mTextPopup)
+ mTextPopup->show(x, y, text);
+}
+
+bool PopupManager::isTextPopupVisible() const
+{
+ return mTextPopup ? mTextPopup->isPopupVisible() : false;
+}
+
+bool PopupManager::isBeingPopupVisible() const
+{
+ return mBeingPopup ? mBeingPopup->isPopupVisible() : false;
+}
diff --git a/src/gui/popupmanager.h b/src/gui/popupmanager.h
new file mode 100644
index 000000000..a44625b1e
--- /dev/null
+++ b/src/gui/popupmanager.h
@@ -0,0 +1,192 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2004-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GUI_POPUPMANAGER_H
+#define GUI_POPUPMANAGER_H
+
+class ActorSprite;
+class Button;
+class Being;
+class BeingPopup;
+class ChatTab;
+class FloorItem;
+class Graphics;
+class Item;
+class Map;
+class MapItem;
+class PopupMenu;
+class ProgressBar;
+class TextCommand;
+class TextField;
+class TextPopup;
+class Window;
+
+#include <string>
+#include <vector>
+
+#include "localconsts.h"
+
+class PopupManager final
+{
+ public:
+ /**
+ * Constructor.
+ */
+ PopupManager();
+
+ A_DELETE_COPY(PopupManager)
+
+ /**
+ * Destructor.
+ */
+ ~PopupManager();
+
+ /**
+ * Shows a popup for an item.
+ * TODO Find some way to get rid of Item here
+ */
+ void showPopup(Window *const parent,
+ const int x, const int y,
+ Item *const item,
+ const bool isInventory = true);
+
+ /**
+ * Shows a popup for an item.
+ * TODO Find some way to get rid of Item here
+ */
+ void showPopup(Window *const parent,
+ Item *const item,
+ const bool isInventory = true);
+
+ void showPopup(const int x, const int y,
+ Button *const button);
+
+ void showPopup(const int x, const int y,
+ const ProgressBar *const bar);
+
+ void showPopup(MapItem *const item);
+
+ void showPopup(const int x, const int y, MapItem *const mapItem);
+
+ void showItemPopup(Item *const item);
+
+ void showItemPopup(const int itemId,
+ const unsigned char color = 1);
+
+ void showDropPopup(Item *const item);
+
+ /**
+ * Shows a popup for being.
+ */
+ void showPopup(const int x, const int y,
+ const Being *const being);
+
+ void showPopup(const Being *const being);
+
+ void showPopup(const int x, const int y,
+ const std::vector<ActorSprite*> &beings);
+
+ void showPopup(const int x, const int y,
+ const FloorItem *const floorItem);
+
+ void showPlayerPopup(const std::string &nick);
+
+ void showOutfitsPopup(const int x, const int y);
+
+ void showOutfitsPopup();
+
+ void showSpellPopup(TextCommand *const cmd);
+
+ void showAttackMonsterPopup(const std::string &name,
+ const int type);
+
+ void showPickupItemPopup(const std::string &name);
+
+ /**
+ * Shows the related popup menu when right click on the chat
+ * at the specified mouse coordinates.
+ */
+ void showChatPopup(const int x, const int y,
+ ChatTab *const tab);
+
+ /**
+ * Shows the related popup menu when right click on the chat
+ */
+ void showChatPopup(ChatTab *const tab);
+
+ void showUndressPopup(const int x, const int y,
+ const Being *const being,
+ Item *const item);
+
+ void showMapPopup(const int x, const int y);
+
+ void showMapPopup(const int x1, const int y1,
+ const int x2, const int y2);
+
+ void showTextFieldPopup(TextField *const input);
+
+ void showLinkPopup(const std::string &link);
+
+ void showWindowsPopup();
+
+ void showNpcDialogPopup(const int npcId);
+
+ void showWindowPopup(Window *const window);
+
+ void showBeingPopup(const int x, const int y,
+ Being *const b);
+
+ void showTextPopup(const int x, const int y,
+ const std::string &text);
+
+ bool isBeingPopupVisible() const;
+
+ bool isTextPopupVisible() const;
+
+ /**
+ * Closes the popup menu. Needed for when the player dies or switching
+ * maps.
+ */
+ void closePopupMenu();
+
+ /**
+ * Hides the BeingPopup.
+ */
+ void hideBeingPopup();
+
+ void hideTextPopup();
+
+ bool isPopupMenuVisible() const A_WARN_UNUSED;
+
+ void clearPopup();
+
+ void hidePopupMenu();
+
+ private:
+ PopupMenu *mPopupMenu; /**< Popup menu. */
+ BeingPopup *mBeingPopup; /**< Being information popup. */
+ TextPopup *mTextPopup; /**< Map Item information popup. */
+};
+
+extern PopupManager *popupManager;
+
+#endif // GUI_POPUPMANAGER_H
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index d0ea8236a..94c34f483 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -42,6 +42,7 @@
#include "input/inputmanager.h"
#include "gui/gui.h"
+#include "gui/popupmanager.h"
#include "gui/fonts/font.h"
@@ -64,12 +65,9 @@ Viewport::Viewport() :
WindowContainer(nullptr),
MouseListener(),
mMap(nullptr),
- mPopupMenu(new PopupMenu),
mHoverBeing(nullptr),
mHoverItem(nullptr),
mHoverSign(nullptr),
- mBeingPopup(new BeingPopup),
- mTextPopup(new TextPopup),
mScrollRadius(config.getIntValue("ScrollRadius")),
mScrollLaziness(config.getIntValue("ScrollLaziness")),
mScrollCenterOffsetX(config.getIntValue("ScrollCenterOffsetX")),
@@ -91,10 +89,6 @@ Viewport::Viewport() :
mMouseClicked(false),
mPlayerFollowMouse(false)
{
- mBeingPopup->postInit();
- mPopupMenu->postInit();
- mTextPopup->postInit();
-
setOpaque(false);
addMouseListener(this);
@@ -113,9 +107,6 @@ Viewport::~Viewport()
{
config.removeListeners(this);
CHECKLISTENERS
- delete2(mPopupMenu);
- delete2(mBeingPopup);
- delete2(mTextPopup);
}
void Viewport::setMap(Map *const map)
@@ -391,29 +382,29 @@ bool Viewport::openContextMenu(const MouseEvent &event)
const int y = mMouseY + mPixelViewY;
actorManager->findBeingsByPixel(beings, x, y, true);
if (beings.size() > 1)
- mPopupMenu->showPopup(eventX, eventY, beings);
+ popupManager->showPopup(eventX, eventY, beings);
else
- mPopupMenu->showPopup(eventX, eventY, mHoverBeing);
+ popupManager->showPopup(eventX, eventY, mHoverBeing);
return true;
}
}
else if (mHoverItem)
{
validateSpeed();
- mPopupMenu->showPopup(eventX, eventY, mHoverItem);
+ popupManager->showPopup(eventX, eventY, mHoverItem);
return true;
}
else if (mHoverSign)
{
validateSpeed();
- mPopupMenu->showPopup(eventX, eventY, mHoverSign);
+ popupManager->showPopup(eventX, eventY, mHoverSign);
return true;
}
else if (settings.cameraMode)
{
if (!mMap)
return false;
- mPopupMenu->showMapPopup(eventX, eventY,
+ popupManager->showMapPopup(eventX, eventY,
(mMouseX + mPixelViewX) / mMap->getTileWidth(),
(mMouseY + mPixelViewY) / mMap->getTileHeight());
return true;
@@ -528,10 +519,10 @@ void Viewport::mousePressed(MouseEvent &event)
}
// If a popup is active, just remove it
- if (mPopupMenu->isPopupVisible())
+ if (popupManager->isPopupMenuVisible())
{
mPlayerFollowMouse = false;
- mPopupMenu->setVisible(false);
+ popupManager->hidePopupMenu();
return;
}
@@ -735,150 +726,6 @@ void Viewport::mouseReleased(MouseEvent &event)
}
}
-void Viewport::showPopup(Window *const parent,
- const int x, const int y,
- Item *const item,
- const bool isInventory)
-{
- mPopupMenu->showPopup(parent, x, y, item, isInventory);
-}
-
-void Viewport::showPopup(MapItem *const item)
-{
- mPopupMenu->showPopup(mMouseX, mMouseY, item);
-}
-
-void Viewport::showPopup(Window *const parent,
- Item *const item,
- const bool isInventory)
-{
- mPopupMenu->showPopup(parent, mMouseX, mMouseY, item, isInventory);
-}
-
-void Viewport::showItemPopup(Item *const item)
-{
- mPopupMenu->showItemPopup(mMouseX, mMouseY, item);
-}
-
-void Viewport::showItemPopup(const int itemId,
- const unsigned char color)
-{
- mPopupMenu->showItemPopup(mMouseX, mMouseY, itemId, color);
-}
-
-void Viewport::showDropPopup(Item *const item)
-{
- mPopupMenu->showDropPopup(mMouseX, mMouseY, item);
-}
-
-void Viewport::showOutfitsPopup(const int x, const int y)
-{
- mPopupMenu->showOutfitsPopup(x, y);
-}
-
-void Viewport::showOutfitsPopup()
-{
- mPopupMenu->showOutfitsPopup(mMouseX, mMouseY);
-}
-
-void Viewport::showSpellPopup(TextCommand *const cmd)
-{
- mPopupMenu->showSpellPopup(mMouseX, mMouseY, cmd);
-}
-
-void Viewport::showChatPopup(const int x, const int y,
- ChatTab *const tab)
-{
- mPopupMenu->showChatPopup(x, y, tab);
-}
-
-void Viewport::showChatPopup(ChatTab *const tab)
-{
- mPopupMenu->showChatPopup(mMouseX, mMouseY, tab);
-}
-
-void Viewport::showPopup(const int x, const int y,
- const Being *const being)
-{
- mPopupMenu->showPopup(x, y, being);
-}
-
-void Viewport::showPopup(const Being *const being)
-{
- mPopupMenu->showPopup(mMouseX, mMouseY, being);
-}
-
-void Viewport::showPlayerPopup(const std::string &nick)
-{
- mPopupMenu->showPlayerPopup(mMouseX, mMouseY, nick);
-}
-
-void Viewport::showPopup(const int x, const int y,
- Button *const button)
-{
- mPopupMenu->showPopup(x, y, button);
-}
-
-void Viewport::showPopup(const int x, const int y,
- const ProgressBar *const bar)
-{
- mPopupMenu->showPopup(x, y, bar);
-}
-
-void Viewport::showAttackMonsterPopup(const std::string &name,
- const int type)
-{
- mPopupMenu->showAttackMonsterPopup(mMouseX, mMouseY, name, type);
-}
-
-void Viewport::showPickupItemPopup(const std::string &name)
-{
- mPopupMenu->showPickupItemPopup(mMouseX, mMouseY, name);
-}
-
-void Viewport::showUndressPopup(const int x, const int y,
- const Being *const being,
- Item *const item)
-{
- mPopupMenu->showUndressPopup(x, y, being, item);
-}
-
-void Viewport::showMapPopup(const int x, const int y)
-{
- mPopupMenu->showMapPopup(mMouseX, mMouseY, x, y);
-}
-
-void Viewport::showTextFieldPopup(TextField *const input)
-{
- mPopupMenu->showTextFieldPopup(mMouseX, mMouseY, input);
-}
-
-void Viewport::showLinkPopup(const std::string &link)
-{
- mPopupMenu->showLinkPopup(mMouseX, mMouseY, link);
-}
-
-void Viewport::showWindowsPopup()
-{
- mPopupMenu->showWindowsPopup(mMouseX, mMouseY);
-}
-
-void Viewport::showNpcDialogPopup(const int npcId)
-{
- mPopupMenu->showNpcDialogPopup(npcId, mMouseX, mMouseY);
-}
-
-void Viewport::showWindowPopup(Window *const window)
-{
- mPopupMenu->showWindowPopup(window, mMouseX, mMouseY);
-}
-
-void Viewport::closePopupMenu()
-{
- if (mPopupMenu)
- mPopupMenu->handleLink("cancel", nullptr);
-}
-
void Viewport::optionChanged(const std::string &name)
{
if (name == "ScrollLaziness")
@@ -918,13 +765,13 @@ void Viewport::mouseMoved(MouseEvent &event A_UNUSED)
|| type == ActorType::NPC
|| type == ActorType::PET))
{
- mTextPopup->setVisible(false);
+ popupManager->hideTextPopup();
if (mShowBeingPopup)
- mBeingPopup->show(mMouseX, mMouseY, mHoverBeing);
+ popupManager->showBeingPopup(mMouseX, mMouseY, mHoverBeing);
}
else
{
- mBeingPopup->setVisible(false);
+ popupManager->hideBeingPopup();
}
mHoverItem = actorManager->findItem(x / mMap->getTileWidth(),
@@ -945,22 +792,22 @@ void Viewport::mouseMoved(MouseEvent &event A_UNUSED)
{
if (!mHoverSign->getComment().empty())
{
- mBeingPopup->setVisible(false);
- mTextPopup->show(mMouseX, mMouseY,
+ popupManager->hideBeingPopup();
+ popupManager->showTextPopup(mMouseX, mMouseY,
mHoverSign->getComment());
}
else
{
- if (mTextPopup->isPopupVisible())
- mTextPopup->setVisible(false);
+ if (popupManager->isTextPopupVisible())
+ popupManager->hideTextPopup();
}
gui->setCursorType(Cursor::CURSOR_UP);
return;
}
}
}
- if (mTextPopup->isPopupVisible())
- mTextPopup->setVisible(false);
+ if (popupManager->isTextPopupVisible())
+ popupManager->hideTextPopup();
if (mHoverBeing)
{
@@ -1022,14 +869,6 @@ void Viewport::toggleCameraMode()
UpdateStatusListener::distributeEvent();
}
-void Viewport::hideBeingPopup()
-{
- if (mBeingPopup)
- mBeingPopup->setVisible(false);
- if (mTextPopup)
- mTextPopup->setVisible(false);
-}
-
void Viewport::clearHover(const ActorSprite *const actor)
{
if (mHoverBeing == actor)
@@ -1052,11 +891,6 @@ void Viewport::moveCamera(const int dx, const int dy)
mCameraRelativeY += dy;
}
-bool Viewport::isPopupMenuVisible() const
-{
- return mPopupMenu ? mPopupMenu->isPopupVisible() : false;
-}
-
void Viewport::moveCameraToActor(const int actorId,
const int x, const int y)
{
@@ -1109,9 +943,3 @@ void Viewport::validateSpeed()
Game::instance()->setValidSpeed();
}
}
-
-void Viewport::clearPopup()
-{
- if (mPopupMenu)
- mPopupMenu->clear();
-}
diff --git a/src/gui/viewport.h b/src/gui/viewport.h
index 579821ce6..0347a3f98 100644
--- a/src/gui/viewport.h
+++ b/src/gui/viewport.h
@@ -121,93 +121,6 @@ class Viewport final : public WindowContainer,
void mouseMoved(MouseEvent &event) override final;
/**
- * Shows a popup for an item.
- * TODO Find some way to get rid of Item here
- */
- void showPopup(Window *const parent,
- const int x, const int y,
- Item *const item,
- const bool isInventory = true);
-
- /**
- * Shows a popup for an item.
- * TODO Find some way to get rid of Item here
- */
- void showPopup(Window *const parent,
- Item *const item,
- const bool isInventory = true);
-
- void showPopup(const int x, const int y,
- Button *const button);
-
- void showPopup(const int x, const int y,
- const ProgressBar *const bar);
-
- void showPopup(MapItem *const item);
-
- void showItemPopup(Item *const item);
-
- void showItemPopup(const int itemId,
- const unsigned char color = 1);
-
- void showDropPopup(Item *const item);
-
- /**
- * Shows a popup for being.
- */
- void showPopup(const int x, const int y,
- const Being *const being);
-
- void showPopup(const Being *const being);
-
- void showPlayerPopup(const std::string &nick);
-
- void showOutfitsPopup(const int x, const int y);
-
- void showOutfitsPopup();
-
- void showSpellPopup(TextCommand *const cmd);
-
- void showAttackMonsterPopup(const std::string &name,
- const int type);
-
- void showPickupItemPopup(const std::string &name);
-
- /**
- * Shows the related popup menu when right click on the chat
- * at the specified mouse coordinates.
- */
- void showChatPopup(const int x, const int y,
- ChatTab *const tab);
-
- /**
- * Shows the related popup menu when right click on the chat
- */
- void showChatPopup(ChatTab *const tab);
-
- void showUndressPopup(const int x, const int y,
- const Being *const being,
- Item *const item);
-
- void showMapPopup(const int x, const int y);
-
- void showTextFieldPopup(TextField *const input);
-
- void showLinkPopup(const std::string &link);
-
- void showWindowsPopup();
-
- void showNpcDialogPopup(const int npcId);
-
- void showWindowPopup(Window *const window);
-
- /**
- * Closes the popup menu. Needed for when the player dies or switching
- * maps.
- */
- void closePopupMenu();
-
- /**
* A relevant config option changed.
*/
void optionChanged(const std::string &name) override final;
@@ -243,11 +156,6 @@ class Viewport final : public WindowContainer,
{ mPixelViewX += x; mPixelViewY += y; }
/**
- * Hides the BeingPopup.
- */
- void hideBeingPopup();
-
- /**
* Clear all hover item\being etc
*/
void cleanHoverItems();
@@ -269,8 +177,6 @@ class Viewport final : public WindowContainer,
void setCameraRelativeY(const int n)
{ mCameraRelativeY = n; }
- bool isPopupMenuVisible() const A_WARN_UNUSED;
-
void moveCameraToActor(const int actorId,
const int x = 0,
const int y = 0);
@@ -281,8 +187,6 @@ class Viewport final : public WindowContainer,
void returnCamera();
- void clearPopup();
-
protected:
friend class ActorManager;
@@ -318,12 +222,9 @@ class Viewport final : public WindowContainer,
Map *mMap; /**< The current map. */
- PopupMenu *mPopupMenu; /**< Popup menu. */
Being *mHoverBeing; /**< Being mouse is currently over. */
FloorItem *mHoverItem; /**< FloorItem mouse is currently over. */
MapItem *mHoverSign; /**< Map sign mouse is currently over. */
- BeingPopup *mBeingPopup; /**< Being information popup. */
- TextPopup *mTextPopup; /**< Map Item information popup. */
int mScrollRadius;
int mScrollLaziness;
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp
index 80bcba94c..6369efce8 100644
--- a/src/gui/widgets/avatarlistbox.cpp
+++ b/src/gui/widgets/avatarlistbox.cpp
@@ -28,6 +28,7 @@
#include "being/localplayer.h"
#include "gui/gui.h"
+#include "gui/popupmanager.h"
#include "gui/skin.h"
#include "gui/viewport.h"
@@ -335,7 +336,7 @@ void AvatarListBox::draw(Graphics *graphics)
void AvatarListBox::mousePressed(MouseEvent &event)
{
- if (!actorManager || !localPlayer || !viewport
+ if (!actorManager || !localPlayer || !popupManager
|| !getFont()->getHeight())
{
return;
@@ -385,9 +386,9 @@ void AvatarListBox::mousePressed(MouseEvent &event)
const Being *const being = actorManager->findBeingByName(
avatar->getName(), ActorType::PLAYER);
if (being)
- viewport->showPopup(being);
+ popupManager->showPopup(being);
else
- viewport->showPlayerPopup(avatar->getName());
+ popupManager->showPlayerPopup(avatar->getName());
}
break;
}
@@ -401,7 +402,7 @@ void AvatarListBox::mousePressed(MouseEvent &event)
else
name = model->getAvatarAt(selected)->getName();
- viewport->showAttackMonsterPopup(name,
+ popupManager->showAttackMonsterPopup(name,
model->getAvatarAt(selected)->getType());
break;
}
@@ -414,7 +415,7 @@ void AvatarListBox::mousePressed(MouseEvent &event)
else
name = model->getAvatarAt(selected)->getName();
- viewport->showPickupItemPopup(name);
+ popupManager->showPickupItemPopup(name);
break;
}
default:
@@ -425,7 +426,7 @@ void AvatarListBox::mousePressed(MouseEvent &event)
{
MapItem *const mapItem = map->findPortalXY(
ava->getX(), ava->getY());
- viewport->showPopup(mapItem);
+ popupManager->showPopup(mapItem);
}
break;
}
diff --git a/src/gui/widgets/dropshortcutcontainer.cpp b/src/gui/widgets/dropshortcutcontainer.cpp
index f1434aa23..5ec847922 100644
--- a/src/gui/widgets/dropshortcutcontainer.cpp
+++ b/src/gui/widgets/dropshortcutcontainer.cpp
@@ -28,6 +28,7 @@
#include "being/playerinfo.h"
+#include "gui/popupmanager.h"
#include "gui/viewport.h"
#include "gui/fonts/font.h"
@@ -214,8 +215,8 @@ void DropShortcutContainer::mousePressed(MouseEvent &event)
Item *const item = inv->findItem(dropShortcut->getItem(index),
dropShortcut->getItemColor(index));
- if (viewport)
- viewport->showDropPopup(item);
+ if (popupManager)
+ popupManager->showDropPopup(item);
}
}
diff --git a/src/gui/widgets/itemlinkhandler.cpp b/src/gui/widgets/itemlinkhandler.cpp
index 50e99a24c..e8976da67 100644
--- a/src/gui/widgets/itemlinkhandler.cpp
+++ b/src/gui/widgets/itemlinkhandler.cpp
@@ -22,6 +22,7 @@
#include "gui/widgets/itemlinkhandler.h"
+#include "gui/popupmanager.h"
#include "gui/viewport.h"
#include "gui/popups/itempopup.h"
@@ -78,8 +79,8 @@ void ItemLinkHandler::handleLink(const std::string &link, MouseEvent *event)
}
else if (button == MouseButton::RIGHT)
{
- if (viewport)
- viewport->showLinkPopup(url);
+ if (popupManager)
+ popupManager->showLinkPopup(url);
}
}
else if (!link.empty() && link[0] == '?')
diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp
index 51a1cef13..2d8deeba9 100644
--- a/src/gui/widgets/itemshortcutcontainer.cpp
+++ b/src/gui/widgets/itemshortcutcontainer.cpp
@@ -33,6 +33,7 @@
#include "input/inputmanager.h"
+#include "gui/popupmanager.h"
#include "gui/viewport.h"
#include "gui/fonts/font.h"
@@ -333,9 +334,9 @@ void ItemShortcutContainer::mousePressed(MouseEvent &event)
else if (event.getButton() == MouseButton::RIGHT)
{
event.consume();
- if (viewport && selShortcut)
+ if (popupManager && selShortcut)
{
- viewport->showItemPopup(selShortcut->getItem(index),
+ popupManager->showItemPopup(selShortcut->getItem(index),
selShortcut->getItemColor(index));
}
}
diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp
index 506b0f050..96faf19c4 100644
--- a/src/gui/widgets/popup.cpp
+++ b/src/gui/widgets/popup.cpp
@@ -25,8 +25,10 @@
#include "graphicsvertexes.h"
+#include "gui/popupmanager.h"
#include "gui/skin.h"
-#include "gui/viewport.h"
+
+#include "gui/widgets/windowcontainer.h"
#include "utils/delete2.h"
@@ -229,8 +231,11 @@ void Popup::position(const int x, const int y)
void Popup::mouseMoved(MouseEvent &event A_UNUSED)
{
- if (viewport)
- viewport->hideBeingPopup();
+ if (popupManager)
+ {
+ popupManager->hideBeingPopup();
+ popupManager->hideTextPopup();
+ }
mRedraw = true;
}
diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp
index 4c7242866..019fd3e63 100644
--- a/src/gui/widgets/shoplistbox.cpp
+++ b/src/gui/widgets/shoplistbox.cpp
@@ -27,6 +27,7 @@
#include "being/playerinfo.h"
+#include "gui/popupmanager.h"
#include "gui/viewport.h"
#include "gui/fonts/font.h"
@@ -233,7 +234,8 @@ void ShopListBox::mouseReleased(MouseEvent& event)
return;
Item *const item = mShopItems->at(mSelected);
- viewport->showItemPopup(item);
+ if (popupManager)
+ popupManager->showItemPopup(item);
}
}
diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp
index 419b63181..33579b5a9 100644
--- a/src/gui/widgets/spellshortcutcontainer.cpp
+++ b/src/gui/widgets/spellshortcutcontainer.cpp
@@ -27,6 +27,7 @@
#include "settings.h"
#include "spellshortcut.h"
+#include "gui/popupmanager.h"
#include "gui/viewport.h"
#include "gui/fonts/font.h"
@@ -259,8 +260,8 @@ void SpellShortcutContainer::mouseReleased(MouseEvent &event)
if (itemId >= 0)
spell = spellManager->getSpell(itemId);
- if (spell && viewport)
- viewport->showSpellPopup(spell);
+ if (spell && popupManager)
+ popupManager->showSpellPopup(spell);
}
}
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index fb1bcc1db..cdfbac68a 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -70,8 +70,8 @@
#include "input/inputmanager.h"
#include "gui/gui.h"
+#include "gui/popupmanager.h"
#include "gui/skin.h"
-#include "gui/viewport.h"
#ifdef ANDROID
#include "gui/windowmanager.h"
#endif
@@ -709,25 +709,8 @@ void TextField::mousePressed(MouseEvent &event)
event.consume();
if (event.getButton() == MouseButton::RIGHT)
{
- if (viewport)
- {
- viewport->showTextFieldPopup(this);
- }
- else
- {
- if (!mPopupMenu)
- {
- mPopupMenu = new PopupMenu();
- mPopupMenu->postInit();
- }
- if (gui)
- {
- int x = 0;
- int y = 0;
- Gui::getMouseState(&x, &y);
- mPopupMenu->showTextFieldPopup(x, y, this);
- }
- }
+ if (popupManager)
+ popupManager->showTextFieldPopup(this);
}
else if (event.getButton() == MouseButton::LEFT)
{
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index f2f7c1dd1..a4fb2d57f 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -74,6 +74,7 @@
#include "gui/focushandler.h"
#include "gui/gui.h"
+#include "gui/popupmanager.h"
#include "gui/skin.h"
#include "gui/viewport.h"
@@ -763,10 +764,10 @@ void Window::mousePressed(MouseEvent &event)
}
else if (button == MouseButton::RIGHT)
{
- if (viewport)
+ if (popupManager)
{
event.consume();
- viewport->showWindowPopup(this);
+ popupManager->showWindowPopup(this);
}
}
}
@@ -837,8 +838,11 @@ void Window::updateResizeHandler(MouseEvent &event)
void Window::mouseMoved(MouseEvent &event)
{
updateResizeHandler(event);
- if (viewport)
- viewport->hideBeingPopup();
+ if (popupManager)
+ {
+ popupManager->hideBeingPopup();
+ popupManager->hideTextPopup();
+ }
}
bool Window::canMove() const
diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp
index 35bd23ec7..ed3905404 100644
--- a/src/gui/windowmenu.cpp
+++ b/src/gui/windowmenu.cpp
@@ -28,8 +28,8 @@
#include "gui/buttoninfo.h"
#include "gui/buttontext.h"
+#include "gui/popupmanager.h"
#include "gui/skin.h"
-#include "gui/viewport.h"
#include "gui/popups/textpopup.h"
@@ -245,7 +245,7 @@ void WindowMenu::addButton(const char *const text,
void WindowMenu::mousePressed(MouseEvent &event)
{
- if (!viewport)
+ if (!popupManager)
return;
if (event.getButton() == MouseButton::RIGHT)
@@ -257,9 +257,9 @@ void WindowMenu::mousePressed(MouseEvent &event)
Button *const btn = dynamic_cast<Button*>(event.getSource());
if (!btn)
return;
- if (viewport)
+ if (popupManager)
{
- viewport->showPopup(getX() + event.getX(),
+ popupManager->showPopup(getX() + event.getX(),
getY() + event.getY(), btn);
}
}
diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp
index 3bf1366f5..2cee38db7 100644
--- a/src/gui/windows/chatwindow.cpp
+++ b/src/gui/windows/chatwindow.cpp
@@ -43,8 +43,8 @@
#include "gui/chatconsts.h"
#include "gui/focushandler.h"
#include "gui/gui.h"
+#include "gui/popupmanager.h"
#include "gui/skin.h"
-#include "gui/viewport.h"
#include "gui/models/colorlistmodel.h"
@@ -657,7 +657,7 @@ void ChatWindow::mousePressed(MouseEvent &event)
if (event.getButton() == MouseButton::RIGHT)
{
- if (viewport)
+ if (popupManager)
{
Tab *const tab = mChatTabs->getSelectedTab();
if (tab)
@@ -674,7 +674,7 @@ void ChatWindow::mousePressed(MouseEvent &event)
{
ChatTab *const cTab = dynamic_cast<ChatTab*>(tab);
if (cTab)
- viewport->showChatPopup(cTab);
+ popupManager->showChatPopup(cTab);
}
}
}
diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp
index 8a558236a..a760f49c8 100644
--- a/src/gui/windows/equipmentwindow.cpp
+++ b/src/gui/windows/equipmentwindow.cpp
@@ -32,7 +32,7 @@
#include "being/localplayer.h"
#include "being/playerinfo.h"
-#include "gui/viewport.h"
+#include "gui/popupmanager.h"
#include "gui/fonts/font.h"
@@ -358,13 +358,13 @@ void EquipmentWindow::mousePressed(MouseEvent& event)
*/
const int mx = x + getX();
const int my = y + getY();
- if (viewport)
+ if (popupManager)
{
event.consume();
if (mForing)
- viewport->showUndressPopup(mx, my, mBeing, item);
+ popupManager->showUndressPopup(mx, my, mBeing, item);
else
- viewport->showPopup(this, mx, my, item, true);
+ popupManager->showPopup(this, mx, my, item, true);
return;
}
}
diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp
index bd7a50674..5d12c95d4 100644
--- a/src/gui/windows/inventorywindow.cpp
+++ b/src/gui/windows/inventorywindow.cpp
@@ -34,7 +34,7 @@
#include "input/inputmanager.h"
#include "gui/gui.h"
-#include "gui/viewport.h"
+#include "gui/popupmanager.h"
#include "gui/fonts/font.h"
@@ -467,8 +467,8 @@ void InventoryWindow::mouseClicked(MouseEvent &event)
const int mx = event.getX() + getX();
const int my = event.getY() + getY();
- if (viewport)
- viewport->showPopup(this, mx, my, item, isMainInventory());
+ if (popupManager)
+ popupManager->showPopup(this, mx, my, item, isMainInventory());
}
if (!mInventory)
diff --git a/src/gui/windows/minimap.cpp b/src/gui/windows/minimap.cpp
index f8eaddd4b..615db0d85 100644
--- a/src/gui/windows/minimap.cpp
+++ b/src/gui/windows/minimap.cpp
@@ -29,6 +29,7 @@
#include "being/localplayer.h"
+#include "gui/popupmanager.h"
#include "gui/viewport.h"
#include "gui/popups/textpopup.h"
@@ -442,7 +443,7 @@ void Minimap::mouseReleased(MouseEvent &event)
{
Window::mouseReleased(event);
- if (!localPlayer || !viewport)
+ if (!localPlayer || !popupManager)
return;
if (event.getButton() == MouseButton::LEFT)
@@ -458,7 +459,7 @@ void Minimap::mouseReleased(MouseEvent &event)
int x = event.getX();
int y = event.getY();
screenToMap(x, y);
- viewport->showMapPopup(x, y);
+ popupManager->showMapPopup(x, y);
}
}
diff --git a/src/gui/windows/ministatuswindow.cpp b/src/gui/windows/ministatuswindow.cpp
index 61d3f4cab..6536617f3 100644
--- a/src/gui/windows/ministatuswindow.cpp
+++ b/src/gui/windows/ministatuswindow.cpp
@@ -30,8 +30,8 @@
#include "being/localplayer.h"
#include "being/playerinfo.h"
+#include "gui/popupmanager.h"
#include "gui/skin.h"
-#include "gui/viewport.h"
#include "gui/popups/textpopup.h"
@@ -443,9 +443,6 @@ void MiniStatusWindow::mouseMoved(MouseEvent &event)
void MiniStatusWindow::mousePressed(MouseEvent &event)
{
- if (!viewport)
- return;
-
if (event.getButton() == MouseButton::RIGHT)
{
const ProgressBar *const bar = dynamic_cast<ProgressBar*>(
@@ -453,9 +450,9 @@ void MiniStatusWindow::mousePressed(MouseEvent &event)
if (!bar)
return;
event.consume();
- if (viewport)
+ if (popupManager)
{
- viewport->showPopup(getX() + event.getX(),
+ popupManager->showPopup(getX() + event.getX(),
getY() + event.getY(), bar);
}
}
diff --git a/src/gui/windows/npcdialog.cpp b/src/gui/windows/npcdialog.cpp
index aab395a85..d11dca0a9 100644
--- a/src/gui/windows/npcdialog.cpp
+++ b/src/gui/windows/npcdialog.cpp
@@ -33,6 +33,7 @@
#include "being/being.h"
#include "gui/gui.h"
+#include "gui/popupmanager.h"
#include "gui/viewport.h"
#include "gui/fonts/font.h"
@@ -947,8 +948,8 @@ void NpcDialog::mousePressed(MouseEvent &event)
&& event.getSource() == mTextBox)
{
event.consume();
- if (viewport)
- viewport->showNpcDialogPopup(mNpcId);
+ if (popupManager)
+ popupManager->showNpcDialogPopup(mNpcId);
}
}
diff --git a/src/gui/windows/outfitwindow.cpp b/src/gui/windows/outfitwindow.cpp
index 85522ade1..82ce553f7 100644
--- a/src/gui/windows/outfitwindow.cpp
+++ b/src/gui/windows/outfitwindow.cpp
@@ -33,7 +33,7 @@
#include "input/inputmanager.h"
-#include "gui/viewport.h"
+#include "gui/popupmanager.h"
#include "gui/windows/setupwindow.h"
@@ -422,9 +422,9 @@ void OutfitWindow::mousePressed(MouseEvent &event)
const int index = getIndexFromGrid(event.getX(), event.getY());
if (index == -1)
{
- if (event.getButton() == MouseButton::RIGHT && viewport)
+ if (event.getButton() == MouseButton::RIGHT && popupManager)
{
- viewport->showOutfitsPopup();
+ popupManager->showOutfitsPopup();
event.consume();
}
else
diff --git a/src/gui/windows/whoisonline.cpp b/src/gui/windows/whoisonline.cpp
index fc4c8cbc4..f19f2662c 100644
--- a/src/gui/windows/whoisonline.cpp
+++ b/src/gui/windows/whoisonline.cpp
@@ -30,7 +30,7 @@
#include "settings.h"
#include "gui/onlineplayer.h"
-#include "gui/viewport.h"
+#include "gui/popupmanager.h"
#include "gui/windows/chatwindow.h"
#include "gui/windows/setupwindow.h"
@@ -197,7 +197,7 @@ void WhoIsOnline::handleLink(const std::string& link, MouseEvent *event)
if (localPlayer && link == localPlayer->getName())
return;
- if (viewport)
+ if (popupManager)
{
if (actorManager)
{
@@ -205,13 +205,13 @@ void WhoIsOnline::handleLink(const std::string& link, MouseEvent *event)
Being *const being = actorManager->findBeingByName(
text, ActorType::PLAYER);
- if (being && viewport)
+ if (being && popupManager)
{
- viewport->showPopup(being);
+ popupManager->showPopup(being);
return;
}
}
- viewport->showPlayerPopup(link);
+ popupManager->showPlayerPopup(link);
}
}
}
diff --git a/src/listeners/playerdeathlistener.h b/src/listeners/playerdeathlistener.h
index 4c9644d68..67eb031a0 100644
--- a/src/listeners/playerdeathlistener.h
+++ b/src/listeners/playerdeathlistener.h
@@ -26,7 +26,7 @@
#include "being/localplayer.h"
#include "gui/dialogsmanager.h"
-#include "gui/viewport.h"
+#include "gui/popupmanager.h"
#include "gui/windows/okdialog.h"
#include "gui/windows/npcdialog.h"
@@ -51,8 +51,8 @@ struct PlayerDeathListener final : public ActionListener
DialogsManager::closeDialogs();
- if (viewport)
- viewport->closePopupMenu();
+ if (popupManager)
+ popupManager->closePopupMenu();
NpcDialog::clearDialogs();
if (localPlayer)