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