X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fsupertux%2Foptions_menu.cpp;h=e218a1037a7b1531bb88a7a0e6c3fee7d8c4be87;hb=78bbf9473d795d9ea9221e38829a9bacfce00fa5;hp=5acb25c0992301302e035762f380c8bbf9276f46;hpb=08813a74da6ac1fd045a105e4e8105f1d7f716f0;p=supertux.git
diff --git a/src/supertux/options_menu.cpp b/src/supertux/options_menu.cpp
index 5acb25c09..e218a1037 100644
--- a/src/supertux/options_menu.cpp
+++ b/src/supertux/options_menu.cpp
@@ -15,12 +15,16 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
+#include "supertux/options_menu.hpp"
+
#include "audio/sound_manager.hpp"
#include "control/joystickkeyboardcontroller.hpp"
#include "gui/menu.hpp"
+#include "gui/menu_item.hpp"
#include "supertux/gameconfig.hpp"
#include "supertux/main.hpp"
#include "supertux/profile_menu.hpp"
+#include "supertux/language_menu.hpp"
#include "util/gettext.hpp"
#include "video/renderer.hpp"
@@ -36,72 +40,8 @@ enum OptionsMenuIDs {
MNID_MUSIC
};
-class LanguageMenu : public Menu
-{
-public:
- LanguageMenu() {
- add_label(_("Language"));
- add_hl();
- add_entry(0, std::string("<")+_("auto-detect")+">");
- 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) {
- g_config->locale = "";
- dictionary_manager.set_language(g_config->locale);
- g_config->save();
- Menu::pop_current();
- }
- else if (item->id == 1) {
- g_config->locale = "en";
- dictionary_manager.set_language(g_config->locale);
- g_config->save();
- Menu::pop_current();
- }
- 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++) {
- g_config->locale = locale_name;
- dictionary_manager.set_language(g_config->locale);
- g_config->save();
- Menu::pop_current();
- }
- }
- }
-};
-
-class OptionsMenu : public Menu
-{
-public:
- OptionsMenu();
- virtual ~OptionsMenu();
-
- virtual void menu_action(MenuItem* item);
-
-protected:
- std::auto_ptr language_menu;
-
-};
-
-OptionsMenu::OptionsMenu()
+OptionsMenu::OptionsMenu() :
+ language_menu()
{
language_menu.reset(new LanguageMenu());