GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/widgets/tabs/setup_visual.cpp Lines: 86 90 95.6 %
Date: 2021-03-17 Branches: 167 332 50.3 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2011-2019  The ManaPlus Developers
4
 *  Copyright (C) 2009-2021  Andrei Karas
5
 *
6
 *  This file is part of The ManaPlus Client.
7
 *
8
 *  This program is free software; you can redistribute it and/or modify
9
 *  it under the terms of the GNU General Public License as published by
10
 *  the Free Software Foundation; either version 2 of the License, or
11
 *  any later version.
12
 *
13
 *  This program is distributed in the hope that it will be useful,
14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 *  GNU General Public License for more details.
17
 *
18
 *  You should have received a copy of the GNU General Public License
19
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
 */
21
22
#include "gui/widgets/tabs/setup_visual.h"
23
24
#include "gui/windowmanager.h"
25
26
#include "gui/models/namesmodel.h"
27
28
#include "gui/widgets/containerplacer.h"
29
#include "gui/widgets/layouthelper.h"
30
#include "gui/widgets/scrollarea.h"
31
32
#include "utils/delete2.h"
33
#include "utils/gettext.h"
34
#include "utils/stringutils.h"
35
36
#include "debug.h"
37
38
static const int speachListSize = 4;
39
40
static const char *const speachList[] =
41
{
42
    // TRANSLATORS: speach type
43
    N_("No text"),
44
    // TRANSLATORS: speach type
45
    N_("Text"),
46
    // TRANSLATORS: speach type
47
    N_("Bubbles, no names"),
48
    // TRANSLATORS: speach type
49
    N_("Bubbles with names")
50
};
51
52
static const int ambientFxListSize = 3;
53
54
static const char *const ambientFxList[] =
55
{
56
    // TRANSLATORS: ambient effect type
57
    N_("off"),
58
    // TRANSLATORS: ambient effect type
59
    N_("low"),
60
    // TRANSLATORS: ambient effect type
61
    N_("high")
62
};
63
64
static const int particleTypeListSize = 3;
65
66
static const char *const particleTypeList[] =
67
{
68
    // TRANSLATORS: patricle effects type
69
    N_("best quality"),
70
    // TRANSLATORS: patricle effects type
71
    N_("normal"),
72
    // TRANSLATORS: patricle effects type
73
    N_("best performance")
74
};
75
76
static const int vSyncListSize = 3;
77
78
static const char *const vSyncList[] =
79
{
80
    // TRANSLATORS: vsync type
81
    N_("default"),
82
    // TRANSLATORS: vsync type
83
    N_("off"),
84
    // TRANSLATORS: vsync type
85
    N_("on")
86
};
87
88
2
Setup_Visual::Setup_Visual(const Widget2 *const widget) :
89
    SetupTabScroll(widget),
90

2
    mSpeachList(new NamesModel),
91

2
    mAmbientFxList(new NamesModel),
92
4
    mParticleList(new SetupItemNames),
93

2
    mParticleTypeList(new NamesModel),
94

2
    mVSyncList(new NamesModel),
95

12
    mScaleList(new NamesModel)
96
{
97
    // TRANSLATORS: settings tab name
98
10
    setName(_("Visual"));
99
    // Do the layout
100
4
    LayoutHelper h(this);
101
2
    ContainerPlacer place = h.getPlacer(0, 0);
102
2
    place(0, 0, mScroll, 10, 10);
103
104
2
    mPreferredFirstItemSize = 150;
105
106
    // TRANSLATORS: settings option
107
2
    new SetupItemLabel(_("Scale"), "", this,
108


14
        Separator_true);
109
110
16
    for (int f = 1; f <= 7; f ++)
111
    {
112
        // TRANSLATORS: particle details
113

56
        mScaleList->add(toString(f) + "x");
114
    }
115
    // TRANSLATORS: settings option
116
2
    new SetupItemSliderInt(_("Scale"), "",
117
2
        "scale", this, "scaleEvent", mScaleList, 1,
118



28
        150, OnTheFly_false, MainConfig_true);
119
120
    // TRANSLATORS: settings option
121
2
    new SetupItemLabel(_("Notifications"), "", this,
122


14
        Separator_true);
123
124
    // TRANSLATORS: settings option
125
2
    new SetupItemCheckBox(_("Show pickup notifications in chat"), "",
126
        "showpickupchat", this, "showpickupchatEvent",
127



26
        MainConfig_true);
128
129
    // TRANSLATORS: settings option
130
2
    new SetupItemCheckBox(_("Show pickup notifications as particle effects"),
131
        "", "showpickupparticle", this, "showpickupparticleEvent",
132



26
        MainConfig_true);
133
134
    // TRANSLATORS: settings option
135
2
    new SetupItemLabel(_("Effects"), "", this,
136


14
        Separator_true);
137
138
#ifndef ANDROID
139
    // TRANSLATORS: settings option
140
2
    new SetupItemCheckBox(_("Grab mouse and keyboard input"),
141
        "", "grabinput", this, "grabinputEvent",
142



26
        MainConfig_true);
143
#endif  // ANDROID
144
145
    // TRANSLATORS: settings option
146
2
    new SetupItemCheckBox(_("Blurring textures (OpenGL)"),
147
        "", "blur", this, "blurEvent",
148



26
        MainConfig_true);
149
150
    // TRANSLATORS: settings option
151
2
    new SetupItemSlider(_("Gui opacity"), "", "guialpha",
152
        this, "guialphaEvent", 0.1, 1.01, 0.1, 150,
153
        OnTheFly_true,
154



26
        MainConfig_true);
155
156
    // TRANSLATORS: settings option
157
2
    new SetupItemCheckBox(_("Enable gui opacity"),
158
        "", "enableGuiOpacity", this, "enableGuiOpacityEvent",
159



26
        MainConfig_true);
160
161
2
    mSpeachList->fillFromArray(&speachList[0], speachListSize);
162
    // TRANSLATORS: settings option
163
2
    new SetupItemDropDown(_("Overhead text"), "", "speech", this,
164
2
        "speechEvent", mSpeachList, 200,
165



28
        MainConfig_true);
166
167
2
    mAmbientFxList->fillFromArray(&ambientFxList[0], ambientFxListSize);
168
    // TRANSLATORS: settings option
169
2
    new SetupItemDropDown(_("Ambient FX"), "", "OverlayDetail", this,
170
2
        "OverlayDetailEvent", mAmbientFxList, 100,
171



28
        MainConfig_true);
172
173
    // TRANSLATORS: settings option
174
2
    new SetupItemCheckBox(_("Show particle effects"), "",
175
        "particleeffects", this, "particleeffectsEvent",
176



26
        MainConfig_true);
177
178
    // TRANSLATORS: settings option
179
2
    new SetupItemCheckBox(_("Show particle effects from maps"), "",
180
        "mapparticleeffects", this, "mapparticleeffectsEvent",
181



26
        MainConfig_true);
182
183
    // TRANSLATORS: particle details
184
10
    mParticleList->push_back(_("low"));
185
    // TRANSLATORS: particle details
186
10
    mParticleList->push_back(_("medium"));
187
    // TRANSLATORS: particle details
188
10
    mParticleList->push_back(_("high"));
189
    // TRANSLATORS: particle details
190
10
    mParticleList->push_back(_("max"));
191
    // TRANSLATORS: settings option
192
2
    (new SetupItemSlider2(_("Particle detail"), "", "particleEmitterSkip",
193
        this, "particleEmitterSkipEvent", 0, 3, 1, mParticleList,
194
        OnTheFly_true,
195
        MainConfig_true,
196



26
        DoNotAlign_false))->setInvertValue(3);
197
198
2
    mParticleTypeList->fillFromArray(&particleTypeList[0],
199
2
        particleTypeListSize);
200
    // TRANSLATORS: settings option
201
2
    new SetupItemDropDown(_("Particle physics"), "", "particleFastPhysics",
202
2
        this, "particleFastPhysicsEvent", mParticleTypeList, 200,
203



28
        MainConfig_true);
204
205
206
    // TRANSLATORS: settings group
207
2
    new SetupItemLabel(_("Gamma"), "", this,
208


14
        Separator_true);
209
210
    // TRANSLATORS: settings option
211
2
    new SetupItemCheckBox(_("Enable gamma control"),
212
        "", "enableGamma", this, "enableGammaEvent",
213



26
        MainConfig_true);
214
215
    // TRANSLATORS: settings option
216
2
    new SetupItemSlider(_("Gamma"), "", "gamma",
217
        this, "gammeEvent", 1, 20, 1, 350,
218
        OnTheFly_true,
219



26
        MainConfig_true);
220
221
222
    // TRANSLATORS: settings group
223
2
    new SetupItemLabel(_("Other"), "", this,
224


14
        Separator_true);
225
226
2
    mVSyncList->fillFromArray(&vSyncList[0], vSyncListSize);
227
    // TRANSLATORS: settings option
228
2
    new SetupItemDropDown(_("Vsync"), "", "vsync", this,
229
2
        "vsyncEvent", mVSyncList, 100,
230



28
        MainConfig_true);
231
232
#if defined(WIN32) || defined(__APPLE__)
233
    // TRANSLATORS: settings option
234
    new SetupItemCheckBox(_("Center game window"),
235
        "", "centerwindow", this, "centerwindowEvent",
236
        MainConfig_true);
237
#endif  // defined(WIN32) || defined(__APPLE__)
238
239
    // TRANSLATORS: settings option
240
2
    new SetupItemCheckBox(_("Allow screensaver to run"),
241
        "", "allowscreensaver", this, "allowscreensaverEvent",
242



26
        MainConfig_true);
243
244
245
    // TRANSLATORS: settings group
246
2
    new SetupItemLabel(_("Screenshots"), "", this,
247


14
        Separator_true);
248
249
    // TRANSLATORS: settings option
250
2
    new SetupItemCheckBox(_("Add water mark into screenshots"),
251
        "", "addwatermark", this, "addwatermarkEvent",
252



26
        MainConfig_true);
253
254
2
    setDimension(Rect(0, 0, 550, 350));
255
2
}
256
257
6
Setup_Visual::~Setup_Visual()
258
{
259
2
    delete2(mSpeachList)
260
2
    delete2(mAmbientFxList)
261
2
    delete2(mParticleList)
262
2
    delete2(mParticleTypeList)
263
2
    delete2(mVSyncList)
264
2
    delete2(mScaleList)
265
4
}
266
267
void Setup_Visual::apply()
268
{
269
    SetupTabScroll::apply();
270
    WindowManager::applyGrabMode();
271
#ifndef WIN32
272
    WindowManager::applyScale();
273
#endif  // WIN32
274
}