[Supertux-Commit] r5425 - in trunk/supertux/src: . gui

grumbel at millhouse.dreamhost.com grumbel at millhouse.dreamhost.com
Tue May 6 06:32:48 PDT 2008


Author: grumbel
Date: 2008-05-06 06:32:47 -0700 (Tue, 06 May 2008)
New Revision: 5425

Modified:
   trunk/supertux/src/gui/menu.cpp
   trunk/supertux/src/options_menu.cpp
Log:
Fixed MN_STRINGSELECT menu item a bit more and hooked up aspect ration

Modified: trunk/supertux/src/gui/menu.cpp
===================================================================
--- trunk/supertux/src/gui/menu.cpp	2008-05-06 13:16:07 UTC (rev 5424)
+++ trunk/supertux/src/gui/menu.cpp	2008-05-06 13:32:47 UTC (rev 5425)
@@ -474,6 +474,8 @@
           items[active_item]->selected--;
         else
           items[active_item]->selected = items[active_item]->list.size()-1;
+        
+        menu_action(items[active_item]);
       }
       break;
 
@@ -483,6 +485,8 @@
           items[active_item]->selected++;
         else
           items[active_item]->selected = 0;
+        
+        menu_action(items[active_item]);
       }
       break;
 
@@ -507,6 +511,15 @@
           menu_action(items[active_item]);
           break;
 
+        case MN_STRINGSELECT:
+          if(items[active_item]->selected+1 < items[active_item]->list.size())
+              items[active_item]->selected++;
+          else
+            items[active_item]->selected = 0;
+
+          menu_action(items[active_item]);
+          break;
+
         case MN_TEXTFIELD:
         case MN_NUMFIELD:
           menuaction = MENU_ACTION_DOWN;

Modified: trunk/supertux/src/options_menu.cpp
===================================================================
--- trunk/supertux/src/options_menu.cpp	2008-05-06 13:16:07 UTC (rev 5424)
+++ trunk/supertux/src/options_menu.cpp	2008-05-06 13:32:47 UTC (rev 5425)
@@ -32,6 +32,7 @@
 
 enum OptionsMenuIDs {
   MNID_FULLSCREEN,
+  MNID_ASPECTRATIO,
   MNID_SOUND,
   MNID_MUSIC
 };
@@ -122,8 +123,12 @@
   add_toggle(MNID_FULLSCREEN,_("Fullscreen"), config->use_fullscreen)
     ->set_help(_("Let the game cover the whole screen"));
 
-  add_toggle(MNID_SOUND, _("Aspect Ration"), config->sound_enabled)
-    ->set_help(_("Change the aspect ratio"));
+  MenuItem* aspect = add_string_select(MNID_ASPECTRATIO, _("Aspect Ration"));
+  aspect->set_help(_("Adjust the aspect ratio"));
+  aspect->list.push_back("16:9");
+  aspect->list.push_back("16:10");
+  aspect->list.push_back("4:3");
+  aspect->list.push_back("5:4");
 
   if (sound_manager->is_audio_enabled()) {
     add_toggle(MNID_SOUND, _("Sound"), config->sound_enabled)
@@ -152,6 +157,32 @@
 OptionsMenu::menu_action(MenuItem* item)
 {
   switch (item->id) {
+    case MNID_ASPECTRATIO:
+      { // FIXME: Really crude and ugly here, move to video or so
+        int   aspect_width;
+        int   aspect_height;
+
+        if(sscanf(item->list[item->selected].c_str(), "%d:%d", &aspect_width, &aspect_height) == 2) 
+          {
+            config->aspect_ratio = static_cast<double>(aspect_width) /
+              static_cast<double>(aspect_height);
+
+            if (config->aspect_ratio > 1) {
+              SCREEN_WIDTH  = static_cast<int> (600 * config->aspect_ratio + 0.5);
+              SCREEN_HEIGHT = 600;
+            } else {
+              SCREEN_WIDTH  = 600;
+              SCREEN_HEIGHT = static_cast<int> (600 * 1/config->aspect_ratio + 0.5);
+            }
+
+            glMatrixMode(GL_PROJECTION);
+            glLoadIdentity();
+            glOrtho(0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, -1.0, 1.0);
+            std::cout << __FILE__ << ":" << __LINE__ << ": change aspect ratio to " << item->list[item->selected] << std::endl;
+          }
+      }
+      break;
+
     case MNID_FULLSCREEN:
       if(config->use_fullscreen != options_menu->is_toggled(MNID_FULLSCREEN)) {
         config->use_fullscreen = !config->use_fullscreen;




More information about the Supertux-Commit mailing list