X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Foptions_menu.cpp;h=9c73bb1f2596c577f08b0b413f1fdb5e68fa9d0a;hb=07ed4c2b80f0bff52fe86cd62acf718b12455962;hp=000592a71cc94542185afac727b341f36c1183b1;hpb=1cd7104259878cd6afbc257a452a1ab1456d4120;p=supertux.git diff --git a/src/options_menu.cpp b/src/options_menu.cpp index 000592a71..9c73bb1f2 100644 --- a/src/options_menu.cpp +++ b/src/options_menu.cpp @@ -26,12 +26,15 @@ #include "control/joystickkeyboardcontroller.hpp" #include "main.hpp" #include "gettext.hpp" +#include "video/renderer.hpp" #include "gameconfig.hpp" Menu* options_menu = 0; enum OptionsMenuIDs { MNID_FULLSCREEN, + MNID_FULLSCREEN_RESOLUTION, + MNID_MAGINFICATION, MNID_ASPECTRATIO, MNID_SOUND, MNID_MUSIC @@ -119,17 +122,63 @@ OptionsMenu::OptionsMenu() 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* fullscreen_res = add_string_select(MNID_FULLSCREEN_RESOLUTION, _("Resolution")); + fullscreen_res->set_help(_("Change the Resolution to be used in Fullscreen Mode, you have to toggle fullscreen mode to let this change take effect")); + + MenuItem* maginfication = add_string_select(MNID_MAGINFICATION, _("Maginfication")); + maginfication->set_help(_("Change the magnification of the game area")); + + // These values go from screen:640/projection:1600 to screen:1600/projection:640 + maginfication->list.push_back("40%"); + maginfication->list.push_back("50%"); + maginfication->list.push_back("62.5%"); + maginfication->list.push_back("80%"); + maginfication->list.push_back("100%"); + maginfication->list.push_back("125%"); + maginfication->list.push_back("160%"); + maginfication->list.push_back("200%"); + maginfication->list.push_back("250%"); + + SDL_Rect** modes = SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_OPENGL); + + if (modes == (SDL_Rect **)0) + { // No resolutions at all available, bad + + } + else if(modes == (SDL_Rect **)-1) + { // All resolutions sould work, so we fall back to hardcoded defaults + 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"); + } + else + { + for(int i = 0; modes[i]; ++i) + { + std::ostringstream out; + out << modes[i]->w << "x" << modes[i]->h; + fullscreen_res->list.push_back(out.str()); + } + } + 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"); + aspect->list.push_back("16:10"); + aspect->list.push_back("16:9"); std::ostringstream out; out << config->aspect_width << ":" << config->aspect_height; @@ -177,31 +226,31 @@ 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) + { + 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); + Renderer::instance()->apply_config(); + Menu::recalc_pos(); } } break; + case MNID_MAGINFICATION: + if(sscanf(item->list[item->selected].c_str(), "%f", &config->magnification) == 1) + { + config->magnification /= 100.0f; + Renderer::instance()->apply_config(); + Menu::recalc_pos(); + } + break; + + case MNID_FULLSCREEN_RESOLUTION: + if(sscanf(item->list[item->selected].c_str(), "%dx%d", &config->fullscreen_width, &config->fullscreen_height) == 2) + { + // do nothing, changes are only applied when toggling fullscreen mode + } + break; + case MNID_FULLSCREEN: if(config->use_fullscreen != options_menu->is_toggled(MNID_FULLSCREEN)) { config->use_fullscreen = !config->use_fullscreen;