Back to index

supertuxkart  0.5+dfsg1
config_sound.cpp
Go to the documentation of this file.
00001 //  $Id: config_sound.cpp 2111 2008-05-31 07:04:30Z cosmosninja $
00002 //
00003 //  SuperTuxKart - a fun racing game with go-kart
00004 //  Copyright (C) 2006 SuperTuxKart-Team
00005 //
00006 //  This program is free software; you can redistribute it and/or
00007 //  modify it under the terms of the GNU General Public License
00008 //  as published by the Free Software Foundation; either version 2
00009 //  of the License, or (at your option) any later version.
00010 //
00011 //  This program is distributed in the hope that it will be useful,
00012 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //  GNU General Public License for more details.
00015 //
00016 //  You should have received a copy of the GNU General Public License
00017 //  along with this program; if not, write to the Free Software
00018 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019 
00020 #include "config_sound.hpp"
00021 #include "widget_manager.hpp"
00022 #include "user_config.hpp"
00023 #include "menu_manager.hpp"
00024 #include "translation.hpp"
00025 #include "sound_manager.hpp"
00026 
00027 enum WidgetTokens
00028 {
00029     WTOK_TITLE,
00030 
00031     WTOK_MUSIC,
00032     WTOK_SFX,
00033 
00034     WTOK_QUIT,
00035 };
00036 
00037 ConfigSound::ConfigSound()
00038 {
00039     widget_manager->switchOrder();
00040     widget_manager->addTitleWgt(WTOK_TITLE, 50, 7, _("Sound Settings"));
00041 
00042     widget_manager->setInitialActivationState(true);
00043     if( user_config->doMusic() )
00044     {
00045         widget_manager->addTextButtonWgt( WTOK_MUSIC, 50, 7, _("Turn off music"));
00046     }
00047     else
00048     {
00049         widget_manager->addTextButtonWgt( WTOK_MUSIC, 50, 7, _("Turn on music"));
00050     }
00051 
00052     if( user_config->doSFX() )
00053     {
00054         widget_manager->addTextButtonWgt( WTOK_SFX, 50, 7, _("Turn off sound effects"));
00055     }
00056     else
00057     {
00058         widget_manager->addTextButtonWgt( WTOK_SFX, 50, 7, _("Turn on sound effects"));
00059     }
00060 
00061     widget_manager->addEmptyWgt( WidgetManager::WGT_NONE, 1, 5);
00062 
00063     widget_manager->addTextButtonWgt(WTOK_QUIT, 50, 7,_("Press <ESC> to go back"));
00064     widget_manager->setWgtTextSize(WTOK_QUIT, WGT_FNT_SML);
00065 
00066     widget_manager->layout(WGT_AREA_ALL);
00067 }
00068 
00069 //-----------------------------------------------------------------------------
00070 ConfigSound::~ConfigSound()
00071 {
00072     widget_manager->reset();
00073 }
00074 
00075 //-----------------------------------------------------------------------------
00076 void ConfigSound::select()
00077 {
00078     switch ( widget_manager->getSelectedWgt())
00079     {
00080     case WTOK_MUSIC:
00081         if(user_config->doMusic())
00082         {
00083             user_config->setMusic(UserConfig::UC_DISABLE);
00084             widget_manager->setWgtText(WTOK_MUSIC, _("Turn on music"));
00085             sound_manager->stopMusic();
00086         }
00087         else
00088         {
00089             user_config->setMusic(UserConfig::UC_ENABLE);
00090             widget_manager->setWgtText(WTOK_MUSIC, _("Turn off music"));
00091             sound_manager->startMusic(sound_manager->getCurrentMusic());
00092         }
00093         break;
00094     case WTOK_SFX:
00095         if(user_config->doSFX())
00096         {
00097             user_config->setSFX(UserConfig::UC_DISABLE);
00098             widget_manager->setWgtText(WTOK_SFX, _("Turn on sound effects"));
00099         }
00100         else
00101         {
00102             user_config->setSFX(UserConfig::UC_ENABLE);
00103             widget_manager->setWgtText(WTOK_SFX, _("Turn off sound effects"));
00104         }
00105         break;
00106     case WTOK_QUIT:
00107         menu_manager->popMenu();
00108         break;
00109     default: break;
00110     }
00111 }
00112 
00113 
00114