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

grumbel at millhouse.dreamhost.com grumbel at millhouse.dreamhost.com
Mon May 5 23:59:42 PDT 2008


Author: grumbel
Date: 2008-05-05 23:59:42 -0700 (Mon, 05 May 2008)
New Revision: 5422

Modified:
   trunk/supertux/src/gui/menu.cpp
   trunk/supertux/src/options_menu.cpp
   trunk/supertux/src/video/font.cpp
Log:
Display some additional help text on Option Menu entries

Modified: trunk/supertux/src/gui/menu.cpp
===================================================================
--- trunk/supertux/src/gui/menu.cpp	2008-05-06 05:41:18 UTC (rev 5421)
+++ trunk/supertux/src/gui/menu.cpp	2008-05-06 06:59:42 UTC (rev 5422)
@@ -185,7 +185,13 @@
 void
 MenuItem::set_help(const std::string& help_text)
 {
-  help = help_text;
+  std::string overflow;
+  help = Menu::default_font->wrap_to_width(help_text, 600, &overflow);
+  while (!overflow.empty())
+    {
+      help += "\n";
+      help += Menu::default_font->wrap_to_width(overflow, 600, &overflow);
+    }
 }
 
 std::string MenuItem::get_input_with_symbol(bool active_item)
@@ -756,17 +762,17 @@
 
   if (effect_progress != 1.0f)
     {
-    if (Menu::previous)
-      {
-        menu_width  = (menu_width  * effect_progress) + (Menu::previous->get_width()  * (1.0f - effect_progress));
-        menu_height = (menu_height * effect_progress) + (Menu::previous->get_height() * (1.0f - effect_progress));
-        //std::cout << effect_progress << " " << this << " " << last_menus.back() << std::endl;
-      }
-    else
-      {
-        menu_width  *= effect_progress;
-        menu_height *= effect_progress;
-      }
+      if (Menu::previous)
+        {
+          menu_width  = (menu_width  * effect_progress) + (Menu::previous->get_width()  * (1.0f - effect_progress));
+          menu_height = (menu_height * effect_progress) + (Menu::previous->get_height() * (1.0f - effect_progress));
+          //std::cout << effect_progress << " " << this << " " << last_menus.back() << std::endl;
+        }
+      else
+        {
+          menu_width  *= effect_progress;
+          menu_height *= effect_progress;
+        }
     }
 
   /* Draw a transparent background */
@@ -782,6 +788,32 @@
                            16.0f,
                            LAYER_GUI-10);
 
+  if (!items[active_item]->help.empty())
+    {
+      int text_width  = default_font->get_text_width(items[active_item]->help);
+      int text_height = default_font->get_text_height(items[active_item]->help);
+      
+      Rect text_rect(pos_x - text_width/2 - 8, 
+                     SCREEN_HEIGHT - 48 - text_height/2 - 4,
+                     pos_x + text_width/2 + 8, 
+                     SCREEN_HEIGHT - 48 + text_height/2 + 4);
+        
+      context.draw_filled_rect(Rect(text_rect.p1 - Vector(4,4),
+                                    text_rect.p2 + Vector(4,4)),
+                               Color(0.2f, 0.3f, 0.4f, 0.8f), 
+                               16.0f,
+                               LAYER_GUI-10);
+      
+      context.draw_filled_rect(text_rect,
+                               Color(0.6f, 0.7f, 0.8f, 0.5f), 
+                               16.0f,
+                               LAYER_GUI-10);
+
+      context.draw_text(default_font, items[active_item]->help,
+                        Vector(pos_x, SCREEN_HEIGHT - 48 - text_height/2),
+                        ALIGN_CENTER, LAYER_GUI);
+    }
+
   if (effect_progress == 1.0f)
     for(unsigned int i = 0; i < items.size(); ++i)
       {

Modified: trunk/supertux/src/options_menu.cpp
===================================================================
--- trunk/supertux/src/options_menu.cpp	2008-05-06 05:41:18 UTC (rev 5421)
+++ trunk/supertux/src/options_menu.cpp	2008-05-06 06:59:42 UTC (rev 5422)
@@ -108,22 +108,38 @@
 
   add_label(_("Options"));
   add_hl();
+
+  add_submenu(_("Select Language"), language_menu.get())
+    ->set_help(_("Switch to another language"));
+
+  add_submenu(_("Select Profile"), get_profile_menu())
+    ->set_help(_("Switch between different savegames"));
+
+  add_toggle(MNID_SOUND, _("Profile on Startup"), config->sound_enabled)
+    ->set_help(_("Display the profile menu when the game is newly started"));
   
   // FIXME: Implement me: if (get_parent() == main_menu)
-    add_submenu(_("Change Profile"), get_profile_menu());
+  add_toggle(MNID_FULLSCREEN,_("Fullscreen"), config->use_fullscreen)
+    ->set_help(_("Let the game cover the whole screen"));
 
-  add_submenu(_("Select Language"), language_menu.get());
-  add_toggle(MNID_FULLSCREEN,_("Fullscreen"), config->use_fullscreen);
-    add_toggle(MNID_SOUND, _("Profile Select on Startup"), config->sound_enabled);
+  add_toggle(MNID_SOUND, _("Aspect Ration"), config->sound_enabled)
+    ->set_help(_("Change the aspect ratio"));
+
   if (sound_manager->is_audio_enabled()) {
-    add_toggle(MNID_SOUND, _("Sound"), config->sound_enabled);
-    add_toggle(MNID_MUSIC, _("Music"), config->music_enabled);
+    add_toggle(MNID_SOUND, _("Sound"), config->sound_enabled)
+      ->set_help(_("Disable all sound effects in the game"));
+    add_toggle(MNID_MUSIC, _("Music"), config->music_enabled)
+      ->set_help(_("Disable all music in the game"));
   } else {
     add_deactive(MNID_SOUND, _("Sound (disabled)"));
     add_deactive(MNID_SOUND, _("Music (disabled)"));
   }
-  add_submenu(_("Setup Keyboard"), main_controller->get_key_options_menu());
-  add_submenu(_("Setup Joystick"),main_controller->get_joystick_options_menu());
+  
+  add_submenu(_("Setup Keyboard"), main_controller->get_key_options_menu())
+    ->set_help(_("Configure how your keyboard maps to the game"));
+
+  add_submenu(_("Setup Joystick"),main_controller->get_joystick_options_menu())
+    ->set_help(_("Configure how your joystick maps to the game"));
   add_hl();
   add_back(_("Back"));
 }

Modified: trunk/supertux/src/video/font.cpp
===================================================================
--- trunk/supertux/src/video/font.cpp	2008-05-06 05:41:18 UTC (rev 5421)
+++ trunk/supertux/src/video/font.cpp	2008-05-06 06:59:42 UTC (rev 5422)
@@ -243,8 +243,10 @@
 }
 
 std::string
-Font::wrap_to_width(const std::string& s, float width, std::string* overflow)
+Font::wrap_to_width(const std::string& s_, float width, std::string* overflow)
 {
+  std::string s = s_;
+
   // if text is already smaller, return full text
   if (get_text_width(s) <= width) {
     if (overflow) *overflow = "";




More information about the Supertux-Commit mailing list