X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fsupertux%2Fmenu%2Foptions_menu.cpp;h=8e1ce9dc0b85e83aef22d84fabc4787ece398358;hb=0dfc9395c709d05e0a6ef27ad825990413939aad;hp=d65aa7d102f9163fe7a09d94b3a8fd508da910f0;hpb=8b1d96110cb224d711749dccba18dd0d86ded20c;p=supertux.git diff --git a/src/supertux/menu/options_menu.cpp b/src/supertux/menu/options_menu.cpp index d65aa7d10..8e1ce9dc0 100644 --- a/src/supertux/menu/options_menu.cpp +++ b/src/supertux/menu/options_menu.cpp @@ -37,30 +37,27 @@ enum OptionsMenuIDs { MNID_FULLSCREEN_RESOLUTION, MNID_MAGNIFICATION, MNID_ASPECTRATIO, - MNID_PROFILES, MNID_SOUND, - MNID_MUSIC + MNID_MUSIC, + MNID_DEVELOPER_MODE }; -OptionsMenu::OptionsMenu() : - language_menu() +OptionsMenu::OptionsMenu(bool complete) { - language_menu.reset(new LanguageMenu()); - add_label(_("Options")); add_hl(); - // 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(_("Select a different language to display text in")); + if (complete) + { + // Language and profile changes are only be possible in the + // main menu, since elsewhere it might not always work fully + add_submenu(_("Select Language"), MenuStorage::LANGUAGE_MENU) + ->set_help(_("Select a different language to display text in")); - add_submenu(_("Select Profile"), MenuStorage::get_profile_menu()) - ->set_help(_("Select a profile to play with")); + add_submenu(_("Select Profile"), MenuStorage::PROFILE_MENU) + ->set_help(_("Select a profile to play with")); + } - add_toggle(MNID_PROFILES, _("Profile on Startup"), g_config->sound_enabled) - ->set_help(_("Select your profile immediately after start-up")); - add_toggle(MNID_FULLSCREEN,_("Fullscreen"), g_config->use_fullscreen) ->set_help(_("Fill the entire screen")); @@ -96,7 +93,7 @@ OptionsMenu::OptionsMenu() : magn.clear(); break; } - + ++count; } if (!magn.empty()) //magnification not in our list but accept anyway @@ -105,8 +102,9 @@ OptionsMenu::OptionsMenu() : magnification->list.push_back(magn); } } - + int display_mode_count = SDL_GetNumDisplayModes(0); + std::string last_display_mode; for(int i = 0; i < display_mode_count; ++i) { SDL_DisplayMode mode; @@ -119,33 +117,44 @@ OptionsMenu::OptionsMenu() : { std::ostringstream out; out << mode.w << "x" << mode.h << "@" << mode.refresh_rate; + if(last_display_mode == out.str()) + continue; + last_display_mode = out.str(); fullscreen_res->list.push_back(out.str()); } } + fullscreen_res->list.push_back("Desktop"); + + std::string fullscreen_size_str = "Desktop"; + { + std::ostringstream out; + if (g_config->fullscreen_size != Size(0, 0)) + { + out << g_config->fullscreen_size.width << "x" << g_config->fullscreen_size.height << "@" << g_config->fullscreen_refresh_rate; + fullscreen_size_str = out.str(); + } + } - std::ostringstream out; - out << g_config->fullscreen_size.width << "x" << g_config->fullscreen_size.height << "@" << g_config->fullscreen_refresh_rate; - std::string fllscrn_sz = out.str(); size_t cnt = 0; - for (std::vector::iterator i = fullscreen_res->list.begin(); i != fullscreen_res->list.end(); ++i) + for (std::vector::iterator i = fullscreen_res->list.begin(); i != fullscreen_res->list.end(); ++i) { - if (*i == fllscrn_sz) + if (*i == fullscreen_size_str) { - fllscrn_sz.clear(); + fullscreen_size_str.clear(); fullscreen_res->selected = cnt; break; } ++cnt; } - if (!fllscrn_sz.empty()) + if (!fullscreen_size_str.empty()) { fullscreen_res->selected = fullscreen_res->list.size(); - fullscreen_res->list.push_back(fllscrn_sz); + fullscreen_res->list.push_back(fullscreen_size_str); } 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("5:4"); aspect->list.push_back("4:3"); @@ -158,16 +167,16 @@ OptionsMenu::OptionsMenu() : std::ostringstream out; out << g_config->aspect_size.width << ":" << g_config->aspect_size.height; std::string aspect_ratio = out.str(); - size_t cnt = 0; + size_t cnt_ = 0; for(std::vector::iterator i = aspect->list.begin(); i != aspect->list.end(); ++i) { if(*i == aspect_ratio) { aspect_ratio.clear(); - aspect->selected = cnt; + aspect->selected = cnt_; break; } - ++cnt; + ++cnt_; } if (!aspect_ratio.empty()) @@ -176,8 +185,8 @@ OptionsMenu::OptionsMenu() : aspect->list.push_back(aspect_ratio); } } - - if (sound_manager->is_audio_enabled()) { + + if (SoundManager::current()->is_audio_enabled()) { add_toggle(MNID_SOUND, _("Sound"), g_config->sound_enabled) ->set_help(_("Disable all sound effects")); add_toggle(MNID_MUSIC, _("Music"), g_config->music_enabled) @@ -186,12 +195,18 @@ OptionsMenu::OptionsMenu() : add_inactive(MNID_SOUND, _("Sound (disabled)")); add_inactive(MNID_MUSIC, _("Music (disabled)")); } - - add_submenu(_("Setup Keyboard"), MenuStorage::get_key_options_menu()) + + add_submenu(_("Setup Keyboard"), MenuStorage::KEYBOARD_MENU) ->set_help(_("Configure key-action mappings")); - add_submenu(_("Setup Joystick"), MenuStorage::get_joystick_options_menu()) + add_submenu(_("Setup Joystick"), MenuStorage::JOYSTICK_MENU) ->set_help(_("Configure joystick control-action mappings")); + + if (g_config->developer_mode) + { + add_toggle(MNID_DEVELOPER_MODE, _("Developer Mode"), g_config->developer_mode); + } + add_hl(); add_back(_("Back")); } @@ -209,14 +224,14 @@ OptionsMenu::menu_action(MenuItem* item) if (item->list[item->selected] == _("auto")) { g_config->aspect_size = Size(0, 0); // Magic values - Renderer::instance()->apply_config(); - MenuManager::recalc_pos(); + VideoSystem::current()->get_renderer().apply_config(); + MenuManager::instance().on_window_resize(); } 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(); - MenuManager::recalc_pos(); + VideoSystem::current()->get_renderer().apply_config(); + MenuManager::instance().on_window_resize(); } else { @@ -228,14 +243,14 @@ OptionsMenu::menu_action(MenuItem* item) case MNID_MAGNIFICATION: if (item->list[item->selected] == _("auto")) { - g_config->magnification = 0.0f; // Magic value + g_config->magnification = 0.0f; // Magic value } else if(sscanf(item->list[item->selected].c_str(), "%f", &g_config->magnification) == 1) { g_config->magnification /= 100.0f; } - Renderer::instance()->apply_config(); - MenuManager::recalc_pos(); + VideoSystem::current()->get_renderer().apply_config(); + MenuManager::instance().on_window_resize(); break; case MNID_FULLSCREEN_RESOLUTION: @@ -243,7 +258,13 @@ OptionsMenu::menu_action(MenuItem* item) int width; int height; int refresh_rate; - if(sscanf(item->list[item->selected].c_str(), "%dx%d@%d", + if (item->list[item->selected] == "Desktop") + { + g_config->fullscreen_size.width = 0; + g_config->fullscreen_size.height = 0; + g_config->fullscreen_refresh_rate = 0; + } + else if(sscanf(item->list[item->selected].c_str(), "%dx%d@%d", &width, &height, &refresh_rate) == 3) { // do nothing, changes are only applied when toggling fullscreen mode @@ -251,14 +272,14 @@ OptionsMenu::menu_action(MenuItem* item) g_config->fullscreen_size.height = height; g_config->fullscreen_refresh_rate = refresh_rate; } - } + } break; case MNID_FULLSCREEN: if(g_config->use_fullscreen != is_toggled(MNID_FULLSCREEN)) { g_config->use_fullscreen = !g_config->use_fullscreen; - Renderer::instance()->apply_config(); - MenuManager::recalc_pos(); + VideoSystem::current()->get_renderer().apply_config(); + MenuManager::instance().on_window_resize(); g_config->save(); } break; @@ -266,7 +287,7 @@ OptionsMenu::menu_action(MenuItem* item) case 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); + SoundManager::current()->enable_sound(g_config->sound_enabled); g_config->save(); } break; @@ -274,19 +295,19 @@ OptionsMenu::menu_action(MenuItem* item) case 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); + SoundManager::current()->enable_music(g_config->music_enabled); g_config->save(); } break; + case MNID_DEVELOPER_MODE: + g_config->developer_mode = is_toggled(MNID_DEVELOPER_MODE); + log_info << "developer mode: " << g_config->developer_mode << std::endl; + break; + default: break; } } -void -OptionsMenu::check_menu() -{ -} - /* EOF */