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 |
|
|
|
42 |
|
|
impHandler0(targetPlayer) |
43 |
|
|
{ |
44 |
|
|
return setTarget(ActorType::Player, AllowSort_true); |
45 |
|
|
} |
46 |
|
|
|
47 |
|
|
impHandler0(targetMonster) |
48 |
|
|
{ |
49 |
|
|
return setTarget(ActorType::Monster, AllowSort_true); |
50 |
|
|
} |
51 |
|
|
|
52 |
|
|
impHandler0(targetClosestMonster) |
53 |
|
|
{ |
54 |
|
|
return setTarget(ActorType::Monster, AllowSort_false); |
55 |
|
|
} |
56 |
|
|
|
57 |
|
|
impHandler0(targetNPC) |
58 |
|
|
{ |
59 |
|
|
return setTarget(ActorType::Npc, AllowSort_true); |
60 |
|
|
} |
61 |
|
|
|
62 |
|
|
impHandler0(targetMercenary) |
63 |
|
|
{ |
64 |
|
|
return setTarget(ActorType::Mercenary, AllowSort_true); |
65 |
|
|
} |
66 |
|
|
|
67 |
|
|
impHandler0(targetSkillUnit) |
68 |
|
|
{ |
69 |
|
|
return setTarget(ActorType::SkillUnit, AllowSort_true); |
70 |
|
|
} |
71 |
|
|
|
72 |
|
|
impHandler0(targetPet) |
73 |
|
|
{ |
74 |
|
|
return setTarget(ActorType::Pet, AllowSort_true); |
75 |
|
|
} |
76 |
|
|
|
77 |
|
|
impHandler0(contextMenu) |
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 |
|
2 |
} // namespace Actions |