Mark "auto" as translatable
[supertux.git] / src / supertux / menu / options_menu.cpp
index a930309..f01b402 100644 (file)
 #include "supertux/menu/keyboard_menu.hpp"
 #include "supertux/menu/language_menu.hpp"
 #include "supertux/menu/menu_storage.hpp"
+#include "supertux/menu/profile_menu.hpp"
+#include "util/string_util.hpp"
 #include "video/renderer.hpp"
 
+#include <algorithm>
+#include <sstream>
+
 enum OptionsMenuIDs {
   MNID_FULLSCREEN,
   MNID_FULLSCREEN_RESOLUTION,
@@ -66,7 +71,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(_("auto"));
   magnification->list.push_back("40%");
   magnification->list.push_back("50%");
   magnification->list.push_back("62.5%");
@@ -105,22 +110,26 @@ OptionsMenu::OptionsMenu() :
       out << modes[i]->w << "x" << modes[i]->h;
       fullscreen_res->list.push_back(out.str());
     }
+
+    // On Ubuntu/Linux resolutions are returned from highest to
+    // lowest, so reverse them
+    std::sort(fullscreen_res->list.begin(), fullscreen_res->list.end(), StringUtil::numeric_less);
   }
 
   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(_("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");
 
-  if (g_config->aspect_width != 0 && g_config->aspect_height != 0)
+  if (g_config->aspect_size != Size(0, 0))
   {
     std::ostringstream out;
-    out << g_config->aspect_width << ":" << g_config->aspect_height;
+    out << g_config->aspect_size.width << ":" << g_config->aspect_size.height;
     std::string aspect_ratio = out.str();
     for(std::vector<std::string>::iterator i = aspect->list.begin(); i != aspect->list.end(); ++i)
     {
@@ -167,14 +176,14 @@ OptionsMenu::menu_action(MenuItem* item)
   switch (item->id) {
     case MNID_ASPECTRATIO:
     { 
-      if (item->list[item->selected] == "auto")
+      if (item->list[item->selected] == _("auto"))
       {
-        g_config->aspect_width  = 0; // Magic values
-        g_config->aspect_height = 0;
+        g_config->aspect_size = Size(0, 0); // Magic values
         Renderer::instance()->apply_config();
         MenuManager::recalc_pos();
       }
-      else if(sscanf(item->list[item->selected].c_str(), "%d:%d", &g_config->aspect_width, &g_config->aspect_height) == 2)
+      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();
@@ -187,7 +196,7 @@ OptionsMenu::menu_action(MenuItem* item)
     break;
 
     case MNID_MAGNIFICATION:
-      if (item->list[item->selected] == "auto")
+      if (item->list[item->selected] == _("auto"))
       {
         g_config->magnification = 0.0f; // Magic value 
       }
@@ -200,7 +209,8 @@ OptionsMenu::menu_action(MenuItem* item)
       break;
 
     case MNID_FULLSCREEN_RESOLUTION:
-      if(sscanf(item->list[item->selected].c_str(), "%dx%d", &g_config->fullscreen_width, &g_config->fullscreen_height) == 2)
+      if(sscanf(item->list[item->selected].c_str(), "%dx%d", 
+                &g_config->fullscreen_size.width, &g_config->fullscreen_size.height) == 2)
       {
         // do nothing, changes are only applied when toggling fullscreen mode
       }      
@@ -236,4 +246,9 @@ OptionsMenu::menu_action(MenuItem* item)
   }
 }
 
+void
+OptionsMenu::check_menu()
+{
+}
+
 /* EOF */