X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Foptions_menu.cpp;h=778f77cd45b4cc48ae05f0bc223d4c36a25a0e6b;hb=403276e51afda11d0738be756025411d9103a6ed;hp=7502ce5bb529c4ced61aa5a95fcbb89a1bedb8aa;hpb=6001852fe09ef3c57b8e51dafd2370881f08592e;p=supertux.git diff --git a/src/options_menu.cpp b/src/options_menu.cpp index 7502ce5bb..778f77cd4 100644 --- a/src/options_menu.cpp +++ b/src/options_menu.cpp @@ -32,6 +32,9 @@ Menu* options_menu = 0; enum OptionsMenuIDs { MNID_FULLSCREEN, + MNID_FULLSCREEN_RESOLUTION, + MNID_PROJECTION_AREA, + MNID_ASPECTRATIO, MNID_SOUND, MNID_MUSIC }; @@ -122,9 +125,63 @@ OptionsMenu::OptionsMenu() add_toggle(MNID_FULLSCREEN,_("Fullscreen"), config->use_fullscreen) ->set_help(_("Let the game cover the whole screen")); - add_toggle(MNID_SOUND, _("Aspect Ration"), config->sound_enabled) - ->set_help(_("Change the aspect ratio")); + MenuItem* projection = add_string_select(MNID_PROJECTION_AREA, _("Projection Area")); + projection->set_help(_("Change the visible area")); + projection->list.push_back("640x480"); + projection->list.push_back("800x600"); + projection->list.push_back("1024x768"); + projection->list.push_back("1152x864"); + projection->list.push_back("1280x960"); + projection->list.push_back("1280x1024"); + projection->list.push_back("1440x900"); + projection->list.push_back("1680x1050"); + projection->list.push_back("1600x1200"); + projection->list.push_back("1920x1080"); + projection->list.push_back("1920x1200"); + + MenuItem* fullscreen_res = add_string_select(MNID_FULLSCREEN_RESOLUTION, _("Fullscreen Resolution")); + fullscreen_res->set_help(_("Change the Fullscreen Resolution")); + + // FIXME: Hardcoded values are evil, these should be queried from the Xorg server + fullscreen_res->list.push_back("640x480"); + fullscreen_res->list.push_back("800x600"); + fullscreen_res->list.push_back("1024x768"); + fullscreen_res->list.push_back("1152x864"); + fullscreen_res->list.push_back("1280x960"); + fullscreen_res->list.push_back("1280x1024"); + fullscreen_res->list.push_back("1440x900"); + fullscreen_res->list.push_back("1680x1050"); + fullscreen_res->list.push_back("1600x1200"); + fullscreen_res->list.push_back("1920x1080"); + fullscreen_res->list.push_back("1920x1200"); + + 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) ->set_help(_("Disable all sound effects in the game")); @@ -152,6 +209,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;