X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Foptions_menu.cpp;h=c4c7ac9a6af096ab20e5ea0ad212d359939dafea;hb=b8bb8a85f28cce0eaecbcd91ad7ed8fc957ef53f;hp=495e0f7f1494241f249c439bdac4381fdf4070e4;hpb=acd1950b9b853d6b7c56a2cb43e77ec3147b2369;p=supertux.git diff --git a/src/options_menu.cpp b/src/options_menu.cpp index 495e0f7f1..c4c7ac9a6 100644 --- a/src/options_menu.cpp +++ b/src/options_menu.cpp @@ -1,5 +1,8 @@ // $Id$ +// +// SuperTux // Copyright (C) 2004 Tobas Glaesser +// Copyright (C) 2006 Matthias Braun // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -10,7 +13,7 @@ // 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. @@ -32,6 +35,59 @@ enum OptionsMenuIDs { 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 languages = dictionary_manager.get_languages(); + for (std::set::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 languages = dictionary_manager.get_languages(); + for (std::set::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: @@ -39,16 +95,28 @@ public: virtual ~OptionsMenu(); virtual void menu_action(MenuItem* item); + +protected: + std::auto_ptr 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")); @@ -90,8 +158,8 @@ OptionsMenu::menu_action(MenuItem* item) Menu* get_options_menu() { - if(options_menu == NULL) - options_menu = new OptionsMenu(); + //if(options_menu == NULL) + options_menu = new OptionsMenu(); return options_menu; }