#303: Typo fixes from mathnerd314
[supertux.git] / src / options_menu.cpp
index 3e0d66f..c947101 100644 (file)
@@ -36,7 +36,6 @@ enum OptionsMenuIDs {
   MNID_FULLSCREEN_RESOLUTION,
   MNID_MAGNIFICATION,
   MNID_ASPECTRATIO,
-  MNID_FILL_SCREEN,
   MNID_PROFILES,
   MNID_SOUND,
   MNID_MUSIC
@@ -137,6 +136,7 @@ OptionsMenu::OptionsMenu()
 
   // These values go from screen:640/projection:1600 to
   // screen:1600/projection:640 (i.e. 640, 800, 1024, 1280, 1600)
+  magnification->list.push_back("auto");
   magnification->list.push_back("40%");
   magnification->list.push_back("50%");
   magnification->list.push_back("62.5%");
@@ -147,9 +147,6 @@ OptionsMenu::OptionsMenu()
   magnification->list.push_back("200%");
   magnification->list.push_back("250%");
 
-  add_toggle(MNID_FILL_SCREEN, _("Fill Screen"), config->fill_screen)
-    ->set_help(_("Stretch SuperTux to fill the screen instead of adding black bars"));
-
   SDL_Rect** modes = SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_OPENGL);
 
   if (modes == (SDL_Rect **)0) 
@@ -183,29 +180,32 @@ OptionsMenu::OptionsMenu()
   MenuItem* aspect = add_string_select(MNID_ASPECTRATIO, _("Aspect Ratio"));
   aspect->set_help(_("Adjust the aspect ratio"));
   
-  aspect->list.push_back("screen");
-  aspect->list.push_back("4:3");
+  aspect->list.push_back("auto");
   aspect->list.push_back("5:4");
+  aspect->list.push_back("4:3");
   aspect->list.push_back("16:10");
   aspect->list.push_back("16:9");
   aspect->list.push_back("1368:768");
 
-  std::ostringstream out;
-  out << config->aspect_width << ":" << config->aspect_height;
-  std::string aspect_ratio = out.str();
-  for(std::vector<std::string>::iterator i = aspect->list.begin(); i != aspect->list.end(); ++i)
+  if (config->aspect_width != 0 && config->aspect_height != 0)
     {
-      if(*i == aspect_ratio)
+      std::ostringstream out;
+      out << config->aspect_width << ":" << config->aspect_height;
+      std::string aspect_ratio = out.str();
+      for(std::vector<std::string>::iterator i = aspect->list.begin(); i != aspect->list.end(); ++i)
         {
-          aspect_ratio.clear();
-          break;
+          if(*i == aspect_ratio)
+            {
+              aspect_ratio.clear();
+              break;
+            }
         }
-    }
 
-  if (!aspect_ratio.empty())
-    {
-      aspect->selected = aspect->list.size();
-      aspect->list.push_back(aspect_ratio);
+      if (!aspect_ratio.empty())
+        {
+          aspect->selected = aspect->list.size();
+          aspect->list.push_back(aspect_ratio);
+        }
     }
   
   if (sound_manager->is_audio_enabled()) {
@@ -214,8 +214,8 @@ OptionsMenu::OptionsMenu()
     add_toggle(MNID_MUSIC, _("Music"), config->music_enabled)
       ->set_help(_("Disable all music"));
   } else {
-    add_deactive(MNID_SOUND, _("Sound (disabled)"));
-    add_deactive(MNID_MUSIC, _("Music (disabled)"));
+    add_inactive(MNID_SOUND, _("Sound (disabled)"));
+    add_inactive(MNID_MUSIC, _("Music (disabled)"));
   }
   
   add_submenu(_("Setup Keyboard"), main_controller->get_key_options_menu())
@@ -235,43 +235,38 @@ void
 OptionsMenu::menu_action(MenuItem* item)
 {
   switch (item->id) {
-    case MNID_FILL_SCREEN:
-      config->fill_screen = options_menu->is_toggled(MNID_FILL_SCREEN);
-      Renderer::instance()->apply_config();
-      Menu::recalc_pos();
-      config->save();
-      break;
-
     case MNID_ASPECTRATIO:
       { 
-        if (item->list[item->selected] == "screen")
+        if (item->list[item->selected] == "auto")
+          {
+            config->aspect_width  = 0; // Magic values
+            config->aspect_height = 0;
+            Renderer::instance()->apply_config();
+            Menu::recalc_pos();
+          }
+        else if(sscanf(item->list[item->selected].c_str(), "%d:%d", &config->aspect_width, &config->aspect_height) == 2)
           {
-            // FIXME: Insert magic for 1:1 mapping, desktop_width/desktop_height
             Renderer::instance()->apply_config();
-            Menu::recalc_pos();            
+            Menu::recalc_pos();
           }
         else
-          {           
-            if(sscanf(item->list[item->selected].c_str(), "%d:%d", &config->aspect_width, &config->aspect_height) == 2)
-              {
-                Renderer::instance()->apply_config();
-                Menu::recalc_pos();
-              }
-            else
-              {
-                assert(!"This must not be reached");
-              }
+          {
+            assert(!"This must not be reached");
           }
       }
       break;
 
     case MNID_MAGNIFICATION:
-      if(sscanf(item->list[item->selected].c_str(), "%f", &config->magnification) == 1)
+      if (item->list[item->selected] == "auto")
+        {
+          config->magnification = 0.0f; // Magic value 
+        }
+      else if(sscanf(item->list[item->selected].c_str(), "%f", &config->magnification) == 1)
         {
           config->magnification /= 100.0f;
-          Renderer::instance()->apply_config();
-          Menu::recalc_pos();
         }
+      Renderer::instance()->apply_config();
+      Menu::recalc_pos();
       break;
 
     case MNID_FULLSCREEN_RESOLUTION:
@@ -284,7 +279,8 @@ OptionsMenu::menu_action(MenuItem* item)
     case MNID_FULLSCREEN:
       if(config->use_fullscreen != options_menu->is_toggled(MNID_FULLSCREEN)) {
         config->use_fullscreen = !config->use_fullscreen;
-        init_video();
+        init_video(); // FIXME: Should call apply_config instead
+        Menu::recalc_pos();
         config->save();
       }
       break;