// $Id$
+//
+// SuperTux
// Copyright (C) 2004 Tobas Glaesser <tobi.web@gmx.de>
+// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-//
+//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
MNID_MUSIC
};
+class LanguageMenu : public Menu
+{
+public:
+ LanguageMenu() {
+ add_label(_("Language"));
+ add_hl();
+ add_entry(0, std::string("(")+_("auto-detect language")+")");
+ add_entry(1, "English");
+
+ int mnid = 10;
+ std::set<std::string> languages = dictionary_manager.get_languages();
+ for (std::set<std::string>::iterator i = languages.begin(); i != languages.end(); i++) {
+ std::string locale_name = *i;
+ TinyGetText::LanguageDef ldef = TinyGetText::get_language_def(locale_name);
+ std::string locale_fullname = locale_name;
+ if (std::string(ldef.code) == locale_name) {
+ locale_fullname = ldef.name;
+ }
+ add_entry(mnid++, locale_fullname);
+ }
+
+ add_hl();
+ add_back(_("Back"));
+ }
+
+ virtual void menu_action(MenuItem* item) {
+ if (item->id == 0) {
+ config->locale = "";
+ dictionary_manager.set_language(config->locale);
+ config->save();
+ Menu::set_current(0);
+ }
+ else if (item->id == 1) {
+ config->locale = "en";
+ dictionary_manager.set_language(config->locale);
+ config->save();
+ Menu::set_current(0);
+ }
+ int mnid = 10;
+ std::set<std::string> languages = dictionary_manager.get_languages();
+ for (std::set<std::string>::iterator i = languages.begin(); i != languages.end(); i++) {
+ std::string locale_name = *i;
+ if (item->id == mnid++) {
+ config->locale = locale_name;
+ dictionary_manager.set_language(config->locale);
+ config->save();
+ Menu::set_current(0);
+ }
+ }
+ }
+};
+
+
class OptionsMenu : public Menu
{
public:
virtual ~OptionsMenu();
virtual void menu_action(MenuItem* item);
+
+protected:
+ std::auto_ptr<LanguageMenu> language_menu;
+
};
OptionsMenu::OptionsMenu()
{
+ language_menu.reset(new LanguageMenu());
+
add_label(_("Options"));
add_hl();
add_toggle(MNID_FULLSCREEN,_("Fullscreen"), config->use_fullscreen);
- add_toggle(MNID_SOUND, _("Sound"), config->sound_enabled);
- add_toggle(MNID_MUSIC, _("Music"), config->music_enabled);
- add_submenu(_("Setup Keys"), main_controller->get_key_options_menu());
+ add_submenu(_("Language"), language_menu.get());
+ if (sound_manager->is_audio_enabled()) {
+ add_toggle(MNID_SOUND, _("Sound"), config->sound_enabled);
+ add_toggle(MNID_MUSIC, _("Music"), config->music_enabled);
+ } else {
+ add_deactive(MNID_SOUND, _("Sound (disabled)"));
+ add_deactive(MNID_SOUND, _("Music (disabled)"));
+ }
+ add_submenu(_("Setup Keyboard"), main_controller->get_key_options_menu());
add_submenu(_("Setup Joystick"),main_controller->get_joystick_options_menu());
add_hl();
add_back(_("Back"));
Menu* get_options_menu()
{
- if(options_menu == NULL)
- options_menu = new OptionsMenu();
-
+ //static OptionsMenu menu;
+ options_menu = new OptionsMenu();
return options_menu;
}
void free_options_menu()
{
delete options_menu;
- options_menu = NULL;
+ options_menu = 0;
}