GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/widgets/tabs/setup_chat.cpp Lines: 114 122 93.4 %
Date: 2021-03-17 Branches: 221 448 49.3 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2009  The Mana World Development Team
4
 *  Copyright (C) 2011-2019  The ManaPlus Developers
5
 *  Copyright (C) 2009-2021  Andrei Karas
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
#include "gui/widgets/tabs/setup_chat.h"
24
25
#include "gui/windows/chatwindow.h"
26
27
#include "gui/widgets/containerplacer.h"
28
#include "gui/widgets/layouthelper.h"
29
#include "gui/widgets/scrollarea.h"
30
#include "gui/widgets/setupitem.h"
31
32
#include "utils/gettext.h"
33
34
#include "debug.h"
35
36
2
Setup_Chat::Setup_Chat(const Widget2 *const widget) :
37
2
    SetupTabScroll(widget)
38
{
39
    // TRANSLATORS: settings tab name
40
8
    setName(_("Chat"));
41
42
    // Do the layout
43
4
    LayoutHelper h(this);
44
2
    ContainerPlacer place = h.getPlacer(0, 0);
45
2
    place(0, 0, mScroll, 10, 10);
46
47
    // TRANSLATORS: settings group
48
2
    new SetupItemLabel(_("Window"), "", this,
49


12
        Separator_true);
50
51
    // TRANSLATORS: settings option
52
2
    new SetupItemCheckBox(_("Auto hide chat window"),
53
        // TRANSLATORS: settings description
54
2
        _("Chat window will be automatically hidden when not in use.\n\n"
55
        "Hit Enter or hover mouse to show chat again."),
56
        "autohideChat", this, "autohideChatEvent",
57



24
        MainConfig_true);
58
59
    // TRANSLATORS: settings option
60
2
    new SetupItemCheckBox(_("Protect chat focus"),
61
        // TRANSLATORS: settings description
62
2
        _("Enables aggressive protection of input focus in chat window.\n\n"
63
        "Note: no other text inputs will be allowed to receive text input "
64
        "when you typing in chat window."),
65
        "protectChatFocus", this, "protectChatFocusEvent",
66



24
        MainConfig_true);
67
68
69
    // TRANSLATORS: settings group
70
2
    new SetupItemLabel(_("Colors"), "", this,
71


12
        Separator_true);
72
73
    // TRANSLATORS: settings option
74
2
    new SetupItemCheckBox(_("Remove colors from received chat messages"),
75
        // TRANSLATORS: settings description
76
2
        _("Enable this setting to strip colors from incoming chat messages. "
77
        "All messages will use default chat text color if this enabled."),
78
        "removeColors", this, "removeColorsEvent",
79



24
        MainConfig_true);
80
81
    // TRANSLATORS: settings option
82
2
    new SetupItemCheckBox(_("Show chat colors list"),
83
        // TRANSLATORS: settings description
84
2
        _("Enable this setting to show color selection drop-down in chat "
85
        "window. Chat window will display color selection drop-down.\n\n"
86
        "It allows one to select default color of outgoing chat messages "
87
        "easily, but also occupies some space in chat window."),
88
        "showChatColorsList", this, "showChatColorsListEvent",
89



24
        MainConfig_true);
90
91
92
    // TRANSLATORS: settings option
93
2
    new SetupItemLabel(_("Commands"), "", this,
94


12
        Separator_true);
95
96
    // TRANSLATORS: settings option
97
2
    new SetupItemCheckBox(_("Allow magic and GM commands in all chat tabs"),
98
        // TRANSLATORS: settings description
99
2
        _("Enable this setting to be able to type spells and GM commands in "
100
        "any tab."),
101
        "allowCommandsInChatTabs", this, "allowCommandsInChatTabsEvent",
102



24
        MainConfig_true);
103
104
105
    // TRANSLATORS: settings group
106
2
    new SetupItemLabel(_("Limits"), "", this,
107


12
        Separator_true);
108
109
    // TRANSLATORS: settings option
110
2
    new SetupItemIntTextField(_("Limit max chars in chat line"),
111
        // TRANSLATORS: settings description
112
2
        _("Limits how many characters will be shown in longest lines "
113
        "of text displayed in chat.\n\n"
114
        "Note: long lines can make client slower. Lines longer than this "
115
        "limit will be truncated."),
116
        "chatMaxCharLimit", this, "chatMaxCharLimitEvent", 0, 500,
117



24
        MainConfig_true);
118
119
    // TRANSLATORS: settings option
120
2
    new SetupItemIntTextField(_("Limit max lines in chat"),
121
        // TRANSLATORS: settings description
122
2
        _("Limits how many lines chat will keep in scrollback buffer. Chat "
123
        "keeps specified number of last lines of text. Oldest lines exceeding "
124
        "this limit are discarded from scrollback buffer.\n\n"
125
        "Note: keeping too many lines in scroll buffer can slow client down."),
126
        "chatMaxLinesLimit", this, "chatMaxLinesLimitEvent", 0, 500,
127



24
        MainConfig_true);
128
129
130
    // TRANSLATORS: settings group
131
    new SetupItemLabel(_("Logs"), "", this,
132


12
        Separator_true);
133
134
    // TRANSLATORS: settings option
135
2
    new SetupItemCheckBox(_("Enable chat Log"),
136
        // TRANSLATORS: settings description
137
2
        _("If you enable this setting, chat logs will be written to disk.\n\n"
138
        "Note: chat logs can take noticeable amount of disk space over time."),
139
        "enableChatLog", this, "enableChatLogEvent",
140



24
        MainConfig_true);
141
142
    // TRANSLATORS: settings option
143
2
    new SetupItemCheckBox(_("Enable debug chat Log"),
144
        // TRANSLATORS: settings description
145
2
        _("If you enable this, debug chat tab also will be logged to disk."),
146
        "enableDebugLog", this, "enableDebugLogEvent",
147



24
        MainConfig_true);
148
149
    // TRANSLATORS: settings option
150
2
    new SetupItemCheckBox(_("Show chat history"),
151
        // TRANSLATORS: settings description
152
2
        _("If this setting enabled, client will load old chat tabs content "
153
         "from logs on startup instead of starting with empty chat tabs."),
154
        "showChatHistory", this, "showChatHistoryEvent",
155



24
        MainConfig_true);
156
157
    // TRANSLATORS: settings option
158
2
    new SetupItemCheckBox(_("Show party online messages"),
159
        // TRANSLATORS: settings description
160
2
        _("If this setting is enabled, online status changes of party members"
161
        " will be shown in party tab of chat.\n\nThis adds some extra noise "
162
        "to chat, but allows one to see when your buddies are coming online."),
163
        "showPartyOnline", this, "showPartyOnlineEvent",
164



24
        MainConfig_true);
165
166
    // TRANSLATORS: settings option
167
2
    new SetupItemCheckBox(_("Show guild online messages"),
168
        // TRANSLATORS: settings description
169
2
        _("If this setting is enabled, online status changes of guild members"
170
        " will be shown in guild tab of chat.\n\nThis adds some extra noise "
171
        "to chat, but allows one to see when your buddies are coming online."),
172
        "showGuildOnline", this, "showGuildOnlineEvent",
173



24
        MainConfig_true);
174
175
176
    // TRANSLATORS: settings group
177
2
    new SetupItemLabel(_("Messages"), "", this,
178


12
        Separator_true);
179
180
    // TRANSLATORS: settings option
181
2
    new SetupItemCheckBox(_("Hide shop messages"),
182
        // TRANSLATORS: settings description
183
2
        _("If this setting enabled, no messages related to built-in ManaPlus "
184
        "shop will be displayed in chat. Disable this setting if you want "
185
        "to see shop-related messages.\n\nNote: technically, ManaPlus shop "
186
        "implemented as usual private messages with special content. If you "
187
        "disable this setting, you will be able to see these messages and get "
188
        "idea when other players are looking at your shop."),
189
        "hideShopMessages", this, "hideShopMessagesEvent",
190



24
        MainConfig_true);
191
192
    // TRANSLATORS: settings option
193
2
    new SetupItemCheckBox(_("Show MVP messages"),
194
        // TRANSLATORS: settings description
195
2
        _("Enable this setting to see MVP messages from server.\n\n"
196
        "Note: MVP messages are not used on TMW/Evol/etc servers, so this "
197
        "feature usually makes little difference."),
198
        "showMVP", this, "showMVPEvent",
199



24
        MainConfig_true);
200
201
202
    // TRANSLATORS: settings group
203
2
    new SetupItemLabel(_("Tabs"), "", this,
204


12
        Separator_true);
205
206
    // TRANSLATORS: settings option
207
2
    new SetupItemCheckBox(_("Put all whispers in tabs"),
208
        // TRANSLATORS: settings description
209
2
        _("If this setting enabled, all whispers (private messages) will "
210
        "be placed in separate tabs, separate tab for each player. If this "
211
        "setting disabled, all whispers will appear in General tab.\n\n"
212
        "Note: putting all whispers to single General tab is known to be "
213
        "confusing. Think twice before disabling this feature."),
214
        "whispertab", this, "whispertabEvent",
215



24
        MainConfig_true);
216
217
    // TRANSLATORS: settings option
218
2
    new SetupItemCheckBox(_("Log magic messages in debug tab"),
219
        // TRANSLATORS: settings description
220
2
        _("If this setting is enabled, spell invocation will be shown in "
221
        "Debug tab. If disabled, it will be shown in General tab instead.\n\n"
222
        "Note: it does not affects server replies related to spells."),
223
        "showMagicInDebug", this, "showMagicInDebugEvent",
224



24
        MainConfig_true);
225
226
    // TRANSLATORS: settings option
227
2
    new SetupItemCheckBox(_("Show server messages in debug tab"),
228
        // TRANSLATORS: settings description
229
2
        _("If this setting is enabled, server messages will be shown in "
230
        "Debug tab of chat. If disabled, server messages will appear in "
231
        "General chat instead.\n\nNote: according to 4144, disabling this "
232
        "could also make you to lose some debug messages from client in "
233
        "Debug tab since these are fake server messages."),
234
        "serverMsgInDebug", this, "serverMsgInDebugEvent",
235



24
        MainConfig_true);
236
237
    // TRANSLATORS: settings option
238
2
    new SetupItemCheckBox(_("Enable trade tab"),
239
        // TRANSLATORS: settings description
240
2
        _("Enables trade tab. Trade tab is basically some filter. Messages "
241
        "containing words typical for trades will go to Trade tab. This "
242
        "will make General tab less noisy. If this setting is disabled, all "
243
        "trade related players messages will stay in General tab."),
244
        "enableTradeTab", this, "enableTradeTabEvent",
245



24
        MainConfig_true);
246
247
    // TRANSLATORS: settings option
248
2
    new SetupItemCheckBox(_("Enable gm tab"),
249
        // TRANSLATORS: settings description
250
2
        _("If enabled, GM tab will appear in chat. It displays text related "
251
        "GM activity.\n\nNote: this setting only makes difference for "
252
        "GMs (Game Masters) since this tab only appears for GMs."),
253
        "enableGmTab", this, "enableGmTabEvent",
254



24
        MainConfig_true);
255
256
    // TRANSLATORS: settings option
257
2
    new SetupItemCheckBox(_("Enable language tab"),
258
        // TRANSLATORS: settings description
259
2
        _("If this feature enabled, language tab will appear if server "
260
        "supports this feature.\n\nNote: only supported by Evol server yet."),
261
        "enableLangTab", this, "enableLangTabEvent",
262



24
        MainConfig_false);
263
264
    // TRANSLATORS: settings option
265
2
    new SetupItemCheckBox(_("Show all languages messages"),
266
        // TRANSLATORS: settings description
267
2
        _("If this setting enabled and server supports different chats "
268
        "for different languages, you will see messages for all languages, "
269
        "regardless of your language preferences.\n\nNote: it only works "
270
        "on servers supporting language tabs feature, like Evol."),
271
        "showAllLang", this, "showAllLangEvent",
272



24
        MainConfig_false);
273
274
    // TRANSLATORS: settings option
275
2
    new SetupItemCheckBox(_("Enable battle tab"),
276
        // TRANSLATORS: settings description
277
2
        _("If this setting enabled, Battle tab will appear in chat. This "
278
        "tab will contain messages related to battles, like damage and "
279
        "experience gain, if battle messages are enabled.\n\n"
280
        "Note: client restart required to take effect."),
281
        "enableBattleTab", this, "enableBattleTabEvent",
282



24
        MainConfig_true);
283
284
    // TRANSLATORS: settings option
285
2
    new SetupItemCheckBox(_("Show battle events"),
286
        // TRANSLATORS: settings description
287
2
        _("If this setting enabled, messages related to battle like damage "
288
        "or experience gain will be displayed in Debug or Battle tab. If "
289
        "disabled, no battle messages will be displayed."),
290
        "showBattleEvents", this, "showBattleEventsEvent",
291



24
        MainConfig_true);
292
293
    // TRANSLATORS: settings option
294
2
    new SetupItemCheckBox(_("Resize chat tabs if need"),
295
        // TRANSLATORS: settings description
296
2
        _("If this feature enabled, text in chat will be automatically "
297
        "adjusted to adapt to appearance of chat input field when you "
298
        "typing message and when input field of chat disappears. If disabled, "
299
        "chat input area will always occupy its place, which could be "
300
        "otherwise usable for text.\n\n"
301
        "Note: its mostly about jumpy attitude vs "
302
        "less usable space for text."),
303
        "hideChatInput", this, "hideChatInputEvent",
304



24
        MainConfig_true);
305
306
    // TRANSLATORS: settings option
307
2
    new SetupItemCheckBox(_("Enable trade spam filter"),
308
        "", "enableTradeFilter", this, "enableTradeFilterEvent",
309



24
        MainConfig_true);
310
311
312
    // TRANSLATORS: settings group
313
2
    new SetupItemLabel(_("Time"), "", this,
314


12
        Separator_true);
315
316
    // TRANSLATORS: settings option
317
2
    new SetupItemCheckBox(_("Use local time"),
318
        // TRANSLATORS: settings description
319
2
        _("If this feature enabled, timestamps in chat will use local times. "
320
        "If disabled, server time will be used (often it is GMT+0)."),
321
        "useLocalTime", this, "useLocalTimeEvent",
322



24
        MainConfig_true);
323
324
    // TRANSLATORS: settings group
325
2
    new SetupItemLabel(_("Other"), "", this,
326


12
        Separator_true);
327
328
    // TRANSLATORS: settings option
329
2
    new SetupItemTextField(_("Highlight words (separated by comma)"),
330
        // TRANSLATORS: settings description
331
2
        _("Here you can specify some extra words which will also cause "
332
        "highlighting. Use comma to separate words.\n\nNote: frequent "
333
        "highlights are annoying - use it with caution."),
334
        "highlightWords", this, "highlightWordsEvent",
335



24
        MainConfig_true, UseBase64_false);
336
337
    // TRANSLATORS: settings option
338
2
    new SetupItemTextField(_("Globals ignore names (separated by comma)"),
339
        // TRANSLATORS: settings description
340
2
        _("This setting allows you to ignore some global messages if "
341
        "particular sender (NPC, GM) annoys you too much. Global will be "
342
        "moved to Debug instead.\n\nNote: careless use of this feature can "
343
        "make you to miss important announces!"),
344
        "globalsFilter", this, "globalsFilterEvent",
345



24
        MainConfig_true, UseBase64_false);
346
347
    // TRANSLATORS: settings option
348
2
    new SetupItemCheckBox(_("Show emotes button in chat"),
349
        // TRANSLATORS: settings description
350
2
        _("If this setting enabled, button will appear near text input "
351
        "field. This button allows one to invoke composing window, which "
352
        "allows one to insert smiles and text formatting easily.\n\n"
353
        "Note: same window can also be invoked by hotkey when typing, usually "
354
        "F1 by default."),
355
        "showEmotesButton", this, "showEmotesButtonEvent",
356



24
        MainConfig_true);
357
358
    // TRANSLATORS: settings option
359
2
    new SetupItemCheckBox(_("Show motd server message on start"),
360
        // TRANSLATORS: settings description
361
2
        _("If this setting enabled, client will display server MOTD (message"
362
        " of the day) once you connect to server. Disable it to hide MOTD."),
363
        "showmotd", this, "showmotdEvent",
364



26
        MainConfig_true);
365
366
2
    setDimension(Rect(0, 0, 550, 350));
367
2
}
368
369
void Setup_Chat::apply()
370
{
371
    SetupTabScroll::apply();
372
373
    if (chatWindow != nullptr)
374
    {
375
        chatWindow->adjustTabSize();
376
        chatWindow->parseHighlights();
377
    }
378
}
379
380
void Setup_Chat::externalUpdated()
381
{
382
    reread("enableLangTab");
383
    reread("showAllLang");
384
}