ManaPlus
Public Member Functions | Private Attributes
Setup_Audio Class Reference

#include <setup_audio.h>

Inheritance diagram for Setup_Audio:
SetupTabScroll SetupTab Container ActionListener WidgetListener BasicContainer2 BasicContainer Widget WidgetDeathListener Widget2

Public Member Functions

 Setup_Audio (const Widget2 *const widget)
 
 ~Setup_Audio ()
 
void apply ()
 
- Public Member Functions inherited from SetupTabScroll
 SetupTabScroll (const Widget2 *const widget)
 
 ~SetupTabScroll ()
 
void addControl (SetupItem *const widget)
 
void addControl (SetupItem *const widget, const std::string &event)
 
VertContainergetContainer () const
 
void apply ()
 
void cancel ()
 
void externalUpdated ()
 
void externalUnloaded ()
 
void action (const ActionEvent &event)
 
int getPreferredFirstItemSize () const
 
void widgetResized (const Event &event)
 
void reread (const std::string &name)
 
void clear ()
 
const std::set< SetupItem * > & getAllItems () const
 
- Public Member Functions inherited from SetupTab
const std::string & getName () const
 
- Public Member Functions inherited from Container
 Container (const Widget2 *const widget)
 
 ~Container ()
 
bool safeRemove (Widget *const widget)
 
void removeControls ()
 
- Public Member Functions inherited from BasicContainer2
 BasicContainer2 (const Widget2 *const widget)
 
 ~BasicContainer2 ()
 
void setOpaque (Opaque opaque)
 
bool isOpaque () const
 
virtual void add (Widget *const widget)
 
void addXY (Widget *const widget, const int x, const int y)
 
void draw (Graphics *const graphics)
 
void safeDraw (Graphics *const graphics)
 
- Public Member Functions inherited from BasicContainer
 BasicContainer (const Widget2 *const widget)
 
 ~BasicContainer ()
 
void showWidgetPart (Widget *const widget, const Rect &area)
 
void moveToTop (Widget *const widget)
 
void moveToBottom (Widget *const widget)
 
Rect getChildrenArea ()
 
void focusNext ()
 
void focusPrevious ()
 
void logic ()
 
void setFocusHandler (FocusHandler *const focusHandler)
 
void setInternalFocusHandler (FocusHandler *const focusHandler)
 
WidgetgetWidgetAt (int x, int y)
 
void death (const Event &event)
 
WidgetfindFirstWidget (const std::set< Widget * > &list)
 
void add (Widget *const widget)
 
virtual void remove (Widget *const widget)
 
- Public Member Functions inherited from Widget
 Widget (const Widget2 *const widget)
 
 ~Widget ()
 
virtual void drawFrame (Graphics *graphics)
 
virtual void safeDrawFrame (Graphics *graphics)
 
void setFrameSize (const unsigned int frameSize)
 
unsigned int getFrameSize () const
 
WidgetgetParent () const
 
void setWidth (const int width)
 
int getWidth () const
 
void setHeight (const int height)
 
int getHeight () const
 
void setSize (const int width, const int height)
 
void setX (const int x)
 
int getX () const
 
void setY (const int y)
 
int getY () const
 
void setPosition (const int x, const int y)
 
void setDimension (const Rect &dimension)
 
const RectgetDimension () const
 
void setFocusable (const bool focusable)
 
bool isFocusable () const
 
virtual bool isFocused () const
 
void setEnabled (const bool enabled)
 
bool isEnabled () const
 
void setVisible (Visible visible)
 
bool isVisible () const
 
void setBaseColor (const Color &color)
 
const ColorgetBaseColor () const
 
void setForegroundColor (const Color &color)
 
const ColorgetForegroundColor () const
 
void setBackgroundColor (const Color &color)
 
const ColorgetBackgroundColor () const
 
virtual void requestFocus ()
 
virtual void requestMoveToTop ()
 
virtual void requestMoveToBottom ()
 
FocusHandlergetFocusHandler ()
 
void addActionListener (ActionListener *const actionListener)
 
void removeActionListener (ActionListener *const actionListener)
 
void addDeathListener (WidgetDeathListener *const deathListener)
 
void removeDeathListener (WidgetDeathListener *const deathListener)
 
void addMouseListener (MouseListener *const mouseListener)
 
void removeMouseListener (MouseListener *const mouseListener)
 
void addKeyListener (KeyListener *const keyListener)
 
void removeKeyListener (KeyListener *const keyListener)
 
void addFocusListener (FocusListener *const focusListener)
 
void removeFocusListener (FocusListener *const focusListener)
 
void addWidgetListener (WidgetListener *const widgetListener)
 
void removeWidgetListener (WidgetListener *const widgetListener)
 
void setActionEventId (const std::string &actionEventId)
 
const std::string & getActionEventId () const
 
virtual void getAbsolutePosition (int &x, int &y) const
 
virtual void setParent (Widget *parent)
 
FontgetFont () const
 
void setFont (Font *const font)
 
virtual void fontChanged ()
 
bool isTabInEnabled () const
 
void setTabInEnabled (const bool enabled)
 
bool isTabOutEnabled () const
 
void setTabOutEnabled (const bool enabled)
 
void requestModalFocus ()
 
virtual void requestModalMouseInputFocus ()
 
virtual void releaseModalFocus ()
 
virtual void releaseModalMouseInputFocus ()
 
virtual bool isModalFocused () const
 
virtual bool isModalMouseInputFocused () const
 
const std::list< MouseListener * > & getMouseListeners () const A_CONST
 
const std::list< KeyListener * > & getKeyListeners () const A_CONST
 
const std::list< FocusListener * > & getFocusListeners () const A_CONST
 
virtual FocusHandlergetInternalFocusHandler ()
 
void setInternalFocusHandler (FocusHandler *const internalFocusHandler)
 
void setId (const std::string &id)
 
const std::string & getId () const
 
virtual void showPart (const Rect &rectangle)
 
bool isAllowLogic () const
 
void setMouseConsume (const bool b)
 
bool isMouseConsume () const
 
void setRedraw (const bool b)
 
virtual bool isSelectable () const
 
void setSelectable (const bool selectable)
 
void windowResized ()
 
virtual void postInit ()
 
- Public Member Functions inherited from Widget2
virtual ~Widget2 ()
 
const ColorgetThemeColor (const ThemeColorIdT type, const unsigned int alpha) const A_INLINE
 
const ColorgetThemeCharColor (const signed char c, bool &valid) const A_INLINE
 
virtual void setWidget2 (const Widget2 *const widget)
 
void setPalette (int palette)
 
void checkPalette ()
 
void setForegroundColor2 (const Color &color)
 
WidgetgetWindow () const
 
virtual void setWindow (Widget *const window)
 
- Public Member Functions inherited from WidgetDeathListener
virtual ~WidgetDeathListener ()
 
- Public Member Functions inherited from ActionListener
virtual ~ActionListener ()
 
- Public Member Functions inherited from WidgetListener
virtual ~WidgetListener ()
 
virtual void widgetMoved (const Event &event)
 
virtual void widgetHidden (const Event &event)
 
virtual void widgetShown (const Event &event)
 

Private Attributes

ListModelmSoundModel
 
SetupItemNamesmChannelsList
 

Additional Inherited Members

- Static Public Member Functions inherited from Widget
static void setGlobalFont (Font *const font)
 
static FontgetGloablFont ()
 
static void cleanGlobalFont ()
 
static bool widgetExists (const Widget *const widget)
 
static void distributeWindowResizeEvent ()
 
static WidgetcallPostInit (Widget *const widget)
 
- Data Fields inherited from Widget
Visible mVisible
 
- Protected Types inherited from BasicContainer
typedef std::vector< Widget * > WidgetList
 
typedef WidgetList::iterator WidgetListIterator
 
typedef WidgetList::const_iterator WidgetListConstIterator
 
typedef WidgetList::reverse_iterator WidgetListReverseIterator
 
typedef WidgetList::const_reverse_iterator WidgetListCReverseIterator
 
- Protected Types inherited from Widget
typedef std::list< MouseListener * > MouseListenerList
 
typedef MouseListenerList::iterator MouseListenerIterator
 
typedef std::list< KeyListener * > KeyListenerList
 
typedef KeyListenerList::iterator KeyListenerIterator
 
typedef std::list< ActionListener * > ActionListenerList
 
typedef ActionListenerList::iterator ActionListenerIterator
 
typedef std::list< WidgetDeathListener * > WidgetDeathListenerList
 
typedef WidgetDeathListenerList::iterator WidgetDeathListenerIterator
 
typedef std::list< FocusListener * > FocusListenerList
 
typedef FocusListenerList::iterator FocusListenerIterator
 
typedef std::list< WidgetListener * > WidgetListenerList
 
typedef WidgetListenerList::iterator WidgetListenerIterator
 
- Protected Member Functions inherited from SetupTabScroll
void removeItems ()
 
- Protected Member Functions inherited from SetupTab
 SetupTab (const Widget2 *const widget)
 
void setName (const std::string &name)
 
- Protected Member Functions inherited from BasicContainer
virtual void drawChildren (Graphics *const graphics)
 
virtual void safeDrawChildren (Graphics *const graphics)
 
virtual void logicChildren ()
 
- Protected Member Functions inherited from Widget
void distributeActionEvent ()
 
void distributeResizedEvent ()
 
void distributeMovedEvent ()
 
void distributeHiddenEvent ()
 
void distributeShownEvent ()
 
- Protected Member Functions inherited from Widget2
 Widget2 (const Widget2 *const widget)
 
- Protected Member Functions inherited from WidgetDeathListener
 WidgetDeathListener ()
 
- Protected Member Functions inherited from ActionListener
 ActionListener ()
 
- Protected Member Functions inherited from WidgetListener
 WidgetListener ()
 
- Protected Attributes inherited from SetupTabScroll
VertContainermContainer
 
ScrollAreamScroll
 
std::map< std::string, SetupItem * > mItems
 
std::set< SetupItem * > mAllItems
 
int mPreferredFirstItemSize
 
- Protected Attributes inherited from BasicContainer2
Opaque mOpaque
 
- Protected Attributes inherited from BasicContainer
WidgetList mWidgets
 
WidgetList mLogicWidgets
 
- Protected Attributes inherited from Widget
MouseListenerList mMouseListeners
 
KeyListenerList mKeyListeners
 
ActionListenerList mActionListeners
 
WidgetDeathListenerList mDeathListeners
 
FocusListenerList mFocusListeners
 
WidgetListenerList mWidgetListeners
 
Color mForegroundColor
 
Color mBackgroundColor
 
Color mBaseColor
 
Rect mDimension
 
std::string mActionEventId
 
std::string mId
 
FocusHandlermFocusHandler
 
FocusHandlermInternalFocusHandler
 
WidgetmParent
 
FontmCurrentFont
 
unsigned int mFrameSize
 
bool mFocusable
 
bool mTabIn
 
bool mTabOut
 
bool mEnabled
 
bool mAllowLogic
 
bool mMouseConsume
 
bool mRedraw
 
bool mSelectable
 
- Protected Attributes inherited from Widget2
int mPaletteOffset
 
WidgetmWindow
 
Color mForegroundColor2
 
- Static Protected Attributes inherited from Widget
static FontmGlobalFont = 0
 

Detailed Description

Definition at line 31 of file setup_audio.h.

Constructor & Destructor Documentation

◆ Setup_Audio()

Setup_Audio::Setup_Audio ( const Widget2 *const  widget)
explicit

Definition at line 43 of file setup_audio.cpp.

43  :
44  SetupTabScroll(widget),
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,
59 
60  // TRANSLATORS: settings option
61  new SetupItemCheckBox(_("Enable Audio"), "", "sound", this, "soundEvent",
63 
64  // TRANSLATORS: settings option
65  new SetupItemCheckBox(_("Enable music"), "",
66  "playMusic", this, "playMusicEvent",
68 
69  // TRANSLATORS: settings option
70  new SetupItemCheckBox(_("Enable game sfx"), "",
71  "playBattleSound", this, "playBattleSoundEvent",
73 
74  // TRANSLATORS: settings option
75  new SetupItemCheckBox(_("Enable gui sfx"), "",
76  "playGuiSound", this, "playGuiSoundEvent",
78 
79  // TRANSLATORS: settings option
80  new SetupItemSlider(_("Sfx volume"), "", "sfxVolume",
81  this, "sfxVolumeEvent", 0, SoundManager::getMaxVolume(), 1,
82  150,
85 
86  // TRANSLATORS: settings option
87  new SetupItemSlider(_("Music volume"), "", "musicVolume",
88  this, "musicVolumeEvent", 0, SoundManager::getMaxVolume(), 1,
89  150,
92 
93  // TRANSLATORS: settings option
94  new SetupItemCheckBox(_("Enable music fade out"), "",
95  "fadeoutmusic", this, "fadeoutmusicEvent",
97 
98  // TRANSLATORS: settings option
99  new SetupItemIntTextField(_("Audio frequency"), "",
100  "audioFrequency", this, "audioFrequencyEvent", 14000, 192000,
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,
117 
118  // TRANSLATORS: settings option
119  new SetupItemIntTextField(_("Parallel number of sounds"), "",
120  "parallelAudioChannels", this, "parallelAudioChannelsEvent", 1, 1000,
122 
123 
124  // TRANSLATORS: settings group
125  new SetupItemLabel(_("Sound effects"), "", this,
127 
128  // TRANSLATORS: settings option
129  new SetupItemSound(_("Information dialog sound"), "",
130  "soundinfo", this, "soundinfoEvent", mSoundModel,
132 
133  // TRANSLATORS: settings option
134  new SetupItemSound(_("Request dialog sound"), "",
135  "soundrequest", this, "soundrequestEvent", mSoundModel,
137 
138  // TRANSLATORS: settings option
139  new SetupItemSound(_("Whisper message sound"), "",
140  "soundwhisper", this, "soundwhisperEvent", mSoundModel,
142 
143  // TRANSLATORS: settings option
144  new SetupItemSound(_("Guild message sound"), "",
145  "soundguild", this, "soundguildEvent", mSoundModel,
147 
148  // TRANSLATORS: settings option
149  new SetupItemSound(_("Party message sound"), "",
150  "soundparty", this, "soundpartyEvent", mSoundModel,
152 
153  // TRANSLATORS: settings option
154  new SetupItemSound(_("Clan message sound"), "",
155  "soundclan", this, "soundclanEvent", mSoundModel,
157 
158  // TRANSLATORS: settings option
159  new SetupItemSound(_("Highlight message sound"), "",
160  "soundhighlight", this, "soundhighlightEvent", mSoundModel,
162 
163  // TRANSLATORS: settings option
164  new SetupItemSound(_("Global message sound"), "",
165  "soundglobal", this, "soundglobalEvent", mSoundModel,
167 
168  // TRANSLATORS: settings option
169  new SetupItemSound(_("Error message sound"), "",
170  "sounderror", this, "sounderrorEvent", mSoundModel,
172 
173  // TRANSLATORS: settings option
174  new SetupItemSound(_("Trade request sound"), "",
175  "soundtrade", this, "soundtradeEvent", mSoundModel,
177 
178  // TRANSLATORS: settings option
179  new SetupItemSound(_("Show window sound"), "",
180  "soundshowwindow", this, "soundshowwindowEvent", mSoundModel,
182 
183  // TRANSLATORS: settings option
184  new SetupItemSound(_("Hide window sound"), "",
185  "soundhidewindow", this, "soundhidewindowEvent", mSoundModel,
187 
188  // TRANSLATORS: settings group
189  new SetupItemLabel(_("Other"), "", this,
191 
192 #ifdef USE_MUMBLE
193  // TRANSLATORS: settings option
194  new SetupItemCheckBox(_("Enable mumble voice chat"), "",
195  "enableMumble", this, "enableMumbleEvent",
197 #endif // USE_MUMBLE
198 
199  // TRANSLATORS: settings option
200  new SetupItemCheckBox(_("Download music"), "",
201  "download-music", this, "download-musicEvent",
203 
204  setDimension(Rect(0, 0, 550, 350));
205 }
Definition: rect.h:74
SetupTabScroll(const Widget2 *const widget)
ScrollArea * mScroll
void setName(const std::string &name)
Definition: setuptab.h:68
SetupItemNames * mChannelsList
Definition: setup_audio.h:45
ListModel * mSoundModel
Definition: setup_audio.h:43
static int getMaxVolume()
Definition: soundmanager.h:104
void setDimension(const Rect &dimension)
Definition: widget.cpp:169
const bool DoNotAlign_false
Definition: donotalign.h:30
#define _(s)
Definition: gettext.h:35
const bool MainConfig_true
Definition: mainconfig.h:30
const bool OnTheFly_false
Definition: onthefly.h:30
const bool OnTheFly_true
Definition: onthefly.h:30
const bool Separator_true
Definition: separator.h:30
std::vector< std::string > SetupItemNames
Definition: setupitem.h:451

References _, DoNotAlign_false, SoundManager::getMaxVolume(), LayoutHelper::getPlacer(), MainConfig_true, mChannelsList, SetupTabScroll::mScroll, mSoundModel, OnTheFly_false, OnTheFly_true, Separator_true, Widget::setDimension(), and SetupTab::setName().

◆ ~Setup_Audio()

Setup_Audio::~Setup_Audio ( )

Definition at line 207 of file setup_audio.cpp.

208 {
211 }
#define delete2(var)
Definition: delete2.h:25

References delete2, mChannelsList, and mSoundModel.

Member Function Documentation

◆ apply()

void Setup_Audio::apply ( )
virtual

Called when the Apply button is pressed in the setup window.

Implements SetupTab.

Definition at line 213 of file setup_audio.cpp.

214 {
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  {
228  }
229  }
230  else
231  { // not in game
233  "loginMusic",
234  "keprohm.ogg"),
236  }
237  }
238  else
239  {
241  }
242  }
243  else
244  {
246  }
247 }
std::string getValue(const std::string &key, const std::string &deflt) const
bool getBoolValue(const std::string &key) const
Definition: map.h:75
const std::string getMusicFile() const
Definition: map.cpp:835
void playMusic(const std::string &fileName, const SkipError skipError)
Map * getMap() const
Definition: viewport.h:135
Configuration config
Configuration branding
Viewport * viewport
Definition: viewport.cpp:36
const bool SkipError_false
Definition: skiperror.h:30
const bool SkipError_true
Definition: skiperror.h:30
SoundManager soundManager

References SetupTabScroll::apply(), branding, SoundManager::close(), config, Configuration::getBoolValue(), Viewport::getMap(), Map::getMusicFile(), ConfigurationObject::getValue(), SoundManager::init(), SoundManager::playMusic(), SkipError_false, SkipError_true, soundManager, SoundManager::stopMusic(), and viewport.

Field Documentation

◆ mChannelsList

SetupItemNames* Setup_Audio::mChannelsList
private

Definition at line 45 of file setup_audio.h.

Referenced by Setup_Audio(), and ~Setup_Audio().

◆ mSoundModel

ListModel* Setup_Audio::mSoundModel
private

Definition at line 43 of file setup_audio.h.

Referenced by Setup_Audio(), and ~Setup_Audio().


The documentation for this class was generated from the following files: