Merge branch 'feature/init-cleanup'
[supertux.git] / src / supertux / menu / options_menu.cpp
index 538233e..a3db0eb 100644 (file)
@@ -37,7 +37,6 @@ enum OptionsMenuIDs {
   MNID_FULLSCREEN_RESOLUTION,
   MNID_MAGNIFICATION,
   MNID_ASPECTRATIO,
-  MNID_PROFILES,
   MNID_SOUND,
   MNID_MUSIC
 };
@@ -58,9 +57,6 @@ OptionsMenu::OptionsMenu(bool complete)
       ->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"));
 
@@ -107,6 +103,7 @@ OptionsMenu::OptionsMenu(bool complete)
   }
 
   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,18 +116,24 @@ OptionsMenu::OptionsMenu(bool complete)
     {
       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::ostringstream out;
   std::string fullscreen_size_str = "Desktop";
-  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;
+    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();
+    }
   }
+
   size_t cnt = 0;
   for (std::vector<std::string>::iterator i = fullscreen_res->list.begin(); i != fullscreen_res->list.end(); ++i)
   {
@@ -163,16 +166,16 @@ OptionsMenu::OptionsMenu(bool complete)
     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<std::string>::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())
@@ -182,7 +185,7 @@ OptionsMenu::OptionsMenu(bool complete)
     }
   }
 
-  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)
@@ -214,13 +217,13 @@ OptionsMenu::menu_action(MenuItem* item)
         if (item->list[item->selected] == _("auto"))
         {
           g_config->aspect_size = Size(0, 0); // Magic values
-          Renderer::instance()->apply_config();
+          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();
+          VideoSystem::current()->get_renderer().apply_config();
           MenuManager::instance().on_window_resize();
         }
         else
@@ -239,7 +242,7 @@ OptionsMenu::menu_action(MenuItem* item)
       {
         g_config->magnification /= 100.0f;
       }
-      Renderer::instance()->apply_config();
+      VideoSystem::current()->get_renderer().apply_config();
       MenuManager::instance().on_window_resize();
       break;
 
@@ -268,7 +271,7 @@ OptionsMenu::menu_action(MenuItem* item)
     case MNID_FULLSCREEN:
       if(g_config->use_fullscreen != is_toggled(MNID_FULLSCREEN)) {
         g_config->use_fullscreen = !g_config->use_fullscreen;
-        Renderer::instance()->apply_config();
+        VideoSystem::current()->get_renderer().apply_config();
         MenuManager::instance().on_window_resize();
         g_config->save();
       }
@@ -277,7 +280,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;
@@ -285,7 +288,7 @@ 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;