GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/popups/popupmenu.h Lines: 1 1 100.0 %
Date: 2021-03-17 Branches: 0 0 0.0 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2004-2009  The Mana World Development Team
4
 *  Copyright (C) 2009-2010  The Mana Developers
5
 *  Copyright (C) 2011-2019  The ManaPlus Developers
6
 *  Copyright (C) 2019-2021  Andrei Karas
7
 *
8
 *  This file is part of The ManaPlus Client.
9
 *
10
 *  This program is free software; you can redistribute it and/or modify
11
 *  it under the terms of the GNU General Public License as published by
12
 *  the Free Software Foundation; either version 2 of the License, or
13
 *  any later version.
14
 *
15
 *  This program is distributed in the hope that it will be useful,
16
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 *  GNU General Public License for more details.
19
 *
20
 *  You should have received a copy of the GNU General Public License
21
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
 */
23
24
#ifndef GUI_POPUPS_POPUPMENU_H
25
#define GUI_POPUPS_POPUPMENU_H
26
27
#ifndef DYECMD
28
29
#include "const/resources/item/cards.h"
30
31
#include "enums/inventorytype.h"
32
33
#include "enums/resources/servercommandtype.h"
34
35
#include "enums/simpletypes/beingid.h"
36
#include "enums/simpletypes/beingtypeid.h"
37
#include "enums/simpletypes/itemcolor.h"
38
39
#include "gui/widgets/linkhandler.h"
40
#include "gui/widgets/popup.h"
41
42
#include "listeners/playerlistener.h"
43
#include "listeners/renamelistener.h"
44
45
#include "localconsts.h"
46
47
class ActorSprite;
48
class Being;
49
class Button;
50
class ChatTab;
51
class FloorItem;
52
class Item;
53
class ListModel;
54
class MapItem;
55
class ProgressBar;
56
class ScrollArea;
57
class StaticBrowserBox;
58
class TextCommand;
59
class TextDialog;
60
class TextField;
61
class Window;
62
63
struct GroupInfo;
64
struct SkillInfo;
65
66
/**
67
 * Window showing popup menu.
68
 */
69
14
class PopupMenu final : public Popup, public LinkHandler
70
{
71
    public:
72
        /**
73
         * Constructor.
74
         */
75
        PopupMenu();
76
77
        A_DELETE_COPY(PopupMenu)
78
79
        void postInit() override final;
80
81
        /**
82
         * Shows the being related popup menu at the specified mouse coords.
83
         */
84
        void showPopup(const int x, const int y, const Being *const being);
85
86
        /**
87
         * Shows the beings related popup menu at the specified mouse coords.
88
         */
89
        void showPopup(const int x, const int y,
90
                       const STD_VECTOR<ActorSprite*> &beings);
91
92
        void showPlayerPopup(const std::string &nick);
93
94
        /**
95
         * Shows the floor item related popup menu at the specified
96
         * mouse coords.
97
         */
98
        void showPopup(const int x, const int y,
99
                       const FloorItem *const floorItem);
100
101
        /**
102
         * Shows the related popup menu when right click on the inventory
103
         * at the specified mouse coordinates.
104
         */
105
        void showPopup(Window *const parent,
106
                       const int x, const int y,
107
                       const Item *const item,
108
                       const InventoryTypeT type);
109
110
        void showPopup(const int x, const int y, Button *const button);
111
112
        void showPopup(const int x, const int y, const ProgressBar *const bar);
113
114
        void showPopup(const int x, const int y, MapItem *const mapItem);
115
116
        void showItemPopup(const int x,
117
                           const int y,
118
                           const Item *const item);
119
120
        void showItemPopup(const int x, const int y,
121
                           const int itemId,
122
                           const ItemColor color);
123
124
        void showDropPopup(const int x,
125
                           const int y,
126
                           const Item *const item);
127
128
        void showOutfitsWindowPopup(const int x, const int y);
129
130
        void showSpellPopup(const int x, const int y, TextCommand *const cmd);
131
132
        void showAttackMonsterPopup(const int x, const int y,
133
                                    const std::string &name,
134
                                    const int type);
135
136
        void showPickupItemPopup(const int x, const int y,
137
                                 const std::string &name);
138
139
        void showUndressPopup(const int x, const int y,
140
                              const Being *const being,
141
                              const Item *const item);
142
143
        void showMapPopup(const int x, const int y,
144
                          const int x2, const int y2,
145
                          const bool isMinimap);
146
147
        /**
148
         * Shows the related popup menu when right click on the chat
149
         * at the specified mouse coordinates.
150
         */
151
        void showChatPopup(const int x, const int y, ChatTab *const tab);
152
153
        void showChangePos(const int x, const int y);
154
155
        void showPopup(const int x, const int y, ListModel *const model);
156
157
        void showTextFieldPopup(TextField *const input);
158
159
        void showLinkPopup(const std::string &link);
160
161
        void showWindowsPopup();
162
163
        void showNpcDialogPopup(const BeingId npcId,
164
                                const int x, const int y);
165
166
        void showWindowPopup(Window *const window);
167
168
        void showSkillPopup(const SkillInfo *const info);
169
170
        void showSkillLevelPopup(const SkillInfo *const info);
171
172
        void showSkillTypePopup(const SkillInfo *const info);
173
174
        void showSkillOffsetPopup(const SkillInfo *const info,
175
                                  const bool isOffsetX);
176
177
        void showCraftPopup();
178
179
        void showEmoteType();
180
181
        void showPartyPopup();
182
183
        void showGuildPopup();
184
185
        void showAttackPopup();
186
187
        void showNavigationPopup();
188
189
        void showPickupPopup();
190
191
        void showPlayersPopup();
192
193
        void showFriendsPopup();
194
195
        /**
196
         * Handles link action.
197
         */
198
        void handleLink(const std::string &link,
199
                        MouseEvent *event A_UNUSED) override final;
200
201
        void clear() override final;
202
203
        void moveUp();
204
205
        void moveDown();
206
207
        void select();
208
209
    private:
210
        void initPopup();
211
212
        bool isAllowCommand(const ServerCommandTypeT command);
213
214
        bool isAllowOtherCommand(const ServerCommandTypeT command);
215
216
        void setMousePos();
217
218
        void setMousePos2();
219
220
        void addPlayerRelation(const std::string &name);
221
222
        void addFollow();
223
224
        void addBuySell(const Being *const being) A_NONNULL(2);
225
226
        void addParty(const std::string &nick);
227
228
        void addPartyName(const std::string &partyName);
229
230
        void addBuySellDefault();
231
232
        void addPlayerMisc();
233
234
        void addPickupFilter(const std::string &name);
235
236
        void addProtection();
237
238
        void addUse(const Item *const item) A_NONNULL(2);
239
240
        void addItemMenu(const Item *const item,
241
                         const InventoryTypeT type) A_NONNULL(2);
242
243
        void addDrop(const Item *const item,
244
                     const bool isProtected) A_NONNULL(2);
245
246
        void addGmCommands();
247
248
        void showMuteCommands();
249
250
        void showPlayerMenu();
251
252
        void showFloorItemGMCommands();
253
254
        void showItemGMCommands();
255
256
        void addNormalRelations();
257
258
        void addWindowMenu(const Window *const window);
259
260
        void showHomunGMCommands();
261
262
        void showPetGMCommands();
263
264
        void showMercenaryGMCommands();
265
266
        void addChat(const Being *const being);
267
268
        void addMailCommands();
269
270
        void addCatchPetCommands();
271
272
        void showGMPopup(const std::string &name);
273
274
        void showPlayerGMCommands(const std::string &name);
275
276
        void showNpcGMCommands();
277
278
        void showMonsterGMCommands();
279
280
        void showAdoptCommands();
281
282
        void addSocialMenu();
283
284
        bool addBeingMenu();
285
286
        StaticBrowserBox *mBrowserBox A_NONNULLPOINTER;
287
        ScrollArea *mScrollArea A_NONNULLPOINTER;
288
289
        BeingId mBeingId;
290
        BeingId mFloorItemId;
291
        int mItemId;
292
        int mItemIndex;
293
        int mItemCards[maxCards];
294
        ItemColor mItemColor;
295
        MapItem *mMapItem;
296
        ChatTab *mTab;
297
        TextCommand *mSpell;
298
        Window *mCallerWindow;
299
        RenameListener mRenameListener;
300
        PlayerListener mPlayerListener;
301
        TextDialog *mDialog;
302
        Button *mButton;
303
        const GroupInfo *mGroup;
304
        std::string mName;
305
        std::string mExtName;
306
        TextField *mTextField;
307
        ActorTypeT mType;
308
        BeingTypeId mSubType;
309
        int mX;
310
        int mY;
311
        bool mAllowCleanMenu;
312
313
        /**
314
         * Shared code for the various showPopup functions.
315
         */
316
        void showPopup(int x, int y);
317
};
318
319
extern PopupMenu *popupMenu;
320
321
#endif  // DYE_CMD
322
#endif  // GUI_POPUPS_POPUPMENU_H