diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/listeners/playerdeathlistener.h | 64 | ||||
-rw-r--r-- | src/net/ea/playerhandler.cpp | 24 |
4 files changed, 68 insertions, 22 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index de85faf2d..bfc8df4c9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -956,6 +956,7 @@ SET(SRCS events/mouseeventtype.h listeners/mouselistener.h listeners/openurllistener.h + listeners/playerdeathlistener.h listeners/playerlistener.cpp listeners/playerlistener.h gui/rect.h diff --git a/src/Makefile.am b/src/Makefile.am index 61ec42b15..c882863d1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -192,6 +192,7 @@ manaplus_SOURCES += events/actionevent.h \ events/mouseeventtype.h \ listeners/mouselistener.h \ listeners/openurllistener.h \ + listeners/playerdeathlistener.h \ listeners/playerlistener.cpp \ listeners/playerlistener.h \ gui/rect.h \ diff --git a/src/listeners/playerdeathlistener.h b/src/listeners/playerdeathlistener.h new file mode 100644 index 000000000..3c4129e07 --- /dev/null +++ b/src/listeners/playerdeathlistener.h @@ -0,0 +1,64 @@ +/* + * 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 LISTENERS_PLAYERDEATHLISTENER_H +#define LISTENERS_PLAYERDEATHLISTENER_H + +#include "game.h" + +#include "being/localplayer.h" + +#include "gui/viewport.h" + +#include "gui/windows/okdialog.h" +#include "gui/windows/npcdialog.h" + +#include "net/net.h" +#include "net/playerhandler.h" + +#include "localconsts.h" + +extern OkDialog *deathNotice; + +/** + * Listener used for handling death message. + */ +struct PlayerDeathListener final : public ActionListener +{ + void action(const ActionEvent &event A_UNUSED) + { + if (Net::getPlayerHandler()) + Net::getPlayerHandler()->respawn(); + deathNotice = nullptr; + + Game::closeDialogs(); + + if (viewport) + viewport->closePopupMenu(); + + NpcDialog::clearDialogs(); + if (player_node) + player_node->respawn(); + } +}; + +#endif // LISTENERS_PLAYERDEATHLISTENER_H diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp index 065ac6365..c6080bcee 100644 --- a/src/net/ea/playerhandler.cpp +++ b/src/net/ea/playerhandler.cpp @@ -44,6 +44,7 @@ #include "resources/map/map.h" #include "listeners/updatestatuslistener.h" +#include "listeners/playerdeathlistener.h" #include "net/messagein.h" #include "net/net.h" @@ -53,7 +54,6 @@ #include "debug.h" extern OkDialog *weightNotice; -extern OkDialog *deathNotice; extern int weightNoticeTime; // Max. distance we are willing to scroll after a teleport; @@ -73,27 +73,7 @@ namespace } } weightListener; - /** - * Listener used for handling death message. - */ - struct DeathListener final : public ActionListener - { - void action(const ActionEvent &event A_UNUSED) - { - if (Net::getPlayerHandler()) - Net::getPlayerHandler()->respawn(); - deathNotice = nullptr; - - Game::closeDialogs(); - - if (viewport) - viewport->closePopupMenu(); - - NpcDialog::clearDialogs(); - if (player_node) - player_node->respawn(); - } - } deathListener; + PlayerDeathListener deathListener; } // anonymous namespace |