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 add_toggle(MNID_SOUND, _("Sound"), config->sound_enabled);
53 add_toggle(MNID_MUSIC, _("Music"), config->music_enabled);
54 add_submenu(_("Setup Keys"), main_controller->get_key_options_menu());
55 add_submenu(_("Setup Joystick"),main_controller->get_joystick_options_menu());
60 OptionsMenu::~OptionsMenu()
65 OptionsMenu::menu_action(MenuItem* item)
69 if(config->use_fullscreen != options_menu->is_toggled(MNID_FULLSCREEN)) {
70 config->use_fullscreen = !config->use_fullscreen;
76 if(config->sound_enabled != options_menu->is_toggled(MNID_SOUND)) {
77 config->sound_enabled = !config->sound_enabled;
78 sound_manager->enable_sound(config->sound_enabled);
83 if(config->music_enabled != options_menu->is_toggled(MNID_MUSIC)) {
84 config->music_enabled = !config->music_enabled;
85 sound_manager->enable_music(config->music_enabled);
94 Menu* get_options_menu()
96 if(options_menu == NULL)
97 options_menu = new OptionsMenu();
102 void free_options_menu()