GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/widgets/tabs/setup_visual.cpp Lines: 85 89 95.5 %
Date: 2018-05-19 03:07:18 Branches: 167 332 50.3 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2009-2010  Andrei Karas
4
 *  Copyright (C) 2011-2018  The ManaPlus Developers
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
4
Setup_Visual::Setup_Visual(const Widget2 *const widget) :
89
    SetupTabScroll(widget),
90

4
    mSpeachList(new NamesModel),
91

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

4
    mParticleTypeList(new NamesModel),
94

4
    mVSyncList(new NamesModel),
95

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

28
    new SetupItemLabel(_("Scale"), "", this,
108

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

112
        mScaleList->add(toString(f) + "x");
114
    }
115
    // TRANSLATORS: settings option
116


52
    new SetupItemSliderInt(_("Scale"), "",
117
4
        "scale", this, "scaleEvent", mScaleList, 1,
118

8
        150, OnTheFly_false, MainConfig_true);
119
120
    // TRANSLATORS: settings option
121

28
    new SetupItemLabel(_("Notifications"), "", this,
122

4
        Separator_true);
123
124
    // TRANSLATORS: settings option
125


52
    new SetupItemCheckBox(_("Show pickup notifications in chat"), "",
126
        "showpickupchat", this, "showpickupchatEvent",
127

4
        MainConfig_true);
128
129
    // TRANSLATORS: settings option
130


52
    new SetupItemCheckBox(_("Show pickup notifications as particle effects"),
131
        "", "showpickupparticle", this, "showpickupparticleEvent",
132

4
        MainConfig_true);
133
134
    // TRANSLATORS: settings option
135

28
    new SetupItemLabel(_("Effects"), "", this,
136

4
        Separator_true);
137
138
#ifndef ANDROID
139
    // TRANSLATORS: settings option
140


52
    new SetupItemCheckBox(_("Grab mouse and keyboard input"),
141
        "", "grabinput", this, "grabinputEvent",
142

4
        MainConfig_true);
143
#endif  // ANDROID
144
145
    // TRANSLATORS: settings option
146


52
    new SetupItemCheckBox(_("Blurring textures (OpenGL)"),
147
        "", "blur", this, "blurEvent",
148

4
        MainConfig_true);
149
150
    // TRANSLATORS: settings option
151


52
    new SetupItemSlider(_("Gui opacity"), "", "guialpha",
152
        this, "guialphaEvent", 0.1, 1.01, 0.1, 150,
153
        OnTheFly_true,
154

4
        MainConfig_true);
155
156
    // TRANSLATORS: settings option
157


52
    new SetupItemCheckBox(_("Enable gui opacity"),
158
        "", "enableGuiOpacity", this, "enableGuiOpacityEvent",
159

4
        MainConfig_true);
160
161
4
    mSpeachList->fillFromArray(&speachList[0], speachListSize);
162
    // TRANSLATORS: settings option
163


52
    new SetupItemDropDown(_("Overhead text"), "", "speech", this,
164
4
        "speechEvent", mSpeachList, 200,
165

8
        MainConfig_true);
166
167
4
    mAmbientFxList->fillFromArray(&ambientFxList[0], ambientFxListSize);
168
    // TRANSLATORS: settings option
169


52
    new SetupItemDropDown(_("Ambient FX"), "", "OverlayDetail", this,
170
4
        "OverlayDetailEvent", mAmbientFxList, 100,
171

8
        MainConfig_true);
172
173
    // TRANSLATORS: settings option
174


52
    new SetupItemCheckBox(_("Show particle effects"), "",
175
        "particleeffects", this, "particleeffectsEvent",
176

4
        MainConfig_true);
177
178
    // TRANSLATORS: settings option
179


52
    new SetupItemCheckBox(_("Show particle effects from maps"), "",
180
        "mapparticleeffects", this, "mapparticleeffectsEvent",
181

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



52
        DoNotAlign_false))->setInvertValue(3);
197
198
4
    mParticleTypeList->fillFromArray(&particleTypeList[0],
199
        particleTypeListSize);
200
    // TRANSLATORS: settings option
201


52
    new SetupItemDropDown(_("Particle physics"), "", "particleFastPhysics",
202
4
        this, "particleFastPhysicsEvent", mParticleTypeList, 200,
203

8
        MainConfig_true);
204
205
206
    // TRANSLATORS: settings group
207

28
    new SetupItemLabel(_("Gamma"), "", this,
208

4
        Separator_true);
209
210
    // TRANSLATORS: settings option
211


52
    new SetupItemCheckBox(_("Enable gamma control"),
212
        "", "enableGamma", this, "enableGammaEvent",
213

4
        MainConfig_true);
214
215
    // TRANSLATORS: settings option
216


52
    new SetupItemSlider(_("Gamma"), "", "gamma",
217
        this, "gammeEvent", 1, 20, 1, 350,
218
        OnTheFly_true,
219

4
        MainConfig_true);
220
221
222
    // TRANSLATORS: settings group
223

28
    new SetupItemLabel(_("Other"), "", this,
224

4
        Separator_true);
225
226
4
    mVSyncList->fillFromArray(&vSyncList[0], vSyncListSize);
227
    // TRANSLATORS: settings option
228


52
    new SetupItemDropDown(_("Vsync"), "", "vsync", this,
229
4
        "vsyncEvent", mVSyncList, 100,
230

8
        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


52
    new SetupItemCheckBox(_("Allow screensaver to run"),
241
        "", "allowscreensaver", this, "allowscreensaverEvent",
242

4
        MainConfig_true);
243
244
245
    // TRANSLATORS: settings group
246

28
    new SetupItemLabel(_("Screenshots"), "", this,
247

4
        Separator_true);
248
249
    // TRANSLATORS: settings option
250


52
    new SetupItemCheckBox(_("Add water mark into screenshots"),
251
        "", "addwatermark", this, "addwatermarkEvent",
252

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