X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Foptions_menu.cpp;h=ccadc447e28f8f158e0cf2415d51747d5aed359e;hb=e126dd8c3da286ab759dc36f3f59f3955e16ed09;hp=bdcc0267f68fac7fc725935494076f2411e84752;hpb=710f773991ac0a67e2426d3ff26197df87bdc460;p=supertux.git diff --git a/src/options_menu.cpp b/src/options_menu.cpp index bdcc0267f..ccadc447e 100644 --- a/src/options_menu.cpp +++ b/src/options_menu.cpp @@ -36,7 +36,6 @@ enum OptionsMenuIDs { MNID_FULLSCREEN_RESOLUTION, MNID_MAGNIFICATION, MNID_ASPECTRATIO, - MNID_FILL_SCREEN, MNID_PROFILES, MNID_SOUND, MNID_MUSIC @@ -72,13 +71,13 @@ public: config->locale = ""; dictionary_manager.set_language(config->locale); config->save(); - Menu::set_current(0); + Menu::pop_current(); } else if (item->id == 1) { config->locale = "en"; dictionary_manager.set_language(config->locale); config->save(); - Menu::set_current(0); + Menu::pop_current(); } int mnid = 10; std::set languages = dictionary_manager.get_languages(); @@ -88,7 +87,7 @@ public: config->locale = locale_name; dictionary_manager.set_language(config->locale); config->save(); - Menu::set_current(0); + Menu::pop_current(); } } } @@ -118,25 +117,26 @@ OptionsMenu::OptionsMenu() // Language change should only be possible in the main menu, since elsewhere it might not always work fully // FIXME: Implement me: if (get_parent() == main_menu) add_submenu(_("Select Language"), language_menu.get()) - ->set_help(_("Switch text to another language")); + ->set_help(_("Select a different language to display text in")); add_submenu(_("Select Profile"), get_profile_menu()) - ->set_help(_("Select a different savegame")); + ->set_help(_("Select a profile to play with")); add_toggle(MNID_PROFILES, _("Profile on Startup"), config->sound_enabled) - ->set_help(_("Allow selection between different profiles after opening the game")); + ->set_help(_("Select your profile immediately after start-up")); add_toggle(MNID_FULLSCREEN,_("Fullscreen"), config->use_fullscreen) - ->set_help(_("Fill the entire screen with the game")); + ->set_help(_("Fill the entire screen")); MenuItem* fullscreen_res = add_string_select(MNID_FULLSCREEN_RESOLUTION, _("Resolution")); - fullscreen_res->set_help(_("Determine the resolution to use in fullscreen mode (you must toggle fullscreen to complete the change)")); + fullscreen_res->set_help(_("Determine the resolution used in fullscreen mode (you must toggle fullscreen to complete the change)")); MenuItem* magnification = add_string_select(MNID_MAGNIFICATION, _("Magnification")); magnification->set_help(_("Change the magnification of the game area")); // 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("40%"); magnification->list.push_back("50%"); magnification->list.push_back("62.5%"); @@ -147,11 +147,6 @@ OptionsMenu::OptionsMenu() magnification->list.push_back("200%"); magnification->list.push_back("250%"); - add_toggle(MNID_FILL_SCREEN, _("Fill Screen"), config->fill_screen) - ->set_help(_("With magnification lower than your screen size, you have the choice " - "between adding black borders to the screen or increasing the magnification " - "to the smallest possible magnification still filling the screen")); - SDL_Rect** modes = SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_OPENGL); if (modes == (SDL_Rect **)0) @@ -185,27 +180,32 @@ OptionsMenu::OptionsMenu() MenuItem* aspect = add_string_select(MNID_ASPECTRATIO, _("Aspect Ratio")); aspect->set_help(_("Adjust the aspect ratio")); - aspect->list.push_back("4:3"); + 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"); - std::ostringstream out; - out << config->aspect_width << ":" << config->aspect_height; - std::string aspect_ratio = out.str(); - for(std::vector::iterator i = aspect->list.begin(); i != aspect->list.end(); ++i) + if (config->aspect_width != 0 && config->aspect_height != 0) { - if(*i == aspect_ratio) + std::ostringstream out; + out << config->aspect_width << ":" << config->aspect_height; + std::string aspect_ratio = out.str(); + for(std::vector::iterator i = aspect->list.begin(); i != aspect->list.end(); ++i) { - aspect_ratio.clear(); - break; + if(*i == aspect_ratio) + { + aspect_ratio.clear(); + break; + } } - } - if (!aspect_ratio.empty()) - { - aspect->selected = aspect->list.size(); - aspect->list.push_back(aspect_ratio); + if (!aspect_ratio.empty()) + { + aspect->selected = aspect->list.size(); + aspect->list.push_back(aspect_ratio); + } } if (sound_manager->is_audio_enabled()) { @@ -214,8 +214,8 @@ OptionsMenu::OptionsMenu() add_toggle(MNID_MUSIC, _("Music"), config->music_enabled) ->set_help(_("Disable all music")); } else { - add_deactive(MNID_SOUND, _("Sound (disabled)")); - add_deactive(MNID_MUSIC, _("Music (disabled)")); + add_inactive(MNID_SOUND, _("Sound (disabled)")); + add_inactive(MNID_MUSIC, _("Music (disabled)")); } add_submenu(_("Setup Keyboard"), main_controller->get_key_options_menu()) @@ -235,30 +235,38 @@ void OptionsMenu::menu_action(MenuItem* item) { switch (item->id) { - case MNID_FILL_SCREEN: - config->fill_screen = options_menu->is_toggled(MNID_FILL_SCREEN); - Renderer::instance()->apply_config(); - Menu::recalc_pos(); - config->save(); - break; - case MNID_ASPECTRATIO: { - if(sscanf(item->list[item->selected].c_str(), "%d:%d", &config->aspect_width, &config->aspect_height) == 2) + if (item->list[item->selected] == "auto") + { + config->aspect_width = 0; // Magic values + config->aspect_height = 0; + Renderer::instance()->apply_config(); + Menu::recalc_pos(); + } + else if(sscanf(item->list[item->selected].c_str(), "%d:%d", &config->aspect_width, &config->aspect_height) == 2) { Renderer::instance()->apply_config(); Menu::recalc_pos(); } + else + { + assert(!"This must not be reached"); + } } break; case MNID_MAGNIFICATION: - if(sscanf(item->list[item->selected].c_str(), "%f", &config->magnification) == 1) + if (item->list[item->selected] == "auto") + { + config->magnification = 0.0f; // Magic value + } + else if(sscanf(item->list[item->selected].c_str(), "%f", &config->magnification) == 1) { config->magnification /= 100.0f; - Renderer::instance()->apply_config(); - Menu::recalc_pos(); } + Renderer::instance()->apply_config(); + Menu::recalc_pos(); break; case MNID_FULLSCREEN_RESOLUTION: @@ -271,7 +279,8 @@ OptionsMenu::menu_action(MenuItem* item) case MNID_FULLSCREEN: if(config->use_fullscreen != options_menu->is_toggled(MNID_FULLSCREEN)) { config->use_fullscreen = !config->use_fullscreen; - init_video(); + init_video(); // FIXME: Should call apply_config instead + Menu::recalc_pos(); config->save(); } break;