summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-08-21 20:30:08 +0300
committerAndrei Karas <akaras@inbox.ru>2014-08-21 20:30:08 +0300
commitf59b0da2f59aff64802e0211ceaa67e50e85e05c (patch)
tree9f3f198827b5a5209bfa2bd154c7b79c7f53bc33 /src
parent6bedc289455528fe609f492cd9f1a0c352d981bb (diff)
downloadmv-f59b0da2f59aff64802e0211ceaa67e50e85e05c.tar.gz
mv-f59b0da2f59aff64802e0211ceaa67e50e85e05c.tar.bz2
mv-f59b0da2f59aff64802e0211ceaa67e50e85e05c.tar.xz
mv-f59b0da2f59aff64802e0211ceaa67e50e85e05c.zip
Move target related actions into separate file.
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/actions/actions.cpp35
-rw-r--r--src/actions/actions.h4
-rw-r--r--src/actions/target.cpp127
-rw-r--r--src/actions/target.h38
-rw-r--r--src/input/inputactionmap.h1
7 files changed, 170 insertions, 39 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 1850702d7..b452aa63e 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -724,6 +724,8 @@ SET(SRCS
actions/statusbar.h
actions/tabs.cpp
actions/tabs.h
+ actions/target.cpp
+ actions/target.h
actions/windows.cpp
actions/windows.h
being/actor.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index 7a6eba376..5454f5e55 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -842,6 +842,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
actions/statusbar.h \
actions/tabs.cpp \
actions/tabs.h \
+ actions/target.cpp \
+ actions/target.h \
actions/windows.cpp \
actions/windows.h \
being/actor.cpp \
diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp
index 926b0e48a..4fb6c7e1d 100644
--- a/src/actions/actions.cpp
+++ b/src/actions/actions.cpp
@@ -427,41 +427,6 @@ impHandler0(targetAttack)
return false;
}
-static bool setTarget(const ActorType::Type type, const bool allowSort)
-{
- if (actorManager && localPlayer)
- {
- Being *const target = actorManager->findNearestLivingBeing(
- localPlayer, 20, type, allowSort);
-
- if (target && target != localPlayer->getTarget())
- localPlayer->setTarget(target);
-
- return true;
- }
- return false;
-}
-
-impHandler0(targetPlayer)
-{
- return setTarget(ActorType::PLAYER, true);
-}
-
-impHandler0(targetMonster)
-{
- return setTarget(ActorType::MONSTER, true);
-}
-
-impHandler0(targetClosestMonster)
-{
- return setTarget(ActorType::MONSTER, false);
-}
-
-impHandler0(targetNPC)
-{
- return setTarget(ActorType::NPC, true);
-}
-
impHandler0(safeVideoMode)
{
if (mainGraphics)
diff --git a/src/actions/actions.h b/src/actions/actions.h
index 36a83d1d3..b88fefc7d 100644
--- a/src/actions/actions.h
+++ b/src/actions/actions.h
@@ -49,10 +49,6 @@ namespace Actions
decHandler(untarget);
decHandler(attack);
decHandler(targetAttack);
- decHandler(targetPlayer);
- decHandler(targetMonster);
- decHandler(targetClosestMonster);
- decHandler(targetNPC);
decHandler(safeVideoMode);
decHandler(stopSit);
decHandler(showKeyboard);
diff --git a/src/actions/target.cpp b/src/actions/target.cpp
new file mode 100644
index 000000000..e183a6a2c
--- /dev/null
+++ b/src/actions/target.cpp
@@ -0,0 +1,127 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2012-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 "actions/target.h"
+
+#include "actormanager.h"
+#include "dropshortcut.h"
+#include "emoteshortcut.h"
+#include "game.h"
+#include "itemshortcut.h"
+#include "soundmanager.h"
+
+#include "actions/actiondef.h"
+
+#include "being/attributes.h"
+#include "being/localplayer.h"
+#include "being/playerinfo.h"
+#include "being/playerrelations.h"
+
+#include "gui/dialogsmanager.h"
+#include "gui/gui.h"
+#include "gui/popupmanager.h"
+#include "gui/sdlinput.h"
+#include "gui/viewport.h"
+
+#include "gui/popups/popupmenu.h"
+
+#include "gui/windows/skilldialog.h"
+#include "gui/windows/socialwindow.h"
+#include "gui/windows/statuswindow.h"
+#include "gui/windows/tradewindow.h"
+#include "gui/windows/questswindow.h"
+#include "gui/windows/quitdialog.h"
+#include "gui/windows/whoisonline.h"
+#include "gui/windows/botcheckerwindow.h"
+#include "gui/windows/buyselldialog.h"
+#include "gui/windows/chatwindow.h"
+#include "gui/windows/debugwindow.h"
+#include "gui/windows/didyouknowwindow.h"
+#include "gui/windows/equipmentwindow.h"
+#include "gui/windows/helpwindow.h"
+#include "gui/windows/inventorywindow.h"
+#include "gui/windows/killstats.h"
+#include "gui/windows/minimap.h"
+#include "gui/windows/npcdialog.h"
+#include "gui/windows/outfitwindow.h"
+#include "gui/windows/setupwindow.h"
+#include "gui/windows/shopwindow.h"
+#include "gui/windows/shortcutwindow.h"
+#include "gui/windows/updaterwindow.h"
+
+#include "gui/widgets/tabs/chattab.h"
+
+#include "render/graphics.h"
+
+#include "net/net.h"
+#include "net/playerhandler.h"
+#include "net/tradehandler.h"
+
+#include "listeners/updatestatuslistener.h"
+
+#include "resources/map/map.h"
+
+#include "utils/gettext.h"
+
+#include "debug.h"
+
+extern ShortcutWindow *spellShortcutWindow;
+extern std::string tradePartnerName;
+extern QuitDialog *quitDialog;
+
+namespace Actions
+{
+
+static bool setTarget(const ActorType::Type type, const bool allowSort)
+{
+ if (actorManager && localPlayer)
+ {
+ Being *const target = actorManager->findNearestLivingBeing(
+ localPlayer, 20, type, allowSort);
+
+ if (target && target != localPlayer->getTarget())
+ localPlayer->setTarget(target);
+
+ return true;
+ }
+ return false;
+}
+
+impHandler0(targetPlayer)
+{
+ return setTarget(ActorType::PLAYER, true);
+}
+
+impHandler0(targetMonster)
+{
+ return setTarget(ActorType::MONSTER, true);
+}
+
+impHandler0(targetClosestMonster)
+{
+ return setTarget(ActorType::MONSTER, false);
+}
+
+impHandler0(targetNPC)
+{
+ return setTarget(ActorType::NPC, true);
+}
+
+} // namespace Actions
diff --git a/src/actions/target.h b/src/actions/target.h
new file mode 100644
index 000000000..0b4bea943
--- /dev/null
+++ b/src/actions/target.h
@@ -0,0 +1,38 @@
+/*
+ * 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 ACTIONS_TARGET_H
+#define ACTIONS_TARGET_H
+
+#define decHandler(name) bool name(const InputEvent &event)
+
+struct InputEvent;
+
+namespace Actions
+{
+ decHandler(targetPlayer);
+ decHandler(targetMonster);
+ decHandler(targetClosestMonster);
+ decHandler(targetNPC);
+} // namespace Actions
+
+#undef decHandler
+
+#endif // ACTIONS_TARGET_H
diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h
index 29c4b9448..ac1cca9cf 100644
--- a/src/input/inputactionmap.h
+++ b/src/input/inputactionmap.h
@@ -30,6 +30,7 @@
#include "actions/move.h"
#include "actions/statusbar.h"
#include "actions/tabs.h"
+#include "actions/target.h"
#include "actions/windows.h"
#include "input/inputaction.h"