GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/widgets/tabs/setup_chat.cpp Lines: 106 114 93.0 %
Date: 2017-11-29 Branches: 221 452 48.9 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2009  The Mana World Development Team
4
 *  Copyright (C) 2009-2010  Andrei Karas
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
#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
4
Setup_Chat::Setup_Chat(const Widget2 *const widget) :
37
4
    SetupTabScroll(widget)
38
{
39
    // TRANSLATORS: settings tab name
40
20
    setName(_("Chat"));
41
42
    // Do the layout
43
8
    LayoutHelper h(this);
44
4
    ContainerPlacer place = h.getPlacer(0, 0);
45
4
    place(0, 0, mScroll, 10, 10);
46
47
    // TRANSLATORS: settings group
48


28
    new SetupItemLabel(_("Window"), "", this);
49
50
    // TRANSLATORS: settings option
51


52
    new SetupItemCheckBox(_("Auto hide chat window"),
52
        // TRANSLATORS: settings description
53
4
        _("Chat window will be automatically hidden when not in use.\n\n"
54
        "Hit Enter or hover mouse to show chat again."),
55

4
        "autohideChat", this, "autohideChatEvent");
56
57
    // TRANSLATORS: settings option
58


52
    new SetupItemCheckBox(_("Protect chat focus"),
59
        // TRANSLATORS: settings description
60
4
        _("Enables aggressive protection of input focus in chat window.\n\n"
61
        "Note: no other text inputs will be allowed to receive text input "
62
        "when you typing in chat window."),
63

4
        "protectChatFocus", this, "protectChatFocusEvent");
64
65
66
    // TRANSLATORS: settings group
67


28
    new SetupItemLabel(_("Colors"), "", this);
68
69
    // TRANSLATORS: settings option
70


52
    new SetupItemCheckBox(_("Remove colors from received chat messages"),
71
        // TRANSLATORS: settings description
72
4
        _("Enable this setting to strip colors from incoming chat messages. "
73
        "All messages will use default chat text color if this enabled."),
74

4
        "removeColors", this, "removeColorsEvent");
75
76
    // TRANSLATORS: settings option
77


52
    new SetupItemCheckBox(_("Show chat colors list"),
78
        // TRANSLATORS: settings description
79
4
        _("Enable this setting to show color selection drop-down in chat "
80
        "window. Chat window will display color selection drop-down.\n\n"
81
        "It allows one to select default color of outgoing chat messages "
82
        "easily, but also occupies some space in chat window."),
83

4
        "showChatColorsList", this, "showChatColorsListEvent");
84
85
86
    // TRANSLATORS: settings option
87


28
    new SetupItemLabel(_("Commands"), "", this);
88
89
    // TRANSLATORS: settings option
90


52
    new SetupItemCheckBox(_("Allow magic and GM commands in all chat tabs"),
91
        // TRANSLATORS: settings description
92
4
        _("Enable this setting to be able to type spells and GM commands in "
93
        "any tab."),
94

4
        "allowCommandsInChatTabs", this, "allowCommandsInChatTabsEvent");
95
96
97
    // TRANSLATORS: settings group
98


28
    new SetupItemLabel(_("Limits"), "", this);
99
100
    // TRANSLATORS: settings option
101


52
    new SetupItemIntTextField(_("Limit max chars in chat line"),
102
        // TRANSLATORS: settings description
103
4
        _("Limits how many characters will be shown in longest lines "
104
        "of text displayed in chat.\n\n"
105
        "Note: long lines can make client slower. Lines longer than this "
106
        "limit will be truncated."),
107

4
        "chatMaxCharLimit", this, "chatMaxCharLimitEvent", 0, 500);
108
109
    // TRANSLATORS: settings option
110


52
    new SetupItemIntTextField(_("Limit max lines in chat"),
111
        // TRANSLATORS: settings description
112
4
        _("Limits how many lines chat will keep in scrollback buffer. Chat "
113
        "keeps specified number of last lines of text. Oldest lines exceeding "
114
        "this limit are discarded from scrollback buffer.\n\n"
115
        "Note: keeping too many lines in scroll buffer can slow client down."),
116

4
        "chatMaxLinesLimit", this, "chatMaxLinesLimitEvent", 0, 500);
117
118
119
    // TRANSLATORS: settings group
120


28
    new SetupItemLabel(_("Logs"), "", this);
121
122
    // TRANSLATORS: settings option
123


52
    new SetupItemCheckBox(_("Enable chat Log"),
124
        // TRANSLATORS: settings description
125
4
        _("If you enable this setting, chat logs will be written to disk.\n\n"
126
        "Note: chat logs can take noticeable amount of disk space over time."),
127

4
        "enableChatLog", this, "enableChatLogEvent");
128
129
    // TRANSLATORS: settings option
130


52
    new SetupItemCheckBox(_("Enable debug chat Log"),
131
        // TRANSLATORS: settings description
132
4
        _("If you enable this, debug chat tab also will be logged to disk."),
133

4
        "enableDebugLog", this, "enableDebugLogEvent");
134
135
    // TRANSLATORS: settings option
136


52
    new SetupItemCheckBox(_("Show chat history"),
137
        // TRANSLATORS: settings description
138
4
        _("If this setting enabled, client will load old chat tabs content "
139
         "from logs on startup instead of starting with empty chat tabs."),
140

4
        "showChatHistory", this, "showChatHistoryEvent");
141
142
    // TRANSLATORS: settings option
143


52
    new SetupItemCheckBox(_("Show party online messages"),
144
        // TRANSLATORS: settings description
145
4
        _("If this setting is enabled, online status changes of party members"
146
        " will be shown in party tab of chat.\n\nThis adds some extra noise "
147
        "to chat, but allows one to see when your buddies are coming online."),
148

4
        "showPartyOnline", this, "showPartyOnlineEvent");
149
150
    // TRANSLATORS: settings option
151


52
    new SetupItemCheckBox(_("Show guild online messages"),
152
        // TRANSLATORS: settings description
153
4
        _("If this setting is enabled, online status changes of guild members"
154
        " will be shown in guild tab of chat.\n\nThis adds some extra noise "
155
        "to chat, but allows one to see when your buddies are coming online."),
156

4
        "showGuildOnline", this, "showGuildOnlineEvent");
157
158
159
    // TRANSLATORS: settings group
160


28
    new SetupItemLabel(_("Messages"), "", this);
161
162
    // TRANSLATORS: settings option
163


52
    new SetupItemCheckBox(_("Hide shop messages"),
164
        // TRANSLATORS: settings description
165
4
        _("If this setting enabled, no messages related to built-in ManaPlus "
166
        "shop will be displayed in chat. Disable this setting if you want "
167
        "to see shop-related messages.\n\nNote: technically, ManaPlus shop "
168
        "implemented as usual private messages with special content. If you "
169
        "disable this setting, you will be able to see these messages and get "
170
        "idea when other players are looking at your shop."),
171

4
        "hideShopMessages", this, "hideShopMessagesEvent");
172
173
    // TRANSLATORS: settings option
174


52
    new SetupItemCheckBox(_("Show MVP messages"),
175
        // TRANSLATORS: settings description
176
4
        _("Enable this setting to see MVP messages from server.\n\n"
177
        "Note: MVP messages are not used on TMW/Evol/etc servers, so this "
178
        "feature usually makes little difference."),
179

4
        "showMVP", this, "showMVPEvent");
180
181
182
    // TRANSLATORS: settings group
183


28
    new SetupItemLabel(_("Tabs"), "", this);
184
185
    // TRANSLATORS: settings option
186


52
    new SetupItemCheckBox(_("Put all whispers in tabs"),
187
        // TRANSLATORS: settings description
188
4
        _("If this setting enabled, all whispers (private messages) will "
189
        "be placed in separate tabs, separate tab for each player. If this "
190
        "setting disabled, all whispers will appear in General tab.\n\n"
191
        "Note: putting all whispers to single General tab is known to be "
192
        "confusing. Think twice before disabling this feature."),
193

4
        "whispertab", this, "whispertabEvent");
194
195
    // TRANSLATORS: settings option
196


52
    new SetupItemCheckBox(_("Log magic messages in debug tab"),
197
        // TRANSLATORS: settings description
198
4
        _("If this setting is enabled, spell invocation will be shown in "
199
        "Debug tab. If disabled, it will be shown in General tab instead.\n\n"
200
        "Note: it does not affects server replies related to spells."),
201

4
        "showMagicInDebug", this, "showMagicInDebugEvent");
202
203
    // TRANSLATORS: settings option
204


52
    new SetupItemCheckBox(_("Show server messages in debug tab"),
205
        // TRANSLATORS: settings description
206
4
        _("If this setting is enabled, server messages will be shown in "
207
        "Debug tab of chat. If disabled, server messages will appear in "
208
        "General chat instead.\n\nNote: according to 4144, disabling this "
209
        "could also make you to lose some debug messages from client in "
210
        "Debug tab since these are fake server messages."),
211

4
        "serverMsgInDebug", this, "serverMsgInDebugEvent");
212
213
    // TRANSLATORS: settings option
214


52
    new SetupItemCheckBox(_("Enable trade tab"),
215
        // TRANSLATORS: settings description
216
4
        _("Enables trade tab. Trade tab is basically some filter. Messages "
217
        "containing words typical for trades will go to Trade tab. This "
218
        "will make General tab less noisy. If this setting is disabled, all "
219
        "trade related players messages will stay in General tab."),
220

4
        "enableTradeTab", this, "enableTradeTabEvent");
221
222
    // TRANSLATORS: settings option
223


52
    new SetupItemCheckBox(_("Enable gm tab"),
224
        // TRANSLATORS: settings description
225
4
        _("If enabled, GM tab will appear in chat. It displays text related "
226
        "GM activity.\n\nNote: this setting only makes difference for "
227
        "GMs (Game Masters) since this tab only appears for GMs."),
228

4
        "enableGmTab", this, "enableGmTabEvent");
229
230
    // TRANSLATORS: settings option
231


52
    new SetupItemCheckBox(_("Enable language tab"),
232
        // TRANSLATORS: settings description
233
4
        _("If this feature enabled, language tab will appear if server "
234
        "supports this feature.\n\nNote: only supported by Evol server yet."),
235
        "enableLangTab", this, "enableLangTabEvent",
236

4
        MainConfig_false);
237
238
    // TRANSLATORS: settings option
239


52
    new SetupItemCheckBox(_("Show all languages messages"),
240
        // TRANSLATORS: settings description
241
4
        _("If this setting enabled and server supports different chats "
242
        "for different languages, you will see messages for all languages, "
243
        "regardless of your language preferences.\n\nNote: it only works "
244
        "on servers supporting language tabs feature, like Evol."),
245
        "showAllLang", this, "showAllLangEvent",
246

4
        MainConfig_false);
247
248
    // TRANSLATORS: settings option
249


52
    new SetupItemCheckBox(_("Enable battle tab"),
250
        // TRANSLATORS: settings description
251
4
        _("If this setting enabled, Battle tab will appear in chat. This "
252
        "tab will contain messages related to battles, like damage and "
253
        "experience gain, if battle messages are enabled.\n\n"
254
        "Note: client restart required to take effect."),
255

4
        "enableBattleTab", this, "enableBattleTabEvent");
256
257
    // TRANSLATORS: settings option
258


52
    new SetupItemCheckBox(_("Show battle events"),
259
        // TRANSLATORS: settings description
260
4
        _("If this setting enabled, messages related to battle like damage "
261
        "or experience gain will be displayed in Debug or Battle tab. If "
262
        "disabled, no battle messages will be displayed."),
263

4
        "showBattleEvents", this, "showBattleEventsEvent");
264
265
    // TRANSLATORS: settings option
266


52
    new SetupItemCheckBox(_("Resize chat tabs if need"),
267
        // TRANSLATORS: settings description
268
4
        _("If this feature enabled, text in chat will be automatically "
269
        "adjusted to adapt to appearance of chat input field when you "
270
        "typing message and when input field of chat disappears. If disabled, "
271
        "chat input area will always occupy its place, which could be "
272
        "otherwise usable for text.\n\n"
273
        "Note: its mostly about jumpy attitude vs "
274
        "less usable space for text."),
275

4
        "hideChatInput", this, "hideChatInputEvent");
276
277
    // TRANSLATORS: settings option
278


52
    new SetupItemCheckBox(_("Enable trade spam filter"),
279

4
        "", "enableTradeFilter", this, "enableTradeFilterEvent");
280
281
282
    // TRANSLATORS: settings group
283


28
    new SetupItemLabel(_("Time"), "", this);
284
285
    // TRANSLATORS: settings option
286


52
    new SetupItemCheckBox(_("Use local time"),
287
        // TRANSLATORS: settings description
288
4
        _("If this feature enabled, timestamps in chat will use local times. "
289
        "If disabled, server time will be used (often it is GMT+0)."),
290

4
        "useLocalTime", this, "useLocalTimeEvent");
291
292
    // TRANSLATORS: settings group
293


28
    new SetupItemLabel(_("Other"), "", this);
294
295
    // TRANSLATORS: settings option
296


52
    new SetupItemTextField(_("Highlight words (separated by comma)"),
297
        // TRANSLATORS: settings description
298
4
        _("Here you can specify some extra words which will also cause "
299
        "highlighting. Use comma to separate words.\n\nNote: frequent "
300
        "highlights are annoying - use it with caution."),
301

4
        "highlightWords", this, "highlightWordsEvent");
302
303
    // TRANSLATORS: settings option
304


52
    new SetupItemTextField(_("Globals ignore names (separated by comma)"),
305
        // TRANSLATORS: settings description
306
4
        _("This setting allows you to ignore some global messages if "
307
        "particular sender (NPC, GM) annoys you too much. Global will be "
308
        "moved to Debug instead.\n\nNote: careless use of this feature can "
309
        "make you to miss important announces!"),
310

4
        "globalsFilter", this, "globalsFilterEvent");
311
312
    // TRANSLATORS: settings option
313


52
    new SetupItemCheckBox(_("Show emotes button in chat"),
314
        // TRANSLATORS: settings description
315
4
        _("If this setting enabled, button will appear near text input "
316
        "field. This button allows one to invoke composing window, which "
317
        "allows one to insert smiles and text formatting easily.\n\n"
318
        "Note: same window can also be invoked by hotkey when typing, usually "
319
        "F1 by default."),
320

4
        "showEmotesButton", this, "showEmotesButtonEvent");
321
322
    // TRANSLATORS: settings option
323


52
    new SetupItemCheckBox(_("Show motd server message on start"),
324
        // TRANSLATORS: settings description
325
4
        _("If this setting enabled, client will display server MOTD (message"
326
        " of the day) once you connect to server. Disable it to hide MOTD."),
327

4
        "showmotd", this, "showmotdEvent");
328
329
8
    setDimension(Rect(0, 0, 550, 350));
330
4
}
331
332
void Setup_Chat::apply()
333
{
334
    SetupTabScroll::apply();
335
336
    if (chatWindow != nullptr)
337
    {
338
        chatWindow->adjustTabSize();
339
        chatWindow->parseHighlights();
340
    }
341
}
342
343
void Setup_Chat::externalUpdated()
344
{
345
    reread("enableLangTab");
346
    reread("showAllLang");
347
}