1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
|
/*
* The ManaPlus Client
* Copyright (C) 2012-2017 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/windows.h"
#include "actormanager.h"
#include "actions/actiondef.h"
#include "being/localplayer.h"
#include "gui/dialogsmanager.h"
#include "gui/windows/bankwindow.h"
#include "gui/windows/skilldialog.h"
#include "gui/windows/socialwindow.h"
#include "gui/windows/statuswindow.h"
#include "gui/windows/questswindow.h"
#include "gui/windows/whoisonline.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/mailwindow.h"
#include "gui/windows/minimap.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/chat/chattab.h"
#include "utils/gettext.h"
#include "net/net.h"
#include "debug.h"
extern ShortcutWindow *spellShortcutWindow;
namespace Actions
{
impHandler0(setupWindowShow)
{
if (setupWindow != nullptr)
{
if (setupWindow->isWindowVisible())
{
setupWindow->doCancel();
}
else
{
setupWindow->setVisible(Visible_true);
setupWindow->requestMoveToTop();
}
return true;
}
return false;
}
impHandler0(hideWindows)
{
if (setupWindow != nullptr)
setupWindow->hideWindows();
return true;
}
static bool showHelpPage(const std::string &page, const bool showHide)
{
if (helpWindow != nullptr)
{
if (showHide && helpWindow->isWindowVisible())
{
helpWindow->setVisible(Visible_false);
}
else
{
helpWindow->loadHelp(page);
helpWindow->requestMoveToTop();
}
return true;
}
return false;
}
impHandler(helpWindowShow)
{
if ((chatWindow == nullptr) || !chatWindow->isInputFocused())
return showHelpPage("index", true);
if (event.tab == nullptr)
return showHelpPage("chatcommands", true);
switch (event.tab->getType())
{
case ChatTabType::PARTY:
return showHelpPage("chatparty", true);
case ChatTabType::GUILD:
return showHelpPage("chatguild", true);
case ChatTabType::WHISPER:
return showHelpPage("chatwhisper", true);
case ChatTabType::DEBUG:
return showHelpPage("chatdebug", true);
case ChatTabType::TRADE:
return showHelpPage("chattrade", true);
case ChatTabType::BATTLE:
return showHelpPage("chatbattle", true);
case ChatTabType::LANG:
return showHelpPage("chatlang", true);
case ChatTabType::GM:
return showHelpPage("chatgm", true);
case ChatTabType::CHANNEL:
return showHelpPage("chatchannel", true);
default:
case ChatTabType::UNKNOWN:
case ChatTabType::INPUT:
return showHelpPage("chatcommands", true);
}
}
impHandler0(aboutWindowShow)
{
return showHelpPage("about", false);
}
static void showHideWindow(Window *const window)
{
if (window != nullptr)
{
window->setVisible(fromBool(
!window->isWindowVisible(), Visible));
if (window->isWindowVisible())
window->requestMoveToTop();
}
}
impHandler0(statusWindowShow)
{
showHideWindow(statusWindow);
return true;
}
impHandler0(inventoryWindowShow)
{
showHideWindow(inventoryWindow);
return true;
}
impHandler0(equipmentWindowShow)
{
showHideWindow(equipmentWindow);
return true;
}
impHandler0(skillDialogShow)
{
showHideWindow(skillDialog);
return true;
}
impHandler0(minimapWindowShow)
{
if (minimap != nullptr)
{
minimap->toggle();
return true;
}
return false;
}
impHandler0(chatWindowShow)
{
showHideWindow(chatWindow);
return true;
}
impHandler0(shortcutWindowShow)
{
showHideWindow(itemShortcutWindow);
return true;
}
impHandler0(debugWindowShow)
{
showHideWindow(debugWindow);
return true;
}
impHandler0(socialWindowShow)
{
showHideWindow(socialWindow);
return true;
}
impHandler0(emoteShortcutWindowShow)
{
showHideWindow(emoteShortcutWindow);
return true;
}
impHandler0(outfitWindowShow)
{
showHideWindow(outfitWindow);
return true;
}
impHandler0(shopWindowShow)
{
showHideWindow(shopWindow);
return true;
}
impHandler0(dropShortcutWindowShow)
{
showHideWindow(dropShortcutWindow);
return true;
}
impHandler0(killStatsWindowShow)
{
showHideWindow(killStats);
return true;
}
impHandler0(spellShortcutWindowShow)
{
showHideWindow(spellShortcutWindow);
return true;
}
impHandler0(whoIsOnlineWindowShow)
{
showHideWindow(whoIsOnline);
return true;
}
impHandler0(didYouKnowWindowShow)
{
showHideWindow(didYouKnowWindow);
return true;
}
impHandler0(questsWindowShow)
{
showHideWindow(questsWindow);
return true;
}
impHandler0(bankWindowShow)
{
#ifdef TMWA_SUPPORT
if (Net::getNetworkType() == ServerType::TMWATHENA)
return false;
#endif // TMWA_SUPPORT
showHideWindow(bankWindow);
return true;
}
impHandler0(cartWindowShow)
{
if (Net::getNetworkType() == ServerType::TMWATHENA ||
(localPlayer == nullptr) ||
!localPlayer->getHaveCart())
{
return false;
}
showHideWindow(cartWindow);
if (inventoryWindow != nullptr)
inventoryWindow->updateDropButton();
return true;
}
impHandler0(updaterWindowShow)
{
if (updaterWindow != nullptr)
updaterWindow->deleteSelf();
else
DialogsManager::createUpdaterWindow();
return true;
}
impHandler0(quickWindowShow)
{
if (setupWindow != nullptr)
{
if (setupWindow->isWindowVisible())
setupWindow->doCancel();
setupWindow->setVisible(Visible_true);
// TRANSLATORS: settings tab name
setupWindow->activateTab(_("Quick"));
setupWindow->requestMoveToTop();
return true;
}
return false;
}
impHandler0(mailWindowShow)
{
showHideWindow(mailWindow);
return true;
}
impHandler(showItems)
{
const std::string args = event.args;
if (args.empty())
return false;
Being *being = nullptr;
if (args[0] == ':')
{
being = actorManager->findBeing(fromInt(atoi(
args.substr(1).c_str()), BeingId));
if ((being != nullptr) && being->getType() == ActorType::Monster)
being = nullptr;
}
else
{
being = actorManager->findBeingByName(args, ActorType::Player);
}
if (being == nullptr)
return true;
if (being == localPlayer)
{
if (equipmentWindow != nullptr &&
!equipmentWindow->isWindowVisible())
{
equipmentWindow->setVisible(Visible_true);
}
}
else
{
if (beingEquipmentWindow != nullptr)
{
beingEquipmentWindow->setBeing(being);
beingEquipmentWindow->setVisible(Visible_true);
}
}
return true;
}
} // namespace Actions
|