X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fsupertux%2Fmenu%2Foptions_menu.cpp;h=f01b402645361d68ccc176a9f6ab092b315d52dc;hb=92068a12966fb960a802b0cdbccaf0391a9ace20;hp=344b38d07a7d7fbcf20066dcf6cc4cca64a1adec;hpb=ac7bb99197bef668da1c699fb5df89b75c8cd2ce;p=supertux.git diff --git a/src/supertux/menu/options_menu.cpp b/src/supertux/menu/options_menu.cpp index 344b38d07..f01b40264 100644 --- a/src/supertux/menu/options_menu.cpp +++ b/src/supertux/menu/options_menu.cpp @@ -18,18 +18,18 @@ #include "supertux/menu/options_menu.hpp" #include "audio/sound_manager.hpp" -#include "control/joystickkeyboardcontroller.hpp" -#include "gui/menu.hpp" -#include "gui/menu_item.hpp" +#include "gui/menu_manager.hpp" #include "supertux/gameconfig.hpp" -#include "supertux/globals.hpp" -#include "supertux/main.hpp" -#include "supertux/menu/profile_menu.hpp" +#include "supertux/menu/joystick_menu.hpp" +#include "supertux/menu/keyboard_menu.hpp" #include "supertux/menu/language_menu.hpp" -#include "util/gettext.hpp" +#include "supertux/menu/menu_storage.hpp" +#include "supertux/menu/profile_menu.hpp" +#include "util/string_util.hpp" #include "video/renderer.hpp" -Menu* options_menu = 0; +#include +#include enum OptionsMenuIDs { MNID_FULLSCREEN, @@ -54,7 +54,7 @@ OptionsMenu::OptionsMenu() : add_submenu(_("Select Language"), language_menu.get()) ->set_help(_("Select a different language to display text in")); - add_submenu(_("Select Profile"), get_profile_menu()) + add_submenu(_("Select Profile"), MenuStorage::get_profile_menu()) ->set_help(_("Select a profile to play with")); add_toggle(MNID_PROFILES, _("Profile on Startup"), g_config->sound_enabled) @@ -71,7 +71,7 @@ OptionsMenu::OptionsMenu() : // These values go from screen:640/projection:1600 to // screen:1600/projection:640 (i.e. 640, 800, 1024, 1280, 1600) - magnification->list.push_back("auto"); + magnification->list.push_back(_("auto")); magnification->list.push_back("40%"); magnification->list.push_back("50%"); magnification->list.push_back("62.5%"); @@ -110,22 +110,26 @@ OptionsMenu::OptionsMenu() : out << modes[i]->w << "x" << modes[i]->h; fullscreen_res->list.push_back(out.str()); } + + // On Ubuntu/Linux resolutions are returned from highest to + // lowest, so reverse them + std::sort(fullscreen_res->list.begin(), fullscreen_res->list.end(), StringUtil::numeric_less); } MenuItem* aspect = add_string_select(MNID_ASPECTRATIO, _("Aspect Ratio")); aspect->set_help(_("Adjust the aspect ratio")); - aspect->list.push_back("auto"); + aspect->list.push_back(_("auto")); aspect->list.push_back("5:4"); aspect->list.push_back("4:3"); aspect->list.push_back("16:10"); aspect->list.push_back("16:9"); aspect->list.push_back("1368:768"); - if (g_config->aspect_width != 0 && g_config->aspect_height != 0) + if (g_config->aspect_size != Size(0, 0)) { std::ostringstream out; - out << g_config->aspect_width << ":" << g_config->aspect_height; + out << g_config->aspect_size.width << ":" << g_config->aspect_size.height; std::string aspect_ratio = out.str(); for(std::vector::iterator i = aspect->list.begin(); i != aspect->list.end(); ++i) { @@ -153,10 +157,10 @@ OptionsMenu::OptionsMenu() : add_inactive(MNID_MUSIC, _("Music (disabled)")); } - add_submenu(_("Setup Keyboard"), g_main_controller->get_key_options_menu()) + add_submenu(_("Setup Keyboard"), MenuStorage::get_key_options_menu()) ->set_help(_("Configure key-action mappings")); - add_submenu(_("Setup Joystick") ,g_main_controller->get_joystick_options_menu()) + add_submenu(_("Setup Joystick"), MenuStorage::get_joystick_options_menu()) ->set_help(_("Configure joystick control-action mappings")); add_hl(); add_back(_("Back")); @@ -172,17 +176,17 @@ OptionsMenu::menu_action(MenuItem* item) switch (item->id) { case MNID_ASPECTRATIO: { - if (item->list[item->selected] == "auto") + if (item->list[item->selected] == _("auto")) { - g_config->aspect_width = 0; // Magic values - g_config->aspect_height = 0; + g_config->aspect_size = Size(0, 0); // Magic values Renderer::instance()->apply_config(); - Menu::recalc_pos(); + MenuManager::recalc_pos(); } - else if(sscanf(item->list[item->selected].c_str(), "%d:%d", &g_config->aspect_width, &g_config->aspect_height) == 2) + else if (sscanf(item->list[item->selected].c_str(), "%d:%d", + &g_config->aspect_size.width, &g_config->aspect_size.height) == 2) { Renderer::instance()->apply_config(); - Menu::recalc_pos(); + MenuManager::recalc_pos(); } else { @@ -192,7 +196,7 @@ OptionsMenu::menu_action(MenuItem* item) break; case MNID_MAGNIFICATION: - if (item->list[item->selected] == "auto") + if (item->list[item->selected] == _("auto")) { g_config->magnification = 0.0f; // Magic value } @@ -201,27 +205,28 @@ OptionsMenu::menu_action(MenuItem* item) g_config->magnification /= 100.0f; } Renderer::instance()->apply_config(); - Menu::recalc_pos(); + MenuManager::recalc_pos(); break; case MNID_FULLSCREEN_RESOLUTION: - if(sscanf(item->list[item->selected].c_str(), "%dx%d", &g_config->fullscreen_width, &g_config->fullscreen_height) == 2) + if(sscanf(item->list[item->selected].c_str(), "%dx%d", + &g_config->fullscreen_size.width, &g_config->fullscreen_size.height) == 2) { // do nothing, changes are only applied when toggling fullscreen mode } break; case MNID_FULLSCREEN: - if(g_config->use_fullscreen != options_menu->is_toggled(MNID_FULLSCREEN)) { + if(g_config->use_fullscreen != is_toggled(MNID_FULLSCREEN)) { g_config->use_fullscreen = !g_config->use_fullscreen; - init_video(); // FIXME: Should call apply_config instead - Menu::recalc_pos(); + Renderer::instance()->apply_config(); + MenuManager::recalc_pos(); g_config->save(); } break; case MNID_SOUND: - if(g_config->sound_enabled != options_menu->is_toggled(MNID_SOUND)) { + if(g_config->sound_enabled != is_toggled(MNID_SOUND)) { g_config->sound_enabled = !g_config->sound_enabled; sound_manager->enable_sound(g_config->sound_enabled); g_config->save(); @@ -229,7 +234,7 @@ OptionsMenu::menu_action(MenuItem* item) break; case MNID_MUSIC: - if(g_config->music_enabled != options_menu->is_toggled(MNID_MUSIC)) { + if(g_config->music_enabled != is_toggled(MNID_MUSIC)) { g_config->music_enabled = !g_config->music_enabled; sound_manager->enable_music(g_config->music_enabled); g_config->save(); @@ -241,17 +246,9 @@ OptionsMenu::menu_action(MenuItem* item) } } -Menu* get_options_menu() -{ - //static OptionsMenu menu; - options_menu = new OptionsMenu(); - return options_menu; -} - -void free_options_menu() +void +OptionsMenu::check_menu() { - delete options_menu; - options_menu = 0; } /* EOF */