Made code -Wshadow clean, missed a bunch of issues in the last commit
[supertux.git] / src / supertux / menu / options_menu.cpp
index 58ebf40..7877fa8 100644 (file)
@@ -103,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;
@@ -115,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)
   {
@@ -159,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())