ManaPlus
target.cpp
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2012-2019 The ManaPlus Developers
4  * Copyright (C) 2019-2021 Andrei Karas
5  *
6  * This file is part of The ManaPlus Client.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #include "actions/target.h"
23 
24 #include "actions/actiondef.h"
25 
26 #include "being/localplayer.h"
27 
28 #include "gui/popups/popupmenu.h"
29 
30 #include "debug.h"
31 
32 namespace Actions
33 {
34 
35 static bool setTarget(const ActorTypeT type, const AllowSort allowSort)
36 {
37  if (localPlayer != nullptr)
38  return localPlayer->setNewTarget(type, allowSort) != nullptr;
39  return false;
40 }
41 
43 {
45 }
46 
48 {
50 }
51 
53 {
55 }
56 
58 {
60 }
61 
63 {
65 }
66 
68 {
70 }
71 
73 {
75 }
76 
78 {
79  if (localPlayer == nullptr)
80  return false;
81  const Being *const target = localPlayer->getTarget();
82  if (target == nullptr)
83  return true;
84 
85  popupMenu->showPopup(target->getPixelX(),
86  target->getPixelY(),
87  target);
88  return true;
89 }
90 
91 } // namespace Actions
#define impHandler0(name)
Definition: actiondef.h:34
ActorType ::T ActorTypeT
Definition: actortype.h:43
const bool AllowSort_true
Definition: allowsort.h:30
const bool AllowSort_false
Definition: allowsort.h:30
bool AllowSort
Definition: allowsort.h:30
virtual int getPixelY() const
Definition: actor.h:93
int getPixelX() const
Definition: actor.h:87
Definition: being.h:96
Being * getTarget() const
Being * setNewTarget(const ActorTypeT type, const AllowSort allowSort)
void showPopup(const int x, const int y, const Being *const being)
Definition: popupmenu.cpp:203
LocalPlayer * localPlayer
bool targetPet(InputEvent &event)
Definition: target.cpp:36
bool targetPlayer(InputEvent &event)
Definition: target.cpp:31
bool targetMercenary(InputEvent &event)
Definition: target.cpp:35
bool targetSkillUnit(InputEvent &event)
Definition: target.cpp:37
bool targetMonster(InputEvent &event)
Definition: target.cpp:32
bool targetNPC(InputEvent &event)
Definition: target.cpp:34
bool setTarget(InputEvent &event)
Definition: commands.cpp:45
bool contextMenu(InputEvent &event)
Definition: target.cpp:38
bool targetClosestMonster(InputEvent &event)
Definition: target.cpp:33
@ Mercenary
Definition: actortype.h:38
@ SkillUnit
Definition: actortype.h:40
PopupMenu * popupMenu
Definition: popupmenu.cpp:103