GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/widgets/tabs/setup_visual.cpp Lines: 74 78 94.9 %
Date: 2017-11-29 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-2017  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
109
32
    for (int f = 1; f <= 7; f ++)
110
    {
111
        // TRANSLATORS: particle details
112

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


52
    new SetupItemSliderInt(_("Scale"), "",
116

4
        "scale", this, "scaleEvent", mScaleList, 1);
117
118
    // TRANSLATORS: settings option
119


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


52
    new SetupItemCheckBox(_("Show pickup notifications in chat"), "",
123

4
        "showpickupchat", this, "showpickupchatEvent");
124
125
    // TRANSLATORS: settings option
126


52
    new SetupItemCheckBox(_("Show pickup notifications as particle effects"),
127

4
        "", "showpickupparticle", this, "showpickupparticleEvent");
128
129
    // TRANSLATORS: settings option
130


28
    new SetupItemLabel(_("Effects"), "", this);
131
132
#ifndef ANDROID
133
    // TRANSLATORS: settings option
134


52
    new SetupItemCheckBox(_("Grab mouse and keyboard input"),
135

4
        "", "grabinput", this, "grabinputEvent");
136
#endif  // ANDROID
137
138
    // TRANSLATORS: settings option
139


36
    new SetupItemCheckBox(_("Blurring textures (OpenGL)"),
140

4
        "", "blur", this, "blurEvent");
141
142
    // TRANSLATORS: settings option
143


52
    new SetupItemSlider(_("Gui opacity"), "", "guialpha",
144
        this, "guialphaEvent", 0.1, 1.01, 0.1, 150,
145
        OnTheFly_true,
146

4
        MainConfig_true);
147
148
    // TRANSLATORS: settings option
149


52
    new SetupItemCheckBox(_("Enable gui opacity"),
150

4
        "", "enableGuiOpacity", this, "enableGuiOpacityEvent");
151
152
4
    mSpeachList->fillFromArray(&speachList[0], speachListSize);
153
    // TRANSLATORS: settings option
154


52
    new SetupItemDropDown(_("Overhead text"), "", "speech", this,
155

4
        "speechEvent", mSpeachList, 200);
156
157
4
    mAmbientFxList->fillFromArray(&ambientFxList[0], ambientFxListSize);
158
    // TRANSLATORS: settings option
159


52
    new SetupItemDropDown(_("Ambient FX"), "", "OverlayDetail", this,
160

4
        "OverlayDetailEvent", mAmbientFxList, 100);
161
162
    // TRANSLATORS: settings option
163


52
    new SetupItemCheckBox(_("Show particle effects"), "",
164

4
        "particleeffects", this, "particleeffectsEvent");
165
166
    // TRANSLATORS: settings option
167


52
    new SetupItemCheckBox(_("Show particle effects from maps"), "",
168

4
        "mapparticleeffects", this, "mapparticleeffectsEvent");
169
170
    // TRANSLATORS: particle details
171
20
    mParticleList->push_back(_("low"));
172
    // TRANSLATORS: particle details
173
20
    mParticleList->push_back(_("medium"));
174
    // TRANSLATORS: particle details
175
20
    mParticleList->push_back(_("high"));
176
    // TRANSLATORS: particle details
177
20
    mParticleList->push_back(_("max"));
178
    // TRANSLATORS: settings option
179
4
    (new SetupItemSlider2(_("Particle detail"), "", "particleEmitterSkip",
180
        this, "particleEmitterSkipEvent", 0, 3, 1, mParticleList,
181
        OnTheFly_true,
182
        MainConfig_true,
183



52
        DoNotAlign_false))->setInvertValue(3);
184
185
4
    mParticleTypeList->fillFromArray(&particleTypeList[0],
186
        particleTypeListSize);
187
    // TRANSLATORS: settings option
188


52
    new SetupItemDropDown(_("Particle physics"), "", "particleFastPhysics",
189

4
        this, "particleFastPhysicsEvent", mParticleTypeList, 200);
190
191
192
    // TRANSLATORS: settings group
193


28
    new SetupItemLabel(_("Gamma"), "", this);
194
195
    // TRANSLATORS: settings option
196


52
    new SetupItemCheckBox(_("Enable gamma control"),
197

4
        "", "enableGamma", this, "enableGammaEvent");
198
199
    // TRANSLATORS: settings option
200


52
    new SetupItemSlider(_("Gamma"), "", "gamma",
201
        this, "gammeEvent", 1, 20, 1, 350,
202
        OnTheFly_true,
203

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


28
    new SetupItemLabel(_("Other"), "", this);
208
209
4
    mVSyncList->fillFromArray(&vSyncList[0], vSyncListSize);
210
    // TRANSLATORS: settings option
211


52
    new SetupItemDropDown(_("Vsync"), "", "vsync", this,
212

4
        "vsyncEvent", mVSyncList, 100);
213
214
#if defined(WIN32) || defined(__APPLE__)
215
    // TRANSLATORS: settings option
216
    new SetupItemCheckBox(_("Center game window"),
217
        "", "centerwindow", this, "centerwindowEvent");
218
#endif  // defined(WIN32) || defined(__APPLE__)
219
220
    // TRANSLATORS: settings option
221


52
    new SetupItemCheckBox(_("Allow screensaver to run"),
222

4
        "", "allowscreensaver", this, "allowscreensaverEvent");
223
224
225
    // TRANSLATORS: settings group
226


28
    new SetupItemLabel(_("Screenshots"), "", this);
227
228
    // TRANSLATORS: settings option
229


52
    new SetupItemCheckBox(_("Add water mark into screenshots"),
230

4
        "", "addwatermark", this, "addwatermarkEvent");
231
232
8
    setDimension(Rect(0, 0, 550, 350));
233
4
}
234
235
12
Setup_Visual::~Setup_Visual()
236
{
237
4
    delete2(mSpeachList);
238
4
    delete2(mAmbientFxList);
239
4
    delete2(mParticleList);
240
4
    delete2(mParticleTypeList);
241
4
    delete2(mVSyncList);
242
4
    delete2(mScaleList);
243
8
}
244
245
void Setup_Visual::apply()
246
{
247
    SetupTabScroll::apply();
248
    WindowManager::applyGrabMode();
249
#ifndef WIN32
250
    WindowManager::applyScale();
251
#endif  // WIN32
252
}