ManaPlus
src
gui
widgets
tabs
setup_audio.cpp
Go to the documentation of this file.
1
/*
2
* The ManaPlus Client
3
* Copyright (C) 2004-2009 The Mana World Development Team
4
* Copyright (C) 2009-2010 The Mana Developers
5
* Copyright (C) 2011-2019 The ManaPlus Developers
6
* Copyright (C) 2019-2021 Andrei Karas
7
*
8
* This file is part of The ManaPlus Client.
9
*
10
* This program is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* any later version.
14
*
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
19
*
20
* You should have received a copy of the GNU General Public License
21
* along with this program. If not, see <http://www.gnu.org/licenses/>.
22
*/
23
24
#include "
gui/widgets/tabs/setup_audio.h
"
25
26
#include "resources/map/map.h"
27
28
#include "
configuration.h
"
29
#include "
soundmanager.h
"
30
31
#include "gui/viewport.h"
32
33
#include "
gui/models/soundsmodel.h
"
34
35
#include "
gui/widgets/containerplacer.h
"
36
#include "
gui/widgets/layouthelper.h
"
37
#include "
gui/widgets/scrollarea.h
"
38
39
#include "
utils/delete2.h
"
40
41
#include "
debug.h
"
42
43
Setup_Audio::Setup_Audio
(
const
Widget2
*
const
widget) :
44
SetupTabScroll
(widget),
45
mSoundModel(
new
SoundsModel
),
46
mChannelsList(
new
SetupItemNames
)
47
{
48
// TRANSLATORS: audio tab in settings
49
setName
(
_
(
"Audio"
));
50
51
// Do the layout
52
LayoutHelper
h(
this
);
53
ContainerPlacer
place = h.
getPlacer
(0, 0);
54
place(0, 0,
mScroll
, 10, 10);
55
56
// TRANSLATORS: settings option
57
new
SetupItemLabel
(
_
(
"Basic settings"
),
""
,
this
,
58
Separator_true
);
59
60
// TRANSLATORS: settings option
61
new
SetupItemCheckBox
(
_
(
"Enable Audio"
),
""
,
"sound"
,
this
,
"soundEvent"
,
62
MainConfig_true
);
63
64
// TRANSLATORS: settings option
65
new
SetupItemCheckBox
(
_
(
"Enable music"
),
""
,
66
"playMusic"
,
this
,
"playMusicEvent"
,
67
MainConfig_true
);
68
69
// TRANSLATORS: settings option
70
new
SetupItemCheckBox
(
_
(
"Enable game sfx"
),
""
,
71
"playBattleSound"
,
this
,
"playBattleSoundEvent"
,
72
MainConfig_true
);
73
74
// TRANSLATORS: settings option
75
new
SetupItemCheckBox
(
_
(
"Enable gui sfx"
),
""
,
76
"playGuiSound"
,
this
,
"playGuiSoundEvent"
,
77
MainConfig_true
);
78
79
// TRANSLATORS: settings option
80
new
SetupItemSlider
(
_
(
"Sfx volume"
),
""
,
"sfxVolume"
,
81
this
,
"sfxVolumeEvent"
, 0,
SoundManager::getMaxVolume
(), 1,
82
150,
83
OnTheFly_true
,
84
MainConfig_true
);
85
86
// TRANSLATORS: settings option
87
new
SetupItemSlider
(
_
(
"Music volume"
),
""
,
"musicVolume"
,
88
this
,
"musicVolumeEvent"
, 0,
SoundManager::getMaxVolume
(), 1,
89
150,
90
OnTheFly_true
,
91
MainConfig_true
);
92
93
// TRANSLATORS: settings option
94
new
SetupItemCheckBox
(
_
(
"Enable music fade out"
),
""
,
95
"fadeoutmusic"
,
this
,
"fadeoutmusicEvent"
,
96
MainConfig_true
);
97
98
// TRANSLATORS: settings option
99
new
SetupItemIntTextField
(
_
(
"Audio frequency"
),
""
,
100
"audioFrequency"
,
this
,
"audioFrequencyEvent"
, 14000, 192000,
101
MainConfig_true
);
102
103
// TRANSLATORS: audio type
104
mChannelsList
->push_back(
_
(
"mono"
));
105
// TRANSLATORS: audio type
106
mChannelsList
->push_back(
_
(
"stereo"
));
107
// TRANSLATORS: audio type
108
mChannelsList
->push_back(
_
(
"surround"
));
109
// TRANSLATORS: audio type
110
mChannelsList
->push_back(
_
(
"surround+center+lfe"
));
111
// TRANSLATORS: settings option
112
new
SetupItemSlider2
(
_
(
"Audio channels"
),
""
,
"audioChannels"
,
this
,
113
"audioChannels"
, 1, 4, 1,
mChannelsList
,
114
OnTheFly_false
,
115
MainConfig_true
,
116
DoNotAlign_false
);
117
118
// TRANSLATORS: settings option
119
new
SetupItemIntTextField
(
_
(
"Parallel number of sounds"
),
""
,
120
"parallelAudioChannels"
,
this
,
"parallelAudioChannelsEvent"
, 1, 1000,
121
MainConfig_true
);
122
123
124
// TRANSLATORS: settings group
125
new
SetupItemLabel
(
_
(
"Sound effects"
),
""
,
this
,
126
Separator_true
);
127
128
// TRANSLATORS: settings option
129
new
SetupItemSound
(
_
(
"Information dialog sound"
),
""
,
130
"soundinfo"
,
this
,
"soundinfoEvent"
,
mSoundModel
,
131
150,
OnTheFly_false
,
MainConfig_true
);
132
133
// TRANSLATORS: settings option
134
new
SetupItemSound
(
_
(
"Request dialog sound"
),
""
,
135
"soundrequest"
,
this
,
"soundrequestEvent"
,
mSoundModel
,
136
150,
OnTheFly_false
,
MainConfig_true
);
137
138
// TRANSLATORS: settings option
139
new
SetupItemSound
(
_
(
"Whisper message sound"
),
""
,
140
"soundwhisper"
,
this
,
"soundwhisperEvent"
,
mSoundModel
,
141
150,
OnTheFly_false
,
MainConfig_true
);
142
143
// TRANSLATORS: settings option
144
new
SetupItemSound
(
_
(
"Guild message sound"
),
""
,
145
"soundguild"
,
this
,
"soundguildEvent"
,
mSoundModel
,
146
150,
OnTheFly_false
,
MainConfig_true
);
147
148
// TRANSLATORS: settings option
149
new
SetupItemSound
(
_
(
"Party message sound"
),
""
,
150
"soundparty"
,
this
,
"soundpartyEvent"
,
mSoundModel
,
151
150,
OnTheFly_false
,
MainConfig_true
);
152
153
// TRANSLATORS: settings option
154
new
SetupItemSound
(
_
(
"Clan message sound"
),
""
,
155
"soundclan"
,
this
,
"soundclanEvent"
,
mSoundModel
,
156
150,
OnTheFly_false
,
MainConfig_true
);
157
158
// TRANSLATORS: settings option
159
new
SetupItemSound
(
_
(
"Highlight message sound"
),
""
,
160
"soundhighlight"
,
this
,
"soundhighlightEvent"
,
mSoundModel
,
161
150,
OnTheFly_false
,
MainConfig_true
);
162
163
// TRANSLATORS: settings option
164
new
SetupItemSound
(
_
(
"Global message sound"
),
""
,
165
"soundglobal"
,
this
,
"soundglobalEvent"
,
mSoundModel
,
166
150,
OnTheFly_false
,
MainConfig_true
);
167
168
// TRANSLATORS: settings option
169
new
SetupItemSound
(
_
(
"Error message sound"
),
""
,
170
"sounderror"
,
this
,
"sounderrorEvent"
,
mSoundModel
,
171
150,
OnTheFly_false
,
MainConfig_true
);
172
173
// TRANSLATORS: settings option
174
new
SetupItemSound
(
_
(
"Trade request sound"
),
""
,
175
"soundtrade"
,
this
,
"soundtradeEvent"
,
mSoundModel
,
176
150,
OnTheFly_false
,
MainConfig_true
);
177
178
// TRANSLATORS: settings option
179
new
SetupItemSound
(
_
(
"Show window sound"
),
""
,
180
"soundshowwindow"
,
this
,
"soundshowwindowEvent"
,
mSoundModel
,
181
150,
OnTheFly_false
,
MainConfig_true
);
182
183
// TRANSLATORS: settings option
184
new
SetupItemSound
(
_
(
"Hide window sound"
),
""
,
185
"soundhidewindow"
,
this
,
"soundhidewindowEvent"
,
mSoundModel
,
186
150,
OnTheFly_false
,
MainConfig_true
);
187
188
// TRANSLATORS: settings group
189
new
SetupItemLabel
(
_
(
"Other"
),
""
,
this
,
190
Separator_true
);
191
192
#ifdef USE_MUMBLE
193
// TRANSLATORS: settings option
194
new
SetupItemCheckBox
(
_
(
"Enable mumble voice chat"
),
""
,
195
"enableMumble"
,
this
,
"enableMumbleEvent"
,
196
MainConfig_true
);
197
#endif
// USE_MUMBLE
198
199
// TRANSLATORS: settings option
200
new
SetupItemCheckBox
(
_
(
"Download music"
),
""
,
201
"download-music"
,
this
,
"download-musicEvent"
,
202
MainConfig_true
);
203
204
setDimension
(
Rect
(0, 0, 550, 350));
205
}
206
207
Setup_Audio::~Setup_Audio
()
208
{
209
delete2
(
mSoundModel
)
210
delete2
(
mChannelsList
)
211
}
212
213
void
Setup_Audio::apply
()
214
{
215
SetupTabScroll::apply
();
216
if
(
config
.
getBoolValue
(
"sound"
))
217
{
218
soundManager
.
init
();
219
if
(
config
.
getBoolValue
(
"playMusic"
))
220
{
221
if
(
viewport
!=
nullptr
)
222
{
// in game
223
const
Map
*
const
map =
viewport
->
getMap
();
224
if
(map !=
nullptr
)
225
{
226
soundManager
.
playMusic
(map->
getMusicFile
(),
227
SkipError_false
);
228
}
229
}
230
else
231
{
// not in game
232
soundManager
.
playMusic
(
branding
.
getValue
(
233
"loginMusic"
,
234
"keprohm.ogg"
),
235
SkipError_true
);
236
}
237
}
238
else
239
{
240
soundManager
.
stopMusic
();
241
}
242
}
243
else
244
{
245
soundManager
.
close
();
246
}
247
}
ConfigurationObject::getValue
std::string getValue(const std::string &key, const std::string &deflt) const
Definition:
configuration.cpp:269
Configuration::getBoolValue
bool getBoolValue(const std::string &key) const
Definition:
configuration.cpp:597
ContainerPlacer
Definition:
containerplacer.h:37
LayoutHelper
Definition:
layouthelper.h:40
LayoutHelper::getPlacer
ContainerPlacer getPlacer(const int x, const int y)
Definition:
layouthelper.cpp:60
Map
Definition:
map.h:75
Map::getMusicFile
const std::string getMusicFile() const
Definition:
map.cpp:835
Rect
Definition:
rect.h:74
SetupItemCheckBox
Definition:
setupitem.h:155
SetupItemIntTextField
Definition:
setupitem.h:242
SetupItemLabel
Definition:
setupitem.h:286
SetupItemSlider2
Definition:
setupitem.h:456
SetupItemSlider
Definition:
setupitem.h:397
SetupItemSound
Definition:
setupitem.h:566
SetupTabScroll
Definition:
setuptabscroll.h:34
SetupTabScroll::apply
void apply()
Definition:
setuptabscroll.cpp:107
SetupTabScroll::mScroll
ScrollArea * mScroll
Definition:
setuptabscroll.h:76
SetupTab::setName
void setName(const std::string &name)
Definition:
setuptab.h:68
Setup_Audio::apply
void apply()
Definition:
setup_audio.cpp:213
Setup_Audio::mChannelsList
SetupItemNames * mChannelsList
Definition:
setup_audio.h:45
Setup_Audio::mSoundModel
ListModel * mSoundModel
Definition:
setup_audio.h:43
Setup_Audio::Setup_Audio
Setup_Audio(const Widget2 *const widget)
Definition:
setup_audio.cpp:43
Setup_Audio::~Setup_Audio
~Setup_Audio()
Definition:
setup_audio.cpp:207
SoundManager::init
void init()
Definition:
soundmanager.cpp:127
SoundManager::getMaxVolume
static int getMaxVolume()
Definition:
soundmanager.h:104
SoundManager::close
void close()
Definition:
soundmanager.cpp:531
SoundManager::playMusic
void playMusic(const std::string &fileName, const SkipError skipError)
Definition:
soundmanager.cpp:352
SoundManager::stopMusic
void stopMusic()
Definition:
soundmanager.cpp:374
SoundsModel
Definition:
soundsmodel.h:35
Viewport::getMap
Map * getMap() const
Definition:
viewport.h:135
Widget2
Definition:
widget2.h:37
Widget::setDimension
void setDimension(const Rect &dimension)
Definition:
widget.cpp:169
config
Configuration config
Definition:
configuration.cpp:52
branding
Configuration branding
Definition:
configuration.cpp:55
configuration.h
containerplacer.h
debug.h
new
#define new
Definition:
debug_new.h:147
delete2.h
delete2
#define delete2(var)
Definition:
delete2.h:25
DoNotAlign_false
const bool DoNotAlign_false
Definition:
donotalign.h:30
viewport
Viewport * viewport
Definition:
viewport.cpp:36
_
#define _(s)
Definition:
gettext.h:35
layouthelper.h
MainConfig_true
const bool MainConfig_true
Definition:
mainconfig.h:30
OnTheFly_false
const bool OnTheFly_false
Definition:
onthefly.h:30
OnTheFly_true
const bool OnTheFly_true
Definition:
onthefly.h:30
scrollarea.h
Separator_true
const bool Separator_true
Definition:
separator.h:30
setup_audio.h
SetupItemNames
std::vector< std::string > SetupItemNames
Definition:
setupitem.h:451
SkipError_false
const bool SkipError_false
Definition:
skiperror.h:30
SkipError_true
const bool SkipError_true
Definition:
skiperror.h:30
soundManager
SoundManager soundManager
Definition:
soundmanager.cpp:55
soundmanager.h
soundsmodel.h
Generated on Wed Mar 17 2021 19:19:07 for ManaPlus by
1.9.1