4 // Copyright (C) 2004 Tobas Glaesser <tobi.web@gmx.de>
5 // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 #include "options_menu.hpp"
23 #include "gui/menu.hpp"
24 #include "audio/sound_manager.hpp"
25 #include "control/joystickkeyboardcontroller.hpp"
27 #include "gettext.hpp"
28 #include "gameconfig.hpp"
30 Menu* options_menu = 0;
38 class OptionsMenu : public Menu
42 virtual ~OptionsMenu();
44 virtual void menu_action(MenuItem* item);
47 OptionsMenu::OptionsMenu()
49 add_label(_("Options"));
51 add_toggle(MNID_FULLSCREEN,_("Fullscreen"), config->use_fullscreen);
52 if (sound_manager->is_audio_enabled()) {
53 add_toggle(MNID_SOUND, _("Sound"), config->sound_enabled);
54 add_toggle(MNID_MUSIC, _("Music"), config->music_enabled);
56 add_deactive(MNID_SOUND, _("Sound (disabled)"));
57 add_deactive(MNID_SOUND, _("Music (disabled)"));
59 add_submenu(_("Setup Keyboard"), main_controller->get_key_options_menu());
60 add_submenu(_("Setup Joystick"),main_controller->get_joystick_options_menu());
65 OptionsMenu::~OptionsMenu()
70 OptionsMenu::menu_action(MenuItem* item)
74 if(config->use_fullscreen != options_menu->is_toggled(MNID_FULLSCREEN)) {
75 config->use_fullscreen = !config->use_fullscreen;
81 if(config->sound_enabled != options_menu->is_toggled(MNID_SOUND)) {
82 config->sound_enabled = !config->sound_enabled;
83 sound_manager->enable_sound(config->sound_enabled);
88 if(config->music_enabled != options_menu->is_toggled(MNID_MUSIC)) {
89 config->music_enabled = !config->music_enabled;
90 sound_manager->enable_music(config->music_enabled);
99 Menu* get_options_menu()
101 if(options_menu == NULL)
102 options_menu = new OptionsMenu();
107 void free_options_menu()