summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-05-14 15:36:21 +0300
committerAndrei Karas <akaras@inbox.ru>2014-05-14 15:36:21 +0300
commit5781d238e97689be482c5ac691143ce35e3e278e (patch)
treec5e362c2e7ebbef874dadb6a2d22a1733d16efdd /src
parent653087c6ffd0f5f4245f6f3a2e18d4e7129070c0 (diff)
downloadmv-5781d238e97689be482c5ac691143ce35e3e278e.tar.gz
mv-5781d238e97689be482c5ac691143ce35e3e278e.tar.bz2
mv-5781d238e97689be482c5ac691143ce35e3e278e.tar.xz
mv-5781d238e97689be482c5ac691143ce35e3e278e.zip
Move playerlistener into separate file.
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/gui/popups/popupmenu.cpp22
-rw-r--r--src/gui/popups/popupmenu.h25
-rw-r--r--src/listeners/playerlistener.cpp51
-rw-r--r--src/listeners/playerlistener.h56
6 files changed, 112 insertions, 46 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index aac6e98e4..5018b97cb 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -853,6 +853,8 @@ SET(SRCS
gui/models/magicschoolmodel.h
events/mouseevent.h
listeners/mouselistener.h
+ listeners/playerlistener.cpp
+ listeners/playerlistener.h
gui/rect.h
events/selectionevent.h
listeners/selectionlistener.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 9040b95d4..0a99d1997 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -172,6 +172,8 @@ manaplus_SOURCES += events/actionevent.h \
gui/models/magicschoolmodel.h \
events/mouseevent.h \
listeners/mouselistener.h \
+ listeners/playerlistener.cpp \
+ listeners/playerlistener.h \
gui/rect.h \
events/selectionevent.h \
listeners/selectionlistener.h \
diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp
index c284b92a0..7629bf9ed 100644
--- a/src/gui/popups/popupmenu.cpp
+++ b/src/gui/popups/popupmenu.cpp
@@ -2900,25 +2900,3 @@ void PopupMenu::showGMPopup()
showPopup(getX(), getY());
}
-
-PlayerListener::PlayerListener() :
- ActionListener(),
- mNick(),
- mDialog(nullptr),
- mType(static_cast<int>(ActorType::UNKNOWN))
-{
-}
-
-void PlayerListener::action(const ActionEvent &event)
-{
- if (event.getId() == "ok" && !mNick.empty() && mDialog)
- {
- std::string comment = mDialog->getText();
- Being *const being = actorManager->findBeingByName(
- mNick, static_cast<ActorType::Type>(mType));
- if (being)
- being->setComment(comment);
- Being::saveComment(mNick, comment, mType);
- }
- mDialog = nullptr;
-}
diff --git a/src/gui/popups/popupmenu.h b/src/gui/popups/popupmenu.h
index fbbb69cd0..1fc124b16 100644
--- a/src/gui/popups/popupmenu.h
+++ b/src/gui/popups/popupmenu.h
@@ -27,6 +27,7 @@
#include "gui/widgets/popup.h"
#include "listeners/actionlistener.h"
+#include "listeners/playerlistener.h"
#include "listeners/renamelistener.h"
#include "localconsts.h"
@@ -47,30 +48,6 @@ class TextField;
class ProgressBar;
class Window;
-class PlayerListener : public ActionListener
-{
- public:
- PlayerListener();
-
- A_DELETE_COPY(PlayerListener)
-
- void action(const ActionEvent &event) override final;
-
- void setNick(const std::string &name)
- { mNick = name; }
-
- void setDialog(TextDialog *const dialog)
- { mDialog = dialog; }
-
- void setType(const int type)
- { mType = type; }
-
- private:
- std::string mNick;
- TextDialog *mDialog;
- int mType;
-};
-
/**
* Window showing popup menu.
*/
diff --git a/src/listeners/playerlistener.cpp b/src/listeners/playerlistener.cpp
new file mode 100644
index 000000000..d50aa20d9
--- /dev/null
+++ b/src/listeners/playerlistener.cpp
@@ -0,0 +1,51 @@
+/*
+ * The ManaPlus Client
+ * 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 "listeners/playerlistener.h"
+
+#include "actormanager.h"
+
+#include "being/being.h"
+
+#include "gui/windows/textdialog.h"
+
+#include "debug.h"
+
+PlayerListener::PlayerListener() :
+ ActionListener(),
+ mNick(),
+ mDialog(nullptr),
+ mType(static_cast<int>(ActorType::UNKNOWN))
+{
+}
+
+void PlayerListener::action(const ActionEvent &event)
+{
+ if (event.getId() == "ok" && !mNick.empty() && mDialog)
+ {
+ std::string comment = mDialog->getText();
+ Being *const being = actorManager->findBeingByName(
+ mNick, static_cast<ActorType::Type>(mType));
+ if (being)
+ being->setComment(comment);
+ Being::saveComment(mNick, comment, mType);
+ }
+ mDialog = nullptr;
+}
diff --git a/src/listeners/playerlistener.h b/src/listeners/playerlistener.h
new file mode 100644
index 000000000..85623fbd5
--- /dev/null
+++ b/src/listeners/playerlistener.h
@@ -0,0 +1,56 @@
+/*
+ * The ManaPlus Client
+ * 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_PLAYERLISTENER_H
+#define LISTENERS_PLAYERLISTENER_H
+
+#include "listeners/actionlistener.h"
+
+#include <string>
+
+#include "localconsts.h"
+
+class TextDialog;
+
+class PlayerListener : public ActionListener
+{
+ public:
+ PlayerListener();
+
+ A_DELETE_COPY(PlayerListener)
+
+ void action(const ActionEvent &event) override final;
+
+ void setNick(const std::string &name)
+ { mNick = name; }
+
+ void setDialog(TextDialog *const dialog)
+ { mDialog = dialog; }
+
+ void setType(const int type)
+ { mType = type; }
+
+ private:
+ std::string mNick;
+ TextDialog *mDialog;
+ int mType;
+};
+
+#endif // LISTENERS_PLAYERLISTENER_H