2 // Copyright (C) 2004 Tobas Glaesser <tobi.web@gmx.de>
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 #include "options_menu.hpp"
20 #include "gui/menu.hpp"
21 #include "audio/sound_manager.hpp"
22 #include "control/joystickkeyboardcontroller.hpp"
24 #include "gettext.hpp"
25 #include "gameconfig.hpp"
27 Menu* options_menu = 0;
35 class OptionsMenu : public Menu
39 virtual ~OptionsMenu();
41 virtual void menu_action(MenuItem* item);
44 OptionsMenu::OptionsMenu()
46 add_label(_("Options"));
48 add_toggle(MNID_FULLSCREEN,_("Fullscreen"), config->use_fullscreen);
49 add_toggle(MNID_SOUND, _("Sound"), config->sound_enabled);
50 add_toggle(MNID_MUSIC, _("Music"), config->music_enabled);
51 add_submenu(_("Setup Keys"), main_controller->get_key_options_menu());
52 add_submenu(_("Setup Joystick"),main_controller->get_joystick_options_menu());
57 OptionsMenu::~OptionsMenu()
62 OptionsMenu::menu_action(MenuItem* item)
66 if(config->use_fullscreen != options_menu->is_toggled(MNID_FULLSCREEN)) {
67 config->use_fullscreen = !config->use_fullscreen;
73 if(config->sound_enabled != options_menu->is_toggled(MNID_SOUND)) {
74 config->sound_enabled = !config->sound_enabled;
75 sound_manager->enable_sound(config->sound_enabled);
80 if(config->music_enabled != options_menu->is_toggled(MNID_MUSIC)) {
81 config->music_enabled = !config->music_enabled;
82 sound_manager->enable_music(config->music_enabled);
91 Menu* get_options_menu()
93 if(options_menu == NULL)
94 options_menu = new OptionsMenu();
99 void free_options_menu()