X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Foptions_menu.cpp;h=000592a71cc94542185afac727b341f36c1183b1;hb=05168beefeda31176ad7ed5ef4879819e9b6af43;hp=2ed6faa98f17d745229ef9cfd979989294861f9c;hpb=45a538e3407dcfa7a9fd8beace9dbd06b8d993a3;p=supertux.git diff --git a/src/options_menu.cpp b/src/options_menu.cpp index 2ed6faa98..000592a71 100644 --- a/src/options_menu.cpp +++ b/src/options_menu.cpp @@ -19,6 +19,7 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include +#include "profile_menu.hpp" #include "options_menu.hpp" #include "gui/menu.hpp" #include "audio/sound_manager.hpp" @@ -31,6 +32,7 @@ Menu* options_menu = 0; enum OptionsMenuIDs { MNID_FULLSCREEN, + MNID_ASPECTRATIO, MNID_SOUND, MNID_MUSIC }; @@ -107,17 +109,61 @@ OptionsMenu::OptionsMenu() add_label(_("Options")); add_hl(); - add_submenu(_("Select Language"), language_menu.get()); - add_toggle(MNID_FULLSCREEN,_("Fullscreen"), config->use_fullscreen); + + add_submenu(_("Select Language"), language_menu.get()) + ->set_help(_("Switch to another language")); + + add_submenu(_("Select Profile"), get_profile_menu()) + ->set_help(_("Switch between different savegames")); + + add_toggle(MNID_SOUND, _("Profile on Startup"), config->sound_enabled) + ->set_help(_("Display the profile menu when the game is newly started")); + + // FIXME: Implement me: if (get_parent() == main_menu) + add_toggle(MNID_FULLSCREEN,_("Fullscreen"), config->use_fullscreen) + ->set_help(_("Let the game cover the whole screen")); + + MenuItem* aspect = add_string_select(MNID_ASPECTRATIO, _("Aspect Ratio")); + aspect->set_help(_("Adjust the aspect ratio")); + + aspect->list.push_back("16:9"); + aspect->list.push_back("16:10"); + aspect->list.push_back("4:3"); + aspect->list.push_back("5:4"); + + 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(*i == aspect_ratio) + { + aspect_ratio.clear(); + break; + } + } + + if (!aspect_ratio.empty()) + { + aspect->selected = aspect->list.size(); + aspect->list.push_back(aspect_ratio); + } + if (sound_manager->is_audio_enabled()) { - add_toggle(MNID_SOUND, _("Sound"), config->sound_enabled); - add_toggle(MNID_MUSIC, _("Music"), config->music_enabled); + add_toggle(MNID_SOUND, _("Sound"), config->sound_enabled) + ->set_help(_("Disable all sound effects in the game")); + add_toggle(MNID_MUSIC, _("Music"), config->music_enabled) + ->set_help(_("Disable all music in the game")); } 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_submenu(_("Setup Keyboard"), main_controller->get_key_options_menu()) + ->set_help(_("Configure how your keyboard maps to the game")); + + add_submenu(_("Setup Joystick"),main_controller->get_joystick_options_menu()) + ->set_help(_("Configure how your joystick maps to the game")); add_hl(); add_back(_("Back")); } @@ -130,6 +176,32 @@ void OptionsMenu::menu_action(MenuItem* item) { switch (item->id) { + case MNID_ASPECTRATIO: + { // FIXME: Really crude and ugly here, move to video or so + if(sscanf(item->list[item->selected].c_str(), "%d:%d", &config->aspect_width, &config->aspect_height) == 2) + { + float aspect_ratio = static_cast(config->aspect_width) / + static_cast(config->aspect_height); + + if (aspect_ratio > 1) { + SCREEN_WIDTH = static_cast (600 * aspect_ratio + 0.5); + SCREEN_HEIGHT = 600; + } else { + SCREEN_WIDTH = 600; + SCREEN_HEIGHT = static_cast (600 * 1/aspect_ratio + 0.5); + } + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, -1.0, 1.0); + std::cout << __FILE__ << ":" << __LINE__ << ": change aspect ratio to " << item->list[item->selected] << std::endl; + + // Reposition the menu to be in the center of the screen again + set_pos(SCREEN_WIDTH/2, SCREEN_HEIGHT/2); + } + } + break; + case MNID_FULLSCREEN: if(config->use_fullscreen != options_menu->is_toggled(MNID_FULLSCREEN)) { config->use_fullscreen = !config->use_fullscreen;